From 87fe487c6f5abe9f40f2f036c3cf6c7f02fa0385 Mon Sep 17 00:00:00 2001 From: hjl Date: Thu, 12 Sep 2002 21:06:16 +0000 Subject: 2002-09-12 H.J. Lu * configure.in: Check svctcp_socket and svcudp_socket. * configure: Regenerated. * support/include/config.h.in (HAVE_SVCTCP_SOCKET): New. (HAVE_SVCUDP_SOCKET): New. * support/include/nfslib.h (svctcp_socket): New. (svcudp_socket): New. * support/nfs/Makefile (OBJS): Add svc_socket.o. * support/nfs/svc_socket.c: New. * support/nfs/rpcmisc.c (rpc_init): Call svctcp_socket and svcudp_socket if port is unspecified. * utils/nfsd/nfsd.c (main): Call getservbyname for port. * utils/rquotad/rquota_svc.c: Include . (killer): New. Signal handler to unregister. (main): Use killer. Call svcudp_socket to get the default socket. --- utils/nfsd/nfsd.c | 10 +++++++--- utils/rquotad/rquota_svc.c | 22 ++++++++++++++++++++-- 2 files changed, 27 insertions(+), 5 deletions(-) (limited to 'utils') diff --git a/utils/nfsd/nfsd.c b/utils/nfsd/nfsd.c index 772f72d..86e8094 100644 --- a/utils/nfsd/nfsd.c +++ b/utils/nfsd/nfsd.c @@ -17,6 +17,7 @@ #include #include #include +#include #include "nfslib.h" static void usage(const char *); @@ -25,10 +26,13 @@ int main(int argc, char **argv) { int count = 1, c, error, port, fd; + struct servent *ent; - port = 2049; - - /* FIXME: Check for nfs in /etc/services */ + ent = getservbyname ("nfs", "udp"); + if (ent != NULL) + port = ntohs (ent->s_port); + else + port = 2049; while ((c = getopt(argc, argv, "hp:P:")) != EOF) { switch(c) { diff --git a/utils/rquotad/rquota_svc.c b/utils/rquotad/rquota_svc.c index e114966..4b3cdc2 100644 --- a/utils/rquotad/rquota_svc.c +++ b/utils/rquotad/rquota_svc.c @@ -38,6 +38,7 @@ #include #include #include +#include #ifdef __STDC__ #define SIG_PF void(*)(int) @@ -222,11 +223,20 @@ usage(const char *prog, int n) exit(n); } +static void +killer (int sig) +{ + (void) pmap_unset(RQUOTAPROG, RQUOTAVERS); + (void) pmap_unset(RQUOTAPROG, EXT_RQUOTAVERS); + syslog(LOG_ERR, "caught signal %d, un-registering and exiting.", sig); +} + int main(int argc, char **argv) { register SVCXPRT *transp; char c; int port = 0; + struct sigaction sa; (void) pmap_unset(RQUOTAPROG, RQUOTAVERS); (void) pmap_unset(RQUOTAPROG, EXT_RQUOTAVERS); @@ -263,12 +273,20 @@ int main(int argc, char **argv) } /* WARNING: the following works on Linux and SysV, but not BSD! */ - signal(SIGCHLD, SIG_IGN); + sa.sa_handler = SIG_IGN; + sa.sa_flags = 0; + sigemptyset(&sa.sa_mask); + sigaction(SIGCHLD, &sa, NULL); + + sa.sa_handler = killer; + sigaction(SIGHUP, &sa, NULL); + sigaction(SIGINT, &sa, NULL); + sigaction(SIGTERM, &sa, NULL); if (port) transp = svcudp_create(makesock(port, IPPROTO_UDP)); else - transp = svcudp_create(RPC_ANYSOCK); + transp = svcudp_create(svcudp_socket (RQUOTAPROG, 1)); if (transp == NULL) { syslog(LOG_ERR, "cannot create udp service."); exit(1); -- cgit