diff options
author | Jakub Hrozek <jhrozek@redhat.com> | 2009-05-04 16:16:39 +0200 |
---|---|---|
committer | Simo Sorce <ssorce@redhat.com> | 2009-05-08 10:11:17 -0400 |
commit | 0ef76122eda140452e2ee97aac18a59d3c686c94 (patch) | |
tree | 51bdcab38d3571c7223ef61b3f35eaa5cd5ddfa2 /server | |
parent | b348e98e47d3ef287fed4d2e272bbf08540e0295 (diff) | |
download | sssd-0ef76122eda140452e2ee97aac18a59d3c686c94.tar.gz sssd-0ef76122eda140452e2ee97aac18a59d3c686c94.tar.bz2 sssd-0ef76122eda140452e2ee97aac18a59d3c686c94.zip |
Chdir to / when daemonizing
Diffstat (limited to 'server')
-rw-r--r-- | server/util/server.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/server/util/server.c b/server/util/server.c index a2402922..7c1c927f 100644 --- a/server/util/server.c +++ b/server/util/server.c @@ -74,6 +74,8 @@ static void close_low_fds(bool stderr_too) void become_daemon(bool Fork) { + int ret; + if (Fork) { if (fork()) { _exit(0); @@ -83,6 +85,15 @@ void become_daemon(bool Fork) /* detach from the terminal */ setsid(); + /* chdir to / to be sure we're not on a remote filesystem */ + errno = 0; + if(chdir("/") == -1) { + ret = errno; + DEBUG(0, ("Cannot change directory (%d [%s])\n", + ret, strerror(ret))); + return; + } + /* Close fd's 0,1,2. Needed if started by rsh */ close_low_fds(false); /* Don't close stderr, let the debug system attach it to the logfile */ |