sh: Prioritize /etc/passwd over the USER environment variable

This commit is contained in:
apio 2023-05-11 20:10:10 +02:00
parent 18130847c1
commit a935039e78
Signed by: apio
GPG Key ID: B8A7D06E42258954

View File

@ -71,12 +71,9 @@ Result<int> luna_main(int argc, char** argv)
if (getuid() == 0) prompt_end = '#';
username = getenv("USER");
if (!username)
{
struct passwd* pw = getpwuid(getuid());
if (pw) { username = pw->pw_name; }
}
struct passwd* pw = getpwuid(getuid());
if (pw) { username = pw->pw_name; }
else { username = getenv("USER"); }
}
while (1)