X-Git-Url: https://git.decadent.org.uk/gitweb/?p=nfs-utils.git;a=blobdiff_plain;f=utils%2Fidmapd%2Fidmapd.c;h=5fc7811a8465b3c5be2ce35ef85c628fc639d092;hp=158feaf66c11627beb931ab253d7c56cb9722c6b;hb=0523fd513c6baa8dbf45d1a7afea2044262aeb3d;hpb=660809fe7e597520d17deab9225f1b371c08d65c diff --git a/utils/idmapd/idmapd.c b/utils/idmapd/idmapd.c index 158feaf..5fc7811 100644 --- a/utils/idmapd/idmapd.c +++ b/utils/idmapd/idmapd.c @@ -1003,10 +1003,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;