unattended-upgrade-shutdown crashes with apt_pkg.Error: E:Syntax error /etc/apt/apt.conf:2: Extra junk at end of file

Bug #1737717 reported by errors.ubuntu.com bug bridge
12
This bug affects 1 person
Affects Status Importance Assigned to Milestone
unattended-upgrades (Ubuntu)
Fix Released
Undecided
Balint Reczey
Xenial
Fix Released
Undecided
Unassigned

Bug Description

[Impact]

 * Unattended-upgrades-shutdown service fails to stop printing a crash
 * The fix would not warrant an SRU itself but it is part of the full backport SRU tracked in LP: #1702793.

[Test Case]

 * Buggy version:
root@x-uu-1702793:~# echo extra-junk >> /etc/apt/apt.conf.d/50unattended-upgrades
root@x-uu-1702793:~# service unattended-upgrades status
● unattended-upgrades.service - Unattended Upgrades Shutdown
   Loaded: loaded (/lib/systemd/system/unattended-upgrades.service; enabled; vendor preset: enabled)
   Active: active (exited) since Fri 2019-02-08 12:55:16 UTC; 39s ago
     Docs: man:unattended-upgrade(8)
    Tasks: 0
   Memory: 0B
      CPU: 0

Feb 08 12:55:16 x-uu-1702793 systemd[1]: Started Unattended Upgrades Shutdown.
root@x-uu-1702793:~# service unattended-upgrades stop
root@x-uu-1702793:~# service unattended-upgrades status
● unattended-upgrades.service - Unattended Upgrades Shutdown
   Loaded: loaded (/lib/systemd/system/unattended-upgrades.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Fri 2019-02-08 12:56:02 UTC; 2s ago
     Docs: man:unattended-upgrade(8)
  Process: 602 ExecStop=/usr/share/unattended-upgrades/unattended-upgrade-shutdown (code=exited, status=1/FAILURE)

Feb 08 12:55:16 x-uu-1702793 systemd[1]: Started Unattended Upgrades Shutdown.
Feb 08 12:56:02 x-uu-1702793 systemd[1]: Stopping Unattended Upgrades Shutdown...
Feb 08 12:56:02 x-uu-1702793 unattended-upgrade-shutdown[602]: Traceback (most recent call last):
Feb 08 12:56:02 x-uu-1702793 unattended-upgrade-shutdown[602]: File "/usr/share/unattended-upgrades/unattended-up
Feb 08 12:56:02 x-uu-1702793 unattended-upgrade-shutdown[602]: apt_pkg.init_config()
Feb 08 12:56:02 x-uu-1702793 unattended-upgrade-shutdown[602]: SystemError: E:Syntax error /etc/apt/apt.conf.d/50un
Feb 08 12:56:02 x-uu-1702793 systemd[1]: unattended-upgrades.service: Control process exited, code=exited status=1
Feb 08 12:56:02 x-uu-1702793 systemd[1]: Stopped Unattended Upgrades Shutdown.
Feb 08 12:56:02 x-uu-1702793 systemd[1]: unattended-upgrades.service: Unit entered failed state.
Feb 08 12:56:02 x-uu-1702793 systemd[1]: unattended-upgrades.service: Failed with result 'exit-code'.

root@x-uu-1702793:~# service unattended-upgrades start
root@x-uu-1702793:~# service unattended-upgrades status
● unattended-upgrades.service - Unattended Upgrades Shutdown
   Loaded: loaded (/lib/systemd/system/unattended-upgrades.service; enabled; vendor preset: enabled)
   Active: active (exited) since Fri 2019-02-08 12:56:28 UTC; 2s ago
     Docs: man:unattended-upgrade(8)
  Process: 602 ExecStop=/usr/share/unattended-upgrades/unattended-upgrade-shutdown (code=exited, status=1/FAILURE)

 * Fixed version:
root@dd-uu-ref:~# echo extra-junk >> /etc/apt/apt.conf.d/50unattended-upgrades

root@dd-uu-ref:~# service unattended-upgrades status
● unattended-upgrades.service - Unattended Upgrades Shutdown
   Loaded: loaded (/lib/systemd/system/unattended-upgrades.service; enabled; vendor preset: enabled)
   Active: active (running) since Fri 2019-02-08 08:59:58 UTC; 3h 42min ago
     Docs: man:unattended-upgrade(8)
 Main PID: 259 (unattended-upgr)
    Tasks: 2 (limit: 4915)
   Memory: 12.4M
   CGroup: /system.slice/unattended-upgrades.service
           └─259 /usr/bin/python3 /usr/share/unattended-upgrades/unattended-upgrade-shutdown --wait-for-signal

Feb 08 08:59:58 dd-uu-ref systemd[1]: Started Unattended Upgrades Shutdown.
root@dd-uu-ref:~# service unattended-upgrades stop
root@dd-uu-ref:~# cat /var/log/unattended-upgrades/unattended-upgrades-shutdown.log
2019-02-07 16:08:14,675 WARNING - SIGTERM or SIGHUP received, stopping unattended-upgrades only if it is running
root@dd-uu-ref:~# service unattended-upgrades status
● unattended-upgrades.service - Unattended Upgrades Shutdown
   Loaded: loaded (/lib/systemd/system/unattended-upgrades.service; enabled; vendor preset: enabled)
   Active: inactive (dead) since Fri 2019-02-08 12:50:35 UTC; 7min ago
     Docs: man:unattended-upgrade(8)
  Process: 760 ExecStart=/usr/share/unattended-upgrades/unattended-upgrade-shutdown --wait-for-signal (code=exited,
 Main PID: 760 (code=exited, status=0/SUCCESS)

Feb 08 12:49:39 dd-uu-ref systemd[1]: Started Unattended Upgrades Shutdown.
Feb 08 12:50:35 dd-uu-ref systemd[1]: Stopping Unattended Upgrades Shutdown...
Feb 08 12:50:35 dd-uu-ref systemd[1]: unattended-upgrades.service: Succeeded.

[Regression Potential]

 * U-u.service used to stop crashing, now it exits normally when the APT configuration was valid when it was started. There is little chance for regressing here since the configuration file is not read again.
 * There is also an enhancement request tracked to start u-u-s with a default config when parsing the config fails to be able to act on shutdown:
https://github.com/mvo5/unattended-upgrades/issues/161

[Original Bug Text]

The Ubuntu Error Tracker has been receiving reports about a problem regarding unattended-upgrades. This problem was most recently seen with package version 0.98ubuntu1, the problem page at https://errors.ubuntu.com/problem/b1c4cd0c858e1c3c6c86f938397e8d5d4208242b contains more details, including versions of packages affected, stacktrace or traceback, and individual crash reports.
If you do not have access to the Ubuntu Error Tracker and are a software developer, you can request it at http://forms.canonical.com/reports/.

Traceback (most recent call last):
  File "/usr/share/unattended-upgrades/unattended-upgrade-shutdown", line 136, in <module>
    apt_pkg.init_config()
apt_pkg.Error: E:Syntax error /etc/apt/apt.conf:2: Extra junk at end of file

Balint Reczey (rbalint)
Changed in unattended-upgrades (Ubuntu):
status: New → In Progress
assignee: nobody → Balint Reczey (rbalint)
description: updated
summary: - /usr/share/unattended-upgrades/unattended-upgrade-
- shutdown:apt_pkg.Error:/usr/share/unattended-upgrades/unattended-
- upgrade-shutdown@136
+ unattended-upgrade-shutdown crashes with apt_pkg.Error: E:Syntax error
+ /etc/apt/apt.conf:2: Extra junk at end of file
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package unattended-upgrades - 0.99ubuntu2

---------------
unattended-upgrades (0.99ubuntu2) bionic; urgency=medium

  * Run upgrade-between-snapshots only on amd64.
    The test exercises only unattented-upgrade's Python code and uses
    dependencies from the frozen Debian snapshot archive thus running
    it on all architectures would provide little benefit.

 -- Balint Reczey <email address hidden> Tue, 13 Feb 2018 11:41:20 +0700

Changed in unattended-upgrades (Ubuntu):
status: In Progress → Fix Released
Balint Reczey (rbalint)
description: updated
Revision history for this message
Brian Murray (brian-murray) wrote : Please test proposed package

Hello errors.ubuntu.com, or anyone else affected,

Accepted unattended-upgrades into xenial-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/unattended-upgrades/1.1ubuntu1.18.04.7~16.04.0 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested and change the tag from verification-needed-xenial to verification-done-xenial. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-xenial. In either case, without details of your testing we will not be able to proceed.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance for helping!

N.B. The updated package will be released to -updates after the bug(s) fixed by this package have been verified and the package has been in -proposed for a minimum of 7 days.

Changed in unattended-upgrades (Ubuntu Xenial):
status: New → Fix Committed
tags: added: verification-needed verification-needed-xenial
Revision history for this message
Łukasz Zemczak (sil2100) wrote :

Hello errors.ubuntu.com, or anyone else affected,

Accepted unattended-upgrades into xenial-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/unattended-upgrades/1.1ubuntu1.18.04.7~16.04.1 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested and change the tag from verification-needed-xenial to verification-done-xenial. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-xenial. In either case, without details of your testing we will not be able to proceed.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance for helping!

N.B. The updated package will be released to -updates after the bug(s) fixed by this package have been verified and the package has been in -proposed for a minimum of 7 days.

Revision history for this message
Balint Reczey (rbalint) wrote :

The crash was first found and fixed in LP: #1737717 but the fix LP: #1778219 introduced it in a slightly different way on start-up.

With the fix for LP: #1737717 u-u.service can gracefully stop u-u when the APT configuration became broken _after_ starting the u-u.service but the service still throws an unhandled exception when it starts with an already broken APT configuration.

Since the original behaviour was crashing on u-u.service stopping i'm marking this but as verified on 1.1ubuntu1.18.04.7~16.04.1.

root@x-uu-ref:~# dpkg -l unattended-upgrades | cat
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-===================-==========================-============-===========================================
ii unattended-upgrades 1.1ubuntu1.18.04.7~16.04.1 all automatic installation of security upgrades
root@x-uu-ref:~# echo extra-junk >> /etc/apt/apt.conf.d/50unattended-upgrades
root@dd-uu-ref:~# service unattended-upgrades status
● unattended-upgrades.service - Unattended Upgrades Shutdown
   Loaded: loaded (/lib/systemd/system/unattended-upgrades.service; enabled; vendor preset: enabled)
   Active: active (running) since Fri 2019-02-08 08:59:58 UTC; 3h 42min ago
     Docs: man:unattended-upgrade(8)
 Main PID: 259 (unattended-upgr)
    Tasks: 2 (limit: 4915)
   Memory: 12.4M
   CGroup: /system.slice/unattended-upgrades.service
           └─259 /usr/bin/python3 /usr/share/unattended-upgrades/unattended-upgrade-shutdown --wait-for-signal

Feb 08 08:59:58 dd-uu-ref systemd[1]: Started Unattended Upgrades Shutdown.
root@dd-uu-ref:~# service unattended-upgrades stop
root@dd-uu-ref:~# cat /var/log/unattended-upgrades/unattended-upgrades-shutdown.log
2019-02-07 16:08:14,675 WARNING - SIGTERM or SIGHUP received, stopping unattended-upgrades only if it is running
2019-02-08 12:42:43,640 WARNING - SIGTERM or SIGHUP received, stopping unattended-upgrades only if it is running

description: updated
tags: added: verification-done verification-done-xenial
removed: verification-needed verification-needed-xenial
Revision history for this message
Łukasz Zemczak (sil2100) wrote :

Hello errors.ubuntu.com, or anyone else affected,

Accepted unattended-upgrades into xenial-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/unattended-upgrades/1.1ubuntu1.18.04.7~16.04.2 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested and change the tag from verification-needed-xenial to verification-done-xenial. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-xenial. In either case, without details of your testing we will not be able to proceed.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance for helping!

N.B. The updated package will be released to -updates after the bug(s) fixed by this package have been verified and the package has been in -proposed for a minimum of 7 days.

tags: added: verification-needed verification-needed-xenial
removed: verification-done verification-done-xenial
Revision history for this message
Balint Reczey (rbalint) wrote :

There were no relevant changes between .1 and .2 thus marking this bug
as verified on Xenial again.

tags: added: verification-done verification-done-xenial
removed: verification-needed verification-needed-xenial
Revision history for this message
Launchpad Janitor (janitor) wrote :
Download full text (33.9 KiB)

This bug was fixed in the package unattended-upgrades - 1.1ubuntu1.18.04.7~16.04.2

---------------
unattended-upgrades (1.1ubuntu1.18.04.7~16.04.2) xenial; urgency=medium

  * Don't check blacklist too early and report updates from not allowed origins
    as kept back. (LP: #1781176)
  * test/test_blacklisted_wrong_origin.py: Fix and enable test
  * Filter out progress indicator from dpkg log (LP: #1599646)
  * Clear cache when autoremoval fails (LP: #1779157)
  * Find autoremovable kernel packages using the patterns in APT's way
    (LP: #1815494)

unattended-upgrades (1.1ubuntu1.18.04.7~16.04.1) xenial; urgency=medium

  * Start service after systemd-logind.service to be able to take inhibition
    lock (LP: #1806487)
  * Handle gracefully when logind is down (LP: #1806487)

unattended-upgrades (1.1ubuntu1.18.04.7~16.04.0) xenial; urgency=medium

  * Backport to Xenial (LP: #1702793)
  * Revert to build-depending on debhelper (>= 9~) and dh-systemd
  * Revert configuration example changes to avoid triggering a debconf question
  * debian/postinst: Update recovery to be triggered on Xenial's package versions

unattended-upgrades (1.1ubuntu1.18.04.7) bionic; urgency=medium

  * Trigger unattended-upgrade-shutdown actions with PrepareForShutdown()
    Performing upgrades in service's ExecStop did not work when the upgrades
    involved restarting services because systemd blocked other stop/start
    actions making maintainer scripts time out and be killed leaving a broken
    system behind.
    Running unattended-upgrades.service before shutdown.target as a oneshot
    service made it run after unmounting filesystems and scheduling services
    properly on shutdown is a complex problem and adding more services to the
    mix make it even more fragile.
    The solution of monitoring PrepareForShutdown() signal from DBus
    allows Unattended Upgrade to run _before_ the jobs related to shutdown are
    queued thus package upgrades can safely restart services without
    risking causing deadlocks or breaking part of the shutdown actions.
    Also ask running unattended-upgrades to stop when shutdown starts even in
    InstallOnShutdown mode and refactor most of unattended-upgrade-shutdown to
    UnattendedUpgradesShutdown class. (LP: #1778219)
  * Increase logind's InhibitDelayMaxSec to 30s. (LP: #1778219)
    This allows more time for unattended-upgrades to shut down gracefully
    or even install a few packages in InstallOnShutdown mode, but is still a
    big step back from the 30 minutes allowed for InstallOnShutdown previously.
    Users enabling InstallOnShutdown node are advised to increase
    InhibitDelayMaxSec even further possibly to 30 minutes.
    - Add NEWS entry about increasing InhibitDelayMaxSec and InstallOnShutdown
      changes
  * Ignore "W503 line break before binary operator"
    because it will become the best practice and breaks the build
  * Stop using ActionGroups, they interfere with apt.Cache.clear()
    causing all autoremovable packages to be handled as newly autoremovable
    ones and be removed by default. Dropping ActionGroup usage does not slow
    down the most frequent case of not having anything to upgrade a...

Changed in unattended-upgrades (Ubuntu Xenial):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.