From c84f5e4a825f17163ead0f60308d548b415334a5 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 15 Jan 2013 03:00:33 +0100 Subject: [PATCH] login: introduce sd_session_get_tty() --- Makefile.am | 2 ++ man/sd_session_is_active.xml | 29 +++++++++++++++++++++++------ src/login/libsystemd-login.sym | 5 +++++ src/login/sd-login.c | 4 ++++ src/systemd/sd-login.h | 3 +++ 5 files changed, 37 insertions(+), 6 deletions(-) diff --git a/Makefile.am b/Makefile.am index 33188294a..e10e421d4 100644 --- a/Makefile.am +++ b/Makefile.am @@ -3690,6 +3690,7 @@ MANPAGES_ALIAS += \ man/sd_session_get_type.3 \ man/sd_session_get_class.3 \ man/sd_session_get_display.3 \ + man/sd_session_get_tty.3 \ man/sd_pid_get_owner_uid.3 \ man/sd_pid_get_unit.3 \ man/sd_uid_is_on_seat.3 \ @@ -3714,6 +3715,7 @@ man/sd_session_get_state.3: man/sd_session_is_active.3 man/sd_session_get_type.3: man/sd_session_is_active.3 man/sd_session_get_class.3: man/sd_session_is_active.3 man/sd_session_get_display.3: man/sd_session_is_active.3 +man/sd_session_get_tty.3: man/sd_session_is_active.3 man/sd_pid_get_owner_uid.3: man/sd_pid_get_session.3 man/sd_pid_get_unit.3: man/sd_pid_get_session.3 man/sd_uid_is_on_seat.3: man/sd_uid_get_state.3 diff --git a/man/sd_session_is_active.xml b/man/sd_session_is_active.xml index a9107cb95..ab48b9efc 100644 --- a/man/sd_session_is_active.xml +++ b/man/sd_session_is_active.xml @@ -51,6 +51,7 @@ sd_session_get_type sd_session_get_class sd_session_get_display + sd_session_get_tty Determine state of a specific session @@ -104,6 +105,12 @@ const char* session char** display + + + int sd_session_get_tty + const char* session + char** tty + @@ -186,6 +193,14 @@ free3 call after use. + sd_session_get_tty() + may be used to determine the TTY device of the + session identified by the specified session + identifier. The returned string is one of needs to be + freed with the libc + free3 + call after use. + If the session parameter of any of these functions is passed as NULL the operation is executed for the session the calling process is a @@ -203,8 +218,9 @@ sd_session_get_seat(), sd_session_get_service(), sd_session_get_type(), - sd_session_get_class() and - sd_session_get_display() return 0 or + sd_session_get_class(), + sd_session_get_display() and + sd_session_get_tty() return 0 or a positive integer. On failure, these calls return a negative errno-style error code. @@ -218,10 +234,11 @@ sd_session_get_seat(), sd_session_get_service(), sd_session_get_type(), - sd_session_get_class() and - sd_session_get_display() interfaces - are available as shared library, which can be compiled - and linked to with the + sd_session_get_class(), + sd_session_get_display() and + sd_session_get_tty() + interfaces are available as shared library, which can + be compiled and linked to with the libsystemd-login pkg-config1 file. diff --git a/src/login/libsystemd-login.sym b/src/login/libsystemd-login.sym index ff51be729..272b0e2b5 100644 --- a/src/login/libsystemd-login.sym +++ b/src/login/libsystemd-login.sym @@ -53,3 +53,8 @@ global: sd_seat_can_tty; sd_seat_can_graphical; } LIBSYSTEMD_LOGIN_43; + +LIBSYSTEMD_LOGIN_198 { +global: + sd_session_get_tty; +} LIBSYSTEMD_LOGIN_186; diff --git a/src/login/sd-login.c b/src/login/sd-login.c index 45e3bb8dc..4bc51e71a 100644 --- a/src/login/sd-login.c +++ b/src/login/sd-login.c @@ -409,6 +409,10 @@ _public_ int sd_session_get_seat(const char *session, char **seat) { return session_get_string(session, "SEAT", seat); } +_public_ int sd_session_get_tty(const char *session, char **tty) { + return session_get_string(session, "TTY", tty); +} + _public_ int sd_session_get_service(const char *session, char **service) { return session_get_string(session, "SERVICE", service); } diff --git a/src/systemd/sd-login.h b/src/systemd/sd-login.h index 6bd1f2da4..3746b45cf 100644 --- a/src/systemd/sd-login.h +++ b/src/systemd/sd-login.h @@ -108,6 +108,9 @@ int sd_session_get_class(const char *session, char **clazz); /* Determine the X11 display of this session. */ int sd_session_get_display(const char *session, char **display); +/* Determine the TTY of this session. */ +int sd_session_get_tty(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); -- 2.30.2