X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Flogin%2Fsd-login.c;h=f433e3e80b15fc5b87f742d0f6a6627876a6dbf9;hb=bcb161b0230f;hp=4bc51e71a253ab4fea5fbcf8528ccb9b87868369;hpb=c84f5e4a825f17163ead0f60308d548b415334a5;p=elogind.git diff --git a/src/login/sd-login.c b/src/login/sd-login.c index 4bc51e71a..f433e3e80 100644 --- a/src/login/sd-login.c +++ b/src/login/sd-login.c @@ -23,12 +23,14 @@ #include #include #include +#include #include "util.h" #include "cgroup-util.h" #include "macro.h" #include "sd-login.h" #include "strv.h" +#include "fileio.h" _public_ int sd_pid_get_session(pid_t pid, char **session) { int r; @@ -196,7 +198,7 @@ _public_ int sd_uid_is_on_seat(uid_t uid, int require_active, const char *seat) } FOREACH_WORD(w, l, s, state) { - if (strncmp(t, w, l) == 0) { + if (strneq(t, w, l)) { free(s); free(t); @@ -728,7 +730,7 @@ _public_ int sd_login_monitor_new(const char *category, sd_login_monitor **m) { fd = inotify_init1(IN_NONBLOCK|IN_CLOEXEC); if (fd < 0) - return errno; + return -errno; if (!category || streq(category, "seat")) { k = inotify_add_watch(fd, "/run/systemd/seats/", IN_MOVED_TO|IN_DELETE); @@ -796,3 +798,29 @@ _public_ int sd_login_monitor_get_fd(sd_login_monitor *m) { return MONITOR_TO_FD(m); } + +_public_ int sd_login_monitor_get_events(sd_login_monitor *m) { + + if (!m) + return -EINVAL; + + /* For now we will only return POLLIN here, since we don't + * need anything else ever for inotify. However, let's have + * this API to keep our options open should we later on need + * it. */ + return POLLIN; +} + +_public_ int sd_login_monitor_get_timeout(sd_login_monitor *m, uint64_t *timeout_usec) { + + if (!m) + return -EINVAL; + if (!timeout_usec) + return -EINVAL; + + /* For now we will only return (uint64_t) -1, since we don't + * need any timeout. However, let's have this API to keep our + * options open should we later on need it. */ + *timeout_usec = (uint64_t) -1; + return 0; +}