summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/libsystemd-login.sym1
-rw-r--r--src/sd-login.c30
-rw-r--r--src/sd-login.h3
-rw-r--r--src/test-login.c4
4 files changed, 38 insertions, 0 deletions
diff --git a/src/libsystemd-login.sym b/src/libsystemd-login.sym
index cd5f52c341..0d51fa76e7 100644
--- a/src/libsystemd-login.sym
+++ b/src/libsystemd-login.sym
@@ -20,6 +20,7 @@ global:
sd_login_monitor_unref;
sd_pid_get_owner_uid;
sd_pid_get_session;
+ sd_seat_can_multi_session;
sd_seat_get_active;
sd_seat_get_sessions;
sd_session_get_seat;
diff --git a/src/sd-login.c b/src/sd-login.c
index 2c5b153fba..d44a1fcf9c 100644
--- a/src/sd-login.c
+++ b/src/sd-login.c
@@ -522,6 +522,36 @@ _public_ int sd_seat_get_sessions(const char *seat, char ***sessions, uid_t **ui
return 0;
}
+_public_ int sd_seat_can_multi_session(const char *seat) {
+ char *p, *s = NULL;
+ int r;
+
+ if (!seat)
+ return -EINVAL;
+
+ p = strappend("/run/systemd/seats/", seat);
+ if (!p)
+ return -ENOMEM;
+
+ r = parse_env_file(p, NEWLINE,
+ "IS_VTCONSOLE", &s,
+ NULL);
+ free(p);
+
+ if (r < 0) {
+ free(s);
+ return r;
+ }
+
+ if (s) {
+ r = parse_boolean(s);
+ free(s);
+ } else
+ r = 0;
+
+ return r;
+}
+
_public_ int sd_get_seats(char ***seats) {
if (!seats)
diff --git a/src/sd-login.h b/src/sd-login.h
index c6835e1235..1623a7dbf6 100644
--- a/src/sd-login.h
+++ b/src/sd-login.h
@@ -82,6 +82,9 @@ int sd_seat_get_active(const char *seat, char **session, uid_t *uid);
/* Return sessions and users on seat */
int sd_seat_get_sessions(const char *seat, char ***sessions, uid_t **uid, unsigned *n_uids);
+/* Return whether the seat is multi-session capable */
+int sd_seat_can_multi_session(const char *seat);
+
/* Get all seats */
int sd_get_seats(char ***seats);
diff --git a/src/test-login.c b/src/test-login.c
index 21cd3a1900..9cd9c27a58 100644
--- a/src/test-login.c
+++ b/src/test-login.c
@@ -71,6 +71,10 @@ int main(int argc, char* argv[]) {
assert_se(sd_session_get_seat(session, &seat) >= 0);
printf("seat = %s\n", seat);
+ r = sd_seat_can_multi_session(seat);
+ assert_se(r >= 0);
+ printf("can do multi session = %s\n", yes_no(r));
+
assert_se(sd_uid_get_state(u, &state) >= 0);
printf("state = %s\n", state);