X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Flogin%2Fsd-login.c;h=1978a05dc02809e887c7330d425bb06b1c5b4f6e;hb=a1a1898f7190a25a579556826379f7486f87459b;hp=912ced31790209c4d495db648e2ddd00fe11e294;hpb=ba1261bc02693ac8a7712ade14aab8e22989ba88;p=elogind.git diff --git a/src/login/sd-login.c b/src/login/sd-login.c index 912ced317..1978a05dc 100644 --- a/src/login/sd-login.c +++ b/src/login/sd-login.c @@ -317,6 +317,30 @@ _public_ int sd_session_is_active(const char *session) { return r; } +_public_ int sd_session_get_state(const char *session, char **state) { + char *p, *s = NULL; + int r; + + if (!state) + return -EINVAL; + + r = file_of_session(session, &p); + if (r < 0) + return r; + + r = parse_env_file(p, NEWLINE, "STATE", &s, NULL); + free(p); + + if (r < 0) { + free(s); + return r; + } else if (!s) + return -EIO; + + *state = s; + return 0; +} + _public_ int sd_session_get_uid(const char *session, uid_t *uid) { int r; char *p, *s = NULL; @@ -559,7 +583,7 @@ _public_ int sd_seat_get_sessions(const char *seat, char ***sessions, uid_t **ui return r; } -_public_ int sd_seat_can_multi_session(const char *seat) { +static int seat_get_can(const char *seat, const char *variable) { char *p, *s = NULL; int r; @@ -568,7 +592,7 @@ _public_ int sd_seat_can_multi_session(const char *seat) { return r; r = parse_env_file(p, NEWLINE, - "CAN_MULTI_SESSION", &s, + variable, &s, NULL); free(p); @@ -586,6 +610,18 @@ _public_ int sd_seat_can_multi_session(const char *seat) { return r; } +_public_ int sd_seat_can_multi_session(const char *seat) { + return seat_get_can(seat, "CAN_MULTI_SESSION"); +} + +_public_ int sd_seat_can_tty(const char *seat) { + return seat_get_can(seat, "CAN_TTY"); +} + +_public_ int sd_seat_can_graphical(const char *seat) { + return seat_get_can(seat, "CAN_GRAPHICAL"); +} + _public_ int sd_get_seats(char ***seats) { return get_files_in_directory("/run/systemd/seats/", seats); }