From a935039e78d18d47dce9dc538a1dfe3ae94a513a Mon Sep 17 00:00:00 2001 From: apio Date: Thu, 11 May 2023 20:10:10 +0200 Subject: [PATCH] sh: Prioritize /etc/passwd over the USER environment variable --- apps/sh.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/apps/sh.cpp b/apps/sh.cpp index 0a25f6c4..2791465f 100644 --- a/apps/sh.cpp +++ b/apps/sh.cpp @@ -71,12 +71,9 @@ Result 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)