summaryrefslogtreecommitdiff
path: root/src/login/sd-login.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2012-01-05 23:14:22 +0100
committerLennart Poettering <lennart@poettering.net>2012-01-05 23:14:22 +0100
commiteff406331adb23e27e4bd29a3b69322fc359ca3d (patch)
tree4b819357ed9977a7e0d689c30603b30ccdee3726 /src/login/sd-login.c
parent4cd9a9d9ecf3a8835e21930f3215a5f5b74144be (diff)
login: implement sd_session_get_service()
Diffstat (limited to 'src/login/sd-login.c')
-rw-r--r--src/login/sd-login.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/login/sd-login.c b/src/login/sd-login.c
index 8893b1de80..ed98412266 100644
--- a/src/login/sd-login.c
+++ b/src/login/sd-login.c
@@ -415,6 +415,34 @@ _public_ int sd_session_get_seat(const char *session, char **seat) {
return 0;
}
+_public_ int sd_session_get_service(const char *session, char **service) {
+ char *p, *s = NULL;
+ int r;
+
+ if (!session)
+ return -EINVAL;
+ if (!service)
+ return -EINVAL;
+
+ p = strappend("/run/systemd/sessions/", session);
+ if (!p)
+ return -ENOMEM;
+
+ r = parse_env_file(p, NEWLINE, "SERVICE", &s, NULL);
+ free(p);
+
+ if (r < 0) {
+ free(s);
+ return r;
+ }
+
+ if (isempty(s))
+ return -ENOENT;
+
+ *service = s;
+ return 0;
+}
+
_public_ int sd_seat_get_active(const char *seat, char **session, uid_t *uid) {
char *p, *s = NULL, *t = NULL;
int r;