1
0
mirror of https://github.com/systemd/systemd.git synced 2025-02-15 09:57:39 +03:00

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.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2020-04-30 14:26:36 +02:00
parent 9321e23c40
commit 4cb1015e6b

View File

@ -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);
}