torture_path_expand_tilde_unix: use getpwuid() if no env variables
This allows operating under environments where the username variables are not present. Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Этот коммит содержится в:
родитель
e005fd310f
Коммит
f3a19d8c96
@ -1,5 +1,8 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
#ifdef HAVE_UNISTD_H
|
||||||
|
#include <unistd.h>
|
||||||
|
#endif
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
|
|
||||||
@ -129,7 +132,14 @@ static void torture_path_expand_tilde_unix(void **state) {
|
|||||||
if (user == NULL){
|
if (user == NULL){
|
||||||
user = getenv("LOGNAME");
|
user = getenv("LOGNAME");
|
||||||
}
|
}
|
||||||
assert_non_null(user);
|
/* in certain CIs there no such variables */
|
||||||
|
if (!user){
|
||||||
|
struct passwd *pw = getpwuid(getuid());
|
||||||
|
if (pw){
|
||||||
|
user = pw->pw_name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
home = getenv("HOME");
|
home = getenv("HOME");
|
||||||
assert_non_null(home);
|
assert_non_null(home);
|
||||||
snprintf(h, 256 - 1, "%s/.ssh", home);
|
snprintf(h, 256 - 1, "%s/.ssh", home);
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user