]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
systemctl: fix edit and cat verbs with --global flag (#39606)
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 11 Nov 2025 23:59:06 +0000 (08:59 +0900)
committerGitHub <noreply@github.com>
Tue, 11 Nov 2025 23:59:06 +0000 (08:59 +0900)
The --global flag has been broken since commit
d77d42ed3ae95ee035dce4707777b077d1a9bf8b, which added a
blanket restriction on acquiring D-Bus connections when
arg_runtime_scope is RUNTIME_SCOPE_GLOBAL. This was done to prevent
crashes, but inadvertently broke legitimate use cases like 'systemctl
edit --global' and 'systemctl cat --global'.

The issue is that verb_edit() and verb_cat() were unconditionally
calling acquire_bus(), which triggers the restriction and fails with
"--global is not supported for this operation."

This commit fixes the issue by making bus acquisition conditional,
following the same pattern used in verb_enable():

- Only acquire the bus when install_client_side() returns NO (i.e., for
system and user scopes)
- For client-side operations (--global, --root, etc.), skip bus
acquisition and use mangle_names() instead of expand_unit_names()
- Update find_paths_to_edit() and verb_cat() to handle NULL bus by
forcing client-side path lookups
- Skip bus-dependent checks (unit_is_masked, need_daemon_reload) when
bus is NULL

This allows both 'systemctl edit --global' and 'systemctl cat --global'
to work correctly by performing all operations client-side without
requiring a connection to the system or user manager.

Fixes #31272

1  2 
test/units/TEST-26-SYSTEMCTL.sh

Simple merge