diff options
-rw-r--r-- | ChangeLog | 25 | ||||
-rwxr-xr-x | configure | 110 | ||||
-rw-r--r-- | configure.in | 2 | ||||
-rw-r--r-- | support/include/config.h.in | 8 | ||||
-rw-r--r-- | support/include/nfslib.h | 3 | ||||
-rw-r--r-- | support/nfs/Makefile | 3 | ||||
-rw-r--r-- | support/nfs/rpcmisc.c | 12 | ||||
-rw-r--r-- | utils/nfsd/nfsd.c | 10 | ||||
-rw-r--r-- | utils/rquotad/rquota_svc.c | 22 |
9 files changed, 187 insertions, 8 deletions
@@ -1,3 +1,28 @@ +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. + 2002-09-02 Juan Gomez <juang@us.ibm.com> NeilBrown <neilb@cse.unsw.edu.au> @@ -1582,6 +1582,116 @@ else fi done +for ac_func in svctcp_socket +do +echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 +echo "configure:1589: checking for $ac_func" >&5 +if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 1594 "configure" +#include "confdefs.h" +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func(); below. */ +#include <assert.h> +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +$ac_func(); +#endif + +; return 0; } +EOF +if { (eval echo configure:1617: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_func_$ac_func=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_$ac_func=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` + cat >> confdefs.h <<EOF +#define $ac_tr_func 1 +EOF + +else + echo "$ac_t""no" 1>&6 +fi +done + +for ac_func in svcudp_socket +do +echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 +echo "configure:1644: checking for $ac_func" >&5 +if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 1649 "configure" +#include "confdefs.h" +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func(); below. */ +#include <assert.h> +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +$ac_func(); +#endif + +; return 0; } +EOF +if { (eval echo configure:1672: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_func_$ac_func=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_$ac_func=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` + cat >> confdefs.h <<EOF +#define $ac_tr_func 1 +EOF + +else + echo "$ac_t""no" 1>&6 +fi +done + cat >> confdefs.h <<EOF #define NFS_STATEDIR "$statedir" diff --git a/configure.in b/configure.in index 08119d0..5403562 100644 --- a/configure.in +++ b/configure.in @@ -98,6 +98,8 @@ dnl ************************************************************* dnl Check for functions dnl ************************************************************* AC_HAVE_FUNCS(innetgr) +AC_HAVE_FUNCS(svctcp_socket) +AC_HAVE_FUNCS(svcudp_socket) dnl ************************************************************* dnl Export some path names to config.h diff --git a/support/include/config.h.in b/support/include/config.h.in index f8c1497..6d12cc6 100644 --- a/support/include/config.h.in +++ b/support/include/config.h.in @@ -9,6 +9,14 @@ */ #undef HAVE_INNETGR +/* Define this if you have svctcp_socket + */ +#undef HAVE_SVCTCP_SOCKET + +/* Define this if you have svcudp_socket + */ +#undef HAVE_SVCUDP_SOCKET + /* Define this if you want NFSv3 support compiled in */ #undef NFS3_SUPPORTED diff --git a/support/include/nfslib.h b/support/include/nfslib.h index 6bcc859..b95c782 100644 --- a/support/include/nfslib.h +++ b/support/include/nfslib.h @@ -125,4 +125,7 @@ struct nfs_fh_len * getfh_size(struct sockaddr *addr, const char *, int size); /* lockd. */ int lockdsvc(); +extern int svctcp_socket (u_long __number, int __reuse); +extern int svcudp_socket (u_long __number, int __reuse); + #endif /* NFSLIB_H */ diff --git a/support/nfs/Makefile b/support/nfs/Makefile index ed1e1ff..12a44e8 100644 --- a/support/nfs/Makefile +++ b/support/nfs/Makefile @@ -5,7 +5,8 @@ LIBNAME = libnfs.a OBJS = exports.o rmtab.o xio.o \ rpcmisc.o rpcdispatch.o xlog.o xmalloc.o wildmat.o \ - nfssvc.o nfsclient.o nfsexport.o getfh.o nfsctl.o lockdsvc.o + nfssvc.o nfsclient.o nfsexport.o getfh.o nfsctl.o \ + lockdsvc.o svc_socket.o include $(TOP)rules.mk diff --git a/support/nfs/rpcmisc.c b/support/nfs/rpcmisc.c index 6eb24a2..832de5f 100644 --- a/support/nfs/rpcmisc.c +++ b/support/nfs/rpcmisc.c @@ -73,11 +73,15 @@ rpc_init(char *name, int prog, int vers, void (*dispatch)(), int defport) transp = last_transp; goto udp_transport; } - if ((sock = makesock(defport, IPPROTO_UDP)) < 0) { + if (defport == 0) + sock = RPC_ANYSOCK; + else if ((sock = makesock(defport, IPPROTO_UDP)) < 0) { xlog(L_FATAL, "%s: cannot make a UDP socket\n", name); } } + if (sock == RPC_ANYSOCK) + sock = svcudp_socket (prog, 1); transp = svcudp_create(sock); if (transp == NULL) { xlog(L_FATAL, "cannot create udp service."); @@ -99,11 +103,15 @@ rpc_init(char *name, int prog, int vers, void (*dispatch)(), int defport) transp = last_transp; goto tcp_transport; } - if ((sock = makesock(defport, IPPROTO_TCP)) < 0) { + if (defport == 0) + sock = RPC_ANYSOCK; + else if ((sock = makesock(defport, IPPROTO_TCP)) < 0) { xlog(L_FATAL, "%s: cannot make a TCP socket\n", name); } } + if (sock == RPC_ANYSOCK) + sock = svctcp_socket (prog, 1); transp = svctcp_create(sock, 0, 0); if (transp == NULL) { xlog(L_FATAL, "cannot create tcp service."); 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); |