From a004cb75c0a0ae085ebc9b470afba68375a53507 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Wed, 8 May 2019 11:29:53 +0200 Subject: [PATCH] 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. --- src/systemctl/systemctl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 }, -- 2.47.3