diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/login/libsystemd-login.sym | 5 | ||||
-rw-r--r-- | src/login/sd-login.c | 17 | ||||
-rw-r--r-- | src/systemd/sd-login.h | 3 |
3 files changed, 25 insertions, 0 deletions
diff --git a/src/login/libsystemd-login.sym b/src/login/libsystemd-login.sym index 0720704dbf..54aa91c609 100644 --- a/src/login/libsystemd-login.sym +++ b/src/login/libsystemd-login.sym @@ -80,3 +80,8 @@ LIBSYSTEMD_LOGIN_205 { global: sd_pid_get_slice; } LIBSYSTEMD_LOGIN_203; + +LIBSYSTEMD_LOGIN_207 { +global: + sd_session_get_vt; +} LIBSYSTEMD_LOGIN_205; diff --git a/src/login/sd-login.c b/src/login/sd-login.c index 06587921cd..8a7838d566 100644 --- a/src/login/sd-login.c +++ b/src/login/sd-login.c @@ -347,6 +347,23 @@ _public_ int sd_session_get_tty(const char *session, char **tty) { return session_get_string(session, "TTY", tty); } +_public_ int sd_session_get_vt(const char *session, unsigned *vtnr) { + _cleanup_free_ char *vtnr_string; + unsigned u; + int r; + + r = session_get_string(session, "VTNr", &vtnr_string); + if (r < 0) + return r; + + r = safe_atou(vtnr_string, &u); + if (r < 0) + return r; + + *vtnr = u; + return 0; +} + _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 e37aeda2bb..c5837f0ca0 100644 --- a/src/systemd/sd-login.h +++ b/src/systemd/sd-login.h @@ -124,6 +124,9 @@ 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); +/* Determine the VT number of this session. */ +int sd_session_get_vt(const char *session, unsigned *vtnr); + /* Return active session and user of seat */ int sd_seat_get_active(const char *seat, char **session, uid_t *uid); |