From 6e7eae968a3e20050a3b1d9ebab68c96660babe4 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Tue, 29 Sep 2015 12:00:10 +0200 Subject: [PATCH] tests: Support other openssh versions ... Signed-off-by: Andreas Schneider --- tests/CMakeLists.txt | 8 ++++++++ tests/client/torture_session.c | 10 ++++------ tests/torture.c | 17 +++++++++++++++-- 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 619d9a46..27cc8697 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -59,6 +59,14 @@ if (WITH_CLIENT_TESTING) message(SEND_ERROR "Could not find sshd which is required for client testing") endif() + find_program(SSH_EXECUTABLE NAME ssh) + if (SSH_EXECUTABLE) + execute_process(COMMAND ${SSH_EXECUTABLE} -V ERROR_VARIABLE OPENSSH_VERSION_STR) + string(REGEX REPLACE "^OpenSSH_([0-9]).[0-9].*$" "\\1" OPENSSH_VERSION_MAJOR "${OPENSSH_VERSION_STR}") + string(REGEX REPLACE "^OpenSSH_[0-9].([0-9]).*$" "\\1" OPENSSH_VERSION_MINOR "${OPENSSH_VERSION_STR}") + add_definitions(-DOPENSSH_VERSION_MAJOR=${OPENSSH_VERSION_MAJOR} -DOPENSSH_VERSION_MINOR=${OPENSSH_VERSION_MINOR}) + endif() + # homedir will be used in passwd set(HOMEDIR ${CMAKE_CURRENT_BINARY_DIR}/home) diff --git a/tests/client/torture_session.c b/tests/client/torture_session.c index c40d348f..2962e464 100644 --- a/tests/client/torture_session.c +++ b/tests/client/torture_session.c @@ -98,14 +98,12 @@ static void torture_channel_read_error(void **state) { if (rc == SSH_ERROR) break; } -#if 0 - /* - * Either this is a change in sshd or socker_wrapper can't detect the - * remote fatal disconnect correctly - */ +#if OPENSSH_VERSION_MAJOR == 6 && OPENSSH_VERSION_MINOR >= 7 + /* With openssh 6.7 this doesn't produce and error anymore */ + assert_int_equal(rc, SSH_OK); +#else assert_int_equal(rc, SSH_ERROR); #endif - assert_int_equal(rc, SSH_OK); ssh_channel_free(channel); } diff --git a/tests/torture.c b/tests/torture.c index dc40348a..9cd311d1 100644 --- a/tests/torture.c +++ b/tests/torture.c @@ -904,9 +904,22 @@ static void torture_setup_create_sshd_config(void **state) "UsePrivilegeSeparation no\n" "StrictModes no\n" "\n" - "Ciphers +3des-cbc,aes128-cbc,aes192-cbc,aes256-cbc,blowfish-cbc\n" - "KexAlgorithms +diffie-hellman-group1-sha1\n" +#if OPENSSH_VERSION_MAJOR == 6 && OPENSSH_VERSION_MINOR >= 7 "HostKeyAlgorithms +ssh-dss\n" + "Ciphers +3des-cbc,aes128-cbc,aes192-cbc,aes256-cbc,blowfish-cbc\n" + "KexAlgorithms +diffie-hellman-group1-sha1" +#else + "Ciphers 3des-cbc,aes128-cbc,aes192-cbc,aes256-cbc,aes128-ctr," + "aes192-ctr,aes256-ctr,aes128-gcm@openssh.com," + "aes256-gcm@openssh.com,arcfour128,arcfour256,arcfour," + "blowfish-cbc,cast128-cbc,chacha20-poly1305@openssh.com\n" + "KexAlgorithms curve25519-sha256@libssh.org,ecdh-sha2-nistp256," + "ecdh-sha2-nistp384,ecdh-sha2-nistp521," + "diffie-hellman-group-exchange-sha256," + "diffie-hellman-group-exchange-sha1," + "diffie-hellman-group14-sha1," + "diffie-hellman-group1-sha1\n" +#endif "\n" "AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES\n" "AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT\n"