From 8a47605dcb90d1241c73cd53dc40f30e313517b8 Mon Sep 17 00:00:00 2001 From: Derek Atkins Date: Fri, 1 Nov 2002 01:29:56 +0000 Subject: [PATCH] Re-port RPC library to Solaris Hook RPC library into build tree Use RPC library when RPC-check fails (need a better way) --- configure.ac | 18 +++++++------- mod_shibrm/Makefile.am | 6 ++++- mod_shire/Makefile.am | 6 ++++- oncrpc/.gitignore | 6 +++++ oncrpc/Makefile.am | 64 +++++++++++++++++++++++++++++++++++++++++++++++++ oncrpc/auth_uni.c | 2 +- oncrpc/authunix.c | 2 +- oncrpc/clnt_per.c | 2 ++ oncrpc/clnt_tcp.c | 4 ++-- oncrpc/clnt_udp.c | 12 ++++++---- oncrpc/get_myad.c | 6 ++++- oncrpc/pmap_cln.c | 4 ++-- oncrpc/pmap_get.c | 8 +++++-- oncrpc/pmap_gma.c | 4 ++-- oncrpc/pmap_rmt.c | 16 ++++++++----- oncrpc/rpc/.gitignore | 6 +++++ oncrpc/rpc/Makefile.am | 22 +++++++++++++++++ oncrpc/rpc/svc_auth.h | 2 +- oncrpc/rpc/types.h | 4 ++++ oncrpc/svc.c | 3 ++- oncrpc/svc_run.c | 2 +- oncrpc/svc_tcp.c | 2 +- oncrpc/svc_udp.c | 19 +++++++-------- oncrpc/xdr_arra.c | 3 ++- oncrpc/xdr_rec.c | 5 ++++ shar/Makefile.am | 4 ++++ shib-target/Makefile.am | 6 +++++ 27 files changed, 190 insertions(+), 48 deletions(-) create mode 100644 oncrpc/.gitignore create mode 100644 oncrpc/Makefile.am create mode 100644 oncrpc/rpc/.gitignore create mode 100644 oncrpc/rpc/Makefile.am diff --git a/configure.ac b/configure.ac index 12e57c1..0ebfcd2 100644 --- a/configure.ac +++ b/configure.ac @@ -36,14 +36,6 @@ AC_SEARCH_LIBS(xdr_uint64_t,nsl,, CXXFLAGS="$CXXFLAGS -DNEED_XDR_LONGLONG"]) LIBS="$old_LIBS" -ACX_RPCTEST([rpctest="yes"],[rpctest="no"]) -if test $rpctest = "no"; then - AC_CHECK_HEADERS([stropts.h]) - CFLAGS="-DNEED_RPC_TLI $CFLAGS" - CXXFLAGS="-DNEED_RPC_TLI $CXXFLAGS" - ACX_RPCTEST(,AC_MSG_ERROR([neither style of ONC RPC worked])) -fi - # checks for pthreads ACX_PTHREAD([enable_threads="pthread"],[enable_threads="no"]) if test $enable_threads != "pthread"; then @@ -159,7 +151,15 @@ AC_TRY_LINK( # output the underlying makefiles WANT_SUBDIRS="shib schemas configs eduPerson shib-target shar test" AC_CONFIG_FILES([Makefile shib/Makefile schemas/Makefile eduPerson/Makefile \ - configs/Makefile shib-target/Makefile shar/Makefile test/Makefile]) + configs/Makefile oncrpc/Makefile oncrpc/rpc/Makefile \ + shib-target/Makefile shar/Makefile test/Makefile]) + +# now test the rpc library, to see if we need to build our own +ACX_RPCTEST([rpctest="yes"],[rpctest="no"]) +if test $rpctest = "no"; then + WANT_SUBDIRS="oncrpc $WANT_SUBDIRS" + AM_CONDITIONAL(USE_OUR_ONCRPC,test "$rpctest" = "no") +fi # Much of this is taken from mod_dav. # The basic idea is to use configure options to control whether/which types diff --git a/mod_shibrm/Makefile.am b/mod_shibrm/Makefile.am index 6fc5767..09e94e4 100644 --- a/mod_shibrm/Makefile.am +++ b/mod_shibrm/Makefile.am @@ -2,12 +2,16 @@ AUTOMAKE_OPTIONS = foreign +if USE_OUR_ONCRPC +RPC_CFLAGS = -I${top_srcdir}/oncrpc +endif + shibrmdir = $(libexecdir) shibrm_LTLIBRARIES = mod_shibrm.la mod_shibrm_la_SOURCES = mod_shibrm.cpp -AM_CXXFLAGS = $(APXS_CFLAGS) -I$(APXS_INCLUDE) +AM_CXXFLAGS = $(APXS_CFLAGS) -I$(APXS_INCLUDE) $(RPC_CFLAGS) mod_shibrm_la_LIBADD = $(top_builddir)/shib/libshib.la $(top_builddir)/shib-target/libshib-target.la diff --git a/mod_shire/Makefile.am b/mod_shire/Makefile.am index 79fe57b..1302884 100644 --- a/mod_shire/Makefile.am +++ b/mod_shire/Makefile.am @@ -2,12 +2,16 @@ AUTOMAKE_OPTIONS = foreign +if USE_OUR_ONCRPC +RPC_CFLAGS = -I${top_srcdir}/oncrpc +endif + shiredir = $(libexecdir) shire_LTLIBRARIES = mod_shire.la mod_shire_la_SOURCES = mod_shire.cpp -AM_CXXFLAGS = $(APXS_CFLAGS) -I$(APXS_INCLUDE) +AM_CXXFLAGS = $(APXS_CFLAGS) -I$(APXS_INCLUDE) $(RPC_CFLAGS) mod_shire_la_LIBADD = $(top_builddir)/shib/libshib.la $(top_builddir)/shib-target/libshib-target.la diff --git a/oncrpc/.gitignore b/oncrpc/.gitignore new file mode 100644 index 0000000..26d1c48 --- /dev/null +++ b/oncrpc/.gitignore @@ -0,0 +1,6 @@ +/Makefile.in +/Makefile +/.libs +/.deps +/*.lo +/*.la \ No newline at end of file diff --git a/oncrpc/Makefile.am b/oncrpc/Makefile.am new file mode 100644 index 0000000..3b8e46d --- /dev/null +++ b/oncrpc/Makefile.am @@ -0,0 +1,64 @@ + +AUTOMAKE_OPTIONS = foreign + +SUBDIRS = . rpc + +AM_CFLAGS = -D_rpc_dtablesize=getdtablesize + +lib_LTLIBRARIES = liboncrpc.la + +liboncrpc_la_SOURCES = \ + auth_non.c \ + auth_uni.c \ + authunix.c \ + clnt_gen.c \ + clnt_per.c \ + clnt_raw.c \ + clnt_sim.c \ + clnt_tcp.c \ + clnt_udp.c \ + get_myad.c \ + pmap_cln.c \ + pmap_get.c \ + pmap_gma.c \ + pmap_pr.c \ + pmap_pro.c \ + pmap_rmt.c \ + rpc_call.c \ + rpc_comm.c \ + rpc_prot.c \ + svc.c \ + svc_auth.c \ + svc_autu.c \ + svc_raw.c \ + svc_run.c \ + svc_simp.c \ + svc_tcp.c \ + svc_udp.c \ + xdr.c \ + xdr_arra.c \ + xdr_floa.c \ + xdr_mem.c \ + xdr_rec.c \ + xdr_refe.c \ + xdr_stdi.c + +# this is different from the project version +# http://sources.redhat.com/autobook/autobook/autobook_91.html +liboncrpc_la_LDFLAGS = -version-info 1:0:0 + +EXTRA_DIST = \ + .cvsignore \ + makefile.bc \ + makefile.nt \ + oncbcimp.def \ + oncrpc.def \ + oncrpc.rc \ + oncrpcbc.def \ + bcopy.c \ + bindresv.c \ + getrpcen.c \ + getrpcpo.c \ + nt.c \ + portmap.c + diff --git a/oncrpc/auth_uni.c b/oncrpc/auth_uni.c index ee482fe..e8da42b 100644 --- a/oncrpc/auth_uni.c +++ b/oncrpc/auth_uni.c @@ -60,7 +60,7 @@ static char sccsid[] = "@(#)auth_unix.c 1.19 87/08/11 Copyr 1984 Sun Micro"; #include #include #include -#include +#include #else #include #include diff --git a/oncrpc/authunix.c b/oncrpc/authunix.c index e170ff0..7f1ac7d 100644 --- a/oncrpc/authunix.c +++ b/oncrpc/authunix.c @@ -54,7 +54,7 @@ static char sccsid[] = "@(#)authunix_prot.c 1.15 87/08/11 Copyr 1984 Sun Micro"; #include #include #include -#include +#include #else #include #include diff --git a/oncrpc/clnt_per.c b/oncrpc/clnt_per.c index d3c10b7..35cd883 100644 --- a/oncrpc/clnt_per.c +++ b/oncrpc/clnt_per.c @@ -59,8 +59,10 @@ static char sccsid[] = "@(#)clnt_perror.c 1.15 87/10/07 Copyr 1984 Sun Micro"; #ifndef WIN32 extern char *sys_errlist[]; +#ifdef NEED_SPRINTF extern char *sprintf(); #endif +#endif static char *auth_errmsg(); extern char *strcpy(); diff --git a/oncrpc/clnt_tcp.c b/oncrpc/clnt_tcp.c index e298608..125851c 100644 --- a/oncrpc/clnt_tcp.c +++ b/oncrpc/clnt_tcp.c @@ -65,7 +65,7 @@ static char sccsid[] = "@(#)clnt_tcp.c 1.37 87/10/05 Copyr 1984 Sun Micro"; #include #ifdef WIN32 #include -#include +#include #else #include #include @@ -504,7 +504,7 @@ readtcp(ct, buf, len) } return (len); #else - switch (select(_rpc_dtablesize(), &readfds, (int*)NULL, (int*)NULL, + switch (select(_rpc_dtablesize(), &readfds, NULL, NULL, &(ct->ct_wait))) { case 0: ct->ct_error.re_status = RPC_TIMEDOUT; diff --git a/oncrpc/clnt_udp.c b/oncrpc/clnt_udp.c index be0f28d..dab060a 100644 --- a/oncrpc/clnt_udp.c +++ b/oncrpc/clnt_udp.c @@ -52,7 +52,7 @@ static char sccsid[] = "@(#)clnt_udp.c 1.39 87/08/11 Copyr 1984 Sun Micro"; #include #ifdef WIN32 #include -#include +#include #else #include #include @@ -60,6 +60,10 @@ static char sccsid[] = "@(#)clnt_udp.c 1.39 87/08/11 Copyr 1984 Sun Micro"; #include #include +#ifndef FIONBIO +#include +#endif + extern int errno; #endif @@ -331,11 +335,11 @@ send_again: for (;;) { readfds = mask; #ifdef WIN32 - switch (select(0 /* unused in winsock */, &readfds, (int *)NULL, + switch (select(0 /* unused in winsock */, &readfds, (int *)NULL, (int *)NULL, #else - switch (select(_rpc_dtablesize(), &readfds, (int *)NULL, + switch (select(_rpc_dtablesize(), &readfds, NULL, NULL, #endif - (int *)NULL, &(cu->cu_wait))) { + &(cu->cu_wait))) { case 0: time_waited.tv_sec += cu->cu_wait.tv_sec; diff --git a/oncrpc/get_myad.c b/oncrpc/get_myad.c index 8528786..a907656 100644 --- a/oncrpc/get_myad.c +++ b/oncrpc/get_myad.c @@ -50,7 +50,7 @@ static char sccsid[] = "@(#)get_myaddress.c 1.4 87/08/11 Copyr 1984 Sun Micro"; #ifdef WIN32 #include -#include +#include #include #define MAX_NAME_LEN 255 @@ -64,6 +64,10 @@ static char sccsid[] = "@(#)get_myaddress.c 1.4 87/08/11 Copyr 1984 Sun Micro"; #include #include +#ifndef SIOCGIFCONF +#include +#endif + /* * don't use gethostbyname, which would invoke yellow pages */ diff --git a/oncrpc/pmap_cln.c b/oncrpc/pmap_cln.c index 24aead2..1514d2e 100644 --- a/oncrpc/pmap_cln.c +++ b/oncrpc/pmap_cln.c @@ -51,8 +51,8 @@ static char sccsid[] = "@(#)pmap_clnt.c 1.37 87/08/11 Copyr 1984 Sun Micro"; #include #ifdef WIN32 -#include -#include +#include +#include #else #include #include diff --git a/oncrpc/pmap_get.c b/oncrpc/pmap_get.c index fa4a6da..302bb4f 100644 --- a/oncrpc/pmap_get.c +++ b/oncrpc/pmap_get.c @@ -50,8 +50,8 @@ static char sccsid[] = "@(#)pmap_getport.c 1.9 87/08/11 Copyr 1984 Sun Micro"; */ #include -#include -#include +#include +#include static struct timeval timeout = { 5, 0 }; static struct timeval tottimeout = { 60, 0 }; @@ -90,7 +90,11 @@ pmap_getport(address, program, version, protocol) } CLNT_DESTROY(client); } +#ifdef WIN32 (void)closesocket(socket); +#else + (void)close(socket); +#endif address->sin_port = 0; return (port); } diff --git a/oncrpc/pmap_gma.c b/oncrpc/pmap_gma.c index f84953b..3c50bc5 100644 --- a/oncrpc/pmap_gma.c +++ b/oncrpc/pmap_gma.c @@ -53,8 +53,8 @@ static char sccsid[] = "@(#)pmap_getmaps.c 1.10 87/08/11 Copyr 1984 Sun Micro"; #include #ifdef WIN32 #include -#include -#include +#include +#include #else #include #include diff --git a/oncrpc/pmap_rmt.c b/oncrpc/pmap_rmt.c index ccd3f8e..d2e0133 100644 --- a/oncrpc/pmap_rmt.c +++ b/oncrpc/pmap_rmt.c @@ -51,8 +51,8 @@ static char sccsid[] = "@(#)pmap_rmt.c 1.21 87/08/27 Copyr 1984 Sun Micro"; #include #ifdef WIN32 -#include -#include +#include +#include #include #include #include @@ -69,6 +69,10 @@ static char sccsid[] = "@(#)pmap_rmt.c 1.21 87/08/27 Copyr 1984 Sun Micro"; #include #define MAX_BROADCAST_SIZE 1400 +#ifndef SIOCGIFCONF +#include +#endif + extern int errno; #endif static struct timeval timeout = { 3, 0 }; @@ -220,7 +224,7 @@ getbroadcastnets(addrs, sock, buf) #ifdef SIOCGIFBRDADDR /* 4.3BSD */ if (ioctl(sock, SIOCGIFBRDADDR, (char *)&ifreq) < 0) { addrs[i++] = inet_makeaddr(inet_netof - (sin->sin_addr.s_addr), INADDR_ANY); + (sin->sin_addr), INADDR_ANY); } else { addrs[i++] = ((struct sockaddr_in*) &ifreq.ifr_addr)->sin_addr; @@ -356,11 +360,11 @@ clnt_broadcast(prog, vers, proc, xargs, argsp, xresults, resultsp, eachresult) msg.acpted_rply.ar_results.proc = xdr_rmtcallres; readfds = mask; #ifdef WIN32 - switch (select(0 /* unused in winsock */, &readfds, (int *)NULL, + switch (select(0 /* unused in winsock */, &readfds, (int *)NULL, (int*)NULL, #else - switch (select(_rpc_dtablesize(), &readfds, (int *)NULL, + switch (select(_rpc_dtablesize(), &readfds, NULL, NULL, #endif - (int *)NULL, &t)) { + &t)) { case 0: /* timed out */ stat = RPC_TIMEDOUT; continue; diff --git a/oncrpc/rpc/.gitignore b/oncrpc/rpc/.gitignore new file mode 100644 index 0000000..26d1c48 --- /dev/null +++ b/oncrpc/rpc/.gitignore @@ -0,0 +1,6 @@ +/Makefile.in +/Makefile +/.libs +/.deps +/*.lo +/*.la \ No newline at end of file diff --git a/oncrpc/rpc/Makefile.am b/oncrpc/rpc/Makefile.am new file mode 100644 index 0000000..edf6284 --- /dev/null +++ b/oncrpc/rpc/Makefile.am @@ -0,0 +1,22 @@ + +AUTOMAKE_OPTIONS = foreign + +oncrpcdir = $(includedir)/rpc +oncrpc_DATA = \ + auth.h \ + clnt.h \ + pmap_prot.h \ + rpc_msg.h \ + types.h \ + auth_unix.h \ + netdb.h \ + pmap_rmt.h \ + svc.h \ + xdr.h \ + bcopy.h \ + pmap_clnt.h \ + rpc.h \ + svc_auth.h + +EXTRA_DIST = \ + ${oncrpc_DATA} diff --git a/oncrpc/rpc/svc_auth.h b/oncrpc/rpc/svc_auth.h index 75e2f23..4d7cd9d 100644 --- a/oncrpc/rpc/svc_auth.h +++ b/oncrpc/rpc/svc_auth.h @@ -53,6 +53,6 @@ #ifdef __cplusplus extern "C" auth_stat _authenticate(...); #else -extern struct auth_stat _authenticate(); +extern enum auth_stat _authenticate(); #endif diff --git a/oncrpc/rpc/types.h b/oncrpc/rpc/types.h index 699be58..1008af0 100644 --- a/oncrpc/rpc/types.h +++ b/oncrpc/rpc/types.h @@ -70,6 +70,8 @@ extern char *malloc(); #endif #ifndef WIN32 #include +#include +#include #endif #ifndef INADDR_LOOPBACK @@ -79,9 +81,11 @@ extern char *malloc(); #define MAXHOSTNAMELEN 64 #endif +#ifdef WIN32 typedef char *caddr_t; typedef unsigned int u_int; typedef unsigned long u_long; typedef unsigned short u_short; +#endif #endif /* ndef __TYPES_RPC_HEADER__ */ diff --git a/oncrpc/svc.c b/oncrpc/svc.c index 8723a77..8b4a3fe 100644 --- a/oncrpc/svc.c +++ b/oncrpc/svc.c @@ -54,7 +54,7 @@ static char sccsid[] = "@(#)svc.c 1.41 87/10/13 Copyr 1984 Sun Micro"; #ifdef WIN32 #include -#include +#include #include #else #include @@ -546,5 +546,6 @@ svc_getreqset(readfds) break; } } while (stat == XPRT_MOREREQS); + } } } diff --git a/oncrpc/svc_run.c b/oncrpc/svc_run.c index fb5ab6a..930adbc 100644 --- a/oncrpc/svc_run.c +++ b/oncrpc/svc_run.c @@ -75,7 +75,7 @@ svc_run() #ifdef WIN32 switch (select(0 /* unused in winsock */, &readfds, (int *)0, (int *)0, #else - switch (select(_rpc_dtablesize(), &readfds, (int *)0, (int *)0, + switch (select(_rpc_dtablesize(), &readfds, NULL, NULL, #endif (struct timeval *)0)) { case -1: diff --git a/oncrpc/svc_tcp.c b/oncrpc/svc_tcp.c index 9b0feff..5f77b67 100644 --- a/oncrpc/svc_tcp.c +++ b/oncrpc/svc_tcp.c @@ -363,7 +363,7 @@ readtcp(xprt, buf, len) #ifdef WIN32 if (select(0 /* unused in winsock */, &readfds, (int*)NULL, (int*)NULL, #else - if (select(_rpc_dtablesize(), &readfds, (int*)NULL, (int*)NULL, + if (select(_rpc_dtablesize(), &readfds, NULL, NULL, #endif &wait_per_try) <= 0) { #ifdef WIN32 diff --git a/oncrpc/svc_udp.c b/oncrpc/svc_udp.c index 0921797..167b045 100644 --- a/oncrpc/svc_udp.c +++ b/oncrpc/svc_udp.c @@ -68,6 +68,10 @@ static bool_t svcudp_getargs(); static bool_t svcudp_freeargs(); static void svcudp_destroy(); +static cache_get(); +static cache_set(); + + static struct xp_ops svcudp_op = { svcudp_recv, svcudp_stat, @@ -323,15 +327,12 @@ svcudp_destroy(xprt) #define CACHE_PERROR(msg) \ nt_rpc_report(msg) #else -#define CACHE_PERROR(msg) \ - (void) fprintf(stderr,"%s\n", msg) +#define CACHE_PERROR(msg) (void) fprintf(stderr,"%s\n", msg) #endif -#define ALLOC(type, size) \ - (type *) mem_alloc((unsigned) (sizeof(type) * (size))) +#define ALLOC(type, size) (type *) mem_alloc((unsigned)(sizeof(type)*(size))) -#define BZERO(addr, type, size) \ - bzero((char *) addr, sizeof(type) * (int) (size)) +#define BZERO(addr, type, size) bzero((char *) addr, sizeof(type) * (int) (size)) /* * An entry in the cache @@ -358,7 +359,6 @@ struct cache_node { }; - /* * The entire cache */ @@ -377,9 +377,7 @@ struct udp_cache { /* * the hashing function */ -#define CACHE_LOC(transp, xid) \ - (xid % (SPARSENESS*((struct udp_cache *) su_data(transp)->su_cache)->uc_size)) - +#define CACHE_LOC(transp, xid) (xid % (SPARSENESS*((struct udp_cache *) su_data(transp)->su_cache)->uc_size)) /* * Enable use of the cache. @@ -524,4 +522,3 @@ cache_get(xprt, msg, replyp, replylenp) uc->uc_addr = xprt->xp_raddr; return(0); } - diff --git a/oncrpc/xdr_arra.c b/oncrpc/xdr_arra.c index fd51554..06a4f6c 100644 --- a/oncrpc/xdr_arra.c +++ b/oncrpc/xdr_arra.c @@ -86,7 +86,8 @@ xdr_array(xdrs, addrp, sizep, maxsize, elsize, elproc) return (FALSE); } c = *sizep; - if ((c > maxsize) && (xdrs->x_op != XDR_FREE)) { + if ((c > maxsize || c > LASTUNSIGNED / elsize) && + (xdrs->x_op != XDR_FREE)) { return (FALSE); } nodesize = c * elsize; diff --git a/oncrpc/xdr_rec.c b/oncrpc/xdr_rec.c index 7711eb5..937a44a 100644 --- a/oncrpc/xdr_rec.c +++ b/oncrpc/xdr_rec.c @@ -83,6 +83,11 @@ static bool_t xdrrec_setpos(); static long * xdrrec_inline(); static void xdrrec_destroy(); +static bool_t flush_out(); +static bool_t get_input_bytes(); +static bool_t set_input_fragment(); +static bool_t skip_input_bytes(); + static struct xdr_ops xdrrec_ops = { xdrrec_getlong, xdrrec_putlong, diff --git a/shar/Makefile.am b/shar/Makefile.am index 4c30e87..a3d0972 100644 --- a/shar/Makefile.am +++ b/shar/Makefile.am @@ -2,6 +2,10 @@ AUTOMAKE_OPTIONS = foreign +if USE_OUR_ONCRPC +AM_CFLAGS = -I${top_srcdir}/oncrpc +endif + bin_PROGRAMS = shar test-client test_client_SOURCES = test-client.c diff --git a/shib-target/Makefile.am b/shib-target/Makefile.am index af219e3..2b553c0 100644 --- a/shib-target/Makefile.am +++ b/shib-target/Makefile.am @@ -4,6 +4,12 @@ AUTOMAKE_OPTIONS = foreign lib_LTLIBRARIES = libshib-target.la +if USE_OUR_ONCRPC +libshib_target_la_LIBADD = ${top_builddir}/oncrpc/liboncrpc.la +AM_CFLAGS = -I${top_srcdir}/oncrpc +AM_CXXFLAGS = -I${top_srcdir}/oncrpc +endif + libshib_targetdir = $(includedir)/shib-target libshib_target_HEADERS = shib-target.h shibrpc.h -- 2.1.4