if (!path)
return -ENOMEM;
+ log_debug("Sending reply about an existing session: "
+ "id=%s object_path=%s uid=%u runtime_path=%s "
+ "session_fd=%d seat=%s vtnr=%u",
+ session->id,
+ path,
+ (uint32_t) session->user->uid,
+ session->user->runtime_path,
+ fifo_fd,
+ session->seat ? session->seat->id : "",
+ (uint32_t) session->vtnr);
+
return sd_bus_reply_method_return(
message, "soshusub",
session->id,
if (!session)
return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_SESSION, "No session '%s' known", name);
- r = session_stop(session);
+ r = session_stop(session, true);
if (r < 0)
return r;
if (!user)
return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_USER, "No user '%lu' known or logged in", (unsigned long) uid);
- r = user_stop(user);
+ r = user_stop(user, true);
if (r < 0)
return r;
if (!seat)
return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_SEAT, "No seat '%s' known", name);
- r = seat_stop_sessions(seat);
+ r = seat_stop_sessions(seat, true);
if (r < 0)
return r;
q, NULL);
}
+static int lid_switch_ignore_handler(sd_event_source *e, uint64_t usec, void *userdata) {
+ Manager *m = userdata;
+
+ assert(e);
+ assert(m);
+
+ m->lid_switch_ignore_event_source = sd_event_source_unref(m->lid_switch_ignore_event_source);
+ return 0;
+}
+
+int manager_set_lid_switch_ignore(Manager *m, usec_t until) {
+ int r;
+
+ assert(m);
+
+ if (until <= now(CLOCK_MONOTONIC))
+ return 0;
+
+ /* We want to ignore the lid switch for a while after each
+ * suspend, and after boot-up. Hence let's install a timer for
+ * this. As long as the event source exists we ignore the lid
+ * switch. */
+
+ if (m->lid_switch_ignore_event_source) {
+ usec_t u;
+
+ r = sd_event_source_get_time(m->lid_switch_ignore_event_source, &u);
+ if (r < 0)
+ return r;
+
+ if (until <= u)
+ return 0;
+
+ r = sd_event_source_set_time(m->lid_switch_ignore_event_source, until);
+ } else
+ r = sd_event_add_time(
+ m->event,
+ &m->lid_switch_ignore_event_source,
+ CLOCK_MONOTONIC,
+ until, 0,
+ lid_switch_ignore_handler, m);
+
+ return r;
+}
+
static int execute_shutdown_or_sleep(
Manager *m,
InhibitWhat w,
m->action_job = c;
m->action_what = w;
+ /* Make sure the lid switch is ignored for a while */
+ manager_set_lid_switch_ignore(m, now(CLOCK_MONOTONIC) + IGNORE_LID_SWITCH_SUSPEND_USEC);
+
return 0;
}
action_multiple_sessions, interactive, error, method, m);
if (r < 0)
return r;
+ if (r == 0)
+ return 1; /* No authorization for now, but the async polkit stuff will call us again when it has it */
}
if (blocked) {
action_ignore_inhibit, interactive, error, method, m);
if (r < 0)
return r;
+ if (r == 0)
+ return 1; /* No authorization for now, but the async polkit stuff will call us again when it has it */
}
if (!multiple_sessions && !blocked) {
action, interactive, error, method, m);
if (r < 0)
return r;
+ if (r == 0)
+ return 1; /* No authorization for now, but the async polkit stuff will call us again when it has it */
}
r = bus_manager_shutdown_or_sleep_now_or_later(m, unit_name, w, error);
r = unit_name_from_dbus_path(path, &unit);
if (r < 0)
- return r;
+ /* quietly ignore non-units paths */
+ return r == -EINVAL ? 0 : r;
session = hashmap_get(m->session_units, unit);
if (session)
r = sd_bus_message_new_method_call(
manager->bus,
+ &m,
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
- "StartTransientUnit",
- &m);
+ "StartTransientUnit");
if (r < 0)
return r;
}
int manager_abandon_scope(Manager *manager, const char *scope, sd_bus_error *error) {
- _cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
_cleanup_free_ char *path = NULL;
int r;