diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2019-05-08 11:48:12 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2019-05-08 11:51:51 +0200 |
commit | 4bea24696a6fb5cf3c9306e83ead5e9efc27239e (patch) | |
tree | 8223968cc7673edaf5267e3c6c11d920513815bb /src/systemctl | |
parent | 62bf89d7d2118d197c6c932c86012e72497c6d24 (diff) | |
download | systemd-4bea24696a6fb5cf3c9306e83ead5e9efc27239e.tar.gz |
systemctl: show a hint if root privileges might yield more information
Diffstat (limited to 'src/systemctl')
-rw-r--r-- | src/systemctl/systemctl.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c index aa263c79c7..61efacf868 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) { |