X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Flogin%2Floginctl.c;h=ff132b3866e477e6ddfbcfd7a1efb7625362b6c3;hb=3388ec3d75fe3000f63514d118a5783ccee0bb3d;hp=450fbc1ebad10f576218703b6c0242cce90d0569;hpb=f5eb2a086bc5d5d36bc2e4755a1d6b508e202250;p=elogind.git diff --git a/src/login/loginctl.c b/src/login/loginctl.c index 450fbc1eb..ff132b386 100644 --- a/src/login/loginctl.c +++ b/src/login/loginctl.c @@ -255,7 +255,6 @@ static int list_seats(int argc, char *argv[], void *userdata) { sd_bus *bus = userdata; unsigned k = 0; int r; - assert(bus); assert(argv); @@ -296,35 +295,17 @@ static int list_seats(int argc, char *argv[], void *userdata) { #if 0 /// UNNEEDED by elogind static int show_unit_cgroup(sd_bus *bus, const char *interface, const char *unit, pid_t leader) { + _cleanup_free_ char *cgroup = NULL; _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL; - _cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL; - _cleanup_free_ char *path = NULL; - const char *cgroup; unsigned c; int r; assert(bus); assert(unit); - path = unit_dbus_path_from_name(unit); - if (!path) - return log_oom(); - - r = sd_bus_get_property( - bus, - "org.freedesktop.systemd1", - path, - interface, - "ControlGroup", - &error, - &reply, - "s"); - if (r < 0) - return log_error_errno(r, "Failed to query ControlGroup: %s", bus_error_message(&error, r)); - - r = sd_bus_message_read(reply, "s", &cgroup); + r = show_cgroup_get_unit_path_and_warn(bus, unit, &cgroup); if (r < 0) - return bus_log_parse_error(r); + return r; if (isempty(cgroup)) return 0; @@ -518,14 +499,15 @@ static int print_session_status_info(sd_bus *bus, const char *path, bool *new_li {} }; + _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL; char since1[FORMAT_TIMESTAMP_RELATIVE_MAX], *s1; char since2[FORMAT_TIMESTAMP_MAX], *s2; _cleanup_(session_status_info_clear) SessionStatusInfo i = {}; int r; - r = bus_map_all_properties(bus, "org.freedesktop.login1", path, map, &i); + r = bus_map_all_properties(bus, "org.freedesktop.login1", path, map, &error, &i); if (r < 0) - return log_error_errno(r, "Could not get properties: %m"); + return log_error_errno(r, "Could not get properties: %s", bus_error_message(&error, r)); if (*new_line) printf("\n"); @@ -649,14 +631,15 @@ static int print_user_status_info(sd_bus *bus, const char *path, bool *new_line) {} }; + _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL; char since1[FORMAT_TIMESTAMP_RELATIVE_MAX], *s1; char since2[FORMAT_TIMESTAMP_MAX], *s2; _cleanup_(user_status_info_clear) UserStatusInfo i = {}; int r; - r = bus_map_all_properties(bus, "org.freedesktop.login1", path, map, &i); + r = bus_map_all_properties(bus, "org.freedesktop.login1", path, map, &error, &i); if (r < 0) - return log_error_errno(r, "Could not get properties: %m"); + return log_error_errno(r, "Could not get properties: %s", bus_error_message(&error, r)); if (*new_line) printf("\n"); @@ -725,12 +708,13 @@ static int print_seat_status_info(sd_bus *bus, const char *path, bool *new_line) {} }; + _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL; _cleanup_(seat_status_info_clear) SeatStatusInfo i = {}; int r; - r = bus_map_all_properties(bus, "org.freedesktop.login1", path, map, &i); + r = bus_map_all_properties(bus, "org.freedesktop.login1", path, map, &error, &i); if (r < 0) - return log_error_errno(r, "Could not get properties: %m"); + return log_error_errno(r, "Could not get properties: %s", bus_error_message(&error, r)); if (*new_line) printf("\n"); @@ -966,7 +950,7 @@ static int show_session(int argc, char *argv[], void *userdata) { _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL; _cleanup_free_ char *path = NULL; - r = get_session_path(bus, argv[1], &error, &path); + r = get_session_path(bus, argv[i], &error, &path); if (r < 0) { log_error("Failed to get session path: %s", bus_error_message(&error, r)); return r; @@ -1435,7 +1419,9 @@ static int help(int argc, char *argv[], void *userdata) { " -i --ignore-inhibitors When shutting down or sleeping, ignore inhibitors\n\n" #endif // 0 "Session Commands:\n" - " list-sessions List sessions\n" +#if 1 /// elogind has "list" as a shorthand for "list-sessions" + " list[-sessions] List sessions (default command)\n" +#endif // 1 " session-status [ID...] Show session status\n" " show-session [ID...] Show properties of sessions or the manager\n" " activate [ID] Activate a session\n" @@ -1636,7 +1622,12 @@ static int loginctl_main(int argc, char *argv[], sd_bus *bus) { static const Verb verbs[] = { { "help", VERB_ANY, VERB_ANY, 0, help }, +#if 0 /// elogind has "list" as a shorthand for "list-sessions" { "list-sessions", VERB_ANY, 1, VERB_DEFAULT, list_sessions }, +#else + { "list", VERB_ANY, 1, VERB_DEFAULT, list_sessions }, + { "list-sessions", VERB_ANY, 1, 0, list_sessions }, +#endif // 0 { "session-status", VERB_ANY, VERB_ANY, 0, show_session }, { "show-session", VERB_ANY, VERB_ANY, 0, show_session }, { "activate", VERB_ANY, 2, 0, activate },