chiark / gitweb /
logind: allow sessions to share a VT if it's a greeter
[elogind.git] / src / login / logind-dbus.c
index 0cc2cdf997d3d45b9c3ea467e21ba69486368225..e1476c9dba832395d9ea60ffb48d199b05f7a0fc 100644 (file)
@@ -690,8 +690,19 @@ static int method_create_session(sd_bus_message *message, void *userdata, sd_bus
         }
 
         manager_get_session_by_pid(m, leader, &session);
-        if (!session && vtnr > 0 && vtnr < m->seat0->position_count)
+        if (!session && vtnr > 0 && vtnr < m->seat0->position_count) {
                 session = m->seat0->positions[vtnr];
+                /*
+                 * Old gdm and lightdm start the user-session on the same VT as
+                 * the greeter session. But they destroy the greeter session
+                 * after the user-session and want the user-session to take
+                 * over the VT. We need to support this for
+                 * backwards-compatibility, so make sure we allow new sessions
+                 * on a VT that a greeter is running on.
+                 */
+                if (session && session->class == SESSION_GREETER)
+                        session = NULL;
+        }
         if (session) {
                 _cleanup_free_ char *path = NULL;
                 _cleanup_close_ int fifo_fd = -1;
@@ -1196,7 +1207,7 @@ static int trigger_device(Manager *m, struct udev_device *d) {
                 if (!t)
                         return -ENOMEM;
 
-                write_string_file(t, "change");
+                write_string_file(t, "change", WRITE_STRING_FILE_CREATE);
         }
 
         return 0;
@@ -1795,7 +1806,7 @@ static int nologin_timeout_handler(
 
         log_info("Creating /run/nologin, blocking further logins...");
 
-        r = write_string_file_atomic("/run/nologin", "System is going down.");
+        r = write_string_file("/run/nologin", "System is going down.", WRITE_STRING_FILE_ATOMIC);
         if (r < 0)
                 log_error_errno(r, "Failed to create /run/nologin: %m");
         else