diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index f6b6fad6..8d4e94b6 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -302,8 +302,9 @@ if (CLIENT_TESTING OR SERVER_TESTING) file(COPY keys/id_ed25519 DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/home/bob/.ssh/ FILE_PERMISSIONS OWNER_READ OWNER_WRITE) file(COPY keys/id_ed25519.pub DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/home/bob/.ssh/ FILE_PERMISSIONS OWNER_READ OWNER_WRITE) - # Allow to auth with bob's public keys on alice account + # Allow to auth with bob's public keys on alice and doe account configure_file(keys/id_rsa.pub ${CMAKE_CURRENT_BINARY_DIR}/home/alice/.ssh/authorized_keys @ONLY) + configure_file(keys/id_rsa.pub ${CMAKE_CURRENT_BINARY_DIR}/home/doe/.ssh/authorized_keys @ONLY) # append ECDSA public key file(READ keys/id_ecdsa.pub CONTENTS) diff --git a/tests/client/torture_proxyjump.c b/tests/client/torture_proxyjump.c index 80e0a05d..3e20d77b 100644 --- a/tests/client/torture_proxyjump.c +++ b/tests/client/torture_proxyjump.c @@ -222,6 +222,55 @@ torture_proxyjump_multiple_sshd_jump(void **state) torture_teardown_sshd_server1(state); } +static void +torture_proxyjump_multiple_sshd_users_jump(void **state) +{ + struct torture_state *s = *state; + ssh_session session = s->ssh.session; + char proxyjump_buf[500] = {0}; + const char *address = torture_server_address(AF_INET6); + const char *address1 = torture_server1_address(AF_INET); + int rc; + socket_t fd; + + struct ssh_jump_callbacks_struct c = { + .before_connection = before_connection, + .verify_knownhost = verify_knownhost, + .authenticate = authenticate, + }; + + torture_setup_sshd_servers(state, false); + + rc = snprintf(proxyjump_buf, + sizeof(proxyjump_buf), + "doe@%s:22,alice@%s:22", + address, + address1); + if (rc < 0 || rc >= (int)sizeof(proxyjump_buf)) { + fail_msg("snprintf failed"); + } + rc = ssh_options_set(session, SSH_OPTIONS_PROXYJUMP, proxyjump_buf); + assert_ssh_return_code(session, rc); + rc = ssh_options_set(session, SSH_OPTIONS_PROXYJUMP_CB_LIST_APPEND, &c); + assert_ssh_return_code(session, rc); + rc = ssh_options_set(session, SSH_OPTIONS_PROXYJUMP_CB_LIST_APPEND, &c); + assert_ssh_return_code(session, rc); + + rc = ssh_connect(session); + assert_ssh_return_code(session, rc); + + fd = ssh_get_fd(session); + assert_int_not_equal(fd, SSH_INVALID_SOCKET); + + rc = fcntl(fd, F_GETFL); + assert_int_equal(rc & O_RDWR, O_RDWR); + + rc = ssh_userauth_publickey_auto(session, NULL, NULL); + assert_int_equal(rc, SSH_AUTH_SUCCESS); + + torture_teardown_sshd_server1(state); +} + static void torture_proxyjump_invalid_jump(void **state) { @@ -259,6 +308,10 @@ torture_run_tests(void) cmocka_unit_test_setup_teardown(torture_proxyjump_multiple_sshd_jump, session_setup, session_teardown), + cmocka_unit_test_setup_teardown( + torture_proxyjump_multiple_sshd_users_jump, + session_setup, + session_teardown), cmocka_unit_test_setup_teardown(torture_proxyjump_invalid_jump, session_setup, session_teardown),