From: Simon Ruderich Date: Sun, 5 Mar 2017 10:40:18 +0000 (+0100) Subject: Chdir to home directory X-Git-Tag: 0.1~11 X-Git-Url: https://ruderich.org/simon/gitweb/?p=ptyas%2Fptyas.git;a=commitdiff_plain;h=db05939cd070914c210343a5b2ae609d8fdc3f93 Chdir to home directory --- diff --git a/ptyas.c b/ptyas.c index c21c6ae..9ffe998 100644 --- a/ptyas.c +++ b/ptyas.c @@ -376,6 +376,12 @@ int main(int argc, char **argv) { } 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];