chiark / gitweb /
login: introduce sd_session_get_display()
authorLennart Poettering <lennart@poettering.net>
Wed, 15 Feb 2012 03:56:10 +0000 (04:56 +0100)
committerLennart Poettering <lennart@poettering.net>
Wed, 15 Feb 2012 03:56:10 +0000 (04:56 +0100)
src/login/libsystemd-login.sym
src/login/sd-login.c
src/login/test-login.c
src/systemd/sd-login.h

index 2ae376da442660fde98725b3bfb7a35d6e130226..a5e6c1e756103f7991a57ba7a9c97b9d832af080 100644 (file)
@@ -44,4 +44,5 @@ LIBSYSTEMD_LOGIN_43 {
 global:
         sd_session_get_type;
         sd_session_get_class;
+        sd_session_get_display;
 } LIBSYSTEMD_LOGIN_38;
index c100a7b4f2bee14080cce7383415ed8a956ac854..887c4210098f2bae00a47ee8487d896d8820f419 100644 (file)
@@ -475,6 +475,10 @@ _public_ int sd_session_get_class(const char *session, char **class) {
         return session_get_string(session, "CLASS", class);
 }
 
+_public_ int sd_session_get_display(const char *session, char **display) {
+        return session_get_string(session, "DISPLAY", display);
+}
+
 static int file_of_seat(const char *seat, char **_p) {
         char *p;
         int r;
index 2aaa31f22f1c3ab064018104465496fc3162dfa6..dd8404285bf1190752d3c49f60d30ab0b1279912 100644 (file)
@@ -30,7 +30,7 @@
 int main(int argc, char* argv[]) {
         int r, k;
         uid_t u, u2;
-        char *seat, *type, *class;
+        char *seat, *type, *class, *display;
         char *session;
         char *state;
         char *session2;
@@ -83,6 +83,10 @@ int main(int argc, char* argv[]) {
         printf("class = %s\n", class);
         free(class);
 
+        assert_se(sd_session_get_display(session, &display) >= 0);
+        printf("display = %s\n", display);
+        free(display);
+
         assert_se(sd_session_get_seat(session, &seat) >= 0);
         printf("seat = %s\n", seat);
 
index 879e0744a87853fd61027a47becb35ce650c40b9..2f3c90c129ec9b21c9855be874a4a3c8a1ed9525 100644 (file)
@@ -96,6 +96,9 @@ int sd_session_get_type(const char *session, char **type);
 /* Determine the class of this session, i.e. one of "user", "greeter" or "lock-screen". */
 int sd_session_get_class(const char *session, char **class);
 
+/* Determine the X11 display of this session. */
+int sd_session_get_display(const char *session, char **display);
+
 /* Return active session and user of seat */
 int sd_seat_get_active(const char *seat, char **session, uid_t *uid);