]> git.decadent.org.uk Git - nfs-utils.git/blobdiff - utils/idmapd/idmapd.c
Merge branch 'master' of git://linux-nfs.org/nfs-utils
[nfs-utils.git] / utils / idmapd / idmapd.c
index 16b1316c60096173d8e3bd9618b76f63ec85f1ed..21a1916ded036da2446df0c839012ca042a888d6 100644 (file)
@@ -1006,10 +1006,15 @@ mydaemon(int nochdir, int noclose)
 
        if (noclose == 0) {
                tempfd = open("/dev/null", O_RDWR);
-               dup2(tempfd, 0);
-               dup2(tempfd, 1);
-               dup2(tempfd, 2);
-               closeall(3);
+               if (tempfd < 0)
+                       tempfd = open("/", O_RDONLY);
+               if (tempfd >= 0) {
+                       dup2(tempfd, 0);
+                       dup2(tempfd, 1);
+                       dup2(tempfd, 2);
+                       closeall(3);
+               } else
+                       closeall(0);
        }
 
        return;