From 57e9d18e38c5f109276cb5a5594d44c84badc347 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Wed, 26 Jul 2023 23:01:02 +0000 Subject: [PATCH] test_read: make it run without Docker Apply an existing fix to `test_read`, so that it falls back to use the current username instead of the hardcoded `libssh2` when run outside Docker. This allows to run algo tests with this command: ```shell cd tests ./test_sshd.test ./test_read_algos.test ``` Closes #1139 --- tests/test_read.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/tests/test_read.c b/tests/test_read.c index ac1a4a82..a248e3cc 100644 --- a/tests/test_read.c +++ b/tests/test_read.c @@ -6,6 +6,7 @@ */ #include "runner.h" +#include "openssh_fixture.h" #include /* for getenv() */ @@ -32,10 +33,19 @@ int test(LIBSSH2_SESSION *session) char remote_command[256]; const char *env; + const char *userauth_list; - const char *userauth_list = - libssh2_userauth_list(session, username, - (unsigned int)strlen(username)); + /* Ignore our hard-wired Dockerfile user when not running under Docker */ + if(!openssh_fixture_have_docker()) { + username = getenv("USER"); +#ifdef WIN32 + if(!username) + username = getenv("USERNAME"); +#endif + } + + userauth_list = libssh2_userauth_list(session, username, + (unsigned int)strlen(username)); if(!userauth_list) { print_last_session_error("libssh2_userauth_list"); return 1;