X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Flogin%2Flogind-dbus.c;h=9538150e2e548c6051a75357c5d5e95f3056d64e;hb=c506027af881a9e4210845a7a8a6ec5910aa0f3b;hp=b1c2ef19b13da67d6f999857572625a219666d3e;hpb=ebcf1f97de4f6b1580ae55eb56b1a3939fe6b602;p=elogind.git diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c index b1c2ef19b..9538150e2 100644 --- a/src/login/logind-dbus.c +++ b/src/login/logind-dbus.c @@ -496,7 +496,7 @@ static int method_create_session(sd_bus *bus, sd_bus_message *message, void *use if (v <= 0) return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Cannot determine VT number from virtual console TTY %s", tty); - if (vtnr <= 0) + if (!vtnr) vtnr = (uint32_t) v; else if (vtnr != (uint32_t) v) return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Specified TTY and VT number do not match"); @@ -514,7 +514,7 @@ static int method_create_session(sd_bus *bus, sd_bus_message *message, void *use if (seat) { if (seat_has_vts(seat)) { - if (vtnr > 63) + if (!vtnr || vtnr > 63) return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "VT number out of range"); } else { if (vtnr != 0) @@ -568,11 +568,12 @@ static int method_create_session(sd_bus *bus, sd_bus_message *message, void *use return -ENOMEM; return sd_bus_reply_method_return( - message, "soshsub", + message, "soshusub", session->id, path, session->user->runtime_path, fifo_fd, + (uint32_t) session->user->uid, session->seat ? session->seat->id : "", (uint32_t) session->vtnr, true); @@ -1398,7 +1399,7 @@ int bus_manager_shutdown_or_sleep_now_or_later( delayed = m->inhibit_delay_max > 0 && - manager_is_inhibited(m, w, INHIBIT_DELAY, NULL, false, false, 0); + manager_is_inhibited(m, w, INHIBIT_DELAY, NULL, false, false, 0, NULL); if (delayed) /* Shutdown is delayed, keep in mind what we @@ -1464,7 +1465,7 @@ static int method_do_shutdown_or_sleep( return r; multiple_sessions = r > 0; - blocked = manager_is_inhibited(m, w, INHIBIT_BLOCK, NULL, false, true, uid); + blocked = manager_is_inhibited(m, w, INHIBIT_BLOCK, NULL, false, true, uid, NULL); if (multiple_sessions) { r = bus_verify_polkit_async(m->bus, &m->polkit_registry, message, @@ -1609,7 +1610,7 @@ static int method_can_shutdown_or_sleep( return r; multiple_sessions = r > 0; - blocked = manager_is_inhibited(m, w, INHIBIT_BLOCK, NULL, false, true, uid); + blocked = manager_is_inhibited(m, w, INHIBIT_BLOCK, NULL, false, true, uid, NULL); if (multiple_sessions) { r = bus_verify_polkit(m->bus, message, action_multiple_sessions, false, &challenge, error); @@ -1855,7 +1856,7 @@ const sd_bus_vtable manager_vtable[] = { SD_BUS_METHOD("ListUsers", NULL, "a(uso)", method_list_users, 0), SD_BUS_METHOD("ListSeats", NULL, "a(so)", method_list_seats, 0), SD_BUS_METHOD("ListInhibitors", NULL, "a(ssssuu)", method_list_inhibitors, 0), - SD_BUS_METHOD("CreateSession", "uussssussbssa(sv)", "soshsub", method_create_session, 0), + SD_BUS_METHOD("CreateSession", "uussssussbssa(sv)", "soshusub", method_create_session, 0), SD_BUS_METHOD("ReleaseSession", "s", NULL, method_release_session, 0), SD_BUS_METHOD("ActivateSession", "s", NULL, method_activate_session, 0), SD_BUS_METHOD("ActivateSessionOnSeat", "ss", NULL, method_activate_session_on_seat, 0), @@ -2104,6 +2105,7 @@ int manager_send_changed(Manager *manager, const char *property, ...) { int manager_dispatch_delayed(Manager *manager) { _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL; + Inhibitor *offending = NULL; int r; assert(manager); @@ -2112,12 +2114,18 @@ int manager_dispatch_delayed(Manager *manager) { return 0; /* Continue delay? */ - if (manager_is_inhibited(manager, manager->action_what, INHIBIT_DELAY, NULL, false, false, 0)) { + if (manager_is_inhibited(manager, manager->action_what, INHIBIT_DELAY, NULL, false, false, 0, &offending)) { + _cleanup_free_ char *comm = NULL, *u = NULL; + + get_process_comm(offending->pid, &comm); + u = uid_to_name(offending->uid); if (manager->action_timestamp + manager->inhibit_delay_max > now(CLOCK_MONOTONIC)) return 0; - log_info("Delay lock is active but inhibitor timeout is reached."); + log_info("Delay lock is active (UID %lu/%s, PID %lu/%s) but inhibitor timeout is reached.", + (unsigned long) offending->uid, strna(u), + (unsigned long) offending->pid, strna(comm)); } /* Actually do the operation */ @@ -2216,6 +2224,10 @@ int manager_start_scope( if (r < 0) return r; + r = sd_bus_message_append(m, "a(sa(sv))", 0); + if (r < 0) + return r; + r = sd_bus_call(manager->bus, m, 0, error, &reply); if (r < 0) return r;