X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=utils%2Fidmapd%2Fidmapd.c;h=21a1916ded036da2446df0c839012ca042a888d6;hb=6fccc04c2569e54c16f9b0992aa1f5a3fbd907b4;hp=16b1316c60096173d8e3bd9618b76f63ec85f1ed;hpb=93608a52655abf5ac23404c4b5cc05fe575a9c04;p=nfs-utils.git 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;