summaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
authorhjl <hjl>2002-09-12 21:06:16 +0000
committerhjl <hjl>2002-09-12 21:06:16 +0000
commit87fe487c6f5abe9f40f2f036c3cf6c7f02fa0385 (patch)
tree15f6af17471f0fc489e236de98cf53fac64bf090 /utils
parent55ce21003ee0fb12fe5ef70909cdc8ce00b803e4 (diff)
downloadnfs-utils-87fe487c6f5abe9f40f2f036c3cf6c7f02fa0385.tar.gz
nfs-utils-87fe487c6f5abe9f40f2f036c3cf6c7f02fa0385.tar.xz
nfs-utils-87fe487c6f5abe9f40f2f036c3cf6c7f02fa0385.zip
2002-09-12 H.J. Lu <hjl@lucon.org>
* 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 <nfslib.h>. (killer): New. Signal handler to unregister. (main): Use killer. Call svcudp_socket to get the default socket.
Diffstat (limited to 'utils')
-rw-r--r--utils/nfsd/nfsd.c10
-rw-r--r--utils/rquotad/rquota_svc.c22
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);