1

Topic: spamassassin cron.daily fail

==== Required information ====
- iRedMail version (check /etc/iredmail-release):
- Linux/BSD distribution name and version:
- Store mail accounts in which backend (LDAP/MySQL/PGSQL):
- Web server (Apache or Nginx):
- Manage mail accounts with iRedAdmin-Pro?
- Related log if you're reporting an issue:
======== Required information ====
- iRedMail version (check /etc/iredmail-release): v0.9.4
- Linux/BSD distribution name and version: Debian Jessie
- Store mail accounts in which backend (LDAP/MySQL/PGSQL): PGSQL
- Web server (Apache or Nginx): Apache
- Manage mail accounts with iRedAdmin-Pro? v2.3.1
- Related log if you're reporting an issue:
====
Hi, each day the cron.daily of spamassassin return this error:

gpg: WARNING: unsafe ownership on homedir `/etc/spamassassin/sa-update-keys'
gpg: failed to create temporary file `/etc/spamassassin/sa-update-keys/.#lk0x1c953e0.mail.22583': Permission denied
gpg: keyblock resource `/etc/spamassassin/sa-update-keys/secring.gpg': general error
gpg: failed to create temporary file `/etc/spamassassin/sa-update-keys/.#lk0x1c958e0.mail.22583': Permission denied
gpg: keyblock resource `/etc/spamassassin/sa-update-keys/pubring.gpg': general error
gpg: no writable keyring found: eof
gpg: error reading `/usr/share/spamassassin/sa-update-pubkey.txt': general error
gpg: import from `/usr/share/spamassassin/sa-update-pubkey.txt' failed: general error
gpg: process '/usr/bin/gpg --homedir='/etc/spamassassin/sa-update-keys' --batch --no-tty --status-fd=1 -q --logger-fd=1 --import' finished: exit 2
./spamassassin: 74: ./spamassassin: --gpghomedir: not found
sa-update failed for unknown reasons

permissions /etc/spamassassin

-rw-r--r-- 1 root root  939 Jan 29  2013 65_debian.cf
-rw-r--r-- 1 root root 1289 Jan 31  2015 init.pre
-rw-r--r-- 1 root root 4974 Nov 11 10:08 local.cf
-rw-r--r-- 1 root root 2214 Oct  8  2013 local.cf.2013.10.08.17.43.30
-rw-r--r-- 1 root root 2213 Jan 31  2015 local.cf.dpkg-dist
-rw-r--r-- 1 root root 4487 Nov 11 09:59 local.cf.stable
-rw-r--r-- 1 root root  118 Jan 31  2015 sa-compile.pre
drwxr-xr-x 2 root root 4096 Apr 15 09:37 sa-update-hooks.d
drwx------ 2 root root 4096 Apr  7 09:13 sa-update-keys
-rw-r--r-- 1 root root 2524 Jan 29  2013 v310.pre
-rw-r--r-- 1 root root 1194 Jan 29  2013 v312.pre
-rw-r--r-- 1 root root 2416 Jan 29  2013 v320.pre
-rw-r--r-- 1 root root 1237 Jan 29  2013 v330.pre
-rw-r--r-- 1 root root 1020 Jan 31  2015 v340.pre

----

Spider Email Archiver: On-Premises, lightweight email archiving software developed by iRedMail team. Supports Amazon S3 compatible storage and custom branding.

2

Re: spamassassin cron.daily fail

Try this:

chown root:root /etc/spamassassin/sa-update-keys
chmod 0773 /etc/spamassassin/sa-update-keys
chmod o+t /etc/spamassassin/sa-update-keys

3 (edited by d4Mn3d 2016-04-16 15:59:02)

Re: spamassassin cron.daily fail

The permission issue it's ok, but now i have this result:

root@mail:/home/d4Mn3d# chown root:root /etc/spamassassin/sa-update-keys
root@mail:/home/d4Mn3d# chmod 0773 /etc/spamassassin/sa-update-keys
root@mail:/home/d4Mn3d# chmod o+t /etc/spamassassin/sa-update-keys
root@mail:/home/d4Mn3d# cd /etc/cron.daily/
root@mail:/etc/cron.daily# ./spamassassin
./spamassassin: 74: ./spamassassin: --gpghomedir: not found
sa-update failed for unknown reasons
root@mail:/etc/cron.daily#

Output of sa-update -D

Apr 16 09:58:17.304 [24499] dbg: logger: adding facilities: all
Apr 16 09:58:17.304 [24499] dbg: logger: logging level is DBG
Apr 16 09:58:17.304 [24499] dbg: generic: SpamAssassin version 3.4.0
Apr 16 09:58:17.304 [24499] dbg: generic: Perl 5.020002, PREFIX=/usr, DEF_RULES_DIR=/usr/share/spamassassin, LOCAL_RULES_DIR=/etc/spamassassin, LOCAL_STATE_DIR=/var/lib/spamassassin
Apr 16 09:58:17.305 [24499] dbg: config: timing enabled
Apr 16 09:58:17.305 [24499] dbg: config: score set 0 chosen.
Apr 16 09:58:17.309 [24499] dbg: generic: sa-update version svn1475932
Apr 16 09:58:17.309 [24499] dbg: generic: using update directory: /var/lib/spamassassin/3.004000
Apr 16 09:58:17.402 [24499] dbg: diag: perl platform: 5.020002 linux
Apr 16 09:58:17.402 [24499] dbg: diag: [...] module installed: Digest::SHA, version 5.88
Apr 16 09:58:17.402 [24499] dbg: diag: [...] module installed: HTML::Parser, version 3.71
Apr 16 09:58:17.402 [24499] dbg: diag: [...] module installed: Net::DNS, version 0.81
Apr 16 09:58:17.402 [24499] dbg: diag: [...] module installed: NetAddr::IP, version 4.075
Apr 16 09:58:17.402 [24499] dbg: diag: [...] module installed: Time::HiRes, version 1.9726
Apr 16 09:58:17.402 [24499] dbg: diag: [...] module installed: Archive::Tar, version 1.96
Apr 16 09:58:17.402 [24499] dbg: diag: [...] module installed: IO::Zlib, version 1.10
Apr 16 09:58:17.402 [24499] dbg: diag: [...] module not installed: Digest::SHA1 ('require' failed)
Apr 16 09:58:17.402 [24499] dbg: diag: [...] module installed: MIME::Base64, version 3.14
Apr 16 09:58:17.403 [24499] dbg: diag: [...] module installed: DB_File, version 1.831
Apr 16 09:58:17.403 [24499] dbg: diag: [...] module installed: Net::SMTP, version 2.33
Apr 16 09:58:17.403 [24499] dbg: diag: [...] module installed: Mail::SPF, version v2.009
Apr 16 09:58:17.403 [24499] dbg: diag: [...] module not installed: Geo::IP ('require' failed)
Apr 16 09:58:17.403 [24499] dbg: diag: [...] module not installed: Razor2::Client::Agent ('require' failed)
Apr 16 09:58:17.403 [24499] dbg: diag: [...] module installed: IO::Socket::IP, version 0.29
Apr 16 09:58:17.403 [24499] dbg: diag: [...] module installed: IO::Socket::INET6, version 2.72
Apr 16 09:58:17.403 [24499] dbg: diag: [...] module installed: IO::Socket::SSL, version 2.002
Apr 16 09:58:17.403 [24499] dbg: diag: [...] module installed: Compress::Zlib, version 2.064
Apr 16 09:58:17.403 [24499] dbg: diag: [...] module installed: Mail::DKIM, version 0.4
Apr 16 09:58:17.404 [24499] dbg: diag: [...] module installed: DBI, version 1.631
Apr 16 09:58:17.404 [24499] dbg: diag: [...] module installed: Getopt::Long, version 2.42
Apr 16 09:58:17.404 [24499] dbg: diag: [...] module installed: LWP::UserAgent, version 6.06
Apr 16 09:58:17.404 [24499] dbg: diag: [...] module installed: HTTP::Date, version 6.02
Apr 16 09:58:17.404 [24499] dbg: diag: [...] module not installed: Encode::Detect ('require' failed)
Apr 16 09:58:17.404 [24499] dbg: diag: [...] module not installed: Net::Patricia ('require' failed)
Apr 16 09:58:17.405 [24499] dbg: gpg: Searching for 'gpg'
Apr 16 09:58:17.405 [24499] dbg: util: current PATH is: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
Apr 16 09:58:17.405 [24499] dbg: util: executable for gpg was found at /usr/bin/gpg
Apr 16 09:58:17.405 [24499] dbg: gpg: found /usr/bin/gpg
Apr 16 09:58:17.405 [24499] dbg: gpg: release trusted key id list: 5E541DC959CB8BAC7C78DFDC4056A61A5244EC45 0C2B1D7175B852C64B3CDC716C55397824F434CE
Apr 16 09:58:17.406 [24499] dbg: channel: attempting channel updates.spamassassin.org
Apr 16 09:58:17.406 [24499] dbg: channel: using existing directory /var/lib/spamassassin/3.004000/updates_spamassassin_org
Apr 16 09:58:17.406 [24499] dbg: channel: channel cf file /var/lib/spamassassin/3.004000/updates_spamassassin_org.cf
Apr 16 09:58:17.406 [24499] dbg: channel: channel pre file /var/lib/spamassassin/3.004000/updates_spamassassin_org.pre
Apr 16 09:58:17.406 [24499] dbg: channel: metadata version = 1736402, from file /var/lib/spamassassin/3.004000/updates_spamassassin_org.cf
Apr 16 09:58:17.450 [24499] dbg: dns: 0.4.3.updates.spamassassin.org => 1736402, parsed as 1736402
Apr 16 09:58:17.451 [24499] dbg: channel: current version is 1736402, new version is 1736402, skipping channel
Apr 16 09:58:17.451 [24499] dbg: diag: updates complete, exiting with code 1

4

Re: spamassassin cron.daily fail

d4Mn3d wrote:

Apr 16 09:58:17.451 [24499] dbg: channel: current version is 1736402, new version is 1736402, skipping channel

It says you're running the latest version.

5 (edited by d4Mn3d 2016-04-17 00:57:35)

Re: spamassassin cron.daily fail

ok, but the cron return me this error, is it normal?:

./spamassassin: 74: ./spamassassin: --gpghomedir: not found
sa-update failed for unknown reasons

6

Re: spamassassin cron.daily fail

d4Mn3d wrote:

root@mail:/etc/cron.daily# ./spamassassin
./spamassassin: 74: ./spamassassin: --gpghomedir: not found
sa-update failed for unknown reasons

You run it directly, this is not proper.

7

Re: spamassassin cron.daily fail

Thank you Zhang, but every day i receive this email:

from: Cron Daemon <root@mail.mydomain.com>
to: “root@mail.mydomain.com” <root@mail.mydomain.com>

/etc/cron.daily/spamassassin:
/etc/cron.daily/spamassassin: 74: /etc/cron.daily/spamassassin: --gpghomedir: not found
sa-update failed for unknown reasons

8

Re: spamassassin cron.daily fail

Weird, i don't get this error while running this script manually. Could you please show us FULL output of commands below?

cd /etc/cron.daily/
bash -xv spamassassin

9 (edited by d4Mn3d 2016-04-18 17:15:21)

Re: spamassassin cron.daily fail

sure, output is:

#!/bin/sh

# Duncan Findlay
# duncf@debian.org

# Daily cronjob for SpamAssassin updates. This isn't pretty but it
# should do the job.

CRON=0
+ CRON=0

test -f /etc/default/spamassassin && . /etc/default/spamassassin
+ test -f /etc/default/spamassassin
+ . /etc/default/spamassassin
# /etc/default/spamassassin
# Duncan Findlay

# WARNING: please read README.spamd before using.
# There may be security risks.

# Change to one to enable spamd
ENABLED=0
++ ENABLED=0

# Options
# See man spamd for possible options. The -d option is automatically added.

# SpamAssassin uses a preforking model, so be careful! You need to
# make sure --max-children is not set to anything higher than 5,
# unless you know what you're doing.

OPTIONS="--create-prefs --max-children 5 --helper-home-dir"
++ OPTIONS='--create-prefs --max-children 5 --helper-home-dir'

# Pid file
# Where should spamd write its PID to file? If you use the -u or
# --username option above, this needs to be writable by that user.
# Otherwise, the init script will not be able to shut spamd down.
PIDFILE="/var/run/spamd.pid"
++ PIDFILE=/var/run/spamd.pid

# Set nice level of spamd
#NICE="--nicelevel 15"

# Cronjob
# Set to anything but 0 to enable the cron job to automatically update
# spamassassin's rules on a nightly basis
CRON=1
++ CRON=1

test -x /usr/bin/sa-update || exit 0
+ test -x /usr/bin/sa-update
test -x /etc/init.d/spamassassin || exit 0
+ test -x /etc/init.d/spamassassin

if [ "$CRON" = "0" ] ; then
    exit 0
fi
+ '[' 1 = 0 ']'

# If there's a problem with the ruleset or configs, print the output
# of spamassassin --lint (which will typically get emailed to root)
# and abort.
die_with_lint() {
    env -i LANG="$LANG" PATH="$PATH" start-stop-daemon \
        --child debian-spamd:debian:spamd --start \
        --exec /usr/sbin/spamassasin -- -D --lint 2>&1
    exit 1
}

do_compile() {
# Compile rules if the required tools are available. Prior to version
# 3.3.2-8, there was an additional check to verify that an sa-compile
# run had previously been executed by hand. With sa-learn now
# distributed in a separate, optional, package, this check is no
# longer necessary.
    if [ -x /usr/bin/re2c -a -x /usr/bin/sa-compile ]; then
        env -i LANG="$LANG" PATH="$PATH" start-stop-daemon \
            --chuid debian-spamd:debian-spamd --start \
            --exec /usr/bin/sa-compile -- --quiet

        # Fixup perms -- group and other should be able to
        # read and execute, but never write.  Works around
        # sa-compile's failure to obey umask.
        chmod -R go-w,go+rX /var/lib/spamassassin/compiled
    fi
}

# Tell a running spamd to reload its configs and rules.
reload() {
    # Reload
    if which invoke-rc.d >/dev/null 2>&1; then
        invoke-rc.d spamassassin reload > /dev/null
    else
        /etc/init.d/spamassassin reload > /dev/null
    fi
    if [ -d /etc/spamassassin/sa-update-hooks.d ]; then
        run-parts --lsbsysinit /etc/spamassassin/sa-update-hooks.d
    fi
}

# Sleep for up to 3600 seconds if not runnin interactively
if [ ! -t 0 ]; then
    RANGE=3600
    number=`od -vAn -N2 -tu4 < /dev/urandom`
    number=`expr $number "%" $RANGE`
    sleep $number
fi
+ '[' '!' -t 0 ']'

# Update
umask 022
+ umask 022
env -i LANG="$LANG" PATH="$PATH" start-stop-daemon \
    --chuid debian-spamd:debian-spamd --start \
    --exec /usr/bin/sa-update -- \
+ env -i LANG=en_GB.UTF-8 PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games start-stop-daemon --chuid debian-spamd:debian-spamd --start --exec /usr/bin/sa-update -- ' '
env: start-stop-daemon: No such file or directory
    --gpghomedir /var/lib/spamassassin/sa-update-keys 2>&1
+ --gpghomedir /var/lib/spamassassin/sa-update-keys
spamassassin: line 74: --gpghomedir: command not found

case $? in
    0)
        # got updates!
        env -i LANG="$LANG" PATH="$PATH" start-stop-daemon \
            --child debian-spamd:debian-spamd --start \
            --exec /usr/bin/spamassassin -- --lint 2>&1 || die_with_lint
        do_compile
        reload
        ;;
    1)
        # no updates
        exit 0
        ;;
    2)
        # lint failed!
        die_with_lint
        ;;
    *)
        echo "sa-update failed for unknown reasons" 1>&2
        ;;
esac
+ case $? in
+ echo 'sa-update failed for unknown reasons'
sa-update failed for unknown reasons

# Local variables:
# mode: shell-script
# tab-width: 4
# indent-tabs-mode: nil
# end:

10

Re: spamassassin cron.daily fail

Did you run it with 'sh -xv ' or 'bash -xv'?
Seems the shell is not bash.

11

Re: spamassassin cron.daily fail

I confirm that I used 'bash -xv spamassassin'

12

Re: spamassassin cron.daily fail

No idea. cannot reproduce this issue on my server or testing machines.