X-Git-Url: https://git.decadent.org.uk/gitweb/?p=nfs-utils.git;a=blobdiff_plain;f=utils%2Fidmapd%2Fidmapd.c;h=21a1916ded036da2446df0c839012ca042a888d6;hp=16b1316c60096173d8e3bd9618b76f63ec85f1ed;hb=940c7c304d4a43c00c27529cdddc7c87db6eef87;hpb=b90d201551aaa712c011c3d5de900fad714a26a6 diff --git a/utils/idmapd/idmapd.c b/utils/idmapd/idmapd.c index 16b1316..21a1916 100644 --- a/utils/idmapd/idmapd.c +++ b/utils/idmapd/idmapd.c @@ -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;