summaryrefslogtreecommitdiff
path: root/src/systemctl
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2023-03-11 17:03:37 +0900
committerLennart Poettering <lennart@poettering.net>2023-03-13 12:27:34 +0100
commitd77d42ed3ae95ee035dce4707777b077d1a9bf8b (patch)
tree2cbe5f1ba4437d84d9688fc8b83d84e5fa6c0a7a /src/systemctl
parent560900be67694798b2230e9b5d4b9449733a2c01 (diff)
downloadsystemd-d77d42ed3ae95ee035dce4707777b077d1a9bf8b.tar.gz
systemctl: refuse to acquire dbus connection with --global
Maybe, better to check the runtime scope each verb for better log message, but this is a good start point to not trigger assertion. Fixes oss-fuzz#56915 (https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=56915). Fixes #26402 and #26754.
Diffstat (limited to 'src/systemctl')
-rw-r--r--src/systemctl/systemctl-util.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/systemctl/systemctl-util.c b/src/systemctl/systemctl-util.c
index bc1be36bd2..6e87b18494 100644
--- a/src/systemctl/systemctl-util.c
+++ b/src/systemctl/systemctl-util.c
@@ -36,6 +36,9 @@ int acquire_bus(BusFocus focus, sd_bus **ret) {
assert(focus < _BUS_FOCUS_MAX);
assert(ret);
+ if (!IN_SET(arg_runtime_scope, RUNTIME_SCOPE_SYSTEM, RUNTIME_SCOPE_USER))
+ return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP), "--global is not supported for this operation.");
+
/* We only go directly to the manager, if we are using a local transport */
if (arg_transport != BUS_TRANSPORT_LOCAL)
focus = BUS_FULL;