chiark / gitweb /
Remove systemd subscription and user/session units
[elogind.git] / src / login / logind-dbus.c
index 3322d66aa9e889ad0f41d50cc437609b3e6fdf4b..9e8cf05390301193c6142614e963481285267dac 100644 (file)
@@ -797,6 +797,15 @@ static int method_create_session(sd_bus *bus, sd_bus_message *message, void *use
          * created. We send the reply back from
          * session_send_create_reply(). */
 
+        /* Elogind note: replying directly, since we're not actually
+           starting slices and thus we aren't waiting on systemd.  */
+
+        r = session_send_create_reply(session, NULL);
+        if (r < 0)
+                goto fail;
+
+        session_save(session);
+
         return 1;
 
 fail:
@@ -827,7 +836,9 @@ static int method_release_session(sd_bus *bus, sd_bus_message *message, void *us
         if (r < 0)
                 return r;
 
-        session_release(session);
+        r = session_release(session);
+        if (r < 0)
+                return r;
 
         return sd_bus_reply_method_return(message, NULL);
 }
@@ -1448,7 +1459,7 @@ static int execute_shutdown_or_sleep(
         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);
+        manager_set_lid_switch_ignore(m, now(CLOCK_MONOTONIC) + m->holdoff_timeout_usec);
 
         return 0;
 }
@@ -1964,7 +1975,6 @@ fail:
 const sd_bus_vtable manager_vtable[] = {
         SD_BUS_VTABLE_START(0),
 
-        SD_BUS_PROPERTY("NAutoVTs", "u", NULL, offsetof(Manager, n_autovts), SD_BUS_VTABLE_PROPERTY_CONST),
         SD_BUS_PROPERTY("KillOnlyUsers", "as", NULL, offsetof(Manager, kill_only_users), SD_BUS_VTABLE_PROPERTY_CONST),
         SD_BUS_PROPERTY("KillExcludeUsers", "as", NULL, offsetof(Manager, kill_exclude_users), SD_BUS_VTABLE_PROPERTY_CONST),
         SD_BUS_PROPERTY("KillUserProcesses", "b", NULL, offsetof(Manager, kill_user_processes), SD_BUS_VTABLE_PROPERTY_CONST),
@@ -1979,6 +1989,7 @@ const sd_bus_vtable manager_vtable[] = {
         SD_BUS_PROPERTY("HandleHibernateKey", "s", property_get_handle_action, offsetof(Manager, handle_hibernate_key), SD_BUS_VTABLE_PROPERTY_CONST),
         SD_BUS_PROPERTY("HandleLidSwitch", "s", property_get_handle_action, offsetof(Manager, handle_lid_switch), SD_BUS_VTABLE_PROPERTY_CONST),
         SD_BUS_PROPERTY("HandleLidSwitchDocked", "s", property_get_handle_action, offsetof(Manager, handle_lid_switch_docked), SD_BUS_VTABLE_PROPERTY_CONST),
+        SD_BUS_PROPERTY("HoldoffTimeoutUSec", "t", NULL, offsetof(Manager, holdoff_timeout_usec), SD_BUS_VTABLE_PROPERTY_CONST),
         SD_BUS_PROPERTY("IdleAction", "s", property_get_handle_action, offsetof(Manager, idle_action), SD_BUS_VTABLE_PROPERTY_CONST),
         SD_BUS_PROPERTY("IdleActionUSec", "t", NULL, offsetof(Manager, idle_action_usec), SD_BUS_VTABLE_PROPERTY_CONST),
         SD_BUS_PROPERTY("PreparingForShutdown", "b", property_get_preparing, 0, 0),
@@ -2054,196 +2065,6 @@ static int session_jobs_reply(Session *s, const char *unit, const char *result)
         return r;
 }
 
-int match_job_removed(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
-        const char *path, *result, *unit;
-        Manager *m = userdata;
-        Session *session;
-        uint32_t id;
-        User *user;
-        int r;
-
-        assert(bus);
-        assert(message);
-        assert(m);
-
-        r = sd_bus_message_read(message, "uoss", &id, &path, &unit, &result);
-        if (r < 0) {
-                bus_log_parse_error(r);
-                return r;
-        }
-
-        if (m->action_job && streq(m->action_job, path)) {
-                log_info("Operation finished.");
-
-                /* Tell people that they now may take a lock again */
-                send_prepare_for(m, m->action_what, false);
-
-                free(m->action_job);
-                m->action_job = NULL;
-                m->action_unit = NULL;
-                m->action_what = 0;
-                return 0;
-        }
-
-        session = hashmap_get(m->session_units, unit);
-        if (session) {
-
-                if (streq_ptr(path, session->scope_job)) {
-                        free(session->scope_job);
-                        session->scope_job = NULL;
-                }
-
-                session_jobs_reply(session, unit, result);
-
-                session_save(session);
-                session_add_to_gc_queue(session);
-        }
-
-        user = hashmap_get(m->user_units, unit);
-        if (user) {
-
-                if (streq_ptr(path, user->service_job)) {
-                        free(user->service_job);
-                        user->service_job = NULL;
-                }
-
-                if (streq_ptr(path, user->slice_job)) {
-                        free(user->slice_job);
-                        user->slice_job = NULL;
-                }
-
-                LIST_FOREACH(sessions_by_user, session, user->sessions) {
-                        session_jobs_reply(session, unit, result);
-                }
-
-                user_save(user);
-                user_add_to_gc_queue(user);
-        }
-
-        return 0;
-}
-
-int match_unit_removed(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
-        const char *path, *unit;
-        Manager *m = userdata;
-        Session *session;
-        User *user;
-        int r;
-
-        assert(bus);
-        assert(message);
-        assert(m);
-
-        r = sd_bus_message_read(message, "so", &unit, &path);
-        if (r < 0) {
-                bus_log_parse_error(r);
-                return r;
-        }
-
-        session = hashmap_get(m->session_units, unit);
-        if (session)
-                session_add_to_gc_queue(session);
-
-        user = hashmap_get(m->user_units, unit);
-        if (user)
-                user_add_to_gc_queue(user);
-
-        return 0;
-}
-
-int match_properties_changed(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
-        _cleanup_free_ char *unit = NULL;
-        Manager *m = userdata;
-        const char *path;
-        Session *session;
-        User *user;
-        int r;
-
-        assert(bus);
-        assert(message);
-        assert(m);
-
-        path = sd_bus_message_get_path(message);
-        if (!path)
-                return 0;
-
-        r = unit_name_from_dbus_path(path, &unit);
-        if (r == -EINVAL) /* not a unit */
-                return 0;
-        if (r < 0)
-                return r;
-
-        session = hashmap_get(m->session_units, unit);
-        if (session)
-                session_add_to_gc_queue(session);
-
-        user = hashmap_get(m->user_units, unit);
-        if (user)
-                user_add_to_gc_queue(user);
-
-        return 0;
-}
-
-int match_reloading(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
-        Manager *m = userdata;
-        Session *session;
-        Iterator i;
-        int b, r;
-
-        assert(bus);
-
-        r = sd_bus_message_read(message, "b", &b);
-        if (r < 0) {
-                bus_log_parse_error(r);
-                return r;
-        }
-
-        if (b)
-                return 0;
-
-        /* systemd finished reloading, let's recheck all our sessions */
-        log_debug("System manager has been reloaded, rechecking sessions...");
-
-        HASHMAP_FOREACH(session, m->sessions, i)
-                session_add_to_gc_queue(session);
-
-        return 0;
-}
-
-int match_name_owner_changed(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
-        const char *name, *old, *new;
-        Manager *m = userdata;
-        Session *session;
-        Iterator i;
-        int r;
-
-
-        char *key;
-
-        r = sd_bus_message_read(message, "sss", &name, &old, &new);
-        if (r < 0) {
-                bus_log_parse_error(r);
-                return r;
-        }
-
-        if (isempty(old) || !isempty(new))
-                return 0;
-
-        key = set_remove(m->busnames, (char*) old);
-        if (!key)
-                return 0;
-
-        /* Drop all controllers owned by this name */
-
-        free(key);
-
-        HASHMAP_FOREACH(session, m->sessions, i)
-                if (session_is_controller(session, old))
-                        session_drop_controller(session);
-
-        return 0;
-}
-
 int manager_send_changed(Manager *manager, const char *property, ...) {
         char **l;