X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=utils%2Fidmapd%2Fidmapd.c;h=5fc7811a8465b3c5be2ce35ef85c628fc639d092;hb=0523fd513c6baa8dbf45d1a7afea2044262aeb3d;hp=5712edbded40b635e85ce53270fcb779795d2a33;hpb=718a044f361ca02178d3679aa0f030f7ecf731fc;p=nfs-utils.git diff --git a/utils/idmapd/idmapd.c b/utils/idmapd/idmapd.c index 5712edb..5fc7811 100644 --- a/utils/idmapd/idmapd.c +++ b/utils/idmapd/idmapd.c @@ -547,9 +547,10 @@ nfsdcb(int fd, short which, void *data) if (which != EV_READ) goto out; - if ((len = read(ic->ic_fd, buf, sizeof(buf))) == -1) { + if ((len = read(ic->ic_fd, buf, sizeof(buf))) <= 0) { idmapd_warnx("nfsdcb: read(%s) failed: errno %d (%s)", - ic->ic_path, errno, strerror(errno)); + ic->ic_path, len?errno:0, + len?strerror(errno):"End of File"); goto out; } @@ -1002,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;