Only chdir to cwd if it is different from the current cwd or there
is a new root (chroot).
This commit is contained in:
@@ -848,14 +848,19 @@ exec_setup(struct command_details *details, const char *ptyname, int ptyfd)
|
|||||||
}
|
}
|
||||||
#endif /* !HAVE_SETRESUID && !HAVE_SETREUID */
|
#endif /* !HAVE_SETRESUID && !HAVE_SETREUID */
|
||||||
|
|
||||||
/* Set cwd after uid to avoid permissions problems. */
|
/*
|
||||||
|
* Only change cwd if we have chroot()ed or the policy modules
|
||||||
|
* specifies a different cwd. Must be done after uid change.
|
||||||
|
*/
|
||||||
if (details->cwd) {
|
if (details->cwd) {
|
||||||
|
if (details->chroot || strcmp(details->cwd, user_details.cwd) != 0) {
|
||||||
/* Note: cwd is relative to the new root, if any. */
|
/* Note: cwd is relative to the new root, if any. */
|
||||||
if (chdir(details->cwd) != 0) {
|
if (chdir(details->cwd) != 0) {
|
||||||
warning("unable to change directory to %s", details->cwd);
|
warning("unable to change directory to %s", details->cwd);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Restore nproc resource limit if pam_limits didn't do it for us.
|
* Restore nproc resource limit if pam_limits didn't do it for us.
|
||||||
|
Reference in New Issue
Block a user