From 90128929e7d41a40a0ae2038fb55d865033f4faa Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Mon, 29 Aug 2022 10:21:57 +0200 Subject: [PATCH] tests: Use ncat instead of nc The ncat tool from nmap is available on all unix platforms. The nc binary might link to ncat or something else. Settle on one we know also the options can be used if needed. Signed-off-by: Andreas Schneider Reviewed-by: Jakub Jelen (cherry picked from commit 6268417ac6a31fe5bdbdb096c49a4608aeb2b03b) --- tests/CMakeLists.txt | 4 ++-- tests/client/torture_proxycommand.c | 17 +++++++++++------ tests/tests_config.h.cmake | 2 +- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index f951426a..f9aa83a5 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -173,9 +173,9 @@ if (CLIENT_TESTING OR SERVER_TESTING) if (NOT SSHD_EXECUTABLE) message(SEND_ERROR "Could not find sshd which is required for client testing") endif() - find_program(NC_EXECUTABLE + find_program(NCAT_EXECUTABLE NAME - nc + ncat PATHS /bin /usr/bin diff --git a/tests/client/torture_proxycommand.c b/tests/client/torture_proxycommand.c index c04ff2ab..7812a959 100644 --- a/tests/client/torture_proxycommand.c +++ b/tests/client/torture_proxycommand.c @@ -59,7 +59,7 @@ static int session_teardown(void **state) return 0; } -#ifdef NC_EXECUTABLE +#ifdef NCAT_EXECUTABLE static void torture_options_set_proxycommand(void **state) { struct torture_state *s = *state; @@ -71,13 +71,18 @@ static void torture_options_set_proxycommand(void **state) int rc; socket_t fd; - rc = stat(NC_EXECUTABLE, &sb); + rc = stat(NCAT_EXECUTABLE, &sb); if (rc != 0 || (sb.st_mode & S_IXOTH) == 0) { - SSH_LOG(SSH_LOG_WARNING, "Could not find " NC_EXECUTABLE ": Skipping the test"); + SSH_LOG(SSH_LOG_WARNING, + "Could not find " NCAT_EXECUTABLE ": Skipping the test"); skip(); } - rc = snprintf(command, sizeof(command), NC_EXECUTABLE " %s %d", address, port); + rc = snprintf(command, + sizeof(command), + NCAT_EXECUTABLE " %s %d", + address, + port); assert_true((size_t)rc < sizeof(command)); rc = ssh_options_set(session, SSH_OPTIONS_PROXYCOMMAND, command); @@ -90,7 +95,7 @@ static void torture_options_set_proxycommand(void **state) assert_int_equal(rc & O_RDWR, O_RDWR); } -#else /* NC_EXECUTABLE */ +#else /* NCAT_EXECUTABLE */ static void torture_options_set_proxycommand(void **state) { @@ -98,7 +103,7 @@ static void torture_options_set_proxycommand(void **state) skip(); } -#endif /* NC_EXECUTABLE */ +#endif /* NCAT_EXECUTABLE */ static void torture_options_set_proxycommand_notexist(void **state) { struct torture_state *s = *state; diff --git a/tests/tests_config.h.cmake b/tests/tests_config.h.cmake index 13815ec6..b162db75 100644 --- a/tests/tests_config.h.cmake +++ b/tests/tests_config.h.cmake @@ -64,7 +64,7 @@ /* Available programs */ -#cmakedefine NC_EXECUTABLE "${NC_EXECUTABLE}" +#cmakedefine NCAT_EXECUTABLE "${NCAT_EXECUTABLE}" #cmakedefine SSHD_EXECUTABLE "${SSHD_EXECUTABLE}" #cmakedefine SSH_EXECUTABLE "${SSH_EXECUTABLE}" #cmakedefine WITH_TIMEOUT ${WITH_TIMEOUT}