From ac84b80afc13d5a96813e678ad5c86c6036f022e Mon Sep 17 00:00:00 2001 From: chip Date: Mon, 26 Nov 2001 19:57:30 +0000 Subject: [PATCH] 2001-11-26 Chip Salzenberg * utils/showmount/showmount.c (main): Don't assume that strings starting with digits are IP addresses. * utils/nfsd/nfsd.c (main): Close all fds and reopen 0,1,2 on /dev/null before nfssvc(). Use syslog to report nfssvc errors. * support/misc/tcpwrapper.c, utils/mountd/mountd.man, utils/rquotad/rquotad.man, utils/statd/statd.man: Fix comments and man pages: We check host names *and* addresses with tcpwrappers. --- ChangeLog | 10 ++++++++++ support/misc/tcpwrapper.c | 4 +--- utils/mountd/mountd.man | 4 +--- utils/nfsd/nfsd.c | 28 +++++++++++++++++++++++++--- utils/rquotad/rquotad.man | 4 +--- utils/showmount/showmount.c | 3 +-- utils/statd/statd.man | 4 +--- 7 files changed, 40 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index d2555a5..8ef1761 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2001-11-26 Chip Salzenberg + + * utils/showmount/showmount.c (main): Don't assume that strings + starting with digits are IP addresses. + * utils/nfsd/nfsd.c (main): Close all fds and reopen 0,1,2 on + /dev/null before nfssvc(). Use syslog to report nfssvc errors. + * support/misc/tcpwrapper.c, utils/mountd/mountd.man, + utils/rquotad/rquotad.man, utils/statd/statd.man: Fix comments and + man pages: We check host names *and* addresses with tcpwrappers. + 2001-11-21 Chip Salzenberg * support/nfs/clients.c (cfname): Added: current clients file name. diff --git a/support/misc/tcpwrapper.c b/support/misc/tcpwrapper.c index 8743a7b..d8a742f 100644 --- a/support/misc/tcpwrapper.c +++ b/support/misc/tcpwrapper.c @@ -25,9 +25,7 @@ * authorized by the /etc/hosts.{allow,deny} files. The local system is * always treated as an authorized host. The access control tables are never * consulted for requests from the local system, and are always consulted - * for requests from other hosts. Access control is based on IP addresses - * only; attempts to map an address to a host name might cause the - * portmapper to hang. + * for requests from other hosts. * * Author: Wietse Venema (wietse@wzv.win.tue.nl), dept. of Mathematics and * Computing Science, Eindhoven University of Technology, The Netherlands. diff --git a/utils/mountd/mountd.man b/utils/mountd/mountd.man index 71560ab..f529ec1 100644 --- a/utils/mountd/mountd.man +++ b/utils/mountd/mountd.man @@ -125,9 +125,7 @@ mountd: .bar.com You have to use the daemon name .B mountd -for the daemon name (even if the binary has a different name). For the -client names you can only use the keyword ALL or IP addresses (NOT -host or domain names). +for the daemon name (even if the binary has a different name). For further information please have a look at the .BR tcpd (8), diff --git a/utils/nfsd/nfsd.c b/utils/nfsd/nfsd.c index c1cb56f..772f72d 100644 --- a/utils/nfsd/nfsd.c +++ b/utils/nfsd/nfsd.c @@ -12,9 +12,11 @@ #include #include #include +#include #include #include #include +#include #include "nfslib.h" static void usage(const char *); @@ -22,7 +24,7 @@ static void usage(const char *); int main(int argc, char **argv) { - int count = 1, c, error, port; + int count = 1, c, error, port, fd; port = 2049; @@ -62,8 +64,28 @@ main(int argc, char **argv) } } - if ((error = nfssvc(port, count)) < 0) - perror("nfssvc"); + /* KLUDGE ALERT: + Some kernels let nfsd kernel threads inherit open files + from the program that spawns them (i.e. us). So close + everything before spawning kernel threads. --Chip */ + fd = open("/dev/null", O_RDWR); + if (fd == -1) + perror("/dev/null"); + else { + (void) dup2(fd, 0); + (void) dup2(fd, 1); + (void) dup2(fd, 2); + } + fd = sysconf(_SC_OPEN_MAX); + while (--fd > 2) + (void) close(fd); + + if ((error = nfssvc(port, count)) < 0) { + int e = errno; + openlog("nfsd", LOG_PID, LOG_DAEMON); + syslog(LOG_ERR, "nfssvc: %s", strerror(e)); + closelog(); + } return (error != 0); } diff --git a/utils/rquotad/rquotad.man b/utils/rquotad/rquotad.man index f4d5d6f..89774f2 100644 --- a/utils/rquotad/rquotad.man +++ b/utils/rquotad/rquotad.man @@ -64,9 +64,7 @@ mountd: .bar.com You have to use the daemon name .BR rquotad -for the daemon name (even if the binary has a different name). For the -client names you can only use the keyword ALL or IP addresses (NOT -host or domain names). +for the daemon name (even if the binary has a different name). For further information please have a look at the .BR tcpd (8), diff --git a/utils/showmount/showmount.c b/utils/showmount/showmount.c index 47b5825..1ff3fa1 100644 --- a/utils/showmount/showmount.c +++ b/utils/showmount/showmount.c @@ -154,9 +154,8 @@ char **argv; break; } - if (hostname[0] >= '0' && hostname[0] <= '9') { + if (inet_aton(hostname, &server_addr.sin_addr.s_addr)) { server_addr.sin_family = AF_INET; - server_addr.sin_addr.s_addr = inet_addr(hostname); } else { if ((hp = gethostbyname(hostname)) == NULL) { diff --git a/utils/statd/statd.man b/utils/statd/statd.man index 9f861b2..b8467fe 100644 --- a/utils/statd/statd.man +++ b/utils/statd/statd.man @@ -115,9 +115,7 @@ statd: .bar.com You have to use the daemon name .B statd -for the daemon name (even if the binary has a different name). For the -client names you can only use the keyword ALL or IP addresses (NOT -host or domain names). +for the daemon name (even if the binary has a different name). For further information please have a look at the .BR tcpd (8), -- 2.39.2