diff options
author | Lennart Poettering <lennart@poettering.net> | 2012-06-21 16:14:53 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2012-06-21 16:14:53 +0200 |
commit | 0604381b9dbef4cc498b5a77311e1da99c1430b8 (patch) | |
tree | ec766081c20d07ddd17c825d42569fbddefdcbe8 /src/login/sd-login.c | |
parent | f1a8e221ecacea23883df57951e291a910463948 (diff) |
logind: introduce a state for session, being one of online, active, closing
online = logged in
active = logged in and session is in the fg
closing = nominally logged out but some left-over processes still around
Related to:
https://bugzilla.gnome.org/show_bug.cgi?id=677556
Diffstat (limited to 'src/login/sd-login.c')
-rw-r--r-- | src/login/sd-login.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/login/sd-login.c b/src/login/sd-login.c index 912ced3179..223e121bed 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; |