summaryrefslogtreecommitdiff
path: root/src/login/sd-login.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/login/sd-login.c')
-rw-r--r--src/login/sd-login.c24
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;