chiark / gitweb /
Help output spring cleaning
[elogind.git] / src / login / loginctl.c
index cb05907ff12dc97cf62c523475663e6b1eed2d0f..f96a568610b07e78be5bb3784842ab064f875b9b 100644 (file)
@@ -53,7 +53,6 @@ static char *arg_host = NULL;
 
 static void pager_open_if_enabled(void) {
 
-        /* Cache result before we open the pager */
         if (arg_no_pager)
                 return;
 
@@ -67,12 +66,10 @@ static void polkit_agent_open_if_enabled(void) {
         if (!arg_ask_password)
                 return;
 
-        polkit_agent_open();
-}
+        if (arg_transport != BUS_TRANSPORT_LOCAL)
+                return;
 
-static int log_parse_error(int r) {
-        log_error("Failed to parse message: %s", strerror(-r));
-        return r;
+        polkit_agent_open();
 }
 
 static int list_sessions(sd_bus *bus, char **args, unsigned n) {
@@ -100,7 +97,7 @@ static int list_sessions(sd_bus *bus, char **args, unsigned n) {
 
         r = sd_bus_message_enter_container(reply, 'a', "(susso)");
         if (r < 0)
-                return log_parse_error(r);
+                return bus_log_parse_error(r);
 
         printf("%10s %10s %-16s %-16s\n", "SESSION", "UID", "USER", "SEAT");
 
@@ -109,7 +106,7 @@ static int list_sessions(sd_bus *bus, char **args, unsigned n) {
                 k++;
         }
         if (r < 0)
-                return log_parse_error(r);
+                return bus_log_parse_error(r);
 
         printf("\n%u sessions listed.\n", k);
 
@@ -141,7 +138,7 @@ static int list_users(sd_bus *bus, char **args, unsigned n) {
 
         r = sd_bus_message_enter_container(reply, 'a', "(uso)");
         if (r < 0)
-                return log_parse_error(r);
+                return bus_log_parse_error(r);
 
         printf("%10s %-16s\n", "UID", "USER");
 
@@ -150,7 +147,7 @@ static int list_users(sd_bus *bus, char **args, unsigned n) {
                 k++;
         }
         if (r < 0)
-                return log_parse_error(r);
+                return bus_log_parse_error(r);
 
         printf("\n%u users listed.\n", k);
 
@@ -181,7 +178,7 @@ static int list_seats(sd_bus *bus, char **args, unsigned n) {
 
         r = sd_bus_message_enter_container(reply, 'a', "(so)");
         if (r < 0)
-                return log_parse_error(r);
+                return bus_log_parse_error(r);
 
         printf("%-16s\n", "SEAT");
 
@@ -190,7 +187,7 @@ static int list_seats(sd_bus *bus, char **args, unsigned n) {
                 k++;
         }
         if (r < 0)
-                return log_parse_error(r);
+                return bus_log_parse_error(r);
 
         printf("\n%u seats listed.\n", k);
 
@@ -254,7 +251,7 @@ typedef struct SessionStatusInfo {
         uid_t uid;
         const char *name;
         usec_t timestamp;
-        int vtnr;
+        unsigned int vtnr;
         const char *seat;
         const char *tty;
         const char *display;
@@ -372,9 +369,9 @@ static int print_session_status_info(sd_bus *bus, const char *path) {
                 {}
         };
 
-        SessionStatusInfo i = {};
         char since1[FORMAT_TIMESTAMP_RELATIVE_MAX], *s1;
         char since2[FORMAT_TIMESTAMP_MAX], *s2;
+        SessionStatusInfo i = {};
         int r;
 
         r = bus_map_all_properties(bus, "org.freedesktop.login1", path, map, &i);
@@ -527,8 +524,8 @@ static int print_seat_status_info(sd_bus *bus, const char *path) {
 
         static const struct bus_properties_map map[]  = {
                 { "Id",            "s",     NULL, offsetof(SeatStatusInfo, id) },
-                { "ActiveSession", "(so)",  &prop_map_first_of_struct, offsetof(SeatStatusInfo, active_session) },
-                { "Sessions",      "a(so)", &prop_map_sessions_strv, offsetof(SeatStatusInfo, sessions) },
+                { "ActiveSession", "(so)",  prop_map_first_of_struct, offsetof(SeatStatusInfo, active_session) },
+                { "Sessions",      "a(so)", prop_map_sessions_strv, offsetof(SeatStatusInfo, sessions) },
                 {}
         };
 
@@ -620,7 +617,7 @@ static int show_session(sd_bus *bus, char **args, unsigned n) {
 
                 r = sd_bus_message_read(reply, "o", &path);
                 if (r < 0)
-                        return log_parse_error(r);
+                        return bus_log_parse_error(r);
 
                 if (show_properties)
                         r = bus_print_all_properties(bus, "org.freedesktop.login1", path, NULL, arg_all);
@@ -687,7 +684,7 @@ static int show_user(sd_bus *bus, char **args, unsigned n) {
 
                 r = sd_bus_message_read(reply, "o", &path);
                 if (r < 0)
-                        return log_parse_error(r);
+                        return bus_log_parse_error(r);
 
                 if (show_properties)
                         r = bus_print_all_properties(bus, "org.freedesktop.login1", path, NULL, arg_all);
@@ -747,7 +744,7 @@ static int show_seat(sd_bus *bus, char **args, unsigned n) {
 
                 r = sd_bus_message_read(reply, "o", &path);
                 if (r < 0)
-                        return log_parse_error(r);
+                        return bus_log_parse_error(r);
 
                 if (show_properties)
                         r = bus_print_all_properties(bus, "org.freedesktop.login1", path, NULL, arg_all);
@@ -1040,29 +1037,29 @@ static int help(void) {
                "     --kill-who=WHO      Who to send signal to\n"
                "  -s --signal=SIGNAL     Which signal to send\n\n"
                "Commands:\n"
-               "  list-sessions                   List sessions\n"
-               "  session-status [ID...]          Show session status\n"
-               "  show-session [ID...]            Show properties of one or more sessions\n"
-               "  activate [ID]                   Activate a session\n"
-               "  lock-session [ID...]            Screen lock one or more sessions\n"
-               "  unlock-session [ID...]          Screen unlock one or more sessions\n"
-               "  lock-sessions                   Screen lock all current sessions\n"
-               "  unlock-sessions                 Screen unlock all current sessions\n"
-               "  terminate-session [ID...]       Terminate one or more sessions\n"
-               "  kill-session [ID...]            Send signal to processes of a session\n"
-               "  list-users                      List users\n"
-               "  user-status [USER...]           Show user status\n"
-               "  show-user [USER...]             Show properties of one or more users\n"
-               "  enable-linger [USER...]         Enable linger state of one or more users\n"
-               "  disable-linger [USER...]        Disable linger state of one or more users\n"
-               "  terminate-user [USER...]        Terminate all sessions of one or more users\n"
-               "  kill-user [USER...]             Send signal to processes of a user\n"
-               "  list-seats                      List seats\n"
-               "  seat-status [NAME...]           Show seat status\n"
-               "  show-seat [NAME...]             Show properties of one or more seats\n"
-               "  attach [NAME] [DEVICE...]       Attach one or more devices to a seat\n"
-               "  flush-devices                   Flush all device associations\n"
-               "  terminate-seat [NAME...]        Terminate all sessions on one or more seats\n",
+               "  list-sessions            List sessions\n"
+               "  session-status ID...     Show session status\n"
+               "  show-session [ID...]     Show properties of sessions or the manager\n"
+               "  activate ID              Activate a session\n"
+               "  lock-session ID...       Screen lock one or more sessions\n"
+               "  unlock-session ID...     Screen unlock one or more sessions\n"
+               "  lock-sessions            Screen lock all current sessions\n"
+               "  unlock-sessions          Screen unlock all current sessions\n"
+               "  terminate-session ID...  Terminate one or more sessions\n"
+               "  kill-session ID...       Send signal to processes of a session\n"
+               "  list-users               List users\n"
+               "  user-status USER...      Show user status\n"
+               "  show-user [USER...]      Show properties of users or the manager\n"
+               "  enable-linger USER...    Enable linger state of one or more users\n"
+               "  disable-linger USER...   Disable linger state of one or more users\n"
+               "  terminate-user USER...   Terminate all sessions of one or more users\n"
+               "  kill-user USER...        Send signal to processes of a user\n"
+               "  list-seats               List seats\n"
+               "  seat-status NAME...      Show seat status\n"
+               "  show-seat NAME...        Show properties of one or more seats\n"
+               "  attach NAME DEVICE...    Attach one or more devices to a seat\n"
+               "  flush-devices            Flush all device associations\n"
+               "  terminate-seat NAME...   Terminate all sessions on one or more seats\n",
                program_invocation_short_name);
 
         return 0;