From 1e922cc7ff016dd7ca56678bdc39453032fe79b9 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Mon, 12 Aug 2024 13:49:54 +1000 Subject: [PATCH 1/2] logind: if EVIOCREVOKE fails, don't try it again Let's assume that if the ioctl fails once with EINVAL, we won't have to try this again. --- src/login/logind-session-device.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/login/logind-session-device.c b/src/login/logind-session-device.c index c924f1e0ca..1b3eb718f7 100644 --- a/src/login/logind-session-device.c +++ b/src/login/logind-session-device.c @@ -95,9 +95,8 @@ static void sd_eviocrevoke(int fd) { assert(fd >= 0); - if (ioctl(fd, EVIOCREVOKE, NULL) < 0) { - - if (errno == EINVAL && !warned) { + if (!warned && ioctl(fd, EVIOCREVOKE, NULL) < 0) { + if (errno == EINVAL) { log_warning_errno(errno, "Kernel does not support evdev-revocation: %m"); warned = true; } From 4fc6bd9e7d4c99d3e61c985caae218d74e71f454 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Mon, 12 Aug 2024 14:05:13 +1000 Subject: [PATCH 2/2] logind: warn about EVIOCREVOKE errors other than EINVAL too EINVAL means the kernel doesn't support it, ENODEV means it's already revoked or the device is no longer there which has the same effect anyway. All others - let's print an error to the logs. --- src/login/logind-session-device.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/login/logind-session-device.c b/src/login/logind-session-device.c index 1b3eb718f7..2aff0b7c8c 100644 --- a/src/login/logind-session-device.c +++ b/src/login/logind-session-device.c @@ -97,8 +97,10 @@ static void sd_eviocrevoke(int fd) { if (!warned && ioctl(fd, EVIOCREVOKE, NULL) < 0) { if (errno == EINVAL) { - log_warning_errno(errno, "Kernel does not support evdev-revocation: %m"); + log_warning_errno(errno, "Kernel does not support evdev-revocation, continuing without revoking device access: %m"); warned = true; + } else if (errno != ENODEV) { + log_warning_errno(errno, "Failed to revoke evdev device, continuing without revoking device access: %m"); } } }