tests/servers.pm: add more ways to figure out current user

Some CI tests fail due to "Can't start ssh server due to lack of USER name" -
add more ways to try to figure it out if no environment variable works: the
whoami and id commands.

Closes #17544
This commit is contained in:
Daniel Stenberg 2025-06-05 23:37:59 +02:00
parent d16a020a87
commit f33ec60fbf
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2

View file

@ -209,9 +209,17 @@ sub initserverconfig {
$USER = $ENV{USER}; # Linux
if (!$USER) {
$USER = $ENV{USERNAME}; # Windows
if (!$USER) {
$USER = $ENV{LOGNAME}; # Some Unix (I think)
}
}
if (!$USER) {
$USER = $ENV{LOGNAME}; # Some Unix (I think)
}
if (!$USER) {
$USER = `whoami`;
chomp $USER;
}
if (!$USER) {
$USER = `id -un`;
chomp $USER;
}
init_serverpidfile_hash();
}