]> git.ipfire.org Git - thirdparty/systemd.git/commit
systemctl: support --global and --root in edit and cat 39606/head
authorgvenugo3 <gvenugo3@asu.edu>
Tue, 11 Nov 2025 17:00:29 +0000 (10:00 -0700)
committergvenugo3 <gvenugo3@asu.edu>
Tue, 11 Nov 2025 17:00:29 +0000 (10:00 -0700)
commitebd222b1c8341cd9739a51eec922b4f1eaf0198f
tree9834bddebafd0751428fd084540e483106b38844
parent423a8ffccc79922b35a3d452f9ca6201fbcfd14d
systemctl: support --global and --root in edit and cat

Make bus acquisition conditional in verb_edit() and verb_cat(), following
the same pattern used in verb_enable(). When install_client_side() returns
non-zero (indicating --global, --root, offline, or similar scenarios), skip
acquiring a D-Bus connection and perform all operations client-side.

Changes:
- Only acquire bus when install_client_side() returns NO
- Use mangle_names() instead of expand_unit_names() in client-side mode
- Pass force_client_side flag based on bus availability
- Skip bus-dependent operations (need_daemon_reload, etc.) when bus is NULL

This allows 'systemctl edit --global' and 'systemctl cat --global' to work
correctly, fixing the regression introduced by commit d77d42ed3a.

Test cases added to verify:
- Creating and editing global user units with --runtime
- Reading global units with cat --global
- Proper detection and rejection of masked units in client-side mode
- Tests use /run/ instead of /etc/ for safer temporary testing

Fixes https://github.com/systemd/systemd/issues/31272
src/systemctl/systemctl-edit.c
test/units/TEST-26-SYSTEMCTL.sh