From: Zbigniew Jędrzejewski-Szmek Date: Thu, 30 Apr 2020 12:26:36 +0000 (+0200) Subject: systemctl: refuse online-only ops with --root X-Git-Tag: v246-rc1~439^2~7 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4cb1015e6b815f72ae7ba4b04d8e7f856e9c51fe;p=thirdparty%2Fsystemd.git systemctl: refuse online-only ops with --root It is super confusing when a command does not support --root, and is called with it specified, and returns some bogus results. Let's just catch this early and refuse. --- diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c index 0a3d975d888..077609f4de6 100644 --- a/src/systemctl/systemctl.c +++ b/src/systemctl/systemctl.c @@ -9213,6 +9213,12 @@ static int systemctl_main(int argc, char *argv[]) { {} }; + const Verb *verb = verbs_find_verb(argv[optind], verbs); + if (verb && (verb->flags & VERB_ONLINE_ONLY) && arg_root) + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), + "Verb '%s' cannot be used with --root=.", + argv[optind] ?: verb->verb); + return dispatch_verb(argc, argv, verbs, NULL); }