summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2009-05-04 16:16:39 +0200
committerSimo Sorce <ssorce@redhat.com>2009-05-08 10:11:17 -0400
commit0ef76122eda140452e2ee97aac18a59d3c686c94 (patch)
tree51bdcab38d3571c7223ef61b3f35eaa5cd5ddfa2
parentb348e98e47d3ef287fed4d2e272bbf08540e0295 (diff)
downloadsssd-0ef76122eda140452e2ee97aac18a59d3c686c94.tar.gz
sssd-0ef76122eda140452e2ee97aac18a59d3c686c94.tar.xz
sssd-0ef76122eda140452e2ee97aac18a59d3c686c94.zip
Chdir to / when daemonizing
-rw-r--r--server/util/server.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/server/util/server.c b/server/util/server.c
index a24029229..7c1c927f3 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 */