Public bug reported:
When `netplan generate` is run as a non-root user (e.g., triggered by a
NetworkManager dispatcher after a connection change), it successfully
generates config files but then crashes with an unhandled
subprocess.CalledProcessError when attempting `systemctl daemon-reload
--no-ask-password`. The daemon-reload command requires root privileges
and fails, causing the entire operation to crash and file an apport
report instead of completing gracefully.
Steps to reproduce:
1. Run `netplan generate` as a non-root user (e.g., after NetworkManager
triggers it via dispatcher)
2. The config generation succeeds, but systemctl daemon-reload fails with exit
status 1
3. The unhandled exception causes an apport crash report
Traceback:
File "/usr/sbin/netplan", line 23, in <module>
netplan.main()
File "/usr/share/netplan/netplan_cli/cli/core.py", line 58, in main
self.run_command()
File "/usr/share/netplan/netplan_cli/cli/utils.py", line 340, in run_command
self.func()
File "/usr/share/netplan/netplan_cli/cli/commands/generate.py", line 47, in run
self.run_command()
File "/usr/share/netplan/netplan_cli/cli/utils.py", line 340, in run_command
self.func()
File "/usr/share/netplan/netplan_cli/cli/commands/generate.py", line 127, in
command_generate
utils.systemctl_daemon_reload()
File "/usr/share/netplan/netplan_cli/cli/utils.py", line 173, in
systemctl_daemon_reload
subprocess.check_call(['systemctl', 'daemon-reload', '--no-ask-password'])
subprocess.CalledProcessError: Command '['systemctl', 'daemon-reload',
'--no-ask-password']' returned non-zero exit status 1.
Expected behavior: netplan generate should handle the daemon-reload
failure gracefully when run as a non-root user, since generating config
files does not require elevated privileges. The daemon-reload should be
wrapped in a try/except or checked for root privileges before
attempting.
Ubuntu version: 26.04 LTS (Resolute Raccoon)
netplan.io version: (from crash report - apport generated report
_usr_share_netplan_netplan.script.1000.crash)
** Affects: netplan.io (Ubuntu)
Importance: Undecided
Status: New
--
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2161924
Title:
netplan generate crashes with CalledProcessError when run as non-root
user
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/netplan.io/+bug/2161924/+subscriptions
--
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs