amavisd-new throws stderr when running cron job

Bug #1481579 reported by quanta
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
amavisd-new (Ubuntu)
Fix Released
Low
Sergio Durigan Junior

Bug Description

- Ubuntu 14.04.2 LTS
- amavisd-new 1:2.7.1-2ubuntu3

/etc/cron.d/amavisd-new

```
#
# SpamAssassin maintenance for amavisd-new
#
# m h dom mon dow user command
18 */3 * * * amavis test -e /usr/sbin/amavisd-new-cronjob && /usr/sbin/amavisd-new-cronjob sa-sync
24 1 * * * amavis test -e /usr/sbin/amavisd-new-cronjob && /usr/sbin/amavisd-new-cronjob sa-clean
```

The contents of `/usr/sbin/amavisd-new-cronjob` file:

```
if ! perl -MMail::SpamAssassin -e "my \$spamtest = Mail::SpamAssassin->new();
\$spamtest->compile_now (); \$spamtest->{conf}->{use_bayes} ? exit 0 : exit 1"
then
        #bayes is disabled - just exit
        exit
fi

case $1 in
        sa-sync)
                /usr/bin/sa-learn --sync 2>&1 >/dev/null
                ;;
        sa-clean)
                /usr/bin/sa-learn --sync --force-expire 2>&1 >/dev/null
                ;;
        *)
                echo "$0: unknown cron routine $1" >&2
                exit 1
                ;;
esac

```

There are 2 problems here:

1. It throws a stderr message at the first time running:

```
bash -x /usr/sbin/amavisd-new-cronjob sa-sync
+ test -e /usr/bin/sa-learn
+ test -e /usr/sbin/amavisd-new
++ id --name -u
+ '[' amavis '!=' amavis ']'
+ set -e
+ umask 022
+ perl -MMail::SpamAssassin -e 'my $spamtest = Mail::SpamAssassin->new();
$spamtest->compile_now (); $spamtest->{conf}->{use_bayes} ? exit 0 : exit 1'
config: created user preferences file: /var/lib/amavis/.spamassassin/user_prefs
+ case $1 in
+ /usr/bin/sa-learn --sync
+ exit 0
```

This should be silent as it's run in a cron job.

2. To redirect both stdout and stderr to /dev/null, the redirection order should `>/dev/null 2>&1` instead of `2>&1 >/dev/null` (this one just redirects stdout).

quanta (quanta-linux)
description: updated
Revision history for this message
Sergio Durigan Junior (sergiodj) wrote :

We apologize for taking so long to reply to this bug. While it can be said to a a low priority/wishlist bug, it should have been dealt with sooner. Sorry about this.

The second part of your report has been fixed a while ago and doesn't impact amavisd-new anymore. The first part, however, is still valid. I took the liberty to submit a Merge Request against the amavisd-new Debian package, and once accepted this fix will make its way into the next Ubuntu release.

https://salsa.debian.org/debian/amavisd-new/-/merge_requests/5

Thanks.

Changed in amavisd-new (Ubuntu):
assignee: nobody → Sergio Durigan Junior (sergiodj)
importance: Undecided → Low
status: New → In Progress
Revision history for this message
Sergio Durigan Junior (sergiodj) wrote :

FWIW, the fix has been accepted by the Debian maintainer and merged into the package. It will eventually be available in Ubuntu as well.

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

This bug was fixed in the package amavisd-new - 1:2.12.2-1ubuntu1

---------------
amavisd-new (1:2.12.2-1ubuntu1) jammy; urgency=medium

  * Merge with Debian unstable (LP: #1946841). Remaining changes:
    - Add information in README.Debian about Ubuntu specific changes.
    - d/README.Debian, d/etc/conf.d/21-ubuntu_defaults: Ubuntu
      configuration changes in 21-ubuntu_defaults.
      + Reduce email responses for virus/blocked mail so as not to be
        a backscatter source by default.
      + Enable DKIM checking by default.
    - d/README.Debian,d/etc/conf.d/40-policy_banks: Include
      policy-bank of known good domains for DKIM whitelisting
      in 40-policy_banks.
    - d/control: drop altermime and ripole to Suggests after
      discussions with the server team.
    - d/control,d/amavisd-new-postfix.*: new package
      amavisd-new-postfix, configuration for anti-spam/virus.
    - do not report FQDN misconfiguration through apport.
      (LP #1587695).
      + d/control: b-dep on dh_apparmor
      + d/rules: enable dh_apparmor
      + d/amavisd-new.apport: apport script
      + d/amavisd-new.dirs: layout required dirs

 -- Miriam España Acebal <email address hidden> Fri, 18 Feb 2022 13:14:20 +0100

Changed in amavisd-new (Ubuntu):
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

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