summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-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 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 */