From 4a95a35bc6897fd0daa199f070a3a78879e7bfc4 Mon Sep 17 00:00:00 2001 From: Jakub Jelen Date: Mon, 29 Oct 2018 18:25:03 +0100 Subject: [PATCH] tests: Properly set the bob's UID also in other tests than pubkey Signed-off-by: Jakub Jelen Reviewed-by: Andreas Schneider --- tests/client/torture_auth.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/client/torture_auth.c b/tests/client/torture_auth.c index 68375cb4..f3936158 100644 --- a/tests/client/torture_auth.c +++ b/tests/client/torture_auth.c @@ -52,9 +52,16 @@ static int session_setup(void **state) { struct torture_state *s = *state; int verbosity = torture_libssh_verbosity(); + struct passwd *pwd; bool b = false; int rc; + pwd = getpwnam("bob"); + assert_non_null(pwd); + + rc = setuid(pwd->pw_uid); + assert_return_code(rc, errno); + s->ssh.session = ssh_new(); assert_non_null(s->ssh.session); @@ -80,19 +87,12 @@ static int session_teardown(void **state) static int pubkey_setup(void **state) { int rc; - struct passwd *pwd; rc = session_setup(state); if (rc != 0) { return rc; } - pwd = getpwnam("bob"); - assert_non_null(pwd); - - rc = setuid(pwd->pw_uid); - assert_return_code(rc, errno); - /* Make sure we do not interfere with another ssh-agent */ unsetenv("SSH_AUTH_SOCK"); unsetenv("SSH_AGENT_PID");