1diff --git usertable.cpp usertable.cpp
2index 11fd04b..a8681bd 100644
3--- a/usertable.cpp
4+++ b/usertable.cpp
5@@ -43,9 +43,6 @@
6 #define DONT_FOLLOW(mask) (false)
7 #endif // IN_DONT_FOLLOW
8
9-// this is not enough, but...
10-#define DEFAULT_PATH "/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin"
11-
12
13 PROC_MAP UserTable::s_procMap;
14
15@@ -597,12 +594,20 @@ void UserTable::RunAsUser(std::string cmd) const
16 if (clearenv() != 0)
17 goto failed;
18
19+ // try to recreate the user path as best as possible
20+ std::string DEFAULT_PATH;
21+ DEFAULT_PATH += "/run/wrappers/bin:";
22+ DEFAULT_PATH += pwd->pw_dir;
23+ DEFAULT_PATH += "/.nix-profile/bin:/nix/var/nix/profiles/default/bin:/run/current-system/sw/bin:/etc/profiles/per-user/";
24+ DEFAULT_PATH += pwd->pw_name;
25+ DEFAULT_PATH += "/bin";
26+
27 if ( setenv("LOGNAME", pwd->pw_name, 1) != 0
28 || setenv("USER", pwd->pw_name, 1) != 0
29 || setenv("USERNAME", pwd->pw_name, 1) != 0
30 || setenv("HOME", pwd->pw_dir, 1) != 0
31 || setenv("SHELL", pwd->pw_shell, 1) != 0
32- || setenv("PATH", DEFAULT_PATH, 1) != 0)
33+ || setenv("PATH", DEFAULT_PATH.c_str(), 1) != 0)
34 {
35 goto failed;
36 }