Package: cron-apt
Version: 0.10.0
Severity: minor

Dear Ola,

/usr/share/cron-apt/functions contains an error (cf. code extract
below): The mail subject never will be "... error on ..." (line 103)
because the error file tested for existance gets deleted beforehand
(line 84ff.).  Thus one cannot trust mails like "completed on..."

I've solved the issue by moving the "if -f ... rm -f ..." clean-up below
the mail command (cf. patch below).

/usr/share/cron-apt/functions:
 84     if [ -f "$ERROR" ] ; then
 85         rm -f "$ERROR"
 86     fi
 87     if [ -f "$RUNSYSLOG" ] ; then
 88         rm -f "$RUNSYSLOG"
 89     fi
 90     if [ -f "$RUNERROR" ] ; then
 91         rm -f "$RUNERROR"
 92     fi
 93     if [ -f "$RUNMAIL" ] ; then
 94         rm -f "$RUNMAIL"
 95     fi
 96     if [ -f "$MAIL" ] && [ "$MAILON" != "never" ] && [ -n "$MAILON" ] ; then
 97         if command -v sendmail >/dev/null; then
 98             HDR="To: $MAILTO"
 99             if [ -z "$HOSTNAME" ]; then
100                 HOSTNAME="$(uname -n)"
101             fi
102             if [ -f "$ERROR" ] ; then
103                 HDR=$(printf "$HDR\nSubject: CRON-APT error on $HOSTNAME 
[$CONFIG]")
104             else
105                 HDR=$(printf "$HDR\nSubject: CRON-APT completed on 
$HOSTNAME [$CONFIG]")
106             fi

--- /tmp/functions      2018-05-23 19:54:05.000000000 +0200
+++ /usr/share/cron-apt/functions       2018-05-23 19:56:36.875793315
+0200
@@ -81,9 +81,6 @@
     if [ -f "$RUNLOG" ] ; then
        rm -f "$RUNLOG"
     fi
-    if [ -f "$ERROR" ] ; then
-       rm -f "$ERROR"
-    fi
     if [ -f "$RUNSYSLOG" ] ; then
        rm -f "$RUNSYSLOG"
     fi
@@ -123,6 +120,9 @@
     if [ -f "$DIFF" ] ; then
        rm -f "$DIFF"
     fi
+    if [ -f "$ERROR" ] ; then
+       rm -f "$ERROR"
+    fi
     if [ -d "$TMPDIR" ] ; then
        rmdir "$TMPDIR"
     fi


BTW, one could move all clean-up code ("if -f ... rm -f ...") below the
mail function in order to prevent similar bugs when extending the mail
function with other variables in the future.

Thank you in advance for merging the patch into mainline version -- and
for spending your free time as debian developer.


Best regards -- Sebastian

-- System Information:
Debian Release: 9.4
Architecture: amd64 (x86_64)

Kernel: Linux 4.9.0-6-amd64 (SMP w/1 CPU core)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), 
LANGUAGE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages cron-apt depends on:
ii  apt  1.4.8

Versions of packages cron-apt recommends:
ii  cron [cron-daemon]                 3.0pl1-128+deb9u1
ii  liblockfile1                       1.14-1+b1
ii  nullmailer [mail-transport-agent]  1:1.13-1.2

cron-apt suggests no packages.

-- Configuration Files:
/etc/cron-apt/action.d/0-update [Errno 2] No such file or directory: 
'/etc/cron-apt/action.d/0-update'
/etc/cron-apt/action.d/3-download [Errno 2] No such file or directory: 
'/etc/cron-apt/action.d/3-download'
/etc/cron-apt/config changed [not included]
/etc/cron.d/cron-apt changed [not included]

-- no debconf information

Reply via email to