chiark / gitweb /
logind: remove unused session->closing field
[elogind.git] / src / login / logind-dbus.c
index a972d93774eb9946539e107a605ee5a6c5407c99..a4bdf5f28cf9cc8e19e69c471f32c2c4984a48c1 100644 (file)
@@ -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)
@@ -1252,7 +1252,6 @@ static int have_multiple_sessions(
          * count, and non-login sessions do not count either. */
         HASHMAP_FOREACH(session, m->sessions, i)
                 if (session->class == SESSION_USER &&
-                    !session->closing &&
                     session->user->uid != uid)
                         return true;
 
@@ -1399,7 +1398,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
@@ -1465,7 +1464,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,
@@ -1610,7 +1609,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);
@@ -2105,6 +2104,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);
@@ -2113,12 +2113,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 */