X-Git-Url: https://git.decadent.org.uk/gitweb/?p=nfs-utils.git;a=blobdiff_plain;f=utils%2Fgssd%2Fsvcgssd.c;h=729b6a6d3b80a86034e6887fd3a0e87c3113a9fa;hp=69d2a6966946b287fed1bcdfef0849cb5a844dfb;hb=1aa4121ba599de836702d7b2d38cad63e6a09044;hpb=f91afa8eaee1d7ba390918d00d4f7d3f338d18d3 diff --git a/utils/gssd/svcgssd.c b/utils/gssd/svcgssd.c index 69d2a69..729b6a6 100644 --- a/utils/gssd/svcgssd.c +++ b/utils/gssd/svcgssd.c @@ -117,10 +117,16 @@ 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) { + dup2(tempfd, 0); + dup2(tempfd, 1); + dup2(tempfd, 2); + close(tempfd); + } else { + printerr(1, "mydaemon: can't open /dev/null: errno %d " + "(%s)\n", errno, strerror(errno)); + exit(1); + } } return;