}
const char *home = passwd->pw_dir;
+ // Ignore errors here as we don't want to die on non-existent home
+ // directories to allow running as any user (think "/nonexistent"
+ // as home) and an error message will be annoying to ignore when
+ // running this command in scripts.
+ chdir(home);
+
char envp_user[strlen("USER=") + strlen(user) + 1];
char envp_home[strlen("HOME=") + strlen(home) + 1];
char envp_term[strlen("TERM=") + strlen(term) + 1];