From: Zbigniew Jędrzejewski-Szmek Date: Wed, 8 May 2019 09:48:12 +0000 (+0200) Subject: systemctl: show a hint if root privileges might yield more information X-Git-Tag: v243-rc1~308^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4bea24696a6fb5cf3c9306e83ead5e9efc27239e;p=thirdparty%2Fsystemd.git systemctl: show a hint if root privileges might yield more information --- diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c index aa263c79c7f..61efacf868f 100644 --- a/src/systemctl/systemctl.c +++ b/src/systemctl/systemctl.c @@ -1940,6 +1940,7 @@ static void output_machines_list(struct machine_info *machine_infos, unsigned n) statelen = STRLEN("STATE"), failedlen = STRLEN("FAILED"), jobslen = STRLEN("JOBS"); + bool state_missing; assert(machine_infos || n == 0); @@ -1989,9 +1990,12 @@ static void output_machines_list(struct machine_info *machine_infos, unsigned n) if (circle_len > 0) printf("%s%s%s ", on_state, circle ? special_glyph(SPECIAL_GLYPH_BLACK_CIRCLE) : " ", off_state); + if (!m->state) + state_missing = true; + if (m->is_host) printf("%-*s (host) %s%-*s%s %s%*" PRIu32 "%s %*" PRIu32 "\n", - (int) (namelen - (STRLEN(" (host)"))), + (int) (namelen - strlen(" (host)")), strna(m->name), on_state, statelen, strna(m->state), off_state, on_failed, failedlen, m->n_failed_units, off_failed, @@ -2004,8 +2008,12 @@ static void output_machines_list(struct machine_info *machine_infos, unsigned n) jobslen, m->n_jobs); } - if (!arg_no_legend) - printf("\n%u machines listed.\n", n); + if (!arg_no_legend) { + printf("\n"); + if (state_missing && geteuid() != 0) + printf("Notice: some information only available to privileged users was not shown.\n"); + printf("%u machines listed.\n", n); + } } static int list_machines(int argc, char *argv[], void *userdata) {