I have setup
unattended-upgrades on servers running Raspbian (
Raspbian GNU/Linux 9.4 (stretch)). Version of Unattended-upgrades:
Updates work, but I am having problems with the email reporting.
I want to use
mailx for sending reports. If I run the update with command
unattended-upgrade -v -d the report gets sent and it uses the email configuration I have in
unattended upgrades are run by the Systemd timer (
apt-daily-upgrade.timer), however, it won’t use
sendmail is present it is used to send the mail. In that case, the mail gets sent, but the sender is
root@hostname and the messages get flagged as spam.
If there is no
sendmail I see this error in journal of
Cannot start "/usr/sbin/sendmail": executable not found (adjust *sendmail* variable)
I cannot understand why different mail programs gets used depending on how the task was started.
I have tried to edit
unattended-upgrades Python program to force it use
if os.path.exists(SENDMAIL_BINARY): ret = _send_mail_using_sendmail(from_email, to_email, subject, body) elif os.path.exists(MAIL_BINARY): ret = _send_mail_using_mailx(from_email, to_email, subject, body
I changed the variable
SENDMAIL_BINARY to point to a non-existing path so it would forced to use
mailx. This too worked when invoked
unattended-upgrades manually but failed when it was run by Systemd. (And the above error about trying to use
sendmail still gets logged.)
How can I force
unattended upgrades to use
mailx even when is run automatically by systemd and what is causing the difference in Mail program that gets used?
System unit file that runs Unattended upgrades:
[Unit] Description=Daily apt upgrade and clean activities Documentation=man:apt(8) ConditionACPower=true After=apt-daily.service [Service] Type=oneshot ExecStart=/usr/lib/apt/apt.systemd.daily install KillMode=process TimeoutStopSec=900