]> ruderich.org/simon Gitweb - ptyas/ptyas.git/commitdiff
Chdir to home directory
authorSimon Ruderich <simon@ruderich.org>
Sun, 5 Mar 2017 10:40:18 +0000 (11:40 +0100)
committerSimon Ruderich <simon@ruderich.org>
Tue, 16 May 2017 15:06:50 +0000 (17:06 +0200)
ptyas.c

diff --git a/ptyas.c b/ptyas.c
index c21c6ae35036af64b627aebf583d5980518ae5a7..9ffe998a7f51c25deedfae106ddb166c68b676ba 100644 (file)
--- a/ptyas.c
+++ b/ptyas.c
@@ -376,6 +376,12 @@ int main(int argc, char **argv) {
             }
             const char *home = passwd->pw_dir;
 
             }
             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];
             char envp_user[strlen("USER=") + strlen(user) + 1];
             char envp_home[strlen("HOME=") + strlen(home) + 1];
             char envp_term[strlen("TERM=") + strlen(term) + 1];