Package: unattended-upgrades
Version: 1.13
Severity: important
Usertags: regression

With every run of unattended-upgrades since I upgraded to 1.13 where
some packages were kept back due to upgrade issues of some kind,
I see this message as the last line of the report:

Could not open var/lib/unattended-upgrades/kept-back for saving list of 
packages kept back.

It appears that the path to the kept-back file is not correctly
determined. If I am interpreting it correctly, no-where in the code
does it change to a particular directory, and os.path.join removes all
empty arguments except a trailing one, so the code writes to a relative
path when the current directory could be anywhere and consequently it
will usually fail unless the current dir happens to be the root dir.

I'm not entirely sure what the correct solution is but I think possibly
that when rootdir is unset it should be set to / like this:

   def main(options, rootdir=None):
       if rootdir:
          
   _setup_alternative_rootdir(rootdir)
       else:
           rootdir = '/'

The current code involved in this issue looks like this: 

KEPT_PACKAGES_FILE = "var/lib/unattended-upgrades/kept-back"
...
def update_kept_packages(kept_pkgs, kept_file):
    # type: (DefaultDict[str, List[str]], str) -> None
    if kept_pkgs:
        pkgs_all_origins = set()
        for origin_pkgs in kept_pkgs.values():
            pkgs_all_origins.update(origin_pkgs)
        try:
            with open(kept_file, "w") as kf:
                kf.write(" ".join(sorted(pkgs_all_origins)))
        except FileNotFoundError:
            logging.error(_("Could not open %s for saving list of packages "
                            "kept back." % kept_file))
    else:
        if os.path.exists(kept_file):
            os.remove(kept_file)
...
def main(options, rootdir=""):
    if rootdir:
        _setup_alternative_rootdir(rootdir)
...
            update_kept_packages(res.pkgs_kept_back,
                                 os.path.join(rootdir, KEPT_PACKAGES_FILE))
...
if __name__ == "__main__":
    sys.exit(main(options))

-- System Information:
Debian Release: bullseye/sid
  APT prefers testing-debug
  APT policy: (900, 'testing-debug'), (900, 'testing'), (800, 
'unstable-debug'), (800, 'unstable'), (790, 'buildd-unstable'), (700, 
'experimental-debug'), (700, 'experimental'), (690, 'buildd-experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 4.19.0-5-amd64 (SMP w/4 CPU cores)
Kernel taint flags: TAINT_FIRMWARE_WORKAROUND, TAINT_OOT_MODULE, 
TAINT_UNSIGNED_MODULE
Locale: LANG=en_AU.utf8, LC_CTYPE=en_AU.utf8 (charmap=UTF-8), 
LANGUAGE=en_AU.utf8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages unattended-upgrades depends on:
ii  debconf [debconf-2.0]  1.5.72
ii  lsb-base               10.2019051400
ii  lsb-release            10.2019051400
ii  python3                3.7.3-1
ii  python3-apt            1.8.4
ii  python3-dbus           1.2.8-3
ii  python3-distro-info    0.21
ii  ucf                    3.0038+nmu1
ii  xz-utils               5.2.4-1

Versions of packages unattended-upgrades recommends:
ii  anacron             2.3-28
ii  cron [cron-daemon]  3.0pl1-134
ii  systemd-sysv        241-6+b1

Versions of packages unattended-upgrades suggests:
ii  bsd-mailx                                  8.1.2-0.20180807cvs-1
ii  exim4-daemon-light [mail-transport-agent]  4.92-9
ii  needrestart                                3.4-5
ii  powermgmt-base                             1.34
ii  python3-gi                                 3.30.4-1

-- 
bye,
pabs

https://wiki.debian.org/PaulWise

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to