]> git.decadent.org.uk Git - nfs-utils.git/blobdiff - utils/idmapd/idmapd.c
Use 65534 for anon uid/gid rather than -2
[nfs-utils.git] / utils / idmapd / idmapd.c
index c8ce6b2db54e305d6cf57aeb8541584490b44e7f..21a1916ded036da2446df0c839012ca042a888d6 100644 (file)
@@ -541,7 +541,8 @@ nfsdcb(int fd, short which, void *data)
        struct idmap_client *ic = data;
        struct idmap_msg im;
        u_char buf[IDMAP_MAXMSGSZ + 1];
-       size_t len, bsiz;
+       size_t len;
+       ssize_t bsiz;
        char *bp, typebuf[IDMAP_MAXMSGSZ],
                buf1[IDMAP_MAXMSGSZ], authbuf[IDMAP_MAXMSGSZ], *p;
        unsigned long tmp;
@@ -558,7 +559,7 @@ nfsdcb(int fd, short which, void *data)
 
        /* Get rid of newline and terminate buffer*/
        buf[len - 1] = '\0';
-       bp = buf;
+       bp = (char *)buf;
 
        memset(&im, 0, sizeof(im));
 
@@ -608,7 +609,7 @@ nfsdcb(int fd, short which, void *data)
        imconv(ic, &im);
 
        buf[0] = '\0';
-       bp = buf;
+       bp = (char *)buf;
        bsiz = sizeof(buf);
 
        /* Authentication name */
@@ -1005,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;