diff options
author | Kenny Levinsen <kl@kl.wtf> | 2020-08-06 02:23:12 +0200 |
---|---|---|
committer | Kenny Levinsen <kl@kl.wtf> | 2020-08-06 02:25:24 +0200 |
commit | 0fd525e85e9297c999c1b651a943743c68103729 (patch) | |
tree | f552ebe483a0616420e7ea00f86235b0357560e6 /libseat | |
parent | 304489c30df7e8a70a4b453f1fe4b4671de2dfd1 (diff) |
logind: close_device always returned error
Error handling was broken in close_device, always returning -1.
Use the return value, and add a few errno assignments while we're at it.
Diffstat (limited to 'libseat')
-rw-r--r-- | libseat/backend/logind.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/libseat/backend/logind.c b/libseat/backend/logind.c index 7224508..ea2821c 100644 --- a/libseat/backend/logind.c +++ b/libseat/backend/logind.c @@ -115,6 +115,7 @@ out: static int close_device(struct libseat *base, int device_id) { struct backend_logind *session = backend_logind_from_libseat_backend(base); if (device_id < 0) { + errno = EINVAL; return -1; } @@ -133,19 +134,20 @@ static int close_device(struct libseat *base, int device_id) { sd_bus_message *msg = NULL; sd_bus_error error = SD_BUS_ERROR_NULL; - sd_bus_call_method(session->bus, "org.freedesktop.login1", session->path, - "org.freedesktop.login1.Session", "ReleaseDevice", &error, &msg, "uu", - major(st.st_rdev), minor(st.st_rdev)); + int ret = sd_bus_call_method(session->bus, "org.freedesktop.login1", session->path, + "org.freedesktop.login1.Session", "ReleaseDevice", &error, + &msg, "uu", major(st.st_rdev), minor(st.st_rdev)); sd_bus_error_free(&error); sd_bus_message_unref(msg); - return -1; + return ret >= 0; } static int switch_session(struct libseat *base, int s) { struct backend_logind *session = backend_logind_from_libseat_backend(base); if (s >= UINT16_MAX || s < 0) { + errno = EINVAL; return -1; } @@ -192,6 +194,7 @@ static int poll_connection(struct backend_logind *backend, int timeout) { } if (fd.revents & (POLLERR | POLLHUP)) { + errno = ECONNRESET; return -1; } return 0; |