summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/login/libsystemd-login.sym2
-rw-r--r--src/login/sd-login.c16
-rw-r--r--src/login/test-login.c8
-rw-r--r--src/systemd/sd-login.h6
4 files changed, 30 insertions, 2 deletions
diff --git a/src/login/libsystemd-login.sym b/src/login/libsystemd-login.sym
index 347e0730a6..ff51be729b 100644
--- a/src/login/libsystemd-login.sym
+++ b/src/login/libsystemd-login.sym
@@ -50,4 +50,6 @@ global:
LIBSYSTEMD_LOGIN_186 {
global:
sd_session_get_state;
+ sd_seat_can_tty;
+ sd_seat_can_graphical;
} LIBSYSTEMD_LOGIN_43;
diff --git a/src/login/sd-login.c b/src/login/sd-login.c
index 223e121bed..1978a05dc0 100644
--- a/src/login/sd-login.c
+++ b/src/login/sd-login.c
@@ -583,7 +583,7 @@ _public_ int sd_seat_get_sessions(const char *seat, char ***sessions, uid_t **ui
return r;
}
-_public_ int sd_seat_can_multi_session(const char *seat) {
+static int seat_get_can(const char *seat, const char *variable) {
char *p, *s = NULL;
int r;
@@ -592,7 +592,7 @@ _public_ int sd_seat_can_multi_session(const char *seat) {
return r;
r = parse_env_file(p, NEWLINE,
- "CAN_MULTI_SESSION", &s,
+ variable, &s,
NULL);
free(p);
@@ -610,6 +610,18 @@ _public_ int sd_seat_can_multi_session(const char *seat) {
return r;
}
+_public_ int sd_seat_can_multi_session(const char *seat) {
+ return seat_get_can(seat, "CAN_MULTI_SESSION");
+}
+
+_public_ int sd_seat_can_tty(const char *seat) {
+ return seat_get_can(seat, "CAN_TTY");
+}
+
+_public_ int sd_seat_can_graphical(const char *seat) {
+ return seat_get_can(seat, "CAN_GRAPHICAL");
+}
+
_public_ int sd_get_seats(char ***seats) {
return get_files_in_directory("/run/systemd/seats/", seats);
}
diff --git a/src/login/test-login.c b/src/login/test-login.c
index d0916ced6a..159ff3efc5 100644
--- a/src/login/test-login.c
+++ b/src/login/test-login.c
@@ -99,6 +99,14 @@ int main(int argc, char* argv[]) {
assert_se(r >= 0);
printf("can do multi session = %s\n", yes_no(r));
+ r = sd_seat_can_tty(seat);
+ assert_se(r >= 0);
+ printf("can do tty = %s\n", yes_no(r));
+
+ r = sd_seat_can_graphical(seat);
+ assert_se(r >= 0);
+ printf("can do graphical = %s\n", yes_no(r));
+
assert_se(sd_uid_get_state(u, &state) >= 0);
printf("state = %s\n", state);
diff --git a/src/systemd/sd-login.h b/src/systemd/sd-login.h
index bddc74e729..1a36a56b12 100644
--- a/src/systemd/sd-login.h
+++ b/src/systemd/sd-login.h
@@ -117,6 +117,12 @@ int sd_seat_get_sessions(const char *seat, char ***sessions, uid_t **uid, unsign
/* Return whether the seat is multi-session capable */
int sd_seat_can_multi_session(const char *seat);
+/* Return whether the seat is TTY capable, i.e. suitable for showing console UIs */
+int sd_seat_can_tty(const char *seat);
+
+/* Return whether the seat is graphics capable, i.e. suitable for showing graphical UIs */
+int sd_seat_can_graphical(const char *seat);
+
/* Get all seats, store in *seats. Returns the number of seats. If
* seats is NULL only returns number of seats. */
int sd_get_seats(char ***seats);