From db05939cd070914c210343a5b2ae609d8fdc3f93 Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Sun, 5 Mar 2017 11:40:18 +0100 Subject: [PATCH 1/1] Chdir to home directory --- ptyas.c | 6 ++++++ 1 file changed, 6 insertions(+) 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]; -- 2.43.2