cronjob fails in dash

Bug #2004007 reported by Daniel Krambrock
26
This bug affects 5 people
Affects Status Importance Assigned to Milestone
ocsinventory-agent (Ubuntu)
Fix Released
Low
Unassigned
Jammy
Fix Released
Undecided
Unassigned

Bug Description

* Impact

The cronjob included in the package errors out due to incorrect shell syntax

* Testcase

$ sudo /etc/cron.daily/ocsinventory-agent

triggered manually or by cron should work without error

* Regression potential

The job depends on bash now and wouldn't work on system without that shell installed. It's unlikely that bash isn't going to be installed though and even in that case it wouldn't be a regression since the script is already not working

---------------------------------

Ubuntu 22.04 comes with ocsinventory-agent in version 2:2.8-2. In this version /etc/cron.daily/ocsinventory-agent holds the `$RANDOM` bashism. As `/bin/sh` links to `dash` by default the script exits with an error:

```
$ dash /etc/cron.daily/ocsinventory-agent
/etc/cron.daily/ocsinventory-agent: 19: arithmetic expression: expecting primary: " /100 "
```

There is also an older debian bug: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=988245

Related branches

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package ocsinventory-agent - 2:2.10.0-3

---------------
ocsinventory-agent (2:2.10.0-3) unstable; urgency=medium

  * Team upload.
  * Use /bin/bash instead of /bin/sh in cronjob as the script uses a
    bashism. (Closes: #988245) (LP: #2004007)
  * Declare compliance with Debian Policy 4.6.2.
  * Drop unneeded (alternative) (test) dependencies.
  * Annotate test-only build dependencies with <!nocheck>.
  * Refresh propagate-ccflags.patch: update buildflags handling.

 -- gregor herrmann <email address hidden> Sun, 29 Jan 2023 02:43:30 +0100

Changed in ocsinventory-agent (Ubuntu):
status: New → Fix Released
Revision history for this message
Daniel Krambrock (danielky) wrote :

Thanks a lot for the quick respond and the fix.
Since the cronjob stays unusable in LTS: Will there be a backport of the fix for 22.04?

Changed in ocsinventory-agent (Ubuntu):
status: Fix Released → Confirmed
description: updated
Changed in ocsinventory-agent (Ubuntu):
status: Confirmed → Fix Released
importance: Undecided → Low
Steve Langasek (vorlon)
description: updated
Revision history for this message
Steve Langasek (vorlon) wrote :

FWIW it looks like the fixing of the cronjob in version 2:2.10.0-3 was actually unnecessary and counterproductive, because the latest version of the package also ships a systemd timer - so now the package in lunar and later is running the agent twice a day...

Changed in ocsinventory-agent (Ubuntu Jammy):
status: New → Fix Committed
tags: added: verification-needed verification-needed-jammy
Revision history for this message
Steve Langasek (vorlon) wrote : Please test proposed package

Hello Daniel, or anyone else affected,

Accepted ocsinventory-agent into jammy-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/ocsinventory-agent/2:2.8-2ubuntu1 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, what testing has been performed on the package and change the tag from verification-needed-jammy to verification-done-jammy. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-jammy. In either case, without details of your testing we will not be able to proceed.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance for helping!

N.B. The updated package will be released to -updates after the bug(s) fixed by this package have been verified and the package has been in -proposed for a minimum of 7 days.

Revision history for this message
cleary (bernard-gray) wrote :

Hi Steve,
I can confirm this is working in my environment.

Thanks for looking taking care of it -

Regards,
Bernie

Revision history for this message
Daniel Krambrock (danielky) wrote :

Hi,

ocsinventory-agent in version 2:2.8-2ubuntu1 from jammy-proposed on ubuntu 22.04.2 is working: /etc/cron.daily/ocsinventory-agent runs without errors.

Thanks,
Daniel

Revision history for this message
Sebastien Bacher (seb128) wrote :

Thanks for testing, I'm marking the bug as verified

tags: added: verification-done verification-done-jammy
removed: verification-needed verification-needed-jammy
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package ocsinventory-agent - 2:2.8-2ubuntu1

---------------
ocsinventory-agent (2:2.8-2ubuntu1) jammy; urgency=medium

  * debian/ocsinventory-agent.cron.daily:
    - Use /bin/bash instead of /bin/sh in cronjob as the script uses a
      bashism. (LP: #2004007)

 -- Daniel Krambrock <email address hidden> Wed, 07 Jun 2023 15:44:56 +0200

Changed in ocsinventory-agent (Ubuntu Jammy):
status: Fix Committed → Fix Released
Revision history for this message
Łukasz Zemczak (sil2100) wrote : Update Released

The verification of the Stable Release Update for ocsinventory-agent has completed successfully and the package is now being released to -updates. Subsequently, the Ubuntu Stable Release Updates Team is being unsubscribed and will not receive messages about this bug report. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regressions.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.