On Fri, Mar 22, 2013 at 04:45:29PM +0100, Michael Vogt wrote:
> On Thu, Mar 21, 2013 at 12:47:12PM +0100, Christian Hofstaedtler wrote:
> > Package: unattended-upgrades
> > Version: 0.79.4
> > Severity: important
> 
> Thanks for your bugreport.
>  
> > unattended-upgrades normally sends an email when there is a package that's
> > not going to be installed because of a modified conffile.
> > When u-a installs other packages in the same run, the mail doesn't get sent
> > out.
> > 
> > Unattended-Upgrade::MailOnlyOnError is set to "true".
> [..]
> > I only got the warning email on 2013-03-21, but not on 2013-03-20.
> > 
> > As this might lead people into thinking their security upgrades are fine 
> > when they aren't, I consider this important.
> 
> Looking at the code I can confirm this, there is a one day delay right
> now due to the way its implemented. I will see how to fix this.

The attached patch should fix the problem.

Thanks again for the bugreport!
 Michael
=== modified file 'test/test_mail.py'
--- test/test_mail.py	2012-11-11 15:34:52 +0000
+++ test/test_mail.py	2013-03-27 15:23:55 +0000
@@ -87,6 +87,13 @@
         self.assertTrue(
             "Packages that attempted to upgrade:\n 2vcard" in mail_txt)
 
+    def test_mail_on_error_with_warning_in_log(self):
+        apt_pkg.config.set("Unattended-Upgrade::MailOnlyOnError", "true")
+        pkgs, res, pkgs_kept_back, mem_log, logfile_dpkg = self._return_mock_data(successful=True)
+        mem_log.write("\nWARNING: some warning\n")
+        send_summary_mail(pkgs, res, pkgs_kept_back, mem_log, logfile_dpkg)
+        self.assertTrue(os.path.exists("mail.txt"))
+
     def test_apt_listchanges(self):
         # test with sendmail available
         unattended_upgrade.SENDMAIL_BINARY="/bin/true"

=== modified file 'unattended-upgrade'
--- unattended-upgrade	2013-03-13 14:43:22 +0000
+++ unattended-upgrade	2013-03-27 15:29:00 +0000
@@ -627,6 +627,8 @@
     # if the operation was successful and the user has requested to get
     # mails on on errors, just exit here
     if (res and
+        # see Debian Bug #703621
+        not re.search("^WARNING:", mem_log.getvalue(), re.MULTILINE) and
         apt_pkg.config.find_b("Unattended-Upgrade::MailOnlyOnError", False)):
 	return
     # Check if reboot-required flag is present

Reply via email to