Undeclared dependency on mailx
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
unattended-upgrades (Ubuntu) |
Fix Released
|
Undecided
|
Michael Vogt |
Bug Description
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-
@@ -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.
if email != "":
- logging.
- mail = subprocess.
- "-s","unattende
- stdin=subproces
- s = "Unattended upgrade returned: %s\n\n" % (res != pm.ResultFailed)
- s += open(logfile_
- mail.stdin.write(s)
- mail.stdin.close()
- ret = mail.wait()
- logging.debug("mail returned: %s" % ret)
-
+ logging.
+ msg = ("From: %s\r\nTo: %s\r\nSubject: unattended-upgrades result\r\n\r\n" % ("unattended-
+ msg += "Unattended upgrade returned: %s\n\n" % (res != pm.ResultFailed)
+ msg += open(logfile_
+ logging.
+ server = smtplib.
+ if options.debug:
+ server.
+ server.
+ server.quit()
+
There is another undeclared dependency here - having a mail server on the localhost. This may not always be wanted.
The patch could be changed by adding another configuration variable for the mail server, which would default to localhost if not set.