summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlan Jenkins <alan.christopher.jenkins@gmail.com>2017-08-08 16:13:52 +0100
committerAlan Jenkins <alan.christopher.jenkins@gmail.com>2017-08-08 16:55:15 +0100
commite6f44233c64084f331eaf9fbd7761cb8b79bdc36 (patch)
tree73ad0814e30fcf08782e230e8a762e5362f33d34 /src
parent5947643cc2982fa2fb057cfe5998b4bc92de7e20 (diff)
downloadsystemd-e6f44233c64084f331eaf9fbd7761cb8b79bdc36.tar.gz
sd-login: test - fix failure when run from non-graphical seat
Observed when running from the console of a systemd nspawn container (see failure below). The value of r was tested, when r was last set by sd_session_can_graphical(). This did not correspond to the value expected. Fix the code, so we compare relevant values now. Hopefully :). Test failure ------------ /* Information printed is from the live system */ sd_pid_get_unit(0, …) → "session-13.scope" sd_pid_get_user_unit(0, …) → "n/a" sd_pid_get_slice(0, …) → "user-1000.slice" sd_pid_get_session(0, …) → "13" sd_pid_get_owner_uid(0, …) → 1000 sd_pid_get_cgroup(0, …) → "/user.slice/user-1000.slice/session-13.scope" sd_uid_get_display(1000, …) → "13" sd_uid_get_sessions(1000, …) → [2] "15 13" sd_uid_get_seats(1000, …) → [1] "seat0" sd_session_is_active("13") → yes sd_session_is_remote("13") → no sd_session_get_state("13") → "active" sd_session_get_uid("13") → 1000 sd_session_get_type("13") → "tty" sd_session_get_class("13") → "user" sd_session_get_display("13") → "n/a" sd_session_get_remote_user("13") → "n/a" sd_session_get_remote_host("13") → "n/a" sd_session_get_seat("13") → "seat0" sd_session_can_multi_seat("seat0") → no sd_session_can_tty("seat0") → no sd_session_can_graphical("seat0") → no sd_uid_get_state(1000, …) → active Assertion '!!k == !!r' failed at ../src/libsystemd/sd-login/test-login.c:191, function test_login(). Aborting.
Diffstat (limited to 'src')
-rw-r--r--src/libsystemd/sd-login/test-login.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/libsystemd/sd-login/test-login.c b/src/libsystemd/sd-login/test-login.c
index 831339eeb4..02a73f9189 100644
--- a/src/libsystemd/sd-login/test-login.c
+++ b/src/libsystemd/sd-login/test-login.c
@@ -55,7 +55,7 @@ static void test_login(void) {
*type = NULL, *class = NULL, *state = NULL, *state2 = NULL,
*seat = NULL, *session = NULL,
*unit = NULL, *user_unit = NULL, *slice = NULL;
- int r, k;
+ int r;
uid_t u, u2;
char *t, **seats, **sessions;
@@ -186,13 +186,14 @@ static void test_login(void) {
assert_se(sd_uid_is_on_seat(u, 0, seat) > 0);
- k = sd_uid_is_on_seat(u, 1, seat);
- assert_se(k >= 0);
- assert_se(!!k == !!r);
-
- assert_se(sd_seat_get_active(seat, &session2, &u2) >= 0);
+ r = sd_seat_get_active(seat, &session2, &u2);
+ assert_se(r >= 0);
log_info("sd_seat_get_active(\"%s\", …) → \"%s\", "UID_FMT, seat, session2, u2);
+ r = sd_uid_is_on_seat(u, 1, seat);
+ assert_se(r >= 0);
+ assert_se(!!r == streq(session, session2));
+
r = sd_seat_get_sessions(seat, &sessions, &uids, &n);
assert_se(r >= 0);
assert_se(r == (int) strv_length(sessions));