Skip to content

Commit f270533

Browse files
committed
login: effectively revert "open device if needed"
This replaces commit 4d3900f. The underlying cause of issue systemd#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.
1 parent 1bef256 commit f270533

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

src/login/logind-session-device.c

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -193,19 +193,16 @@ static int session_device_start(SessionDevice *sd) {
193193
switch (sd->type) {
194194

195195
case DEVICE_TYPE_DRM:
196-
197196
if (sd->fd < 0) {
198-
/* Open device if it isn't open yet */
199-
sd->fd = session_device_open(sd, true);
200-
if (sd->fd < 0)
201-
return sd->fd;
202-
} else {
203-
/* Device is kept open. Simply call drmSetMaster() and hope there is no-one else. In case it fails, we
204-
* keep the device paused. Maybe at some point we have a drmStealMaster(). */
205-
r = sd_drmsetmaster(sd->fd);
206-
if (r < 0)
207-
return r;
197+
log_error("Failed to re-activate DRM fd, as the fd was lost (maybe logind restart went wrong?)");
198+
return -EBADF;
208199
}
200+
201+
/* Device is kept open. Simply call drmSetMaster() and hope there is no-one else. In case it fails, we
202+
* keep the device paused. Maybe at some point we have a drmStealMaster(). */
203+
r = sd_drmsetmaster(sd->fd);
204+
if (r < 0)
205+
return r;
209206
break;
210207

211208
case DEVICE_TYPE_EVDEV:
@@ -239,6 +236,11 @@ static void session_device_stop(SessionDevice *sd) {
239236
switch (sd->type) {
240237

241238
case DEVICE_TYPE_DRM:
239+
if (sd->fd < 0) {
240+
log_error("Failed to de-activate DRM fd, as the fd was lost (maybe logind restart went wrong?)");
241+
return;
242+
}
243+
242244
/* On DRM devices we simply drop DRM-Master but keep it open.
243245
* This allows the user to keep resources allocated. The
244246
* CAP_SYS_ADMIN restriction to DRM-Master prevents users from

0 commit comments

Comments
 (0)