]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
logind: when setting a new controller, don't prepare the VT if logind is restarted
authorFranck Bui <fbui@suse.com>
Wed, 26 Apr 2017 12:20:41 +0000 (14:20 +0200)
committerFranck Bui <fbui@suse.com>
Thu, 8 Jun 2017 14:21:36 +0000 (16:21 +0200)
When assigning a new session controller to a session, the VT is prepared so the
controller can expect the VT to be in a good default state.

However when logind is restarted and a session controller already took control
of a session, there's no need to prepare th VT otherwise logind may screw up
the VT state set by the controller.

This patch prevents the preparation of the VT in this case.

src/login/logind-session-dbus.c
src/login/logind-session.c
src/login/logind-session.h

index 22dea5db1f959961cec4ec7309c154dfd294be74..412efcd958f5c17167cdf754242687211ca2eb9c 100644 (file)
@@ -396,7 +396,7 @@ static int method_take_control(sd_bus_message *message, void *userdata, sd_bus_e
         if (uid != 0 && (force || uid != s->user->uid))
                 return sd_bus_error_setf(error, SD_BUS_ERROR_ACCESS_DENIED, "Only owner of session may take control");
 
-        r = session_set_controller(s, sd_bus_message_get_sender(message), force);
+        r = session_set_controller(s, sd_bus_message_get_sender(message), force, true);
         if (r < 0)
                 return r;
 
index 4a168906d6f8f70391289ba9de7fbc11189490a4..ae05877a68681a8a22724d7b641d9f3200ee00fc 100644 (file)
@@ -449,7 +449,7 @@ int session_load(Session *s) {
 
         if (controller) {
                 if (bus_name_has_owner(s->manager->bus, controller, NULL) > 0)
-                        session_set_controller(s, controller, false);
+                        session_set_controller(s, controller, false, false);
                 else
                         session_restore_vt(s);
         }
@@ -1170,7 +1170,7 @@ static int on_bus_track(sd_bus_track *track, void *userdata) {
         return 0;
 }
 
-int session_set_controller(Session *s, const char *sender, bool force) {
+int session_set_controller(Session *s, const char *sender, bool force, bool prepare) {
         _cleanup_free_ char *name = NULL;
         int r;
 
@@ -1202,11 +1202,14 @@ int session_set_controller(Session *s, const char *sender, bool force) {
          * Note that we reset the VT on ReleaseControl() and if the controller
          * exits.
          * If logind crashes/restarts, we restore the controller during restart
-         * or reset the VT in case it crashed/exited, too. */
-        r = session_prepare_vt(s);
-        if (r < 0) {
-                s->track = sd_bus_track_unref(s->track);
-                return r;
+         * (without preparing the VT since the controller has probably overridden
+         * VT state by now) or reset the VT in case it crashed/exited, too. */
+        if (prepare) {
+                r = session_prepare_vt(s);
+                if (r < 0) {
+                        s->track = sd_bus_track_unref(s->track);
+                        return r;
+                }
         }
 
         session_release_controller(s, true);
index ffb7cd2d4176ef174025e06bfd85cba2184b651c..c8a3152acb58f3108de921f50f27c3f819629872 100644 (file)
@@ -176,7 +176,7 @@ void session_restore_vt(Session *s);
 void session_leave_vt(Session *s);
 
 bool session_is_controller(Session *s, const char *sender);
-int session_set_controller(Session *s, const char *sender, bool force);
+int session_set_controller(Session *s, const char *sender, bool force, bool prepare);
 void session_drop_controller(Session *s);
 
 int bus_session_method_activate(sd_bus_message *message, void *userdata, sd_bus_error *error);