X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fsd-login.c;h=d44a1fcf9c473487f5e48355f2681659a3305de1;hp=6dfc2d086e4ff9d0895929d62859389d5cf3da39;hb=add30678a1bf284ecd79438d219c45ca7a1c9f51;hpb=034a2a52ac0ec83e0229941d635d310b23eb04df diff --git a/src/sd-login.c b/src/sd-login.c index 6dfc2d086..d44a1fcf9 100644 --- a/src/sd-login.c +++ b/src/sd-login.c @@ -327,7 +327,6 @@ _public_ int sd_session_is_active(const char *session) { _public_ int sd_session_get_uid(const char *session, uid_t *uid) { int r; char *p, *s = NULL; - unsigned long ul; if (!session) return -EINVAL; @@ -349,14 +348,10 @@ _public_ int sd_session_get_uid(const char *session, uid_t *uid) { if (!s) return -EIO; - r = safe_atolu(s, &ul); + r = parse_uid(s, uid); free(s); - if (r < 0) - return r; - - *uid = (uid_t) ul; - return 0; + return r; } _public_ int sd_session_get_seat(const char *session, char **seat) { @@ -527,6 +522,36 @@ _public_ int sd_seat_get_sessions(const char *seat, char ***sessions, uid_t **ui return 0; } +_public_ int sd_seat_can_multi_session(const char *seat) { + char *p, *s = NULL; + int r; + + if (!seat) + return -EINVAL; + + p = strappend("/run/systemd/seats/", seat); + if (!p) + return -ENOMEM; + + r = parse_env_file(p, NEWLINE, + "IS_VTCONSOLE", &s, + NULL); + free(p); + + if (r < 0) { + free(s); + return r; + } + + if (s) { + r = parse_boolean(s); + free(s); + } else + r = 0; + + return r; +} + _public_ int sd_get_seats(char ***seats) { if (!seats) @@ -614,7 +639,6 @@ static inline sd_login_monitor* FD_TO_MONITOR(int fd) { } _public_ int sd_login_monitor_new(const char *category, sd_login_monitor **m) { - const char *path; int fd, k; bool good = false;