diff --git a/apps/sh.cpp b/apps/sh.cpp index efed77f6..0a25f6c4 100644 --- a/apps/sh.cpp +++ b/apps/sh.cpp @@ -70,8 +70,13 @@ Result luna_main(int argc, char** argv) hostname = g_sysinfo.nodename; if (getuid() == 0) prompt_end = '#'; - struct passwd* pw = getpwuid(getuid()); - if (pw) { username = pw->pw_name; } + + username = getenv("USER"); + if (!username) + { + struct passwd* pw = getpwuid(getuid()); + if (pw) { username = pw->pw_name; } + } } while (1) diff --git a/apps/su.cpp b/apps/su.cpp index 7aa36f34..2f544e6b 100644 --- a/apps/su.cpp +++ b/apps/su.cpp @@ -92,11 +92,10 @@ Result luna_main(int argc, char** argv) setuid(entry->pw_uid); chdir(entry->pw_dir); - if (setenv("HOME", entry->pw_dir, 1) < 0) - { - perror("setenv"); - return 1; - } + + setenv("HOME", entry->pw_dir, 1); + setenv("USER", entry->pw_name, 1); + setenv("SHELL", entry->pw_shell, 1); execl(entry->pw_shell, entry->pw_shell, NULL);