mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-08-08 19:02:06 +03:00
Assorted changes to make the proxycommand test pass
Cherry-picked from the following commit:
e4653b82bd
This commit is contained in:
committed by
Andreas Schneider
parent
743a34ad9f
commit
c977a97093
@@ -4,8 +4,39 @@
|
||||
#include <libssh/libssh.h>
|
||||
#include "libssh/priv.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <sys/types.h>
|
||||
#include <pwd.h>
|
||||
|
||||
static int sshd_setup(void **state)
|
||||
{
|
||||
torture_setup_sshd_server(state);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int sshd_teardown(void **state) {
|
||||
torture_teardown_sshd_server(state);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void setup(void **state) {
|
||||
ssh_session session = ssh_new();
|
||||
int verbosity = torture_libssh_verbosity();
|
||||
struct passwd *pwd;
|
||||
int rc;
|
||||
|
||||
pwd = getpwnam("bob");
|
||||
assert_non_null(pwd);
|
||||
|
||||
rc = setuid(pwd->pw_uid);
|
||||
assert_return_code(rc, errno);
|
||||
|
||||
ssh_options_set(session, SSH_OPTIONS_LOG_VERBOSITY, &verbosity);
|
||||
ssh_options_set(session, SSH_OPTIONS_HOST, TORTURE_SSH_SERVER);
|
||||
|
||||
ssh_options_set(session, SSH_OPTIONS_USER, TORTURE_SSH_USER_ALICE);
|
||||
|
||||
*state = session;
|
||||
}
|
||||
@@ -18,10 +49,7 @@ static void torture_options_set_proxycommand(void **state) {
|
||||
ssh_session session = *state;
|
||||
int rc;
|
||||
|
||||
rc = ssh_options_set(session, SSH_OPTIONS_HOST, "localhost");
|
||||
assert_true(rc == 0);
|
||||
|
||||
rc = ssh_options_set(session, SSH_OPTIONS_PROXYCOMMAND, "nc localhost 22");
|
||||
rc = ssh_options_set(session, SSH_OPTIONS_PROXYCOMMAND, "nc 127.0.0.10 22");
|
||||
assert_true(rc == 0);
|
||||
rc = ssh_connect(session);
|
||||
assert_true(rc == SSH_OK);
|
||||
@@ -31,9 +59,6 @@ static void torture_options_set_proxycommand_notexist(void **state) {
|
||||
ssh_session session = *state;
|
||||
int rc;
|
||||
|
||||
rc = ssh_options_set(session, SSH_OPTIONS_HOST, "localhost");
|
||||
assert_true(rc == 0);
|
||||
|
||||
rc = ssh_options_set(session, SSH_OPTIONS_PROXYCOMMAND, "this_command_does_not_exist");
|
||||
assert_true(rc == SSH_OK);
|
||||
rc = ssh_connect(session);
|
||||
@@ -42,6 +67,7 @@ static void torture_options_set_proxycommand_notexist(void **state) {
|
||||
|
||||
int torture_run_tests(void) {
|
||||
int rc;
|
||||
struct torture_state *s = NULL;
|
||||
UnitTest tests[] = {
|
||||
unit_test_setup_teardown(torture_options_set_proxycommand, setup, teardown),
|
||||
unit_test_setup_teardown(torture_options_set_proxycommand_notexist, setup, teardown),
|
||||
@@ -51,7 +77,9 @@ int torture_run_tests(void) {
|
||||
ssh_init();
|
||||
|
||||
torture_filter_tests(tests);
|
||||
sshd_setup((void **)&s);
|
||||
rc = run_tests(tests);
|
||||
sshd_teardown((void **)&s);
|
||||
ssh_finalize();
|
||||
|
||||
return rc;
|
||||
|
Reference in New Issue
Block a user