chiark / gitweb /
logind: log which process is delaying suspend and not closing locks
[elogind.git] / src / login / logind-dbus.c
index b1c2ef19b13da67d6f999857572625a219666d3e..e0333cd6b0bc883784551c88eb7a43554e523e22 100644 (file)
@@ -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;