1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2025-07-31 00:03:07 +03:00

torture_config: Use getpwuid() instead of env variables

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Sahana Prasad <sahana@redhat.com>
This commit is contained in:
Andreas Schneider
2025-01-15 13:24:41 +01:00
parent e9046fc069
commit e9b76ff1bd

View File

@ -2392,24 +2392,14 @@ static void torture_config_make_absolute_int(void **state, bool no_sshdir_fails)
ssh_session session = *state; ssh_session session = *state;
char *result = NULL; char *result = NULL;
#ifndef _WIN32 #ifndef _WIN32
char h[256]; char h[256] = {0};
char *user; char *user = NULL;
char *home; char *home = NULL;
struct passwd *pw = getpwuid(getuid());
user = getenv("USER"); assert_non_null(pw);
if (user == NULL) { user = pw->pw_name;
user = getenv("LOGNAME"); assert_non_null(user);
} home = pw->pw_dir;
/* in certain CIs there no such variables */
if (!user) {
struct passwd *pw = getpwuid(getuid());
if (pw){
user = pw->pw_name;
}
}
home = getenv("HOME");
assert_non_null(home); assert_non_null(home);
#endif #endif