]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
login: effectively revert "open device if needed" 8377/head
authorAlan Jenkins <alan.christopher.jenkins@gmail.com>
Tue, 6 Mar 2018 12:28:54 +0000 (12:28 +0000)
committerAlan Jenkins <alan.christopher.jenkins@gmail.com>
Sat, 10 Mar 2018 10:47:18 +0000 (10:47 +0000)
This replaces commit 4d3900f1b7ccce03366f9a57d259d0735c1cfbcf.
The underlying cause of issue #8291 has been fixed, so there is no reason
to paper over it any more.

But it might still be useful not to crash in the face of bad restart data.
That can cause several restarts, or maybe at some point an infinite loop
of restarts.  Fail the start (or stop!) request, and write an error to the
system log.  Each time reflects a user request where we fail to resume the
display server's access (or revoke it), and it can be useful if the log
shows the most recent one.

src/login/logind-session-device.c

index 04063c37646ec1a00a631b50a031f792015e1d5e..9f0149725150969073f4be6f866a01e514a82c3a 100644 (file)
@@ -193,19 +193,16 @@ static int session_device_start(SessionDevice *sd) {
         switch (sd->type) {
 
         case DEVICE_TYPE_DRM:
-
                 if (sd->fd < 0) {
-                        /* Open device if it isn't open yet */
-                        sd->fd = session_device_open(sd, true);
-                        if (sd->fd < 0)
-                                return sd->fd;
-                } else {
-                        /* Device is kept open. Simply call drmSetMaster() and hope there is no-one else. In case it fails, we
-                         * keep the device paused. Maybe at some point we have a drmStealMaster(). */
-                        r = sd_drmsetmaster(sd->fd);
-                        if (r < 0)
-                                return r;
+                        log_error("Failed to re-activate DRM fd, as the fd was lost (maybe logind restart went wrong?)");
+                        return -EBADF;
                 }
+
+                /* Device is kept open. Simply call drmSetMaster() and hope there is no-one else. In case it fails, we
+                 * keep the device paused. Maybe at some point we have a drmStealMaster(). */
+                r = sd_drmsetmaster(sd->fd);
+                if (r < 0)
+                        return r;
                 break;
 
         case DEVICE_TYPE_EVDEV:
@@ -239,6 +236,11 @@ static void session_device_stop(SessionDevice *sd) {
         switch (sd->type) {
 
         case DEVICE_TYPE_DRM:
+                if (sd->fd < 0) {
+                        log_error("Failed to de-activate DRM fd, as the fd was lost (maybe logind restart went wrong?)");
+                        return;
+                }
+
                 /* On DRM devices we simply drop DRM-Master but keep it open.
                  * This allows the user to keep resources allocated. The
                  * CAP_SYS_ADMIN restriction to DRM-Master prevents users from