Don't set cwd to user's home for services

allow `cwd` setting to take effect
This commit is contained in:
Min RK
2017-01-15 20:10:06 +01:00
parent a276421d25
commit 6fc9e90f28
2 changed files with 5 additions and 4 deletions

View File

@@ -639,7 +639,7 @@ def _try_setcwd(path):
os.chdir(td)
def set_user_setuid(username):
def set_user_setuid(username, chdir=True):
"""Return a preexec_fn for spawning a single-user server as a particular user.
Returned preexec_fn will set uid/gid, and attempt to chdir to the target user's
@@ -666,7 +666,8 @@ def set_user_setuid(username):
os.setuid(uid)
# start in the user's home dir
_try_setcwd(home)
if chdir:
_try_setcwd(home)
return preexec