From a983142a07de4cf0fa95c01806ef04f0434d51c1 Mon Sep 17 00:00:00 2001 From: Jakub Jelen Date: Fri, 9 Jan 2026 13:26:16 +0100 Subject: [PATCH] tests: Set explicit kex algorithm MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit without explicitly setting the algorithms, they might be set by some other configuration file, for example crypto policies pulled from `/etc/libssh/libssh_server.config` during RPM build. Log also the generated configuration file and change the other case to use standard logging mechanism instead of fprintf. Signed-off-by: Jakub Jelen Reviewed-by: Pavol Žáčik Reviewed-by: Andreas Schneider --- tests/server/torture_server_algorithms.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/tests/server/torture_server_algorithms.c b/tests/server/torture_server_algorithms.c index f7a28a48..a3300864 100644 --- a/tests/server/torture_server_algorithms.c +++ b/tests/server/torture_server_algorithms.c @@ -263,7 +263,7 @@ static void test_algorithm_no_hmac_overlap(void **state, const char *algorithm) s = tss->state; assert_non_null(s); - /* Prepare key files */ + /* Prepare config file */ snprintf(config_content, sizeof(config_content), "HostKey %s\nCiphers %s\nMACs %s\n", @@ -274,9 +274,10 @@ static void test_algorithm_no_hmac_overlap(void **state, const char *algorithm) assert_non_null(s->srv_config); torture_write_file(s->srv_config, config_content); - fprintf(stderr, "Config file %s content: \n\n%s\n", s->srv_config, + SSH_LOG(SSH_LOG_TRACE, + "Config file %s content: \n\n%s\n", + s->srv_config, config_content); - fflush(stderr); /* Start server */ rc = start_server(state); @@ -354,12 +355,28 @@ static void test_kex_self_compat(void **state, const char *kex) struct test_server_st *tss = *state; struct torture_state *s = NULL; ssh_session session = NULL; + char config_content[4096]; int rc; assert_non_null(tss); s = tss->state; assert_non_null(s); + /* Prepare config file */ + snprintf(config_content, + sizeof(config_content), + "HostKey %s\nKexAlgorithms %s\n", + tss->rsa_hostkey, + kex); + + assert_non_null(s->srv_config); + torture_write_file(s->srv_config, config_content); + + SSH_LOG(SSH_LOG_TRACE, + "Config file %s content: \n\n%s\n", + s->srv_config, + config_content); + rc = start_server(state); assert_int_equal(rc, 0);