From e7fd8a39abd3a9c9d2139e686b17efb5dc3bf444 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Thu, 27 Mar 1997 01:59:53 +0000 Subject: Update. 1997-03-27 02:28 Ulrich Drepper * gmon/gmon.c (monstartup): Mark all messages. (write_call_graph): Rewrite to use larger I/O vector for writev call to reduce syscall overhead. (write_bb_counts): Simplify writev handling. * inet/rexec.c: Make string parameters `const'. * resolv/netdb.h: Add prototypes for rcmd, rexec, ruserok, and rresvport. * math/Makefile: Don't define CFLAGS-* macros to prevent inlining in libm-test. * math/libm-test.c (this_does_nothing): Remove functions. It's notuseful on any platform but ix86. (inverse_func_pair_test): Don't use this_does_nothing. Use memory reference. (identities1_test): Likewise. (identities2_test): Likewise. (identities3_test): Likewise. (basic_test): Likewise. Patch by Andreas Schwab. (BUILD_COMPLEX): New macro. Create complex number from real and imaginary parts. This works around bugs/inefficiencies in current gcc. (cexp_test): Use BUILD_COMPLEX. Add more tests. * nss/nsswitch.c: Fix typo. * posix/glob.h: Add declaration for glob_pattern_p. * posix/glob.c: Rename glob_pattern_p to __glob_pattern_p and make glob_pattern_p a weak alias. This function is used in other packages (e.g. bash). * signal/Makefile (routines): Add sigisempty, sigandset, and sigorset. * signal/signal.h: Add prototypes for sigisempty, sigandset, and sigorset. * signal/sigisempty.c: New file. * signal/sigandset.c: New file. * signal/sigorset.c: New file. * sysdeps/generic/sigset.h: Define __sigisemptyset, __sigandset, and __sigorset. * sysdeps/unix/sysv/linux/sigset.h: Likewise. * stdlib/strtod.c: Handle `n-char-sequence' in NaN parsing. It determines the bits in the mantissa part of the NaN. * stdlib/strtof.c: Define SET_MANTISSA for float type. * wcsmbs/wcstof.c: Define SET_MANTISSA for float type. * stdlib/strtold.c: Define SET_MANTISSA for long double type. * wcsmbs/wcstold.c: Define SET_MANTISSA for long double type. * sysdeps/libm-ieee754/s_cexp.c: Use explicit assignment to complex number components. Some more corrects for special cases. * sysdeps/libm-ieee754/s_cexpf.c: Likewise. * sysdeps/libm-ieee754/s_cexpl.c: Likewise. * sysdeps/sparc/elf/start.S: Remove as per request of Miguel de Icaza. * sysdeps/unix/sysv/linux/netinet/icmp.h: Remove since we have ip_icmp.h. Reported by HJ Lu. 1997-03-25 03:50 Andreas Schwab * sysdeps/m68k/Makefile (CFLAGS-rtld.c): Add -Wno-unused. * sysdeps/m68k/dl-machine.h (elf_machine_rela): Rewritten as for i386. (elf_machine_lookup_noexec_p, elf_machine_lookup_noplt_p, ELF_MACHINE_RELOC_NOPLT): Define. 1997-03-25 03:48 Andreas Schwab * grp/grp.h: Include only once. 1997-03-25 09:38 Andreas Schwab * sysdeps/unix/sysv/linux/termbits.h (OXTABS): Don't define. * sysdeps/unix/sysv/linux/alpha/termbits.h (OXTABS): Likewise. * termios/sys/ttydefaults.h (TTYDEF_OFLAG): Use either OXTABS or TAB3, if one of them is defined. 1997-03-26 04:53 Ulrich Drepper * posix/glob.c (next_brace_sub): Decrement depth counter when '}' is found. Patch by Dennis Henriksen . 1997-03-25 16:25 Thorsten Kukuk * sunrpc/Makefile: Comment gccwarn out. * sunrpc/auth_none.c: Fix prototypes and parameters for compiling with enabled warnings. * sunrpc/auth_unix.c: Likewise. * sunrpc/authuxprot.c: Likewise. * sunrpc/bindrsvprt.c: Likewise. * sunrpc/clnt_gen.c: Likewise. * sunrpc/clnt_perr.c: Likewise. * sunrpc/clnt_raw.c: Likewise. * sunrpc/clnt_simp.c: Likewise. * sunrpc/clnt_tcp.c: Likewise. * sunrpc/clnt_udp.c: Likewise. * sunrpc/get_myaddr.c: Likewise. * sunrpc/getrpcport.c: Likewise. * sunrpc/pm_getmaps.c: Likewise. * sunrpc/pm_getport.c: Likewise. * sunrpc/pmap_clnt.c: Likewise. * sunrpc/pmap_prot.c: Likewise. * sunrpc/pmap_prot2.c: Likewise. * sunrpc/pmap_rmt.c: Likewise. * sunrpc/rpc/auth.h: Likewise. * sunrpc/rpc/clnt.h: Likewise. * sunrpc/rpc/pmap_clnt.h: Likewise. * sunrpc/rpc/svc.h: Likewise. * sunrpc/rpc/svc_auth.h: Likewise. * sunrpc/rpc/types.h: Likewise. * sunrpc/rpc/xdr.h: Likewise. * sunrpc/rpc_clntout.c: Likewise. * sunrpc/rpc_cmsg.c: Likewise. * sunrpc/rpc_dtable.c: Likewise. * sunrpc/rpc_prot.c: Likewise. * sunrpc/svc.c: Likewise. * sunrpc/svc_auth.c: Likewise. * sunrpc/svc_authux.c: Likewise. * sunrpc/svc_raw.c: Likewise. * sunrpc/svc_run.c: Likewise. * sunrpc/svc_simple.c: Likewise. * sunrpc/svc_tcp.c: Likewise. * sunrpc/svc_udp.c: Likewise. * sunrpc/xdr.c: Likewise. * sunrpc/xdr_array.c: Likewise. * sunrpc/xdr_mem.c: Likewise. * sunrpc/xdr_rec.c: Likewise. * sunrpc/xdr_ref.c: Likewise. * sunrpc/xdr_stdio.c: Likewise. 1997-03-25 13:39 Ulrich Drepper * math/libm-test.c (log2_test): Compile this function and call it. (exp2_test): Likewise, but check whether function really exists before testing. * math/Makefile (libm-calls): Add s_log2 and s_exp2. 1997-03-25 04:50 Ulrich Drepper Implement exp2 function. * sysdeps/libm-i387/s_exp2.S: New file. * sysdeps/libm-i387/s_exp2f.S: New file. * sysdeps/libm-i387/s_exp2l.S: New file. Implement log2 function. * sysdeps/libm-i387/s_log2.S: New file. * sysdeps/libm-i387/s_log2f.S: New file. * sysdeps/libm-i387/s_log2l.S: New file. * sysdeps/libm-ieee754/s_log2.c: New file. * sysdeps/libm-ieee754/s_log2f.c: New file. * sysdeps/stub/s_log2.c: New file. Stub version. --- sunrpc/Makefile | 16 +- sunrpc/auth_none.c | 135 ++--- sunrpc/auth_unix.c | 415 +++++++------- sunrpc/authuxprot.c | 36 +- sunrpc/bindrsvprt.c | 68 ++- sunrpc/clnt_gen.c | 168 +++--- sunrpc/clnt_perr.c | 406 +++++++------ sunrpc/clnt_raw.c | 313 +++++----- sunrpc/clnt_simp.c | 164 +++--- sunrpc/clnt_tcp.c | 682 +++++++++++----------- sunrpc/clnt_udp.c | 647 +++++++++++---------- sunrpc/get_myaddr.c | 69 +-- sunrpc/getrpcport.c | 48 +- sunrpc/pm_getmaps.c | 53 +- sunrpc/pm_getport.c | 71 +-- sunrpc/pmap_clnt.c | 99 ++-- sunrpc/pmap_prot.c | 26 +- sunrpc/pmap_prot2.c | 94 +-- sunrpc/pmap_rmt.c | 568 ++++++++++--------- sunrpc/rpc/auth.h | 38 +- sunrpc/rpc/clnt.h | 133 +++-- sunrpc/rpc/pmap_clnt.h | 26 +- sunrpc/rpc/svc.h | 56 +- sunrpc/rpc/svc_auth.h | 1 + sunrpc/rpc/types.h | 20 +- sunrpc/rpc/xdr.h | 184 +++--- sunrpc/rpc_clntout.c | 291 +++++----- sunrpc/rpc_cmsg.c | 309 +++++----- sunrpc/rpc_dtable.c | 17 +- sunrpc/rpc_prot.c | 328 ++++++----- sunrpc/rpc_sample.c | 315 ++++++----- sunrpc/rpc_scan.c | 764 +++++++++++++------------ sunrpc/rpc_svcout.c | 1477 +++++++++++++++++++++++++----------------------- sunrpc/rpc_tblout.c | 214 +++---- sunrpc/rpc_util.c | 563 +++++++++--------- sunrpc/rpcinfo.c | 1130 +++++++++++++++++++----------------- sunrpc/svc.c | 527 ++++++++--------- sunrpc/svc_auth.c | 75 +-- sunrpc/svc_authux.c | 145 ++--- sunrpc/svc_raw.c | 173 +++--- sunrpc/svc_run.c | 46 +- sunrpc/svc_simple.c | 184 +++--- sunrpc/svc_tcp.c | 530 ++++++++--------- sunrpc/svc_udp.c | 642 +++++++++++---------- sunrpc/xdr.c | 819 ++++++++++++++------------- sunrpc/xdr_array.c | 152 ++--- sunrpc/xdr_mem.c | 196 +++---- sunrpc/xdr_rec.c | 821 ++++++++++++++------------- sunrpc/xdr_ref.c | 91 +-- sunrpc/xdr_stdio.c | 155 +++-- 50 files changed, 7582 insertions(+), 6918 deletions(-) (limited to 'sunrpc') diff --git a/sunrpc/Makefile b/sunrpc/Makefile index 1981c75941..9feff64c53 100644 --- a/sunrpc/Makefile +++ b/sunrpc/Makefile @@ -80,9 +80,6 @@ extra-objs = $(rpcgen-objs) all: # Make this the default target; it will be defined in Rules. -# Sun's code is not too clean. -override +gccwarn := -w - include ../Makeconfig ifeq (no,$(cross-compiling)) @@ -96,6 +93,19 @@ librpcsvc-inhibit-o = .so # Build no shared rpcsvc library. omit-deps = $(librpcsvc-routines) endif +CFLAGS-xbootparam.c = -Wno-unused +CFLAGS-xnlm_prot.c = -Wno-unused +CFLAGS-xrstat.c = -Wno-unused +CFLAGS-xyppasswd.c = -Wno-unused +CFLAGS-xklm_prot.c = -Wno-unused +CFLAGS-xrex.c = -Wno-unused +CFLAGS-xsm_inter.c = -Wno-unused +CFLAGS-xmount.c = -Wno-unused +CFLAGS-xrusers.c = -Wno-unused +CFLAGS-xspray.c = -Wno-unused +CFLAGS-xnfs_prot.c = -Wno-unused +CFLAGS-xrquote.c = -Wno-unused + include ../Rules $(objpfx)rpcgen: $(addprefix $(objpfx),$(rpcgen-objs)) $(common-objpfx)libc.a diff --git a/sunrpc/auth_none.c b/sunrpc/auth_none.c index 630037fb47..a7c1524ef5 100644 --- a/sunrpc/auth_none.c +++ b/sunrpc/auth_none.c @@ -6,23 +6,23 @@ * may copy or modify Sun RPC without charge, but are not authorized * to license or distribute it to anyone else except as part of a product or * program developed by the user. - * + * * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * + * * Sun RPC is provided with no support and without any obligation on the * part of Sun Microsystems, Inc. to assist in its use, correction, * modification or enhancement. - * + * * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC * OR ANY PART THEREOF. - * + * * In no event will Sun Microsystems, Inc. be liable for any lost revenue * or profits or other special, indirect and consequential damages, even if * Sun has been advised of the possibility of such damages. - * + * * Sun Microsystems, Inc. * 2550 Garcia Avenue * Mountain View, California 94043 @@ -33,101 +33,104 @@ static char sccsid[] = "@(#)auth_none.c 1.19 87/08/11 Copyr 1984 Sun Micro"; /* * auth_none.c - * Creates a client authentication handle for passing "null" - * credentials and verifiers to remote systems. - * - * Copyright (C) 1984, Sun Microsystems, Inc. + * Creates a client authentication handle for passing "null" + * credentials and verifiers to remote systems. + * + * Copyright (C) 1984, Sun Microsystems, Inc. */ #include -#include #include + #define MAX_MARSHEL_SIZE 20 +extern bool_t xdr_opaque_auth (XDR *, struct opaque_auth *); + /* * Authenticator operations routines */ -static void authnone_verf(); -static void authnone_destroy(); -static bool_t authnone_marshal(); -static bool_t authnone_validate(); -static bool_t authnone_refresh(); +static void authnone_verf (AUTH *); +static void authnone_destroy (AUTH *); +static bool_t authnone_marshal (AUTH *, XDR *); +static bool_t authnone_validate (AUTH *, struct opaque_auth *); +static bool_t authnone_refresh (AUTH *); -static struct auth_ops ops = { - authnone_verf, - authnone_marshal, - authnone_validate, - authnone_refresh, - authnone_destroy +static struct auth_ops ops = +{ + authnone_verf, + authnone_marshal, + authnone_validate, + authnone_refresh, + authnone_destroy }; -static struct authnone_private { - AUTH no_client; - char marshalled_client[MAX_MARSHEL_SIZE]; - u_int mcnt; -} *authnone_private; +static struct authnone_private + { + AUTH no_client; + char marshalled_client[MAX_MARSHEL_SIZE]; + u_int mcnt; + } + *authnone_private; AUTH * -authnone_create() +authnone_create (void) { - register struct authnone_private *ap = authnone_private; - XDR xdr_stream; - register XDR *xdrs; + struct authnone_private *ap = authnone_private; + XDR xdr_stream; + XDR *xdrs; - if (ap == 0) { - ap = (struct authnone_private *)calloc(1, sizeof (*ap)); - if (ap == 0) - return (0); - authnone_private = ap; - } - if (!ap->mcnt) { - ap->no_client.ah_cred = ap->no_client.ah_verf = _null_auth; - ap->no_client.ah_ops = &ops; - xdrs = &xdr_stream; - xdrmem_create(xdrs, ap->marshalled_client, (u_int)MAX_MARSHEL_SIZE, - XDR_ENCODE); - (void)xdr_opaque_auth(xdrs, &ap->no_client.ah_cred); - (void)xdr_opaque_auth(xdrs, &ap->no_client.ah_verf); - ap->mcnt = XDR_GETPOS(xdrs); - XDR_DESTROY(xdrs); - } - return (&ap->no_client); + if (ap == 0) + { + ap = (struct authnone_private *) calloc (1, sizeof (*ap)); + if (ap == 0) + return NULL; + authnone_private = ap; + } + if (!ap->mcnt) + { + ap->no_client.ah_cred = ap->no_client.ah_verf = _null_auth; + ap->no_client.ah_ops = &ops; + xdrs = &xdr_stream; + xdrmem_create (xdrs, ap->marshalled_client, (u_int) MAX_MARSHEL_SIZE, + XDR_ENCODE); + (void) xdr_opaque_auth (xdrs, &ap->no_client.ah_cred); + (void) xdr_opaque_auth (xdrs, &ap->no_client.ah_verf); + ap->mcnt = XDR_GETPOS (xdrs); + XDR_DESTROY (xdrs); + } + return (&ap->no_client); } -/*ARGSUSED*/ +/*ARGSUSED */ static bool_t -authnone_marshal(client, xdrs) - AUTH *client; - XDR *xdrs; +authnone_marshal (AUTH *client, XDR *xdrs) { - register struct authnone_private *ap = authnone_private; + struct authnone_private *ap = authnone_private; - if (ap == 0) - return (0); - return ((*xdrs->x_ops->x_putbytes)(xdrs, - ap->marshalled_client, ap->mcnt)); + if (ap == 0) + return (0); + return ((*xdrs->x_ops->x_putbytes) (xdrs, + ap->marshalled_client, ap->mcnt)); } -static void -authnone_verf() +static void +authnone_verf (AUTH *auth) { } static bool_t -authnone_validate() +authnone_validate (AUTH *auth, struct opaque_auth *oa) { - - return (TRUE); + return TRUE; } static bool_t -authnone_refresh() +authnone_refresh (AUTH *auth) { - - return (FALSE); + return FALSE; } static void -authnone_destroy() +authnone_destroy (AUTH *auth) { } diff --git a/sunrpc/auth_unix.c b/sunrpc/auth_unix.c index 8890a926ba..5e5dc995ca 100644 --- a/sunrpc/auth_unix.c +++ b/sunrpc/auth_unix.c @@ -45,6 +45,7 @@ static char sccsid[] = "@(#)auth_unix.c 1.19 87/08/11 Copyr 1984 Sun Micro"; #include #include +#include #include #include @@ -53,36 +54,40 @@ static char sccsid[] = "@(#)auth_unix.c 1.19 87/08/11 Copyr 1984 Sun Micro"; #include #include +extern bool_t xdr_opaque_auth (XDR *, struct opaque_auth *); + /* * Unix authenticator operations vector */ -static void authunix_nextverf(); -static bool_t authunix_marshal(); -static bool_t authunix_validate(); -static bool_t authunix_refresh(); -static void authunix_destroy(); - -static struct auth_ops auth_unix_ops = { - authunix_nextverf, - authunix_marshal, - authunix_validate, - authunix_refresh, - authunix_destroy +static void authunix_nextverf (AUTH *); +static bool_t authunix_marshal (AUTH *, XDR *); +static bool_t authunix_validate (AUTH *, struct opaque_auth *); +static bool_t authunix_refresh (AUTH *); +static void authunix_destroy (AUTH *); + +static struct auth_ops auth_unix_ops = +{ + authunix_nextverf, + authunix_marshal, + authunix_validate, + authunix_refresh, + authunix_destroy }; /* * This struct is pointed to by the ah_private field of an auth_handle. */ -struct audata { - struct opaque_auth au_origcred; /* original credentials */ - struct opaque_auth au_shcred; /* short hand cred */ - u_long au_shfaults; /* short hand cache faults */ - char au_marshed[MAX_AUTH_BYTES]; - u_int au_mpos; /* xdr pos at end of marshed */ -}; +struct audata + { + struct opaque_auth au_origcred; /* original credentials */ + struct opaque_auth au_shcred; /* short hand cred */ + u_long au_shfaults; /* short hand cache faults */ + char au_marshed[MAX_AUTH_BYTES]; + u_int au_mpos; /* xdr pos at end of marshed */ + }; #define AUTH_PRIVATE(auth) ((struct audata *)auth->ah_private) -static bool_t marshal_new_auth(); +static bool_t marshal_new_auth (AUTH *); /* @@ -90,77 +95,72 @@ static bool_t marshal_new_auth(); * Returns an auth handle with the given stuff in it. */ AUTH * -authunix_create(machname, uid, gid, len, aup_gids) - char *machname; - uid_t uid; - gid_t gid; - register int len; - gid_t *aup_gids; +authunix_create (machname, uid, gid, len, aup_gids) + char *machname; + uid_t uid; + gid_t gid; + int len; + gid_t *aup_gids; { - struct authunix_parms aup; - char mymem[MAX_AUTH_BYTES]; - struct timeval now; - XDR xdrs; - register AUTH *auth; - register struct audata *au; - - /* - * Allocate and set up auth handle - */ - auth = (AUTH *)mem_alloc(sizeof(*auth)); -#ifndef KERNEL - if (auth == NULL) { - (void)fprintf(stderr, "authunix_create: out of memory\n"); - return (NULL); - } -#endif - au = (struct audata *)mem_alloc(sizeof(*au)); -#ifndef KERNEL - if (au == NULL) { - (void)fprintf(stderr, "authunix_create: out of memory\n"); - return (NULL); - } -#endif - auth->ah_ops = &auth_unix_ops; - auth->ah_private = (caddr_t)au; - auth->ah_verf = au->au_shcred = _null_auth; - au->au_shfaults = 0; - - /* - * fill in param struct from the given params - */ - (void)gettimeofday(&now, (struct timezone *)0); - aup.aup_time = now.tv_sec; - aup.aup_machname = machname; - aup.aup_uid = uid; - aup.aup_gid = gid; - aup.aup_len = (u_int)len; - aup.aup_gids = aup_gids; - - /* - * Serialize the parameters into origcred - */ - xdrmem_create(&xdrs, mymem, MAX_AUTH_BYTES, XDR_ENCODE); - if (! xdr_authunix_parms(&xdrs, &aup)) - abort(); - au->au_origcred.oa_length = len = XDR_GETPOS(&xdrs); - au->au_origcred.oa_flavor = AUTH_UNIX; -#ifdef KERNEL - au->au_origcred.oa_base = mem_alloc((u_int) len); -#else - if ((au->au_origcred.oa_base = mem_alloc((u_int) len)) == NULL) { - (void)fprintf(stderr, "authunix_create: out of memory\n"); - return (NULL); - } -#endif - bcopy(mymem, au->au_origcred.oa_base, (u_int)len); - - /* - * set auth handle to reflect new cred. - */ - auth->ah_cred = au->au_origcred; - marshal_new_auth(auth); - return (auth); + struct authunix_parms aup; + char mymem[MAX_AUTH_BYTES]; + struct timeval now; + XDR xdrs; + AUTH *auth; + struct audata *au; + + /* + * Allocate and set up auth handle + */ + auth = (AUTH *) mem_alloc (sizeof (*auth)); + if (auth == NULL) + { + (void) fprintf (stderr, _("authunix_create: out of memory\n")); + return NULL; + } + au = (struct audata *) mem_alloc (sizeof (*au)); + if (au == NULL) + { + (void) fprintf (stderr, _("authunix_create: out of memory\n")); + return NULL; + } + auth->ah_ops = &auth_unix_ops; + auth->ah_private = (caddr_t) au; + auth->ah_verf = au->au_shcred = _null_auth; + au->au_shfaults = 0; + + /* + * fill in param struct from the given params + */ + (void) gettimeofday (&now, (struct timezone *) 0); + aup.aup_time = now.tv_sec; + aup.aup_machname = machname; + aup.aup_uid = uid; + aup.aup_gid = gid; + aup.aup_len = (u_int) len; + aup.aup_gids = aup_gids; + + /* + * Serialize the parameters into origcred + */ + xdrmem_create (&xdrs, mymem, MAX_AUTH_BYTES, XDR_ENCODE); + if (!xdr_authunix_parms (&xdrs, &aup)) + abort (); + au->au_origcred.oa_length = len = XDR_GETPOS (&xdrs); + au->au_origcred.oa_flavor = AUTH_UNIX; + if ((au->au_origcred.oa_base = mem_alloc ((u_int) len)) == NULL) + { + (void) fprintf (stderr, _("authunix_create: out of memory\n")); + return NULL; + } + bcopy (mymem, au->au_origcred.oa_base, (u_int) len); + + /* + * set auth handle to reflect new cred. + */ + auth->ah_cred = au->au_origcred; + marshal_new_auth (auth); + return auth; } /* @@ -168,27 +168,27 @@ authunix_create(machname, uid, gid, len, aup_gids) * syscalls. */ AUTH * -authunix_create_default() +authunix_create_default (void) { - register int len; - char machname[MAX_MACHINE_NAME + 1]; - register uid_t uid; - register gid_t gid; - int max_nr_groups = sysconf (_SC_NGROUPS_MAX); - gid_t gids[max_nr_groups]; - - if (gethostname(machname, MAX_MACHINE_NAME) == -1) - abort(); - machname[MAX_MACHINE_NAME] = 0; - uid = geteuid(); - gid = getegid(); - - if ((len = getgroups(max_nr_groups, gids)) < 0) - abort(); - /* This braindamaged Sun code forces us here to truncate the - list of groups to NGRPS members since the code in - authuxprot.c transforms a fixed array. Grrr. */ - return (authunix_create(machname, uid, gid, MIN (NGRPS, len), gids)); + int len; + char machname[MAX_MACHINE_NAME + 1]; + uid_t uid; + gid_t gid; + int max_nr_groups = sysconf (_SC_NGROUPS_MAX); + gid_t gids[max_nr_groups]; + + if (gethostname (machname, MAX_MACHINE_NAME) == -1) + abort (); + machname[MAX_MACHINE_NAME] = 0; + uid = geteuid (); + gid = getegid (); + + if ((len = getgroups (max_nr_groups, gids)) < 0) + abort (); + /* This braindamaged Sun code forces us here to truncate the + list of groups to NGRPS members since the code in + authuxprot.c transforms a fixed array. Grrr. */ + return authunix_create (machname, uid, gid, MIN (NGRPS, len), gids); } /* @@ -196,113 +196,112 @@ authunix_create_default() */ static void -authunix_nextverf(auth) - AUTH *auth; +authunix_nextverf (AUTH *auth) { - /* no action necessary */ + /* no action necessary */ } static bool_t -authunix_marshal(auth, xdrs) - AUTH *auth; - XDR *xdrs; +authunix_marshal (AUTH *auth, XDR *xdrs) { - register struct audata *au = AUTH_PRIVATE(auth); + struct audata *au = AUTH_PRIVATE (auth); - return (XDR_PUTBYTES(xdrs, au->au_marshed, au->au_mpos)); + return XDR_PUTBYTES (xdrs, au->au_marshed, au->au_mpos); } static bool_t -authunix_validate(auth, verf) - register AUTH *auth; - struct opaque_auth *verf; +authunix_validate (AUTH *auth, struct opaque_auth *verf) { - register struct audata *au; - XDR xdrs; - - if (verf->oa_flavor == AUTH_SHORT) { - au = AUTH_PRIVATE(auth); - xdrmem_create(&xdrs, verf->oa_base, verf->oa_length, - XDR_DECODE); - - if (au->au_shcred.oa_base != NULL) { - mem_free(au->au_shcred.oa_base, - au->au_shcred.oa_length); - au->au_shcred.oa_base = NULL; - } - if (xdr_opaque_auth(&xdrs, &au->au_shcred)) { - auth->ah_cred = au->au_shcred; - } else { - xdrs.x_op = XDR_FREE; - (void)xdr_opaque_auth(&xdrs, &au->au_shcred); - au->au_shcred.oa_base = NULL; - auth->ah_cred = au->au_origcred; - } - marshal_new_auth(auth); + struct audata *au; + XDR xdrs; + + if (verf->oa_flavor == AUTH_SHORT) + { + au = AUTH_PRIVATE (auth); + xdrmem_create (&xdrs, verf->oa_base, verf->oa_length, + XDR_DECODE); + + if (au->au_shcred.oa_base != NULL) + { + mem_free (au->au_shcred.oa_base, + au->au_shcred.oa_length); + au->au_shcred.oa_base = NULL; + } + if (xdr_opaque_auth (&xdrs, &au->au_shcred)) + { + auth->ah_cred = au->au_shcred; } - return (TRUE); + else + { + xdrs.x_op = XDR_FREE; + (void) xdr_opaque_auth (&xdrs, &au->au_shcred); + au->au_shcred.oa_base = NULL; + auth->ah_cred = au->au_origcred; + } + marshal_new_auth (auth); + } + return TRUE; } static bool_t -authunix_refresh(auth) - register AUTH *auth; +authunix_refresh (AUTH *auth) { - register struct audata *au = AUTH_PRIVATE(auth); - struct authunix_parms aup; - struct timeval now; - XDR xdrs; - register int stat; - - if (auth->ah_cred.oa_base == au->au_origcred.oa_base) { - /* there is no hope. Punt */ - return (FALSE); - } - au->au_shfaults ++; - - /* first deserialize the creds back into a struct authunix_parms */ - aup.aup_machname = NULL; - aup.aup_gids = (gid_t *)NULL; - xdrmem_create(&xdrs, au->au_origcred.oa_base, - au->au_origcred.oa_length, XDR_DECODE); - stat = xdr_authunix_parms(&xdrs, &aup); - if (! stat) - goto done; - - /* update the time and serialize in place */ - (void)gettimeofday(&now, (struct timezone *)0); - aup.aup_time = now.tv_sec; - xdrs.x_op = XDR_ENCODE; - XDR_SETPOS(&xdrs, 0); - stat = xdr_authunix_parms(&xdrs, &aup); - if (! stat) - goto done; - auth->ah_cred = au->au_origcred; - marshal_new_auth(auth); + struct audata *au = AUTH_PRIVATE (auth); + struct authunix_parms aup; + struct timeval now; + XDR xdrs; + int stat; + + if (auth->ah_cred.oa_base == au->au_origcred.oa_base) + { + /* there is no hope. Punt */ + return FALSE; + } + au->au_shfaults++; + + /* first deserialize the creds back into a struct authunix_parms */ + aup.aup_machname = NULL; + aup.aup_gids = (gid_t *) NULL; + xdrmem_create (&xdrs, au->au_origcred.oa_base, + au->au_origcred.oa_length, XDR_DECODE); + stat = xdr_authunix_parms (&xdrs, &aup); + if (!stat) + goto done; + + /* update the time and serialize in place */ + (void) gettimeofday (&now, (struct timezone *) 0); + aup.aup_time = now.tv_sec; + xdrs.x_op = XDR_ENCODE; + XDR_SETPOS (&xdrs, 0); + stat = xdr_authunix_parms (&xdrs, &aup); + if (!stat) + goto done; + auth->ah_cred = au->au_origcred; + marshal_new_auth (auth); done: - /* free the struct authunix_parms created by deserializing */ - xdrs.x_op = XDR_FREE; - (void)xdr_authunix_parms(&xdrs, &aup); - XDR_DESTROY(&xdrs); - return (stat); + /* free the struct authunix_parms created by deserializing */ + xdrs.x_op = XDR_FREE; + (void) xdr_authunix_parms (&xdrs, &aup); + XDR_DESTROY (&xdrs); + return stat; } static void -authunix_destroy(auth) - register AUTH *auth; +authunix_destroy (AUTH *auth) { - register struct audata *au = AUTH_PRIVATE(auth); + struct audata *au = AUTH_PRIVATE (auth); - mem_free(au->au_origcred.oa_base, au->au_origcred.oa_length); + mem_free (au->au_origcred.oa_base, au->au_origcred.oa_length); - if (au->au_shcred.oa_base != NULL) - mem_free(au->au_shcred.oa_base, au->au_shcred.oa_length); + if (au->au_shcred.oa_base != NULL) + mem_free (au->au_shcred.oa_base, au->au_shcred.oa_length); - mem_free(auth->ah_private, sizeof(struct audata)); + mem_free (auth->ah_private, sizeof (struct audata)); - if (auth->ah_verf.oa_base != NULL) - mem_free(auth->ah_verf.oa_base, auth->ah_verf.oa_length); + if (auth->ah_verf.oa_base != NULL) + mem_free (auth->ah_verf.oa_base, auth->ah_verf.oa_length); - mem_free((caddr_t)auth, sizeof(*auth)); + mem_free ((caddr_t) auth, sizeof (*auth)); } /* @@ -310,19 +309,23 @@ authunix_destroy(auth) * sets private data, au_marshed and au_mpos */ static bool_t -marshal_new_auth(auth) - register AUTH *auth; +marshal_new_auth (AUTH *auth) { - XDR xdr_stream; - register XDR *xdrs = &xdr_stream; - register struct audata *au = AUTH_PRIVATE(auth); - - xdrmem_create(xdrs, au->au_marshed, MAX_AUTH_BYTES, XDR_ENCODE); - if ((! xdr_opaque_auth(xdrs, &(auth->ah_cred))) || - (! xdr_opaque_auth(xdrs, &(auth->ah_verf)))) { - perror(_("auth_none.c - Fatal marshalling problem")); - } else { - au->au_mpos = XDR_GETPOS(xdrs); - } - XDR_DESTROY(xdrs); + XDR xdr_stream; + XDR *xdrs = &xdr_stream; + struct audata *au = AUTH_PRIVATE (auth); + + xdrmem_create (xdrs, au->au_marshed, MAX_AUTH_BYTES, XDR_ENCODE); + if ((!xdr_opaque_auth (xdrs, &(auth->ah_cred))) || + (!xdr_opaque_auth (xdrs, &(auth->ah_verf)))) + { + perror (_("auth_none.c - Fatal marshalling problem")); + } + else + { + au->au_mpos = XDR_GETPOS (xdrs); + } + XDR_DESTROY (xdrs); + + return TRUE; } diff --git a/sunrpc/authuxprot.c b/sunrpc/authuxprot.c index 9b21ce195e..d172ebc655 100644 --- a/sunrpc/authuxprot.c +++ b/sunrpc/authuxprot.c @@ -48,24 +48,22 @@ static char sccsid[] = "@(#)authunix_prot.c 1.15 87/08/11 Copyr 1984 Sun Micro"; * XDR for unix authentication parameters. */ bool_t -xdr_authunix_parms(xdrs, p) - register XDR *xdrs; - register struct authunix_parms *p; +xdr_authunix_parms (XDR * xdrs, struct authunix_parms *p) { - - if (xdr_u_long(xdrs, &(p->aup_time)) - && xdr_string(xdrs, &(p->aup_machname), MAX_MACHINE_NAME) - && (sizeof (uid_t) == sizeof (short int) - ? xdr_u_short(xdrs, (u_short *) &(p->aup_uid)) - : xdr_u_int(xdrs, (u_int *) &(p->aup_uid))) - && (sizeof (gid_t) == sizeof (short int) - ? xdr_u_short(xdrs, (u_short *) &(p->aup_gid)) - : xdr_u_int(xdrs, (u_int *) &(p->aup_gid))) - && xdr_array(xdrs, (caddr_t *)&(p->aup_gids), - &(p->aup_len), NGRPS, sizeof(gid_t), - (sizeof (gid_t) == sizeof (short int) - ? xdr_u_short : xdr_u_int)) ) { - return (TRUE); - } - return (FALSE); + if (xdr_u_long (xdrs, &(p->aup_time)) + && xdr_string (xdrs, &(p->aup_machname), MAX_MACHINE_NAME) + && (sizeof (uid_t) == sizeof (short int) + ? xdr_u_short (xdrs, (u_short *) & (p->aup_uid)) + : xdr_u_int (xdrs, (u_int *) & (p->aup_uid))) + && (sizeof (gid_t) == sizeof (short int) + ? xdr_u_short (xdrs, (u_short *) & (p->aup_gid)) + : xdr_u_int (xdrs, (u_int *) & (p->aup_gid))) + && xdr_array (xdrs, (caddr_t *) & (p->aup_gids), + & (p->aup_len), NGRPS, sizeof (gid_t), + (sizeof (gid_t) == sizeof (short int) + ? (xdrproc_t) xdr_u_short : (xdrproc_t) xdr_u_int))) + { + return TRUE; + } + return FALSE; } diff --git a/sunrpc/bindrsvprt.c b/sunrpc/bindrsvprt.c index 44660dede6..e1d53ce950 100644 --- a/sunrpc/bindrsvprt.c +++ b/sunrpc/bindrsvprt.c @@ -1,4 +1,3 @@ -static char sccsid[] = "@(#)bindresvport.c 2.2 88/07/29 4.0 RPCSRC 1.8 88/02/08 SMI"; /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for * unrestricted use provided that this legend is included on all tape @@ -27,11 +26,15 @@ static char sccsid[] = "@(#)bindresvport.c 2.2 88/07/29 4.0 RPCSRC 1.8 88/02/08 * 2550 Garcia Avenue * Mountain View, California 94043 */ - +#if !defined(lint) && defined(SCCSIDS) +static char sccsid[] = "@(#)bindresvport.c 2.2 88/07/29 4.0 RPCSRC 1.8 88/02/08 SMI"; +#endif /* * Copyright (c) 1987 by Sun Microsystems, Inc. */ +#include +#include #include #include #include @@ -40,41 +43,46 @@ static char sccsid[] = "@(#)bindresvport.c 2.2 88/07/29 4.0 RPCSRC 1.8 88/02/08 /* * Bind a socket to a privileged IP port */ -bindresvport(sd, sin) - int sd; - struct sockaddr_in *sin; +int +bindresvport (int sd, struct sockaddr_in *sin) { - int res; - static short port; - struct sockaddr_in myaddr; + int res; + static short port; + struct sockaddr_in myaddr; #ifndef errno - extern int errno; + extern int errno; #endif - int i; + int i; #define STARTPORT 600 #define ENDPORT (IPPORT_RESERVED - 1) #define NPORTS (ENDPORT - STARTPORT + 1) - if (sin == (struct sockaddr_in *)0) { - sin = &myaddr; - bzero(sin, sizeof (*sin)); - sin->sin_family = AF_INET; - } else if (sin->sin_family != AF_INET) { - __set_errno (EPFNOSUPPORT); - return (-1); - } - if (port == 0) { - port = (getpid() % NPORTS) + STARTPORT; - } - res = -1; - __set_errno (EADDRINUSE); - for (i = 0; i < NPORTS && res < 0 && errno == EADDRINUSE; i++) { - sin->sin_port = htons(port++); - if (port > ENDPORT) { - port = STARTPORT; - } - res = bind(sd, sin, sizeof(struct sockaddr_in)); + if (sin == (struct sockaddr_in *) 0) + { + sin = &myaddr; + bzero (sin, sizeof (*sin)); + sin->sin_family = AF_INET; + } + else if (sin->sin_family != AF_INET) + { + __set_errno (EPFNOSUPPORT); + return -1; + } + if (port == 0) + { + port = (getpid () % NPORTS) + STARTPORT; + } + res = -1; + __set_errno (EADDRINUSE); + for (i = 0; i < NPORTS && res < 0 && errno == EADDRINUSE; i++) + { + sin->sin_port = htons (port++); + if (port > ENDPORT) + { + port = STARTPORT; } - return (res); + res = bind (sd, sin, sizeof (struct sockaddr_in)); + } + return res; } diff --git a/sunrpc/clnt_gen.c b/sunrpc/clnt_gen.c index d7b949caa6..c24442cb36 100644 --- a/sunrpc/clnt_gen.c +++ b/sunrpc/clnt_gen.c @@ -35,6 +35,7 @@ static char sccsid[] = "@(#)clnt_generic.c 1.4 87/08/11 (C) 1987 SMI"; */ #include #include +#include #include #include #include @@ -46,95 +47,96 @@ static char sccsid[] = "@(#)clnt_generic.c 1.4 87/08/11 (C) 1987 SMI"; * change using the rpc equivalent of ioctl()'s. */ CLIENT * -clnt_create(hostname, prog, vers, proto) - char *hostname; - unsigned prog; - unsigned vers; - char *proto; +clnt_create (const char *hostname, u_long prog, u_long vers, + const char *proto) { - struct hostent hostbuf, *h; - size_t hstbuflen; - char *hsttmpbuf; - struct protoent protobuf, *p; - size_t prtbuflen; - char *prttmpbuf; - struct sockaddr_in sin; - int sock; - struct timeval tv; - CLIENT *client; - int herr; + struct hostent hostbuf, *h; + size_t hstbuflen; + char *hsttmpbuf; + struct protoent protobuf, *p; + size_t prtbuflen; + char *prttmpbuf; + struct sockaddr_in sin; + int sock; + struct timeval tv; + CLIENT *client; + int herr; - hstbuflen = 1024; + hstbuflen = 1024; + hsttmpbuf = __alloca (hstbuflen); + while (__gethostbyname_r (hostname, &hostbuf, hsttmpbuf, hstbuflen, + &h, &herr) < 0) + if (herr != NETDB_INTERNAL || errno != ERANGE) + { + rpc_createerr.cf_stat = RPC_UNKNOWNHOST; + return NULL; + } + else + { + /* Enlarge the buffer. */ + hstbuflen *= 2; hsttmpbuf = __alloca (hstbuflen); - while (__gethostbyname_r (hostname, &hostbuf, hsttmpbuf, hstbuflen, - &h, &herr) < 0) - if (herr != NETDB_INTERNAL || errno != ERANGE) - { - rpc_createerr.cf_stat = RPC_UNKNOWNHOST; - return NULL; - } - else - { - /* Enlarge the buffer. */ - hstbuflen *= 2; - hsttmpbuf = __alloca (hstbuflen); - } + } - if (h->h_addrtype != AF_INET) { - /* - * Only support INET for now - */ - rpc_createerr.cf_stat = RPC_SYSTEMERROR; - rpc_createerr.cf_error.re_errno = EAFNOSUPPORT; - return (NULL); - } - sin.sin_family = h->h_addrtype; - sin.sin_port = 0; - bzero(sin.sin_zero, sizeof(sin.sin_zero)); - bcopy(h->h_addr, (char*)&sin.sin_addr, h->h_length); + if (h->h_addrtype != AF_INET) + { + /* + * Only support INET for now + */ + rpc_createerr.cf_stat = RPC_SYSTEMERROR; + rpc_createerr.cf_error.re_errno = EAFNOSUPPORT; + return NULL; + } + sin.sin_family = h->h_addrtype; + sin.sin_port = 0; + bzero (sin.sin_zero, sizeof (sin.sin_zero)); + bcopy (h->h_addr, (char *) &sin.sin_addr, h->h_length); - prtbuflen = 1024; + prtbuflen = 1024; + prttmpbuf = __alloca (prtbuflen); + while (__getprotobyname_r (proto, &protobuf, prttmpbuf, prtbuflen, &p) + < 0) + if (errno != ERANGE) + { + rpc_createerr.cf_stat = RPC_UNKNOWNPROTO; + rpc_createerr.cf_error.re_errno = EPFNOSUPPORT; + return NULL; + } + else + { + /* Enlarge the buffer. */ + prtbuflen *= 2; prttmpbuf = __alloca (prtbuflen); - while (__getprotobyname_r (proto, &protobuf, prttmpbuf, prtbuflen, &p) - < 0) - if (errno != ERANGE) - { - rpc_createerr.cf_stat = RPC_UNKNOWNPROTO; - rpc_createerr.cf_error.re_errno = EPFNOSUPPORT; - return NULL; - } - else - { - /* Enlarge the buffer. */ - prtbuflen *= 2; - prttmpbuf = __alloca (prtbuflen); - } + } - sock = RPC_ANYSOCK; - switch (p->p_proto) { - case IPPROTO_UDP: - tv.tv_sec = 5; - tv.tv_usec = 0; - client = clntudp_create(&sin, prog, vers, tv, &sock); - if (client == NULL) { - return (NULL); - } - tv.tv_sec = 25; - clnt_control(client, CLSET_TIMEOUT, &tv); - break; - case IPPROTO_TCP: - client = clnttcp_create(&sin, prog, vers, &sock, 0, 0); - if (client == NULL) { - return (NULL); - } - tv.tv_sec = 25; - tv.tv_usec = 0; - clnt_control(client, CLSET_TIMEOUT, &tv); - break; - default: - rpc_createerr.cf_stat = RPC_SYSTEMERROR; - rpc_createerr.cf_error.re_errno = EPFNOSUPPORT; - return (NULL); + sock = RPC_ANYSOCK; + switch (p->p_proto) + { + case IPPROTO_UDP: + tv.tv_sec = 5; + tv.tv_usec = 0; + client = clntudp_create (&sin, prog, vers, tv, &sock); + if (client == NULL) + { + return NULL; + } + tv.tv_sec = 25; + clnt_control (client, CLSET_TIMEOUT, (char *)&tv); + break; + case IPPROTO_TCP: + client = clnttcp_create (&sin, prog, vers, &sock, 0, 0); + if (client == NULL) + { + return NULL; } - return (client); + tv.tv_sec = 25; + tv.tv_usec = 0; + clnt_control (client, CLSET_TIMEOUT, (char *)&tv); + break; + default: + rpc_createerr.cf_stat = RPC_SYSTEMERROR; + rpc_createerr.cf_error.re_errno = EPFNOSUPPORT; + return (NULL); + } + return client; } diff --git a/sunrpc/clnt_perr.c b/sunrpc/clnt_perr.c index 147a5ea23c..68f3640cd7 100644 --- a/sunrpc/clnt_perr.c +++ b/sunrpc/clnt_perr.c @@ -38,165 +38,156 @@ static char sccsid[] = "@(#)clnt_perror.c 1.15 87/10/07 Copyr 1984 Sun Micro"; * */ #include - +#include #include #include #include -/* extern char *sys_errlist[]; --drepper@gnu */ -/* extern char *sprintf(); --roland@gnu */ -static char *auth_errmsg(); - -extern char *strcpy(); +static char *auth_errmsg (enum auth_stat stat); static char *buf; static char * -_buf() +_buf (void) { - - if (buf == 0) - buf = (char *)malloc(256); - return (buf); + if (buf == NULL) + buf = (char *) malloc (256); + return buf; } /* * Print reply error info */ char * -clnt_sperror(rpch, s) - CLIENT *rpch; - char *s; +clnt_sperror (CLIENT * rpch, const char *msg) { - struct rpc_err e; - void clnt_perrno(); - char *err; - char *str = _buf(); - char *strstart = str; - - if (str == 0) - return (0); - CLNT_GETERR(rpch, &e); - - (void) sprintf(str, "%s: ", s); - str += strlen(str); - - (void) strcpy(str, clnt_sperrno(e.re_status)); - str += strlen(str); - - switch (e.re_status) { - case RPC_SUCCESS: - case RPC_CANTENCODEARGS: - case RPC_CANTDECODERES: - case RPC_TIMEDOUT: - case RPC_PROGUNAVAIL: - case RPC_PROCUNAVAIL: - case RPC_CANTDECODEARGS: - case RPC_SYSTEMERROR: - case RPC_UNKNOWNHOST: - case RPC_UNKNOWNPROTO: - case RPC_PMAPFAILURE: - case RPC_PROGNOTREGISTERED: - case RPC_FAILED: - break; - - case RPC_CANTSEND: - case RPC_CANTRECV: - (void) sprintf(str, "; errno = %s", - sys_errlist[e.re_errno]); - str += strlen(str); - break; - - case RPC_VERSMISMATCH: - (void) sprintf(str, - _("; low version = %lu, high version = %lu"), - e.re_vers.low, e.re_vers.high); - str += strlen(str); - break; - - case RPC_AUTHERROR: - err = auth_errmsg(e.re_why); - (void) sprintf(str,_("; why = ")); - str += strlen(str); - if (err != NULL) { - (void) sprintf(str, "%s",err); - } else { - (void) sprintf(str, - _("(unknown authentication error - %d)"), - (int) e.re_why); - } - str += strlen(str); - break; - - case RPC_PROGVERSMISMATCH: - (void) sprintf(str, - _("; low version = %lu, high version = %lu"), - e.re_vers.low, e.re_vers.high); - str += strlen(str); - break; - - default: /* unknown */ - (void) sprintf(str, - "; s1 = %lu, s2 = %lu", - e.re_lb.s1, e.re_lb.s2); - str += strlen(str); - break; + char buf[1024]; + struct rpc_err e; + char *err; + char *str = _buf (); + char *strstart = str; + int len; + + if (str == NULL) + return NULL; + CLNT_GETERR (rpch, &e); + + len = sprintf (str, "%s: ", msg); + str += len; + + str = stpcpy (str, clnt_sperrno (e.re_status)); + + switch (e.re_status) + { + case RPC_SUCCESS: + case RPC_CANTENCODEARGS: + case RPC_CANTDECODERES: + case RPC_TIMEDOUT: + case RPC_PROGUNAVAIL: + case RPC_PROCUNAVAIL: + case RPC_CANTDECODEARGS: + case RPC_SYSTEMERROR: + case RPC_UNKNOWNHOST: + case RPC_UNKNOWNPROTO: + case RPC_PMAPFAILURE: + case RPC_PROGNOTREGISTERED: + case RPC_FAILED: + break; + + case RPC_CANTSEND: + case RPC_CANTRECV: + len = sprintf (str, "; errno = %s", strerror_r (e.re_errno, + buf, sizeof buf)); + str += len; + break; + + case RPC_VERSMISMATCH: + len= sprintf (str, _("; low version = %lu, high version = %lu"), + e.re_vers.low, e.re_vers.high); + str += len; + break; + + case RPC_AUTHERROR: + err = auth_errmsg (e.re_why); + str = stpcpy (str, _ ("; why = ")); + if (err != NULL) + { + str = stpcpy (str, err); + } + else + { + len = sprintf (str, _("(unknown authentication error - %d)"), + (int) e.re_why); + str += len; } - (void) sprintf(str, "\n"); - return(strstart) ; + break; + + case RPC_PROGVERSMISMATCH: + len = sprintf (str, _("; low version = %lu, high version = %lu"), + e.re_vers.low, e.re_vers.high); + str += len; + break; + + default: /* unknown */ + len = sprintf (str, "; s1 = %lu, s2 = %lu", e.re_lb.s1, e.re_lb.s2); + str += len; + break; + } + *str = '\n'; + return (strstart); } void -clnt_perror(rpch, s) - CLIENT *rpch; - char *s; +clnt_perror (CLIENT * rpch, const char *msg) { - (void) fprintf(stderr,"%s",clnt_sperror(rpch,s)); + (void) fputs (clnt_sperror (rpch, msg), stderr); } -struct rpc_errtab { - enum clnt_stat status; - char *message; +struct rpc_errtab +{ + enum clnt_stat status; + const char *message; }; -static struct rpc_errtab rpc_errlist[] = { - { RPC_SUCCESS, - N_("RPC: Success") }, - { RPC_CANTENCODEARGS, - N_("RPC: Can't encode arguments") }, - { RPC_CANTDECODERES, - N_("RPC: Can't decode result") }, - { RPC_CANTSEND, - N_("RPC: Unable to send") }, - { RPC_CANTRECV, - N_("RPC: Unable to receive") }, - { RPC_TIMEDOUT, - N_("RPC: Timed out") }, - { RPC_VERSMISMATCH, - N_("RPC: Incompatible versions of RPC") }, - { RPC_AUTHERROR, - N_("RPC: Authentication error") }, - { RPC_PROGUNAVAIL, - N_("RPC: Program unavailable") }, - { RPC_PROGVERSMISMATCH, - N_("RPC: Program/version mismatch") }, - { RPC_PROCUNAVAIL, - N_("RPC: Procedure unavailable") }, - { RPC_CANTDECODEARGS, - N_("RPC: Server can't decode arguments") }, - { RPC_SYSTEMERROR, - N_("RPC: Remote system error") }, - { RPC_UNKNOWNHOST, - N_("RPC: Unknown host") }, - { RPC_UNKNOWNPROTO, - N_("RPC: Unknown protocol") }, - { RPC_PMAPFAILURE, - N_("RPC: Port mapper failure") }, - { RPC_PROGNOTREGISTERED, - N_("RPC: Program not registered") }, - { RPC_FAILED, - N_("RPC: Failed (unspecified error)") } +static const struct rpc_errtab rpc_errlist[] = +{ + {RPC_SUCCESS, + N_("RPC: Success")}, + {RPC_CANTENCODEARGS, + N_("RPC: Can't encode arguments")}, + {RPC_CANTDECODERES, + N_("RPC: Can't decode result")}, + {RPC_CANTSEND, + N_("RPC: Unable to send")}, + {RPC_CANTRECV, + N_("RPC: Unable to receive")}, + {RPC_TIMEDOUT, + N_("RPC: Timed out")}, + {RPC_VERSMISMATCH, + N_("RPC: Incompatible versions of RPC")}, + {RPC_AUTHERROR, + N_("RPC: Authentication error")}, + {RPC_PROGUNAVAIL, + N_("RPC: Program unavailable")}, + {RPC_PROGVERSMISMATCH, + N_("RPC: Program/version mismatch")}, + {RPC_PROCUNAVAIL, + N_("RPC: Procedure unavailable")}, + {RPC_CANTDECODEARGS, + N_("RPC: Server can't decode arguments")}, + {RPC_SYSTEMERROR, + N_("RPC: Remote system error")}, + {RPC_UNKNOWNHOST, + N_("RPC: Unknown host")}, + {RPC_UNKNOWNPROTO, + N_("RPC: Unknown protocol")}, + {RPC_PMAPFAILURE, + N_("RPC: Port mapper failure")}, + {RPC_PROGNOTREGISTERED, + N_("RPC: Program not registered")}, + {RPC_FAILED, + N_("RPC: Failed (unspecified error)")} }; @@ -204,102 +195,109 @@ static struct rpc_errtab rpc_errlist[] = { * This interface for use by clntrpc */ char * -clnt_sperrno(stat) - enum clnt_stat stat; +clnt_sperrno (enum clnt_stat stat) { - int i; + int i; - for (i = 0; i < sizeof(rpc_errlist)/sizeof(struct rpc_errtab); i++) { - if (rpc_errlist[i].status == stat) { - return _(rpc_errlist[i].message); - } + for (i = 0; i < sizeof (rpc_errlist) / sizeof (struct rpc_errtab); i++) + { + if (rpc_errlist[i].status == stat) + { + return _(rpc_errlist[i].message); } - return _("RPC: (unknown error code)"); + } + return _("RPC: (unknown error code)"); } void -clnt_perrno(num) - enum clnt_stat num; +clnt_perrno (enum clnt_stat num) { - (void) fprintf(stderr,"%s",clnt_sperrno(num)); + (void) fputs (clnt_sperrno (num), stderr); } char * -clnt_spcreateerror(s) - char *s; +clnt_spcreateerror (const char *msg) { - extern int sys_nerr; - /* extern char *sys_errlist[]; --drepper@gnu */ - char *str = _buf(); - - if (str == 0) - return(0); - (void) sprintf(str, "%s: ", s); - (void) strcat(str, clnt_sperrno(rpc_createerr.cf_stat)); - switch (rpc_createerr.cf_stat) { - case RPC_PMAPFAILURE: - (void) strcat(str, " - "); - (void) strcat(str, - clnt_sperrno(rpc_createerr.cf_error.re_status)); - break; - - case RPC_SYSTEMERROR: - (void) strcat(str, " - "); - if (rpc_createerr.cf_error.re_errno > 0 - && rpc_createerr.cf_error.re_errno < sys_nerr) - (void) strcat(str, - sys_errlist[rpc_createerr.cf_error.re_errno]); - else - (void) sprintf(&str[strlen(str)], _("Error %d"), - rpc_createerr.cf_error.re_errno); - break; + char buf[1024]; + char *str = _buf (); + char *cp; + int len; + + if (str == NULL) + return NULL; + len = sprintf (str, "%s: ", msg); + cp = str + len; + cp = stpcpy (cp, clnt_sperrno (rpc_createerr.cf_stat)); + switch (rpc_createerr.cf_stat) + { + case RPC_PMAPFAILURE: + cp = stpcpy (cp, " - "); + cp = stpcpy (cp, clnt_sperrno (rpc_createerr.cf_error.re_status)); + break; + + case RPC_SYSTEMERROR: + cp = stpcpy (str, " - "); + if (rpc_createerr.cf_error.re_errno > 0 + && rpc_createerr.cf_error.re_errno < sys_nerr) + cp = stpcpy (str, strerror_r (rpc_createerr.cf_error.re_errno, + buf, sizeof buf)); + else + { + len = sprintf (cp, _("Error %d"), rpc_createerr.cf_error.re_errno); + cp += len; } - (void) strcat(str, "\n"); - return (str); + break; + default: + break; + } + *cp = '\n'; + return str; } void -clnt_pcreateerror(s) - char *s; +clnt_pcreateerror (const char *msg) { - (void) fprintf(stderr,"%s",clnt_spcreateerror(s)); + (void) fputs (clnt_spcreateerror (msg), stderr); } -struct auth_errtab { - enum auth_stat status; - char *message; +struct auth_errtab +{ + enum auth_stat status; + const char *message; }; -static struct auth_errtab auth_errlist[] = { - { AUTH_OK, - N_("Authentication OK") }, - { AUTH_BADCRED, - N_("Invalid client credential") }, - { AUTH_REJECTEDCRED, - N_("Server rejected credential") }, - { AUTH_BADVERF, - N_("Invalid client verifier") }, - { AUTH_REJECTEDVERF, - N_("Server rejected verifier") }, - { AUTH_TOOWEAK, - N_("Client credential too weak") }, - { AUTH_INVALIDRESP, - N_("Invalid server verifier") }, - { AUTH_FAILED, - N_("Failed (unspecified error)") }, +static const struct auth_errtab auth_errlist[] = +{ + {AUTH_OK, + N_("Authentication OK")}, + {AUTH_BADCRED, + N_("Invalid client credential")}, + {AUTH_REJECTEDCRED, + N_("Server rejected credential")}, + {AUTH_BADVERF, + N_("Invalid client verifier")}, + {AUTH_REJECTEDVERF, + N_("Server rejected verifier")}, + {AUTH_TOOWEAK, + N_("Client credential too weak")}, + {AUTH_INVALIDRESP, + N_("Invalid server verifier")}, + {AUTH_FAILED, + N_("Failed (unspecified error)")}, }; static char * -auth_errmsg(stat) - enum auth_stat stat; +auth_errmsg (enum auth_stat stat) { - int i; + size_t i; - for (i = 0; i < sizeof(auth_errlist)/sizeof(struct auth_errtab); i++) { - if (auth_errlist[i].status == stat) { - return _(auth_errlist[i].message); - } + for (i = 0; i < sizeof (auth_errlist) / sizeof (struct auth_errtab); i++) + { + if (auth_errlist[i].status == stat) + { + return _(auth_errlist[i].message); } - return(NULL); + } + return NULL; } diff --git a/sunrpc/clnt_raw.c b/sunrpc/clnt_raw.c index fe2aecfa5a..a9ff3ca00a 100644 --- a/sunrpc/clnt_raw.c +++ b/sunrpc/clnt_raw.c @@ -43,196 +43,209 @@ static char sccsid[] = "@(#)clnt_raw.c 1.22 87/08/11 Copyr 1984 Sun Micro"; */ #include +#include +#include + +extern bool_t xdr_opaque_auth (XDR *, struct opaque_auth *); #define MCALL_MSG_SIZE 24 /* * This is the "network" we will be moving stuff over. */ -static struct clntraw_private { - CLIENT client_object; - XDR xdr_stream; - char _raw_buf[UDPMSGSIZE]; - char mashl_callmsg[MCALL_MSG_SIZE]; - u_int mcnt; -} *clntraw_private; - -static enum clnt_stat clntraw_call(); -static void clntraw_abort(); -static void clntraw_geterr(); -static bool_t clntraw_freeres(); -static bool_t clntraw_control(); -static void clntraw_destroy(); - -static struct clnt_ops client_ops = { - clntraw_call, - clntraw_abort, - clntraw_geterr, - clntraw_freeres, - clntraw_destroy, - clntraw_control +static struct clntraw_private + { + CLIENT client_object; + XDR xdr_stream; + char _raw_buf[UDPMSGSIZE]; + char mashl_callmsg[MCALL_MSG_SIZE]; + u_int mcnt; + } + *clntraw_private; + +static enum clnt_stat clntraw_call (CLIENT *, u_long, xdrproc_t, caddr_t, + xdrproc_t, caddr_t, struct timeval); +static void clntraw_abort (void); +static void clntraw_geterr (CLIENT *, struct rpc_err *); +static bool_t clntraw_freeres (CLIENT *, xdrproc_t, caddr_t); +static bool_t clntraw_control (CLIENT *, int, char *); +static void clntraw_destroy (CLIENT *); + +static struct clnt_ops client_ops = +{ + clntraw_call, + clntraw_abort, + clntraw_geterr, + clntraw_freeres, + clntraw_destroy, + clntraw_control }; -void svc_getreq(); - /* * Create a client handle for memory based rpc. */ CLIENT * -clntraw_create(prog, vers) - u_long prog; - u_long vers; +clntraw_create (u_long prog, u_long vers) { - register struct clntraw_private *clp = clntraw_private; - struct rpc_msg call_msg; - XDR *xdrs = &clp->xdr_stream; - CLIENT *client = &clp->client_object; - - if (clp == 0) { - clp = (struct clntraw_private *)calloc(1, sizeof (*clp)); - if (clp == 0) - return (0); - clntraw_private = clp; - } - /* - * pre-serialize the static part of the call msg and stash it away - */ - call_msg.rm_direction = CALL; - call_msg.rm_call.cb_rpcvers = RPC_MSG_VERSION; - call_msg.rm_call.cb_prog = prog; - call_msg.rm_call.cb_vers = vers; - xdrmem_create(xdrs, clp->mashl_callmsg, MCALL_MSG_SIZE, XDR_ENCODE); - if (! xdr_callhdr(xdrs, &call_msg)) { - perror(_("clnt_raw.c - Fatal header serialization error.")); - } - clp->mcnt = XDR_GETPOS(xdrs); - XDR_DESTROY(xdrs); - - /* - * Set xdrmem for client/server shared buffer - */ - xdrmem_create(xdrs, clp->_raw_buf, UDPMSGSIZE, XDR_FREE); - - /* - * create client handle - */ - client->cl_ops = &client_ops; - client->cl_auth = authnone_create(); - return (client); + struct clntraw_private *clp = clntraw_private; + struct rpc_msg call_msg; + XDR *xdrs = &clp->xdr_stream; + CLIENT *client = &clp->client_object; + + if (clp == 0) + { + clp = (struct clntraw_private *) calloc (1, sizeof (*clp)); + if (clp == 0) + return (0); + clntraw_private = clp; + } + /* + * pre-serialize the static part of the call msg and stash it away + */ + call_msg.rm_direction = CALL; + call_msg.rm_call.cb_rpcvers = RPC_MSG_VERSION; + call_msg.rm_call.cb_prog = prog; + call_msg.rm_call.cb_vers = vers; + xdrmem_create (xdrs, clp->mashl_callmsg, MCALL_MSG_SIZE, XDR_ENCODE); + if (!xdr_callhdr (xdrs, &call_msg)) + { + perror (_ ("clnt_raw.c - Fatal header serialization error.")); + } + clp->mcnt = XDR_GETPOS (xdrs); + XDR_DESTROY (xdrs); + + /* + * Set xdrmem for client/server shared buffer + */ + xdrmem_create (xdrs, clp->_raw_buf, UDPMSGSIZE, XDR_FREE); + + /* + * create client handle + */ + client->cl_ops = &client_ops; + client->cl_auth = authnone_create (); + return client; } static enum clnt_stat -clntraw_call(h, proc, xargs, argsp, xresults, resultsp, timeout) - CLIENT *h; - u_long proc; - xdrproc_t xargs; - caddr_t argsp; - xdrproc_t xresults; - caddr_t resultsp; - struct timeval timeout; +clntraw_call (h, proc, xargs, argsp, xresults, resultsp, timeout) + CLIENT *h; + u_long proc; + xdrproc_t xargs; + caddr_t argsp; + xdrproc_t xresults; + caddr_t resultsp; + struct timeval timeout; { - register struct clntraw_private *clp = clntraw_private; - register XDR *xdrs = &clp->xdr_stream; - struct rpc_msg msg; - enum clnt_stat status; - struct rpc_err error; - - if (clp == 0) - return (RPC_FAILED); + struct clntraw_private *clp = clntraw_private; + XDR *xdrs = &clp->xdr_stream; + struct rpc_msg msg; + enum clnt_stat status; + struct rpc_err error; + + if (clp == NULL) + return RPC_FAILED; call_again: - /* - * send request - */ - xdrs->x_op = XDR_ENCODE; - XDR_SETPOS(xdrs, 0); - ((struct rpc_msg *)clp->mashl_callmsg)->rm_xid ++ ; - if ((! XDR_PUTBYTES(xdrs, clp->mashl_callmsg, clp->mcnt)) || - (! XDR_PUTLONG(xdrs, (long *)&proc)) || - (! AUTH_MARSHALL(h->cl_auth, xdrs)) || - (! (*xargs)(xdrs, argsp))) { - return (RPC_CANTENCODEARGS); + /* + * send request + */ + xdrs->x_op = XDR_ENCODE; + XDR_SETPOS (xdrs, 0); + ((struct rpc_msg *) clp->mashl_callmsg)->rm_xid++; + if ((!XDR_PUTBYTES (xdrs, clp->mashl_callmsg, clp->mcnt)) || + (!XDR_PUTLONG (xdrs, (long *) &proc)) || + (!AUTH_MARSHALL (h->cl_auth, xdrs)) || + (!(*xargs) (xdrs, argsp))) + { + return (RPC_CANTENCODEARGS); + } + (void) XDR_GETPOS (xdrs); /* called just to cause overhead */ + + /* + * We have to call server input routine here because this is + * all going on in one process. Yuk. + */ + svc_getreq (1); + + /* + * get results + */ + xdrs->x_op = XDR_DECODE; + XDR_SETPOS (xdrs, 0); + msg.acpted_rply.ar_verf = _null_auth; + msg.acpted_rply.ar_results.where = resultsp; + msg.acpted_rply.ar_results.proc = xresults; + if (!xdr_replymsg (xdrs, &msg)) + return RPC_CANTDECODERES; + _seterr_reply (&msg, &error); + status = error.re_status; + + if (status == RPC_SUCCESS) + { + if (!AUTH_VALIDATE (h->cl_auth, &msg.acpted_rply.ar_verf)) + { + status = RPC_AUTHERROR; } - (void)XDR_GETPOS(xdrs); /* called just to cause overhead */ - - /* - * We have to call server input routine here because this is - * all going on in one process. Yuk. - */ - svc_getreq(1); - - /* - * get results - */ - xdrs->x_op = XDR_DECODE; - XDR_SETPOS(xdrs, 0); - msg.acpted_rply.ar_verf = _null_auth; - msg.acpted_rply.ar_results.where = resultsp; - msg.acpted_rply.ar_results.proc = xresults; - if (! xdr_replymsg(xdrs, &msg)) - return (RPC_CANTDECODERES); - _seterr_reply(&msg, &error); - status = error.re_status; - - if (status == RPC_SUCCESS) { - if (! AUTH_VALIDATE(h->cl_auth, &msg.acpted_rply.ar_verf)) { - status = RPC_AUTHERROR; - } - } /* end successful completion */ - else { - if (AUTH_REFRESH(h->cl_auth)) - goto call_again; - } /* end of unsuccessful completion */ - - if (status == RPC_SUCCESS) { - if (! AUTH_VALIDATE(h->cl_auth, &msg.acpted_rply.ar_verf)) { - status = RPC_AUTHERROR; - } - if (msg.acpted_rply.ar_verf.oa_base != NULL) { - xdrs->x_op = XDR_FREE; - (void)xdr_opaque_auth(xdrs, &(msg.acpted_rply.ar_verf)); - } + } /* end successful completion */ + else + { + if (AUTH_REFRESH (h->cl_auth)) + goto call_again; + } /* end of unsuccessful completion */ + + if (status == RPC_SUCCESS) + { + if (!AUTH_VALIDATE (h->cl_auth, &msg.acpted_rply.ar_verf)) + { + status = RPC_AUTHERROR; + } + if (msg.acpted_rply.ar_verf.oa_base != NULL) + { + xdrs->x_op = XDR_FREE; + (void) xdr_opaque_auth (xdrs, &(msg.acpted_rply.ar_verf)); } + } - return (status); + return status; } static void -clntraw_geterr() +clntraw_geterr (CLIENT *cl, struct rpc_err *err) { } static bool_t -clntraw_freeres(cl, xdr_res, res_ptr) - CLIENT *cl; - xdrproc_t xdr_res; - caddr_t res_ptr; +clntraw_freeres (cl, xdr_res, res_ptr) + CLIENT *cl; + xdrproc_t xdr_res; + caddr_t res_ptr; { - register struct clntraw_private *clp = clntraw_private; - register XDR *xdrs = &clp->xdr_stream; - bool_t rval; - - if (clp == 0) - { - rval = (bool_t) RPC_FAILED; - return (rval); - } - xdrs->x_op = XDR_FREE; - return ((*xdr_res)(xdrs, res_ptr)); + struct clntraw_private *clp = clntraw_private; + XDR *xdrs = &clp->xdr_stream; + bool_t rval; + + if (clp == NULL) + { + rval = (bool_t) RPC_FAILED; + return rval; + } + xdrs->x_op = XDR_FREE; + return (*xdr_res) (xdrs, res_ptr); } static void -clntraw_abort() +clntraw_abort (void) { } static bool_t -clntraw_control() +clntraw_control (CLIENT *cl, int i, char *c) { - return (FALSE); + return FALSE; } static void -clntraw_destroy() +clntraw_destroy (CLIENT *cl) { } diff --git a/sunrpc/clnt_simp.c b/sunrpc/clnt_simp.c index 42ab1a28f8..30a051724f 100644 --- a/sunrpc/clnt_simp.c +++ b/sunrpc/clnt_simp.c @@ -41,94 +41,102 @@ static char sccsid[] = "@(#)clnt_simple.c 1.35 87/08/11 Copyr 1984 Sun Micro"; #include #include #include +#include #include #include #include #include -static struct callrpc_private { - CLIENT *client; - int socket; - int oldprognum, oldversnum, valid; - char *oldhost; -} *callrpc_private; +static struct callrpc_private + { + CLIENT *client; + int socket; + u_long oldprognum, oldversnum, valid; + char *oldhost; + } + *callrpc_private; -callrpc(host, prognum, versnum, procnum, inproc, in, outproc, out) - char *host; - xdrproc_t inproc, outproc; - char *in, *out; +int +callrpc (const char *host, u_long prognum, u_long versnum, u_long procnum, + xdrproc_t inproc, const char *in, xdrproc_t outproc, char *out) { - register struct callrpc_private *crp = callrpc_private; - struct sockaddr_in server_addr; - enum clnt_stat clnt_stat; - struct hostent hostbuf, *hp; - struct timeval timeout, tottimeout; + struct callrpc_private *crp = callrpc_private; + struct sockaddr_in server_addr; + enum clnt_stat clnt_stat; + struct hostent hostbuf, *hp; + struct timeval timeout, tottimeout; - if (crp == 0) { - crp = (struct callrpc_private *)calloc(1, sizeof (*crp)); - if (crp == 0) - return (0); - callrpc_private = crp; + if (crp == 0) + { + crp = (struct callrpc_private *) calloc (1, sizeof (*crp)); + if (crp == 0) + return 0; + callrpc_private = crp; + } + if (crp->oldhost == NULL) + { + crp->oldhost = malloc (256); + crp->oldhost[0] = 0; + crp->socket = RPC_ANYSOCK; + } + if (crp->valid && crp->oldprognum == prognum && crp->oldversnum == versnum + && strcmp (crp->oldhost, host) == 0) + { + /* reuse old client */ + } + else + { + size_t buflen; + char *buffer; + int herr; + + crp->valid = 0; + if (crp->socket != RPC_ANYSOCK) + { + (void) close (crp->socket); + crp->socket = RPC_ANYSOCK; } - if (crp->oldhost == NULL) { - crp->oldhost = malloc(256); - crp->oldhost[0] = 0; - crp->socket = RPC_ANYSOCK; + if (crp->client) + { + clnt_destroy (crp->client); + crp->client = NULL; } - if (crp->valid && crp->oldprognum == prognum && crp->oldversnum == versnum - && strcmp(crp->oldhost, host) == 0) { - /* reuse old client */ - } else { - size_t buflen; - char *buffer; - int herr; - - crp->valid = 0; - if (crp->socket != RPC_ANYSOCK) - { - (void)close(crp->socket); - crp->socket = RPC_ANYSOCK; - } - if (crp->client) { - clnt_destroy(crp->client); - crp->client = NULL; - } - buflen = 1024; - buffer = __alloca (buflen); - while (__gethostbyname_r (host, &hostbuf, buffer, buflen, - &hp, &herr) < 0) - if (herr != NETDB_INTERNAL || errno != ERANGE) - return (int) RPC_UNKNOWNHOST; - else - { - /* Enlarge the buffer. */ - buflen *= 2; - buffer = __alloca (buflen); - } + buflen = 1024; + buffer = __alloca (buflen); + while (__gethostbyname_r (host, &hostbuf, buffer, buflen, + &hp, &herr) < 0) + if (herr != NETDB_INTERNAL || errno != ERANGE) + return (int) RPC_UNKNOWNHOST; + else + { + /* Enlarge the buffer. */ + buflen *= 2; + buffer = __alloca (buflen); + } - timeout.tv_usec = 0; - timeout.tv_sec = 5; - bcopy(hp->h_addr, (char *)&server_addr.sin_addr, hp->h_length); - server_addr.sin_family = AF_INET; - server_addr.sin_port = 0; - if ((crp->client = clntudp_create(&server_addr, (u_long)prognum, - (u_long)versnum, timeout, &crp->socket)) == NULL) - return ((int) rpc_createerr.cf_stat); - crp->valid = 1; - crp->oldprognum = prognum; - crp->oldversnum = versnum; - (void) strncpy(crp->oldhost, host, 255); - crp->oldhost[256] = '\0'; - } - tottimeout.tv_sec = 25; - tottimeout.tv_usec = 0; - clnt_stat = clnt_call(crp->client, procnum, inproc, in, - outproc, out, tottimeout); - /* - * if call failed, empty cache - */ - if (clnt_stat != RPC_SUCCESS) - crp->valid = 0; - return ((int) clnt_stat); + timeout.tv_usec = 0; + timeout.tv_sec = 5; + bcopy (hp->h_addr, (char *) &server_addr.sin_addr, hp->h_length); + server_addr.sin_family = AF_INET; + server_addr.sin_port = 0; + if ((crp->client = clntudp_create (&server_addr, (u_long) prognum, + (u_long) versnum, timeout, &crp->socket)) == NULL) + return (int) rpc_createerr.cf_stat; + crp->valid = 1; + crp->oldprognum = prognum; + crp->oldversnum = versnum; + (void) strncpy (crp->oldhost, host, 255); + crp->oldhost[256] = '\0'; + } + tottimeout.tv_sec = 25; + tottimeout.tv_usec = 0; + clnt_stat = clnt_call (crp->client, procnum, inproc, (char *) in, + outproc, out, tottimeout); + /* + * if call failed, empty cache + */ + if (clnt_stat != RPC_SUCCESS) + crp->valid = 0; + return (int) clnt_stat; } diff --git a/sunrpc/clnt_tcp.c b/sunrpc/clnt_tcp.c index aeaf558ad2..02c43dd26f 100644 --- a/sunrpc/clnt_tcp.c +++ b/sunrpc/clnt_tcp.c @@ -50,48 +50,50 @@ static char sccsid[] = "@(#)clnt_tcp.c 1.37 87/10/05 Copyr 1984 Sun Micro"; * Now go hang yourself. */ +#include +#include #include +#include #include #include -#include -#include #include -#define MCALL_MSG_SIZE 24 - -#ifndef errno -extern int errno; -#endif +extern bool_t xdr_opaque_auth (XDR *, struct opaque_auth *); -static int readtcp(); -static int writetcp(); - -static enum clnt_stat clnttcp_call(); -static void clnttcp_abort(); -static void clnttcp_geterr(); -static bool_t clnttcp_freeres(); -static bool_t clnttcp_control(); -static void clnttcp_destroy(); - -static struct clnt_ops tcp_ops = { - clnttcp_call, - clnttcp_abort, - clnttcp_geterr, - clnttcp_freeres, - clnttcp_destroy, - clnttcp_control -}; +#define MCALL_MSG_SIZE 24 -struct ct_data { - int ct_sock; - bool_t ct_closeit; - struct timeval ct_wait; - bool_t ct_waitset; /* wait set by clnt_control? */ - struct sockaddr_in ct_addr; - struct rpc_err ct_error; - char ct_mcall[MCALL_MSG_SIZE]; /* marshalled callmsg */ - u_int ct_mpos; /* pos after marshal */ - XDR ct_xdrs; +struct ct_data + { + int ct_sock; + bool_t ct_closeit; + struct timeval ct_wait; + bool_t ct_waitset; /* wait set by clnt_control? */ + struct sockaddr_in ct_addr; + struct rpc_err ct_error; + char ct_mcall[MCALL_MSG_SIZE]; /* marshalled callmsg */ + u_int ct_mpos; /* pos after marshal */ + XDR ct_xdrs; + }; + +static int readtcp (char *, char *, int); +static int writetcp (char *, char *, int); + +static enum clnt_stat clnttcp_call (CLIENT *, u_long, xdrproc_t, caddr_t, + xdrproc_t, caddr_t, struct timeval); +static void clnttcp_abort (void); +static void clnttcp_geterr (CLIENT *, struct rpc_err *); +static bool_t clnttcp_freeres (CLIENT *, xdrproc_t, caddr_t); +static bool_t clnttcp_control (CLIENT *, int, char *); +static void clnttcp_destroy (CLIENT *); + +static struct clnt_ops tcp_ops = +{ + clnttcp_call, + clnttcp_abort, + clnttcp_geterr, + clnttcp_freeres, + clnttcp_destroy, + clnttcp_control }; /* @@ -109,284 +111,301 @@ struct ct_data { * something more useful. */ CLIENT * -clnttcp_create(raddr, prog, vers, sockp, sendsz, recvsz) - struct sockaddr_in *raddr; - u_long prog; - u_long vers; - register int *sockp; - u_int sendsz; - u_int recvsz; +clnttcp_create (struct sockaddr_in *raddr, u_long prog, u_long vers, + int *sockp, u_int sendsz, u_int recvsz) { - CLIENT *h; - register struct ct_data *ct; - struct timeval now; - struct rpc_msg call_msg; - - h = (CLIENT *)mem_alloc(sizeof(*h)); - if (h == NULL) { - (void)fprintf(stderr, "clnttcp_create: out of memory\n"); - rpc_createerr.cf_stat = RPC_SYSTEMERROR; - rpc_createerr.cf_error.re_errno = errno; - goto fooy; - } - ct = (struct ct_data *)mem_alloc(sizeof(*ct)); - if (ct == NULL) { - (void)fprintf(stderr, "clnt