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

Attachment: signature.asc
Description: PGP signature

Reply via email to