summaryrefslogtreecommitdiff
path: root/src/login/test-login.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-03-17 18:14:26 +0100
committerLennart Poettering <lennart@poettering.net>2014-03-17 18:15:57 +0100
commitbf34ab149f3038686bc75e1592179abac1700322 (patch)
tree42a953b9e17ef1614a890f699f245c84bd6a831b /src/login/test-login.c
parent7366b080b324caf66e2ca1671f8ce7f57ace7553 (diff)
sd-login: add calls that retrieve credentials of peers connected to AF_UNIX peers
This is supposed to be an extension of SO_PEERCRED and SO_PEERSEC, except for cgroup information.
Diffstat (limited to 'src/login/test-login.c')
-rw-r--r--src/login/test-login.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/login/test-login.c b/src/login/test-login.c
index d78cea46af..2ab083bb71 100644
--- a/src/login/test-login.c
+++ b/src/login/test-login.c
@@ -28,6 +28,8 @@
#include "strv.h"
static void test_login(void) {
+ _cleanup_close_pipe_ int pair[2] = { -1, -1 };
+ _cleanup_free_ char *pp = NULL, *qq = NULL;
int r, k;
uid_t u, u2;
char *seat, *type, *class, *display, *remote_user, *remote_host;
@@ -47,6 +49,11 @@ static void test_login(void) {
assert_se(sd_pid_get_owner_uid(0, &u2) == 0);
printf("user = %lu\n", (unsigned long) u2);
+ assert_se(socketpair(AF_UNIX, SOCK_STREAM, 0, pair) == 0);
+ sd_peer_get_session(pair[0], &pp);
+ sd_peer_get_session(pair[1], &qq);
+ assert_se(streq_ptr(pp, qq));
+
r = sd_uid_get_sessions(u2, false, &sessions);
assert_se(r >= 0);
assert_se(r == (int) strv_length(sessions));