From: Zbigniew Jędrzejewski-Szmek Date: Wed, 8 May 2019 09:29:53 +0000 (+0200) Subject: systemctl: drop one must_be_root_check() X-Git-Tag: v243-rc1~308^2~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a004cb75c0a0ae085ebc9b470afba68375a53507;p=thirdparty%2Fsystemd.git systemctl: drop one must_be_root_check() (before) $ build/systemctl list-machines Need to be root. $ sudo build/systemctl list-machines NAME STATE FAILED JOBS krowka (host) running 0 0 rawhide running 0 0 2 machines listed. (after) $ build/systemctl list-machines NAME STATE FAILED JOBS krowka (host) running 0 0 rawhide n/a 0 0 2 machines listed. The output for non-root is missing some bits of information, but we display what information is missing nicely, and e.g. in the case when no machines are running at all, or only VMs are running, the unprivileged output would be the same as the privileged one. --- diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c index 059f7220b54..aa263c79c7f 100644 --- a/src/systemctl/systemctl.c +++ b/src/systemctl/systemctl.c @@ -1950,7 +1950,7 @@ static void output_machines_list(struct machine_info *machine_infos, unsigned n) failedlen = MAX(failedlen, DECIMAL_STR_WIDTH(m->n_failed_units)); jobslen = MAX(jobslen, DECIMAL_STR_WIDTH(m->n_jobs)); - if (!arg_plain && !streq_ptr(m->state, "running")) + if (!arg_plain && m->state && !streq(m->state, "running")) circle_len = 2; } @@ -8808,7 +8808,7 @@ static int systemctl_main(int argc, char *argv[]) { { "list-sockets", VERB_ANY, VERB_ANY, VERB_ONLINE_ONLY, list_sockets }, { "list-timers", VERB_ANY, VERB_ANY, VERB_ONLINE_ONLY, list_timers }, { "list-jobs", VERB_ANY, VERB_ANY, VERB_ONLINE_ONLY, list_jobs }, - { "list-machines", VERB_ANY, VERB_ANY, VERB_ONLINE_ONLY|VERB_MUST_BE_ROOT, list_machines }, + { "list-machines", VERB_ANY, VERB_ANY, VERB_ONLINE_ONLY, list_machines }, { "clear-jobs", VERB_ANY, 1, VERB_ONLINE_ONLY, trivial_method }, { "cancel", VERB_ANY, VERB_ANY, VERB_ONLINE_ONLY, cancel_job }, { "start", 2, VERB_ANY, VERB_ONLINE_ONLY, start_unit },