diff options
Diffstat (limited to 'utils')
| -rw-r--r-- | utils/nfsd/nfsd.c | 10 | ||||
| -rw-r--r-- | utils/rquotad/rquota_svc.c | 22 |
2 files changed, 27 insertions, 5 deletions
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 <errno.h> #include <getopt.h> #include <syslog.h> +#include <netdb.h> #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 <signal.h> #include <getopt.h> #include <rpcmisc.h> +#include <nfslib.h> #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); |
