mirror of
https://github.com/libssh2/libssh2.git
synced 2025-07-31 00:03:08 +03:00
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
This commit is contained in:
@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
#include "runner.h"
|
||||
#include "openssh_fixture.h"
|
||||
|
||||
#include <stdlib.h> /* 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;
|
||||
|
Reference in New Issue
Block a user