Hi Jochen, Thanks very much for looking into this so quickly. On a machine with root's $PATH set to the default value:
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin Without powermgmt-base installed, I am seeing the following: root# which -a on_ac_power root# (i.e. an executable on_ac_power is not found anywhere in root's $PATH), and; root# for p in $( echo $PATH | sed 's/:/ /g' ) ; do ls -l ${p}/on_ac_power ; done ls: cannot access '/usr/local/sbin/on_ac_power': No such file or directory ls: cannot access '/usr/local/bin/on_ac_power': No such file or directory ls: cannot access '/usr/sbin/on_ac_power': No such file or directory ls: cannot access '/usr/bin/on_ac_power': No such file or directory ls: cannot access '/sbin/on_ac_power': No such file or directory ls: cannot access '/bin/on_ac_power': No such file or directory root# (i.e. as far as I am able to determine, there is no on_ac_power file in root's $PATH without powermgmt-base installed on this machine). Note that, in this situation, I am seeing the following: root# which unattended-upgrade /usr/bin/unattended-upgrade root# unattended-upgrade root# (i.e. normal / expected behavior from unattended-upgrade). After installing powermgmt-base, I see the following: root# which -a on_ac_power /usr/sbin/on_ac_power /usr/bin/on_ac_power /sbin/on_ac_power /bin/on_ac_power root# for p in $( echo $PATH | sed 's/:/ /g' ) ; do ls -l ${p}/on_ac_power ; done ls: cannot access '/usr/local/sbin/on_ac_power': No such file or directory ls: cannot access '/usr/local/bin/on_ac_power': No such file or directory -rwxr-xr-x 1 root root 2228 Jul 20 2019 /usr/sbin/on_ac_power lrwxrwxrwx 1 root root 17 Jul 20 2019 /usr/bin/on_ac_power -> /sbin/on_ac_power -rwxr-xr-x 1 root root 2228 Jul 20 2019 /sbin/on_ac_power lrwxrwxrwx 1 root root 17 Jul 20 2019 /bin/on_ac_power -> /sbin/on_ac_power and unattended-upgrade continues to behave normally. I suspect that what happened was, on the machines I was testing on, incomplete uninstalls of powermgmt-base resulted in the executables being removed, but the links in /usr/bin and/or /bin to remain, creating the problem I was seeing. (I have a very slight idea how this might have happened, but that is a separate issue.) I think your recommended solution under these circumstances is the right one. Thanks again very much for looking into this. Please feel free to close this ticket (if you have not done so already). Best, -- Steve Lane On Sat, Feb 25, 2023 at 12:21 AM Jochen Sprickerhof <jspri...@debian.org> wrote: > Hi Steve, > > * Steve Lane <sdl...@lbl.gov> [2023-02-24 09:23]: > >Currently unattended-upgrades marks the powermgmt-base package > >as Suggested. powermgmt-base provides the /sbin/on_ac_power and > >/usr/sbin/on_ac_power script(s), which unattended-upgrades requires to > >function at all, because of this check in /usr/bin/unattended-upgrade > >at line 676: > > > >if apt_pkg.config.find_b("Unattended-Upgrade::OnlyOnACPower", True) \ > > and subprocess.call("on_ac_power") == 1: > > > >The absence of the powermgmt-base package, and thus the on_ac_power > >script, results in the following error: > > > >root# /usr/bin/unattended-upgrade > >Traceback (most recent call last): > > File "/usr/bin/unattended-upgrade", line 2522, in <module> > > sys.exit(main(options)) > > File "/usr/bin/unattended-upgrade", line 1993, in main > > res = run(options, rootdir, mem_log, logfile_dpkg, > > File "/usr/bin/unattended-upgrade", line 2061, in run > > if should_stop(): > > File "/usr/bin/unattended-upgrade", line 676, in should_stop > > and subprocess.call("on_ac_power") == 1: > > File "/usr/lib/python3.9/subprocess.py", line 349, in call > > with Popen(*popenargs, **kwargs) as p: > > File "/usr/lib/python3.9/subprocess.py", line 951, in __init__ > > self._execute_child(args, executable, preexec_fn, close_fds, > > File "/usr/lib/python3.9/subprocess.py", line 1823, in _execute_child > > raise child_exception_type(errno_num, err_msg, err_filename) > >PermissionError: [Errno 13] Permission denied: 'on_ac_power' > > I can't reproduce this error on a fresh stable nor unstable VM without > powermgmt-base installed. > > >(Note that it's not clear to me why this is a PermissionError, since > >the script doesn't actually exist, but that is a secondary point.) > > But this makes it reproducible: > > touch /usr/bin/on_ac_power > > So I guess you have a non executable on_ac_power in your $PATH. > > >The powermgmt-base package needs to be installed in order for > >unattended-upgrades to function at all. Thus, the powermgmt-base package > >needs to be marked as Depends for unattended-upgrades. > > I disagree and propose this patch instead: > > https://github.com/mvo5/unattended-upgrades/pull/341 > > Cheers Jochen >