From a1a8064169aeda79e3266a2db9cce25e361a86dc Mon Sep 17 00:00:00 2001 From: Waldemar Brodkorb <wbx@openadk.org> Date: Mon, 20 Mar 2017 18:10:36 +0100 Subject: remove RPC implementation The included RPC implementation is ipv4 only. Other C library projects have either deprecated the internal RPC implementation (GNU C Library) or never implemented such functionality (musl C Library). The latest rpcbind release (0.2.4) checks for libtirpc and does not allow to be build with uClibc-ng RPC without patching. The common use case for RPC nowadays is to use rpcbind together with nfs-utils to provide NFS server or client support to a system. The included RPC implementation does create issues with duplicate symbol failures when statically compiling with RPC enabled. --- libc/inet/Makefile.in | 2 - libc/inet/rpc/.indent.pro | 33 -- libc/inet/rpc/Makefile | 13 - libc/inet/rpc/Makefile.in | 42 --- libc/inet/rpc/auth_none.c | 140 -------- libc/inet/rpc/auth_unix.c | 323 ------------------ libc/inet/rpc/authunix_prot.c | 67 ---- libc/inet/rpc/bindresvport.c | 87 ----- libc/inet/rpc/clnt_generic.c | 176 ---------- libc/inet/rpc/clnt_perror.c | 411 ----------------------- libc/inet/rpc/clnt_raw.c | 247 -------------- libc/inet/rpc/clnt_simple.c | 161 --------- libc/inet/rpc/clnt_tcp.c | 518 ----------------------------- libc/inet/rpc/clnt_udp.c | 600 ---------------------------------- libc/inet/rpc/clnt_unix.c | 586 --------------------------------- libc/inet/rpc/create_xid.c | 53 --- libc/inet/rpc/errqueue.h | 45 --- libc/inet/rpc/get_myaddress.c | 109 ------- libc/inet/rpc/getrpcent.c | 345 -------------------- libc/inet/rpc/getrpcport.c | 75 ----- libc/inet/rpc/pm_getmaps.c | 84 ----- libc/inet/rpc/pm_getport.c | 106 ------ libc/inet/rpc/pmap_clnt.c | 173 ---------- libc/inet/rpc/pmap_prot.c | 56 ---- libc/inet/rpc/pmap_prot2.c | 117 ------- libc/inet/rpc/pmap_rmt.c | 404 ----------------------- libc/inet/rpc/rcmd.c | 692 --------------------------------------- libc/inet/rpc/rexec.c | 193 ----------- libc/inet/rpc/rpc_cmsg.c | 205 ------------ libc/inet/rpc/rpc_commondata.c | 47 --- libc/inet/rpc/rpc_dtablesize.c | 52 --- libc/inet/rpc/rpc_private.h | 55 ---- libc/inet/rpc/rpc_prot.c | 282 ---------------- libc/inet/rpc/rpc_thread.c | 163 --------- libc/inet/rpc/rtime.c | 149 --------- libc/inet/rpc/ruserpass.c | 323 ------------------ libc/inet/rpc/sa_len.c | 64 ---- libc/inet/rpc/svc.c | 505 ---------------------------- libc/inet/rpc/svc_auth.c | 124 ------- libc/inet/rpc/svc_authux.c | 156 --------- libc/inet/rpc/svc_raw.c | 164 ---------- libc/inet/rpc/svc_run.c | 87 ----- libc/inet/rpc/svc_simple.c | 177 ---------- libc/inet/rpc/svc_tcp.c | 407 ----------------------- libc/inet/rpc/svc_udp.c | 567 -------------------------------- libc/inet/rpc/svc_unix.c | 517 ----------------------------- libc/inet/rpc/xdr.c | 726 ----------------------------------------- libc/inet/rpc/xdr_array.c | 156 --------- libc/inet/rpc/xdr_float.c | 131 -------- libc/inet/rpc/xdr_intXX_t.c | 204 ------------ libc/inet/rpc/xdr_mem.c | 235 ------------- libc/inet/rpc/xdr_rec.c | 628 ----------------------------------- libc/inet/rpc/xdr_reference.c | 131 -------- libc/inet/rpc/xdr_stdio.c | 184 ----------- 54 files changed, 12297 deletions(-) delete mode 100644 libc/inet/rpc/.indent.pro delete mode 100644 libc/inet/rpc/Makefile delete mode 100644 libc/inet/rpc/Makefile.in delete mode 100644 libc/inet/rpc/auth_none.c delete mode 100644 libc/inet/rpc/auth_unix.c delete mode 100644 libc/inet/rpc/authunix_prot.c delete mode 100644 libc/inet/rpc/bindresvport.c delete mode 100644 libc/inet/rpc/clnt_generic.c delete mode 100644 libc/inet/rpc/clnt_perror.c delete mode 100644 libc/inet/rpc/clnt_raw.c delete mode 100644 libc/inet/rpc/clnt_simple.c delete mode 100644 libc/inet/rpc/clnt_tcp.c delete mode 100644 libc/inet/rpc/clnt_udp.c delete mode 100644 libc/inet/rpc/clnt_unix.c delete mode 100644 libc/inet/rpc/create_xid.c delete mode 100644 libc/inet/rpc/errqueue.h delete mode 100644 libc/inet/rpc/get_myaddress.c delete mode 100644 libc/inet/rpc/getrpcent.c delete mode 100644 libc/inet/rpc/getrpcport.c delete mode 100644 libc/inet/rpc/pm_getmaps.c delete mode 100644 libc/inet/rpc/pm_getport.c delete mode 100644 libc/inet/rpc/pmap_clnt.c delete mode 100644 libc/inet/rpc/pmap_prot.c delete mode 100644 libc/inet/rpc/pmap_prot2.c delete mode 100644 libc/inet/rpc/pmap_rmt.c delete mode 100644 libc/inet/rpc/rcmd.c delete mode 100644 libc/inet/rpc/rexec.c delete mode 100644 libc/inet/rpc/rpc_cmsg.c delete mode 100644 libc/inet/rpc/rpc_commondata.c delete mode 100644 libc/inet/rpc/rpc_dtablesize.c delete mode 100644 libc/inet/rpc/rpc_private.h delete mode 100644 libc/inet/rpc/rpc_prot.c delete mode 100644 libc/inet/rpc/rpc_thread.c delete mode 100644 libc/inet/rpc/rtime.c delete mode 100644 libc/inet/rpc/ruserpass.c delete mode 100644 libc/inet/rpc/sa_len.c delete mode 100644 libc/inet/rpc/svc.c delete mode 100644 libc/inet/rpc/svc_auth.c delete mode 100644 libc/inet/rpc/svc_authux.c delete mode 100644 libc/inet/rpc/svc_raw.c delete mode 100644 libc/inet/rpc/svc_run.c delete mode 100644 libc/inet/rpc/svc_simple.c delete mode 100644 libc/inet/rpc/svc_tcp.c delete mode 100644 libc/inet/rpc/svc_udp.c delete mode 100644 libc/inet/rpc/svc_unix.c delete mode 100644 libc/inet/rpc/xdr.c delete mode 100644 libc/inet/rpc/xdr_array.c delete mode 100644 libc/inet/rpc/xdr_float.c delete mode 100644 libc/inet/rpc/xdr_intXX_t.c delete mode 100644 libc/inet/rpc/xdr_mem.c delete mode 100644 libc/inet/rpc/xdr_rec.c delete mode 100644 libc/inet/rpc/xdr_reference.c delete mode 100644 libc/inet/rpc/xdr_stdio.c (limited to 'libc/inet') diff --git a/libc/inet/Makefile.in b/libc/inet/Makefile.in index 3bfe4b29e..332e70e53 100644 --- a/libc/inet/Makefile.in +++ b/libc/inet/Makefile.in @@ -7,8 +7,6 @@ subdirs += libc/inet -include $(top_srcdir)libc/inet/rpc/Makefile.in - INET_DIR := $(top_srcdir)libc/inet INET_OUT := $(top_builddir)libc/inet V4_OR_V6 := $(findstring y,$(UCLIBC_HAS_IPV4)$(UCLIBC_HAS_IPV6)) diff --git a/libc/inet/rpc/.indent.pro b/libc/inet/rpc/.indent.pro deleted file mode 100644 index 492ecf1c7..000000000 --- a/libc/inet/rpc/.indent.pro +++ /dev/null @@ -1,33 +0,0 @@ ---blank-lines-after-declarations ---blank-lines-after-procedures ---break-before-boolean-operator ---no-blank-lines-after-commas ---braces-on-if-line ---braces-on-struct-decl-line ---comment-indentation25 ---declaration-comment-column25 ---no-comment-delimiters-on-blank-lines ---cuddle-else ---continuation-indentation4 ---case-indentation0 ---else-endif-column33 ---space-after-cast ---line-comments-indentation0 ---declaration-indentation1 ---dont-format-first-column-comments ---dont-format-comments ---honour-newlines ---indent-level4 -/* changed from 0 to 4 */ ---parameter-indentation4 ---line-length78 /* changed from 75 */ ---continue-at-parentheses ---no-space-after-function-call-names ---dont-break-procedure-type ---dont-star-comments ---leave-optional-blank-lines ---dont-space-special-semicolon ---tab-size4 -/* additions by Mark */ ---case-brace-indentation0 ---leave-preprocessor-space diff --git a/libc/inet/rpc/Makefile b/libc/inet/rpc/Makefile deleted file mode 100644 index 4a8f4a072..000000000 --- a/libc/inet/rpc/Makefile +++ /dev/null @@ -1,13 +0,0 @@ -# Makefile for uClibc -# -# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org> -# -# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. -# - -top_srcdir=../../../ -top_builddir=../../../ -all: objs -include $(top_builddir)Rules.mak -include Makefile.in -include $(top_srcdir)Makerules diff --git a/libc/inet/rpc/Makefile.in b/libc/inet/rpc/Makefile.in deleted file mode 100644 index 9abe85dc8..000000000 --- a/libc/inet/rpc/Makefile.in +++ /dev/null @@ -1,42 +0,0 @@ -# Makefile for uClibc -# -# Copyright (C) 2000-2008 Erik Andersen <andersen@uclibc.org> -# -# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. -# - -subdirs += libc/inet/rpc - -CFLAGS-y-libc/inet/rpc := -fno-strict-aliasing - -# For now, only compile the stuff needed to do an NFS mount.... -CSRC_NFS = authunix_prot.c auth_none.c auth_unix.c bindresvport.c \ - clnt_perror.c clnt_simple.c clnt_tcp.c clnt_udp.c \ - create_xid.c getrpcent.c \ - pmap_clnt.c pm_getmaps.c pm_getport.c pmap_prot.c pmap_prot2.c \ - rcmd.c rexec.c rpc_cmsg.c rpc_commondata.c rpc_dtablesize.c \ - rpc_prot.c rpc_thread.c rtime.c ruserpass.c sa_len.c \ - svc.c svc_auth.c svc_authux.c \ - xdr.c xdr_array.c xdr_mem.c xdr_rec.c xdr_reference.c - -INET_RPC_DIR:=$(top_srcdir)libc/inet/rpc -INET_RPC_OUT:=$(top_builddir)libc/inet/rpc - -CSRC_ALL = $(notdir $(wildcard $(INET_RPC_DIR)/*.c)) -CSRC-y := $(if $(UCLIBC_HAS_FULL_RPC),$(CSRC_ALL),$(CSRC_NFS)) -# rpc_thread.oS is better, because the header adds unneeded references -# to __pthread_internal_tsd* -CSRC-y := $(filter-out rpc_thread.c,$(CSRC-y)) - -INET_RPC_SRC:=$(patsubst %.c,$(INET_RPC_DIR)/%.c,$(CSRC-y)) -INET_RPC_OBJ:=$(patsubst %.c,$(INET_RPC_OUT)/%.o,$(CSRC-y)) - -libc-static-$(UCLIBC_HAS_RPC) += $(INET_RPC_OUT)/rpc_thread.o -libc-shared-$(UCLIBC_HAS_RPC) += $(INET_RPC_OUT)/rpc_thread.oS -libc-nomulti-$(UCLIBC_HAS_RPC) += $(INET_RPC_OUT)/rpc_thread.o -libc-$(UCLIBC_HAS_RPC) += $(INET_RPC_OBJ) - -objclean-y+=CLEAN_libc/inet/rpc - -CLEAN_libc/inet/rpc: - $(do_rm) $(addprefix $(INET_RPC_OUT)/*., o os oS) diff --git a/libc/inet/rpc/auth_none.c b/libc/inet/rpc/auth_none.c deleted file mode 100644 index 4bf37cb10..000000000 --- a/libc/inet/rpc/auth_none.c +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * 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 - */ -/* - * Copyright (C) 1984, Sun Microsystems, Inc. - */ -/* - * auth_none.c - * Creates a client authentication handle for passing "null" - * credentials and verifiers to remote systems. - */ - -#include "rpc_private.h" - - -#define MAX_MARSHAL_SIZE 20 - -/* - * Authenticator operations routines - */ -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 const struct auth_ops ops = { - authnone_verf, - authnone_marshal, - authnone_validate, - authnone_refresh, - authnone_destroy -}; - -/* Internal data and routines */ - -struct authnone_private_s { - AUTH no_client; - char marshalled_client[MAX_MARSHAL_SIZE]; - u_int mcnt; -}; - -static struct authnone_private_s authnone_private; -#ifdef __UCLIBC_HAS_THREADS__ -__libc_once_define(static, authnone_private_guard); -#endif - -static void authnone_create_once (void); - -static void -authnone_create_once (void) -{ - struct authnone_private_s *ap; - XDR xdr_stream; - XDR *xdrs; - - ap = &authnone_private; - - ap->no_client.ah_cred = ap->no_client.ah_verf = _null_auth; - ap->no_client.ah_ops = (struct auth_ops *) &ops; - xdrs = &xdr_stream; - xdrmem_create(xdrs, ap->marshalled_client, - (u_int) MAX_MARSHAL_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); -} - -AUTH * -authnone_create (void) -{ -#ifdef __UCLIBC_HAS_THREADS__ - __libc_once (authnone_private_guard, authnone_create_once); -#else - authnone_create_once(); -#endif - return &authnone_private.no_client; -} -libc_hidden_def(authnone_create) - -static bool_t -authnone_marshal (AUTH *client, XDR *xdrs) -{ - struct authnone_private_s *ap; - - /* authnone_create returned authnone_private->no_client, which is - the first field of struct authnone_private_s. */ - ap = (struct authnone_private_s *) client; - if (ap == NULL) - return FALSE; - return (*xdrs->x_ops->x_putbytes) (xdrs, ap->marshalled_client, ap->mcnt); -} - -static void -authnone_verf (AUTH *auth attribute_unused) -{ -} - -static bool_t -authnone_validate (AUTH *auth attribute_unused, struct opaque_auth *oa attribute_unused) -{ - return TRUE; -} - -static bool_t -authnone_refresh (AUTH *auth attribute_unused) -{ - return FALSE; -} - -static void -authnone_destroy (AUTH *auth attribute_unused) -{ -} diff --git a/libc/inet/rpc/auth_unix.c b/libc/inet/rpc/auth_unix.c deleted file mode 100644 index 86c5ce956..000000000 --- a/libc/inet/rpc/auth_unix.c +++ /dev/null @@ -1,323 +0,0 @@ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * 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 - */ -/* - * Copyright (C) 1984, Sun Microsystems, Inc. - */ -/* - * auth_unix.c, Implements UNIX style authentication parameters. - * - * The system is very weak. The client uses no encryption for it's - * credentials and only sends null verifiers. The server sends backs - * null verifiers or optionally a verifier that suggests a new short hand - * for the credentials. - */ - -#include <limits.h> -#include <stdio.h> -#include <string.h> -#include <unistd.h> -#include <sys/param.h> - -#include <rpc/types.h> -#include <rpc/xdr.h> -#include <rpc/auth.h> -#include <rpc/auth_unix.h> - -/* - * Unix authenticator operations vector - */ -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 const 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 */ -}; -#define AUTH_PRIVATE(auth) ((struct audata *)auth->ah_private) - -static bool_t marshal_new_auth (AUTH *) internal_function; - - -/* - * Create a unix style authenticator. - * Returns an auth handle with the given stuff in it. - */ -AUTH * -authunix_create (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; - AUTH *auth; - struct audata *au; - - /* - * Allocate and set up auth handle - */ - auth = (AUTH *) mem_alloc (sizeof (*auth)); - au = (struct audata *) mem_alloc (sizeof (*au)); - if (auth == NULL || au == NULL) - { -no_memory: - (void) fputs ("authunix_create: out of memory\n", stderr); - mem_free (auth, sizeof (*auth)); - mem_free (au, sizeof (*au)); - 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; - au->au_origcred.oa_base = mem_alloc ((u_int) len); - if (au->au_origcred.oa_base == NULL) - goto no_memory; - memcpy(au->au_origcred.oa_base, mymem, (u_int) len); - - /* - * set auth handle to reflect new cred. - */ - auth->ah_cred = au->au_origcred; - marshal_new_auth (auth); - return auth; -} -libc_hidden_def(authunix_create) - -/* - * Returns an auth handle with parameters determined by doing lots of - * syscalls. - */ -AUTH * -authunix_create_default (void) -{ - 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 = NULL; - AUTH *ret_auth; - - if (max_nr_groups) { - gids = (gid_t*)malloc(sizeof(*gids) * max_nr_groups); - if (gids == NULL) - abort (); - } - - 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. */ - ret_auth = authunix_create (machname, uid, gid, MIN (NGRPS, len), gids); - free (gids); - return ret_auth; -} -libc_hidden_def(authunix_create_default) - -/* - * authunix operations - */ - -static void -authunix_nextverf (AUTH *auth attribute_unused) -{ - /* no action necessary */ -} - -static bool_t -authunix_marshal (AUTH *auth, XDR *xdrs) -{ - struct audata *au = AUTH_PRIVATE (auth); - - return XDR_PUTBYTES (xdrs, au->au_marshed, au->au_mpos); -} - -static bool_t -authunix_validate (AUTH *auth, struct opaque_auth *verf) -{ - 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); - } - return TRUE; -} - -static bool_t -authunix_refresh (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; -} - -static void -authunix_destroy (AUTH *auth) -{ - struct audata *au = AUTH_PRIVATE (auth); - - 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); - - 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); - - mem_free ((caddr_t) auth, sizeof (*auth)); -} - -/* - * Marshals (pre-serializes) an auth struct. - * sets private data, au_marshed and au_mpos - */ -static bool_t -internal_function -marshal_new_auth (AUTH *auth) -{ - 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_unix.c - Fatal marshalling problem"); - else - au->au_mpos = XDR_GETPOS (xdrs); - - XDR_DESTROY (xdrs); - - return TRUE; -} diff --git a/libc/inet/rpc/authunix_prot.c b/libc/inet/rpc/authunix_prot.c deleted file mode 100644 index 272990056..000000000 --- a/libc/inet/rpc/authunix_prot.c +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * 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 - */ -/* - * Copyright (C) 1984, Sun Microsystems, Inc. - */ -/* - * authunix_prot.c - * XDR for UNIX style authentication parameters for RPC - */ - -#include <rpc/types.h> -#include <rpc/xdr.h> -#include <rpc/auth.h> -#include <rpc/auth_unix.h> - - -/* - * XDR for unix authentication parameters. - * Unfortunately, none of these can be declared const. - */ -bool_t -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) - ? (xdrproc_t) xdr_u_short : (xdrproc_t) xdr_u_int))) - { - return TRUE; - } - return FALSE; -} -libc_hidden_def(xdr_authunix_parms) diff --git a/libc/inet/rpc/bindresvport.c b/libc/inet/rpc/bindresvport.c deleted file mode 100644 index 30bbd2684..000000000 --- a/libc/inet/rpc/bindresvport.c +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * 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 - */ -/* - * Copyright (c) 1987 by Sun Microsystems, Inc. - */ - -#include <errno.h> -#include <unistd.h> -#include <string.h> -#include <sys/types.h> -#include <sys/socket.h> -#include <netinet/in.h> - - -/* - * Bind a socket to a privileged IP port - */ -int -bindresvport (int sd, struct sockaddr_in *sin) -{ - int res; - static short port; - struct sockaddr_in myaddr; - int i; - -#define STARTPORT 600 -#define ENDPORT (IPPORT_RESERVED - 1) -#define NPORTS (ENDPORT - STARTPORT + 1) - - if (sin == (struct sockaddr_in *) 0) - { - sin = &myaddr; - memset (sin, 0, 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, (struct sockaddr *)sin, sizeof(struct sockaddr_in)); - } - - return res; -} -libc_hidden_def(bindresvport) diff --git a/libc/inet/rpc/clnt_generic.c b/libc/inet/rpc/clnt_generic.c deleted file mode 100644 index f2d6c1295..000000000 --- a/libc/inet/rpc/clnt_generic.c +++ /dev/null @@ -1,176 +0,0 @@ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * 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 - */ -/* - * Copyright (C) 1987, Sun Microsystems, Inc. - */ - -#include <alloca.h> -#include <errno.h> -#include <string.h> -#include <rpc/rpc.h> -#include <sys/socket.h> -#include <netdb.h> - - -/* - * Generic client creation: takes (hostname, program-number, protocol) and - * returns client handle. Default options are set, which the user can - * change using the rpc equivalent of ioctl()'s. - */ -CLIENT * -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; - struct sockaddr_un sun; - int sock; - struct timeval tv; - CLIENT *client; - int herr; - - if (strcmp (proto, "unix") == 0) - { - memset ((char *)&sun, 0, sizeof (sun)); - sun.sun_family = AF_UNIX; - strcpy (sun.sun_path, hostname); - sock = RPC_ANYSOCK; - client = clntunix_create (&sun, prog, vers, &sock, 0, 0); - if (client == NULL) - return NULL; -#if 0 - /* This is not wanted. This would disable the user from having - a timeout in the clnt_call() call. Only a call to cnlt_control() - by the user should set the timeout value. */ - tv.tv_sec = 25; - tv.tv_usec = 0; - clnt_control (client, CLSET_TIMEOUT, (char *)&tv); -#endif - return client; - } - - hstbuflen = 1024; - hsttmpbuf = alloca (hstbuflen); - while (gethostbyname_r (hostname, &hostbuf, hsttmpbuf, hstbuflen, - &h, &herr) != 0 - || h == NULL) - if (herr != NETDB_INTERNAL || errno != ERANGE) - { - get_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 - */ - struct rpc_createerr *ce = &get_rpc_createerr (); - ce->cf_stat = RPC_SYSTEMERROR; - ce->cf_error.re_errno = EAFNOSUPPORT; - return NULL; - } - sin.sin_family = h->h_addrtype; - sin.sin_port = 0; - memset (sin.sin_zero, 0, sizeof (sin.sin_zero)); - memcpy ((char *) &sin.sin_addr, h->h_addr, h->h_length); - - prtbuflen = 1024; - prttmpbuf = alloca (prtbuflen); - while (getprotobyname_r (proto, &protobuf, prttmpbuf, prtbuflen, &p) != 0 - || p == NULL) - if (errno != ERANGE) - { - struct rpc_createerr *ce = &get_rpc_createerr (); - ce->cf_stat = RPC_UNKNOWNPROTO; - ce->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; - } -#if 0 - /* This is not wanted. This would disable the user from having - a timeout in the clnt_call() call. Only a call to cnlt_control() - by the user should set the timeout value. */ - tv.tv_sec = 25; - clnt_control (client, CLSET_TIMEOUT, (char *)&tv); -#endif - break; - case IPPROTO_TCP: - client = clnttcp_create (&sin, prog, vers, &sock, 0, 0); - if (client == NULL) - { - return NULL; - } -#if 0 - /* This is not wanted. This would disable the user from having - a timeout in the clnt_call() call. Only a call to cnlt_control() - by the user should set the timeout value. */ - tv.tv_sec = 25; - tv.tv_usec = 0; - clnt_control (client, CLSET_TIMEOUT, (char *)&tv); -#endif - break; - default: - { - struct rpc_createerr *ce = &get_rpc_createerr (); - ce->cf_stat = RPC_SYSTEMERROR; - ce->cf_error.re_errno = EPFNOSUPPORT; - } - return (NULL); - } - return client; -} diff --git a/libc/inet/rpc/clnt_perror.c b/libc/inet/rpc/clnt_perror.c deleted file mode 100644 index f34900d54..000000000 --- a/libc/inet/rpc/clnt_perror.c +++ /dev/null @@ -1,411 +0,0 @@ -/* @(#)clnt_perror.c 2.1 88/07/29 4.0 RPCSRC */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * 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 - */ -#if 0 -static char sccsid[] = "@(#)clnt_perror.c 1.15 87/10/07 Copyr 1984 Sun Micro"; -#endif - -/* - * clnt_perror.c - * - * Copyright (C) 1984, Sun Microsystems, Inc. - * - */ - -#include <stdio.h> -#include <string.h> -#include "rpc_private.h" - -static char *auth_errmsg (enum auth_stat stat) internal_function; - -#ifdef __UCLIBC_HAS_THREADS__ -/* - * Making buf a preprocessor macro requires renaming the local - * buf variable in a few functions. Overriding a global variable - * with a local variable of the same name is a bad idea, anyway. - */ -#define buf (*(char **)&RPC_THREAD_VARIABLE(clnt_perr_buf_s)) -#else -static char *buf; -#endif - -static char * -_buf (void) -{ - if (buf == NULL) - buf = (char *) malloc (256); - return buf; -} - -struct rpc_errtab -{ - enum clnt_stat status; - unsigned int message_off; -}; - -static const char rpc_errstr[] = -{ -#define RPC_SUCCESS_IDX 0 - "RPC: Success" - "\0" -#define RPC_CANTENCODEARGS_IDX (RPC_SUCCESS_IDX + sizeof "RPC: Success") - "RPC: Can't encode arguments" - "\0" -#define RPC_CANTDECODERES_IDX (RPC_CANTENCODEARGS_IDX \ - + sizeof "RPC: Can't encode arguments") - "RPC: Can't decode result" - "\0" -#define RPC_CANTSEND_IDX (RPC_CANTDECODERES_IDX \ - + sizeof "RPC: Can't decode result") - "RPC: Unable to send" - "\0" -#define RPC_CANTRECV_IDX (RPC_CANTSEND_IDX \ - + sizeof "RPC: Unable to send") - "RPC: Unable to receive" - "\0" -#define RPC_TIMEDOUT_IDX (RPC_CANTRECV_IDX \ - + sizeof "RPC: Unable to receive") - "RPC: Timed out" - "\0" -#define RPC_VERSMISMATCH_IDX (RPC_TIMEDOUT_IDX \ - + sizeof "RPC: Timed out") - "RPC: Incompatible versions of RPC" - "\0" -#define RPC_AUTHERROR_IDX (RPC_VERSMISMATCH_IDX \ - + sizeof "RPC: Incompatible versions of RPC") - "RPC: Authentication error" - "\0" -#define RPC_PROGUNAVAIL_IDX (RPC_AUTHERROR_IDX \ - + sizeof "RPC: Authentication error") - "RPC: Program unavailable" - "\0" -#define RPC_PROGVERSMISMATCH_IDX (RPC_PROGUNAVAIL_IDX \ - + sizeof "RPC: Program unavailable") - "RPC: Program/version mismatch" - "\0" -#define RPC_PROCUNAVAIL_IDX (RPC_PROGVERSMISMATCH_IDX \ - + sizeof "RPC: Program/version mismatch") - "RPC: Procedure unavailable" - "\0" -#define RPC_CANTDECODEARGS_IDX (RPC_PROCUNAVAIL_IDX \ - + sizeof "RPC: Procedure unavailable") - "RPC: Server can't decode arguments" - "\0" -#define RPC_SYSTEMERROR_IDX (RPC_CANTDECODEARGS_IDX \ - + sizeof "RPC: Server can't decode arguments") - "RPC: Remote system error" - "\0" -#define RPC_UNKNOWNHOST_IDX (RPC_SYSTEMERROR_IDX \ - + sizeof "RPC: Remote system error") - "RPC: Unknown host" - "\0" -#define RPC_UNKNOWNPROTO_IDX (RPC_UNKNOWNHOST_IDX \ - + sizeof "RPC: Unknown host") - "RPC: Unknown protocol" - "\0" -#define RPC_PMAPFAILURE_IDX (RPC_UNKNOWNPROTO_IDX \ - + sizeof "RPC: Unknown protocol") - "RPC: Port mapper failure" - "\0" -#define RPC_PROGNOTREGISTERED_IDX (RPC_PMAPFAILURE_IDX \ - + sizeof "RPC: Port mapper failure") - "RPC: Program not registered" - "\0" -#define RPC_FAILED_IDX (RPC_PROGNOTREGISTERED_IDX \ - + sizeof "RPC: Program not registered") - "RPC: Failed (unspecified error)" -}; - -static const struct rpc_errtab rpc_errlist[] = -{ - { RPC_SUCCESS, RPC_SUCCESS_IDX }, - { RPC_CANTENCODEARGS, RPC_CANTENCODEARGS_IDX }, - { RPC_CANTDECODERES, RPC_CANTDECODERES_IDX }, - { RPC_CANTSEND, RPC_CANTSEND_IDX }, - { RPC_CANTRECV, RPC_CANTRECV_IDX }, - { RPC_TIMEDOUT, RPC_TIMEDOUT_IDX }, - { RPC_VERSMISMATCH, RPC_VERSMISMATCH_IDX }, - { RPC_AUTHERROR, RPC_AUTHERROR_IDX }, - { RPC_PROGUNAVAIL, RPC_PROGUNAVAIL_IDX }, - { RPC_PROGVERSMISMATCH, RPC_PROGVERSMISMATCH_IDX }, - { RPC_PROCUNAVAIL, RPC_PROCUNAVAIL_IDX }, - { RPC_CANTDECODEARGS, RPC_CANTDECODEARGS_IDX }, - { RPC_SYSTEMERROR, RPC_SYSTEMERROR_IDX }, - { RPC_UNKNOWNHOST, RPC_UNKNOWNHOST_IDX }, - { RPC_UNKNOWNPROTO, RPC_UNKNOWNPROTO_IDX }, - { RPC_PMAPFAILURE, RPC_PMAPFAILURE_IDX }, - { RPC_PROGNOTREGISTERED, RPC_PROGNOTREGISTERED_IDX }, - { RPC_FAILED, RPC_FAILED_IDX } -}; - - -/* - * This interface for use by clntrpc - */ -char * -clnt_sperrno (enum clnt_stat stat) -{ - size_t i; - - for (i = 0; i < sizeof (rpc_errlist) / sizeof (struct rpc_errtab); i++) - { - if (rpc_errlist[i].status == stat) - { - return (char*)rpc_errstr + rpc_errlist[i].message_off; - } - } - return "RPC: (unknown error code)"; -} -libc_hidden_def(clnt_sperrno) - -void -clnt_perrno (enum clnt_stat num) -{ - (void) fputs (clnt_sperrno (num), stderr); -} - -/* - * Print reply error info - */ -char * -clnt_sperror (CLIENT * rpch, const char *msg) -{ - char chrbuf[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; - - (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: - __glibc_strerror_r (e.re_errno, chrbuf, sizeof chrbuf); - len = sprintf (str, "; errno = %s", chrbuf); - 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); - (void) strcpy(str, "; why = "); - str += strlen(str); - - if (err != NULL) - { - (void) strcpy(str, err); - str += strlen(str); - } - else - { - len = sprintf (str, "(unknown authentication error - %d)", - (int) e.re_why); - str += len; - } - 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'; - *++str = '\0'; - return (strstart); -} -libc_hidden_def(clnt_sperror) - -void -clnt_perror (CLIENT * rpch, const char *msg) -{ - (void) fputs (clnt_sperror (rpch, msg), stderr); -} -libc_hidden_def(clnt_perror) - -char * -clnt_spcreateerror (const char *msg) -{ - char chrbuf[1024]; - char *str = _buf (); - char *cp; - int len; - struct rpc_createerr *ce; - - if (str == NULL) - return NULL; - ce = &get_rpc_createerr (); - len = sprintf (str, "%s: ", msg); - cp = str + len; - (void) strcpy(cp, clnt_sperrno (ce->cf_stat)); - cp += strlen(cp); - - switch (ce->cf_stat) - { - case RPC_PMAPFAILURE: - (void) strcpy(cp, " - "); - cp += strlen(cp); - - (void) strcpy(cp, clnt_sperrno (ce->cf_error.re_status)); - cp += strlen(cp); - - break; - - case RPC_SYSTEMERROR: - (void) strcpy(cp, " - "); - cp += strlen(cp); - - __glibc_strerror_r (ce->cf_error.re_errno, chrbuf, sizeof chrbuf); - (void) strcpy(cp, chrbuf); - cp += strlen(cp); - break; - default: - break; - } - *cp = '\n'; - *++cp = '\0'; - return str; -} -libc_hidden_def(clnt_spcreateerror) - -void -clnt_pcreateerror (const char *msg) -{ - (void) fputs (clnt_spcreateerror (msg), stderr); -} - -struct auth_errtab -{ - enum auth_stat status; - unsigned int message_off; -}; - -static const char auth_errstr[] = -{ -#define AUTH_OK_IDX 0 - "Authentication OK" - "\0" -#define AUTH_BADCRED_IDX (AUTH_OK_IDX + sizeof "Authentication OK") - "Invalid client credential" - "\0" -#define AUTH_REJECTEDCRED_IDX (AUTH_BADCRED_IDX \ - + sizeof "Invalid client credential") - "Server rejected credential" - "\0" -#define AUTH_BADVERF_IDX (AUTH_REJECTEDCRED_IDX \ - + sizeof "Server rejected credential") - "Invalid client verifier" - "\0" -#define AUTH_REJECTEDVERF_IDX (AUTH_BADVERF_IDX \ - + sizeof "Invalid client verifier") - "Server rejected verifier" - "\0" -#define AUTH_TOOWEAK_IDX (AUTH_REJECTEDVERF_IDX \ - + sizeof "Server rejected verifier") - "Client credential too weak" - "\0" -#define AUTH_INVALIDRESP_IDX (AUTH_TOOWEAK_IDX \ - + sizeof "Client credential too weak") - "Invalid server verifier" - "\0" -#define AUTH_FAILED_IDX (AUTH_INVALIDRESP_IDX \ - + sizeof "Invalid server verifier") - "Failed (unspecified error)" -}; - -static const struct auth_errtab auth_errlist[] = -{ - { AUTH_OK, AUTH_OK_IDX }, - { AUTH_BADCRED, AUTH_BADCRED_IDX }, - { AUTH_REJECTEDCRED, AUTH_REJECTEDCRED_IDX }, - { AUTH_BADVERF, AUTH_BADVERF_IDX }, - { AUTH_REJECTEDVERF, AUTH_REJECTEDVERF_IDX }, - { AUTH_TOOWEAK, AUTH_TOOWEAK_IDX }, - { AUTH_INVALIDRESP, AUTH_INVALIDRESP_IDX }, - { AUTH_FAILED, AUTH_FAILED_IDX } -}; - -static char * -internal_function -auth_errmsg (enum auth_stat stat) -{ - size_t i; - - for (i = 0; i < sizeof (auth_errlist) / sizeof (struct auth_errtab); i++) - { - if (auth_errlist[i].status == stat) - { - return (char*)auth_errstr + auth_errlist[i].message_off; - } - } - return NULL; -} - - -static void __attribute_used__ -free_mem (void) -{ - free (buf); -} diff --git a/libc/inet/rpc/clnt_raw.c b/libc/inet/rpc/clnt_raw.c deleted file mode 100644 index 0d4efde21..000000000 --- a/libc/inet/rpc/clnt_raw.c +++ /dev/null @@ -1,247 +0,0 @@ -/* @(#)clnt_raw.c 2.2 88/08/01 4.0 RPCSRC */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * 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 - */ -#if 0 -static char sccsid[] = "@(#)clnt_raw.c 1.22 87/08/11 Copyr 1984 Sun Micro"; -#endif - -/* - * clnt_raw.c - * - * Copyright (C) 1984, Sun Microsystems, Inc. - * - * Memory based rpc for simple testing and timing. - * Interface to create an rpc client and server in the same process. - * This lets us simulate rpc and get round trip overhead, without - * any interference from the kernel. - */ - -#include <features.h> -#include "rpc_private.h" -#include <rpc/svc.h> -#include <rpc/xdr.h> - - -#define MCALL_MSG_SIZE 24 - -/* - * This is the "network" we will be moving stuff over. - */ -struct clntraw_private_s - { - CLIENT client_object; - XDR xdr_stream; - char _raw_buf[UDPMSGSIZE]; - char mashl_callmsg[MCALL_MSG_SIZE]; - u_int mcnt; - }; -#ifdef __UCLIBC_HAS_THREADS__ -#define clntraw_private (*(struct clntraw_private_s **)&RPC_THREAD_VARIABLE(clntraw_private_s)) -#else -static struct clntraw_private_s *clntraw_private; -#endif - -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 const struct clnt_ops client_ops = -{ - clntraw_call, - clntraw_abort, - clntraw_geterr, - clntraw_freeres, - clntraw_destroy, - clntraw_control -}; - -/* - * Create a client handle for memory based rpc. - */ -CLIENT * -clntraw_create (u_long prog, u_long vers) -{ - struct clntraw_private_s *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_s *) 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 (CLIENT *h, u_long proc, xdrproc_t xargs, caddr_t argsp, - xdrproc_t xresults, caddr_t resultsp, - struct timeval timeout attribute_unused) -{ - struct clntraw_private_s *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); - } - (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)); - } - } - - return status; -} - -static void -clntraw_geterr (CLIENT *cl attribute_unused, struct rpc_err *err attribute_unused) -{ -} - - -static bool_t -clntraw_freeres (CLIENT *cl attribute_unused, xdrproc_t xdr_res, caddr_t res_ptr) -{ - struct clntraw_private_s *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 (void) -{ -} - -static bool_t -clntraw_control (CLIENT *cl attribute_unused, int i attribute_unused, char *c attribute_unused) -{ - return FALSE; -} - -static void -clntraw_destroy (CLIENT *cl attribute_unused) -{ -} diff --git a/libc/inet/rpc/clnt_simple.c b/libc/inet/rpc/clnt_simple.c deleted file mode 100644 index d67e69527..000000000 --- a/libc/inet/rpc/clnt_simple.c +++ /dev/null @@ -1,161 +0,0 @@ -/* @(#)clnt_simple.c 2.2 88/08/01 4.0 RPCSRC */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * 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 - */ -#if 0 -static char sccsid[] = "@(#)clnt_simple.c 1.35 87/08/11 Copyr 1984 Sun Micro"; -#endif - -/* - * clnt_simple.c - * Simplified front end to rpc. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - */ - -#include <alloca.h> -#include <errno.h> -#include <stdio.h> -#include <unistd.h> -#include "rpc_private.h" -#include <sys/socket.h> -#include <netdb.h> -#include <string.h> - - -struct callrpc_private_s - { - CLIENT *client; - int socket; - u_long oldprognum, oldversnum, valid; - char *oldhost; - }; -#ifdef __UCLIBC_HAS_THREADS__ -#define callrpc_private (*(struct callrpc_private_s **)&RPC_THREAD_VARIABLE(callrpc_private_s)) -#else -static struct callrpc_private_s *callrpc_private; -#endif - -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) -{ - struct callrpc_private_s *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_s *) 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->client) - { - clnt_destroy (crp->client); - crp->client = NULL; - } - - buflen = 1024; - buffer = alloca (buflen); - while (gethostbyname_r (host, &hostbuf, buffer, buflen, - &hp, &herr) != 0 - || hp == NULL) - 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; - memcpy ((char *) &server_addr.sin_addr, hp->h_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) get_rpc_createerr().cf_stat; - crp->valid = 1; - crp->oldprognum = prognum; - crp->oldversnum = versnum; - (void) strncpy (crp->oldhost, host, 255); - crp->oldhost[255] = '\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; -} - -#ifdef __UCLIBC_HAS_THREADS__ -void attribute_hidden __rpc_thread_clnt_cleanup (void) -{ - struct callrpc_private_s *rcp = RPC_THREAD_VARIABLE(callrpc_private_s); - - if (rcp) { - if (rcp->client) - CLNT_DESTROY (rcp->client); - free (rcp); - } -} -#endif /* __UCLIBC_HAS_THREADS__ */ diff --git a/libc/inet/rpc/clnt_tcp.c b/libc/inet/rpc/clnt_tcp.c deleted file mode 100644 index 7046057ab..000000000 --- a/libc/inet/rpc/clnt_tcp.c +++ /dev/null @@ -1,518 +0,0 @@ -/* @(#)clnt_tcp.c 2.2 88/08/01 4.0 RPCSRC */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * 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 - */ -#if 0 -static char sccsid[] = "@(#)clnt_tcp.c 1.37 87/10/05 Copyr 1984 Sun Micro"; -#endif - -/* - * clnt_tcp.c, Implements a TCP/IP based, client side RPC. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - * - * TCP based RPC supports 'batched calls'. - * A sequence of calls may be batched-up in a send buffer. The rpc call - * return immediately to the client even though the call was not necessarily - * sent. The batching occurs if the results' xdr routine is NULL (0) AND - * the rpc timeout value is zero (see clnt.h, rpc). - * - * Clients should NOT casually batch calls that in fact return results; that is, - * the server side should be aware that a call is batched and not produce any - * return message. Batched calls that produce many result messages can - * deadlock (netlock) the client and the server.... - * - * Now go hang yourself. - */ - -#include <netdb.h> -#include <errno.h> -#include <stdio.h> -#include <unistd.h> -#include "rpc_private.h" -#include <sys/poll.h> -#include <sys/socket.h> -#include <rpc/pmap_clnt.h> - -#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; - }; - -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 const struct clnt_ops tcp_ops = -{ - clnttcp_call, - clnttcp_abort, - clnttcp_geterr, - clnttcp_freeres, - clnttcp_destroy, - clnttcp_control -}; - -/* - * Create a client handle for a tcp/ip connection. - * If *sockp<0, *sockp is set to a newly created TCP socket and it is - * connected to raddr. If *sockp non-negative then - * raddr is ignored. The rpc/tcp package does buffering - * similar to stdio, so the client must pick send and receive buffer sizes,]; - * 0 => use the default. - * If raddr->sin_port is 0, then a binder on the remote machine is - * consulted for the right port number. - * NB: *sockp is copied into a private area. - * NB: It is the clients responsibility to close *sockp. - * NB: The rpch->cl_auth is set null authentication. Caller may wish to set this - * something more useful. - */ -CLIENT * -clnttcp_create (struct sockaddr_in *raddr, u_long prog, u_long vers, - int *sockp, u_int sendsz, u_int recvsz) -{ - CLIENT *h; - struct ct_data *ct; - struct rpc_msg call_msg; - - h = (CLIENT *) mem_alloc (sizeof (*h)); - ct = (struct ct_data *) mem_alloc (sizeof (*ct)); - if (h == NULL || ct == NULL) - { - struct rpc_createerr *ce = &get_rpc_createerr (); - (void) fputs ("clnttcp_create: out of memory\n", stderr); - ce->cf_stat = RPC_SYSTEMERROR; - ce->cf_error.re_errno = ENOMEM; - goto fooy; - } - - /* - * If no port number given ask the pmap for one - */ - if (raddr->sin_port == 0) - { - u_short port; - if ((port = pmap_getport (raddr, prog, vers, IPPROTO_TCP)) == 0) - { - mem_free ((caddr_t) ct, sizeof (struct ct_data)); - mem_free ((caddr_t) h, sizeof (CLIENT)); - return ((CLIENT *) NULL); - } - raddr->sin_port = htons (port); - } - - /* - * If no socket given, open one - */ - if (*sockp < 0) - { - *sockp = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP); - (void) bindresvport (*sockp, (struct sockaddr_in *) 0); - if ((*sockp < 0) - || (connect (*sockp, (struct sockaddr *) raddr, - sizeof (*raddr)) < 0)) - { - struct rpc_createerr *ce = &get_rpc_createerr (); - ce->cf_stat = RPC_SYSTEMERROR; - ce->cf_error.re_errno = errno; - if (*sockp >= 0) - (void) close (*sockp); - goto fooy; - } - ct->ct_closeit = TRUE; - } - else - { - ct->ct_closeit = FALSE; - } - - /* - * Set up private data struct - */ - ct->ct_sock = *sockp; - ct->ct_wait.tv_usec = 0; - ct->ct_waitset = FALSE; - ct->ct_addr = *raddr; - - /* - * Initialize call message - */ - call_msg.rm_xid = _create_xid (); - 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; - - /* - * pre-serialize the static part of the call msg and stash it away - */ - xdrmem_create (&(ct->ct_xdrs), ct->ct_mcall, MCALL_MSG_SIZE, - XDR_ENCODE); - if (!xdr_callhdr (&(ct->ct_xdrs), &call_msg)) - { - if (ct->ct_closeit) - { - (void) close (*sockp); - } - goto fooy; - } - ct->ct_mpos = XDR_GETPOS (&(ct->ct_xdrs)); - XDR_DESTROY (&(ct->ct_xdrs)); - - /* - * Create a client handle which uses xdrrec for serialization - * and authnone for authentication. - */ - xdrrec_create (&(ct->ct_xdrs), sendsz, recvsz, - (caddr_t) ct, readtcp, writetcp); - h->cl_ops = &tcp_ops; - h->cl_private = (caddr_t) ct; - h->cl_auth = authnone_create (); - return h; - -fooy: - /* - * Something goofed, free stuff and barf - */ - mem_free ((caddr_t) ct, sizeof (struct ct_data)); - mem_free ((caddr_t) h, sizeof (CLIENT)); - return ((CLIENT *) NULL); -} -libc_hidden_def(clnttcp_create) - -static enum clnt_stat -clnttcp_call (CLIENT *h, u_long proc, xdrproc_t xdr_args, caddr_t args_ptr, - xdrproc_t xdr_results, caddr_t results_ptr, - struct timeval timeout) -{ - struct ct_data *ct = (struct ct_data *) h->cl_private; - XDR *xdrs = &(ct->ct_xdrs); - struct rpc_msg reply_msg; - u_long x_id; - u_int32_t *msg_x_id = (u_int32_t *) (ct->ct_mcall); /* yuk */ - bool_t shipnow; - int refreshes = 2; - - if (!ct->ct_waitset) - { - ct->ct_wait = timeout; - } - - shipnow = - (xdr_results == (xdrproc_t) 0 && ct->ct_wait.tv_sec == 0 - && ct->ct_wait.tv_usec == 0) ? FALSE : TRUE; - -call_again: - xdrs->x_op = XDR_ENCODE; - ct->ct_error.re_status = RPC_SUCCESS; - x_id = ntohl (--(*msg_x_id)); - if ((!XDR_PUTBYTES (xdrs, ct->ct_mcall, ct->ct_mpos)) || - (!XDR_PUTLONG (xdrs, (long *) &proc)) || - (!AUTH_MARSHALL (h->cl_auth, xdrs)) || - (!(*xdr_args) (xdrs, args_ptr))) - { - if (ct->ct_error.re_status == RPC_SUCCESS) - ct->ct_error.re_status = RPC_CANTENCODEARGS; - (void) xdrrec_endofrecord (xdrs, TRUE); - return (ct->ct_error.re_status); - } - if (!xdrrec_endofrecord (xdrs, shipnow)) - return ct->ct_error.re_status = RPC_CANTSEND; - if (!shipnow) - return RPC_SUCCESS; - /* - * Hack to provide rpc-based message passing - */ - if (ct->ct_wait.tv_sec == 0 && ct->ct_wait.tv_usec == 0) - { - return ct->ct_error.re_status = RPC_TIMEDOUT; - } - - - /* - * Keep receiving until we get a valid transaction id - */ - xdrs->x_op = XDR_DECODE; - while (TRUE) - { - reply_msg.acpted_rply.ar_verf = _null_auth; - reply_msg.acpted_rply.ar_results.where = NULL; - reply_msg.acpted_rply.ar_results.proc = (xdrproc_t)xdr_void; - if (!xdrrec_skiprecord (xdrs)) - return (ct->ct_error.re_statu