Public bug reported:
Binary package hint: unattended-upgrades
When asked to send an email report the unattended-upgrade python script
uses the 'mail' command without checking that it is present. There is
also no dependency on the mailx package, so it will not be installed
automatically.
Below is a patch I've written that uses python's own smtplib module to
send the email as well as adding a few extra bits of debugging output:
--- unattended-upgrade 2007-09-05 16:34:59.000000000 +0100
+++ unattended-upgrade_smtplib 2007-09-05 17:34:55.000000000 +0100
@@ -15,6 +15,7 @@
import apt
import logging
import subprocess
+import smtplib
class MyCache(apt.Cache):
def __init__(self):
@@ -256,14 +257,14 @@
# check if we need to send a mail
email = apt_pkg.Config.Find("Unattended-Upgrade::Mail", "")
if email != "":
- logging.debug("Sending mail with '%s' to '%s'" % (logfile_dpkg, email))
- mail = subprocess.Popen(["mail",
- "-s","unattended-upgrades result",email],
- stdin=subprocess.PIPE)
- s = "Unattended upgrade returned: %s\n\n" % (res != pm.ResultFailed)
- s += open(logfile_dpkg).read()
- mail.stdin.write(s)
- mail.stdin.close()
- ret = mail.wait()
- logging.debug("mail returned: %s" % ret)
-
+ logging.debug("Sending mail using smtplib with '%s' to '%s'" %
(logfile_dpkg, email))
+ msg = ("From: %s\r\nTo: %s\r\nSubject: unattended-upgrades
result\r\n\r\n" % ("unattended-upgrades", email))
+ msg += "Unattended upgrade returned: %s\n\n" % (res != pm.ResultFailed)
+ msg += open(logfile_dpkg).read()
+ logging.debug("Content of email should be '%s'" % (msg))
+ server = smtplib.SMTP('localhost')
+ if options.debug:
+ server.set_debuglevel(1)
+ server.sendmail("unattended-upgrades", email, msg)
+ server.quit()
+
** Affects: unattended-upgrades (Ubuntu)
Importance: Undecided
Status: New
--
Undeclared dependency on mailx
https://bugs.launchpad.net/bugs/137994
You received this bug notification because you are a member of Ubuntu
Bugs, which is the bug contact for Ubuntu.
--
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs