Skip to content

Commit

Permalink
launch_daemon: Set working directory to user's directory.
Browse files Browse the repository at this point in the history
* This fixes #12257.
  • Loading branch information
axeld committed Jul 30, 2015
1 parent b4665f9 commit 6306a26
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/servers/launch/LaunchDaemon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1215,9 +1215,16 @@ LaunchDaemon::_StartSession(const char* login)
if (setuid(user) != 0)
exit(EXIT_FAILURE);

BString home="HOME=\"";
home << passwd->pw_dir << "\"";
putenv(home.String());
if (passwd->pw_dir != NULL && passwd->pw_dir[0] != '\0') {
BString home="HOME=\"";
home << passwd->pw_dir << "\"";
putenv(home.String());

if (chdir(passwd->pw_dir) != 0) {
debug_printf("Could not switch to home dir %s: %s\n",
passwd->pw_dir, strerror(errno));
}
}

// TODO: This leaks the parent application
be_app = NULL;
Expand Down

0 comments on commit 6306a26

Please sign in to comment.