mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-08-08 19:02:06 +03:00
Assorted changes from master to make torture_algorithms test working
Cherry-picked from the following commits:cbd75c3e35
3014e3c458
This commit is contained in:
committed by
Andreas Schneider
parent
d678f6a9ea
commit
74102dfd7a
@@ -25,11 +25,37 @@
|
||||
#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) {
|
||||
int verbosity=torture_libssh_verbosity();
|
||||
ssh_session session = ssh_new();
|
||||
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);
|
||||
*state = session;
|
||||
}
|
||||
|
||||
@@ -40,9 +66,6 @@ static void teardown(void **state) {
|
||||
static void test_algorithm(ssh_session session, const char *algo, const char *hmac) {
|
||||
int rc;
|
||||
|
||||
rc = ssh_options_set(session, SSH_OPTIONS_HOST, "localhost");
|
||||
assert_true(rc == SSH_OK);
|
||||
|
||||
rc = ssh_options_set(session, SSH_OPTIONS_CIPHERS_C_S, algo);
|
||||
assert_true(rc == SSH_OK);
|
||||
|
||||
@@ -169,9 +192,6 @@ static void torture_algorithms_zlib(void **state) {
|
||||
ssh_session session = *state;
|
||||
int rc;
|
||||
|
||||
rc = ssh_options_set(session,SSH_OPTIONS_HOST,"localhost");
|
||||
assert_true(rc == SSH_OK);
|
||||
|
||||
rc = ssh_options_set(session, SSH_OPTIONS_COMPRESSION_C_S, "zlib");
|
||||
#ifdef WITH_ZLIB
|
||||
assert_true(rc == SSH_OK);
|
||||
@@ -209,9 +229,6 @@ static void torture_algorithms_zlib_openssh(void **state) {
|
||||
ssh_session session = *state;
|
||||
int rc;
|
||||
|
||||
rc = ssh_options_set(session,SSH_OPTIONS_HOST,"localhost");
|
||||
assert_true(rc == SSH_OK);
|
||||
|
||||
rc = ssh_options_set(session, SSH_OPTIONS_COMPRESSION_C_S, "zlib@openssh.com");
|
||||
#ifdef WITH_ZLIB
|
||||
assert_true(rc == SSH_OK);
|
||||
@@ -251,9 +268,6 @@ static void torture_algorithms_ecdh_sha2_nistp256(void **state) {
|
||||
ssh_session session = *state;
|
||||
int rc;
|
||||
|
||||
rc = ssh_options_set(session,SSH_OPTIONS_HOST,"localhost");
|
||||
assert_true(rc == SSH_OK);
|
||||
|
||||
rc = ssh_options_set(session, SSH_OPTIONS_KEY_EXCHANGE, "ecdh-sha2-nistp256");
|
||||
assert_true(rc == SSH_OK);
|
||||
|
||||
@@ -273,9 +287,6 @@ static void torture_algorithms_dh_group1(void **state) {
|
||||
ssh_session session = *state;
|
||||
int rc;
|
||||
|
||||
rc = ssh_options_set(session,SSH_OPTIONS_HOST,"localhost");
|
||||
assert_true(rc == SSH_OK);
|
||||
|
||||
rc = ssh_options_set(session, SSH_OPTIONS_KEY_EXCHANGE, "diffie-hellman-group1-sha1");
|
||||
assert_true(rc == SSH_OK);
|
||||
|
||||
@@ -291,6 +302,7 @@ static void torture_algorithms_dh_group1(void **state) {
|
||||
}
|
||||
int torture_run_tests(void) {
|
||||
int rc;
|
||||
struct torture_state *s = NULL;
|
||||
UnitTest tests[] = {
|
||||
unit_test_setup_teardown(torture_algorithms_aes128_cbc_hmac_sha1, setup, teardown),
|
||||
unit_test_setup_teardown(torture_algorithms_aes128_cbc_hmac_sha2_256, setup, teardown),
|
||||
@@ -328,7 +340,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