aboutsummaryrefslogtreecommitdiff
path: root/tests/client
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2016-02-02 11:28:07 +0100
committerAndreas Schneider <asn@cryptomilk.org>2016-02-03 09:01:29 +0100
commitf128ffd88b0a739e42a0e8cead04d7f60fc478e6 (patch)
treee8a7754f3be6a638024255049bc21ed6b02b70d6 /tests/client
parent063430744ddd401c0fe217da611b87837a5b5db3 (diff)
downloadlibssh-f128ffd88b0a739e42a0e8cead04d7f60fc478e6.tar.gz
libssh-f128ffd88b0a739e42a0e8cead04d7f60fc478e6.tar.xz
libssh-f128ffd88b0a739e42a0e8cead04d7f60fc478e6.zip
tests: Fix running ssh-agent
ssh-agent needs to be executed as the local user and not a fake user or we will not be able to add identies. Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Diffstat (limited to 'tests/client')
-rw-r--r--tests/client/torture_auth.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/tests/client/torture_auth.c b/tests/client/torture_auth.c
index 84507d74..77a3c555 100644
--- a/tests/client/torture_auth.c
+++ b/tests/client/torture_auth.c
@@ -25,6 +25,8 @@
#include "libssh/libssh.h"
#include "libssh/priv.h"
#include "libssh/session.h"
+
+#include <errno.h>
#include <sys/types.h>
#include <pwd.h>
@@ -80,7 +82,9 @@ static int pubkey_setup(void **state)
pwd = getpwnam("bob");
assert_non_null(pwd);
- setuid(pwd->pw_uid);
+
+ rc = setuid(pwd->pw_uid);
+ assert_return_code(rc, errno);
/* Make sure we do not interfere with another ssh-agent */
unsetenv("SSH_AUTH_SOCK");
@@ -95,6 +99,8 @@ static int agent_setup(void **state)
char ssh_agent_cmd[4096];
char ssh_agent_sock[1024];
char ssh_agent_pidfile[1024];
+ char bob_ssh_key[1024];
+ struct passwd *pwd;
int rc;
rc = pubkey_setup(state);
@@ -102,6 +108,9 @@ static int agent_setup(void **state)
return rc;
}
+ pwd = getpwnam("bob");
+ assert_non_null(pwd);
+
snprintf(ssh_agent_sock,
sizeof(ssh_agent_cmd),
"%s/agent.sock",
@@ -118,13 +127,21 @@ static int agent_setup(void **state)
"eval `ssh-agent -a %s`; echo $SSH_AGENT_PID > %s",
ssh_agent_sock, ssh_agent_pidfile);
+ /* run ssh-agent and ssh-add as the normal user */
+ unsetenv("UID_WRAPPER_ROOT");
+
rc = system(ssh_agent_cmd);
assert_return_code(rc, errno);
setenv("SSH_AUTH_SOCK", ssh_agent_sock, 1);
setenv("TORTURE_SSH_AGENT_PIDFILE", ssh_agent_pidfile, 1);
- rc = system("ssh-add");
+ snprintf(bob_ssh_key,
+ sizeof(bob_ssh_key),
+ "ssh-add %s/.ssh/id_rsa",
+ pwd->pw_dir);
+
+ rc = system(bob_ssh_key);
assert_return_code(rc, errno);
return 0;