From cc479c5abf86e0014cf6bc3492bbf53a47f503fc Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Mon, 23 Jan 2006 23:22:10 +0000 Subject: sync with glibc --- libc/inet/rpc/Makefile.in | 4 +- libc/inet/rpc/auth_none.c | 13 +-- libc/inet/rpc/rpc_callmsg.c | 215 ------------------------------------------ libc/inet/rpc/rpc_cmsg.c | 215 ++++++++++++++++++++++++++++++++++++++++++ libc/inet/rpc/svc_auth_unix.c | 161 ------------------------------- libc/inet/rpc/svc_authux.c | 161 +++++++++++++++++++++++++++++++ libc/inet/rpc/xdr_mem.c | 30 +++--- libc/inet/rpc/xdr_rec.c | 4 +- libc/inet/rpc/xdr_stdio.c | 16 ++-- 9 files changed, 413 insertions(+), 406 deletions(-) delete mode 100644 libc/inet/rpc/rpc_callmsg.c create mode 100644 libc/inet/rpc/rpc_cmsg.c delete mode 100644 libc/inet/rpc/svc_auth_unix.c create mode 100644 libc/inet/rpc/svc_authux.c (limited to 'libc/inet/rpc') diff --git a/libc/inet/rpc/Makefile.in b/libc/inet/rpc/Makefile.in index 9bfa781d6..0b766f2b6 100644 --- a/libc/inet/rpc/Makefile.in +++ b/libc/inet/rpc/Makefile.in @@ -11,8 +11,8 @@ CSRC:= auth_none.c auth_unix.c authunix_prot.c bindresvport.c \ clnt_generic.c clnt_perror.c clnt_raw.c clnt_simple.c clnt_tcp.c \ clnt_udp.c rpc_dtablesize.c get_myaddress.c getrpcent.c getrpcport.c \ pmap_clnt.c pmap_getmaps.c pmap_getport.c pmap_prot.c \ - pmap_prot2.c pmap_rmt.c rpc_prot.c rpc_commondata.c rpc_callmsg.c \ - svc.c svc_auth.c svc_auth_unix.c svc_raw.c svc_run.c svc_simple.c \ + pmap_prot2.c pmap_rmt.c rpc_prot.c rpc_commondata.c rpc_cmsg.c \ + svc.c svc_auth.c svc_authux.c svc_raw.c svc_run.c svc_simple.c \ svc_tcp.c svc_udp.c xdr.c xdr_array.c xdr_float.c xdr_mem.c \ xdr_rec.c xdr_reference.c xdr_stdio.c \ rtime.c clnt_unix.c svc_unix.c create_xid.c xdr_intXX_t.c rcmd.c \ diff --git a/libc/inet/rpc/auth_none.c b/libc/inet/rpc/auth_none.c index e69dc2233..05851025f 100644 --- a/libc/inet/rpc/auth_none.c +++ b/libc/inet/rpc/auth_none.c @@ -42,7 +42,7 @@ libc_hidden_proto(xdrmem_create) libc_hidden_proto(xdr_opaque_auth) -#define MAX_MARSHEL_SIZE 20 +#define MAX_MARSHAL_SIZE 20 /* * Authenticator operations routines @@ -53,7 +53,7 @@ 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 = { +static const struct auth_ops ops = { authnone_verf, authnone_marshal, authnone_validate, @@ -61,9 +61,11 @@ static struct auth_ops ops = { authnone_destroy }; +/* Internal data and routines */ + struct authnone_private_s { AUTH no_client; - char marshalled_client[MAX_MARSHEL_SIZE]; + char marshalled_client[MAX_MARSHAL_SIZE]; u_int mcnt; }; #ifdef __UCLIBC_HAS_THREADS__ @@ -91,9 +93,9 @@ authnone_create (void) if (!ap->mcnt) { ap->no_client.ah_cred = ap->no_client.ah_verf = _null_auth; - ap->no_client.ah_ops = &ops; + ap->no_client.ah_ops = (struct auth_ops *)&ops; xdrs = &xdr_stream; - xdrmem_create (xdrs, ap->marshalled_client, (u_int) MAX_MARSHEL_SIZE, + 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); @@ -104,7 +106,6 @@ authnone_create (void) } libc_hidden_def(authnone_create) -/*ARGSUSED */ static bool_t authnone_marshal (AUTH *client attribute_unused, XDR *xdrs) { diff --git a/libc/inet/rpc/rpc_callmsg.c b/libc/inet/rpc/rpc_callmsg.c deleted file mode 100644 index b47a67c71..000000000 --- a/libc/inet/rpc/rpc_callmsg.c +++ /dev/null @@ -1,215 +0,0 @@ -/* @(#)rpc_callmsg.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[] = "@(#)rpc_callmsg.c 1.4 87/08/11 Copyr 1984 Sun Micro"; -#endif - -/* - * rpc_callmsg.c - * - * Copyright (C) 1984, Sun Microsystems, Inc. - * - */ - -#define __FORCE_GLIBC -#include - -#include -#include -#include - -libc_hidden_proto(memcpy) -libc_hidden_proto(xdr_enum) -libc_hidden_proto(xdr_opaque) -libc_hidden_proto(xdr_u_int) -libc_hidden_proto(xdr_u_long) -libc_hidden_proto(xdr_opaque_auth) - -/* - * XDR a call message - */ -libc_hidden_proto(xdr_callmsg) -bool_t -xdr_callmsg (XDR *xdrs, struct rpc_msg *cmsg) -{ - int32_t *buf; - struct opaque_auth *oa; - - if (xdrs->x_op == XDR_ENCODE) - { - if (cmsg->rm_call.cb_cred.oa_length > MAX_AUTH_BYTES) - { - return (FALSE); - } - if (cmsg->rm_call.cb_verf.oa_length > MAX_AUTH_BYTES) - { - return (FALSE); - } - buf = XDR_INLINE (xdrs, 8 * BYTES_PER_XDR_UNIT - + RNDUP (cmsg->rm_call.cb_cred.oa_length) - + 2 * BYTES_PER_XDR_UNIT - + RNDUP (cmsg->rm_call.cb_verf.oa_length)); - if (buf != NULL) - { - IXDR_PUT_LONG (buf, cmsg->rm_xid); - IXDR_PUT_ENUM (buf, cmsg->rm_direction); - if (cmsg->rm_direction != CALL) - return FALSE; - IXDR_PUT_LONG (buf, cmsg->rm_call.cb_rpcvers); - if (cmsg->rm_call.cb_rpcvers != RPC_MSG_VERSION) - return FALSE; - IXDR_PUT_LONG (buf, cmsg->rm_call.cb_prog); - IXDR_PUT_LONG (buf, cmsg->rm_call.cb_vers); - IXDR_PUT_LONG (buf, cmsg->rm_call.cb_proc); - oa = &cmsg->rm_call.cb_cred; - IXDR_PUT_ENUM (buf, oa->oa_flavor); - IXDR_PUT_INT32 (buf, oa->oa_length); - if (oa->oa_length) - { - memcpy ((caddr_t) buf, oa->oa_base, oa->oa_length); - buf = (int32_t *) ((char *) buf + RNDUP (oa->oa_length)); - } - oa = &cmsg->rm_call.cb_verf; - IXDR_PUT_ENUM (buf, oa->oa_flavor); - IXDR_PUT_INT32 (buf, oa->oa_length); - if (oa->oa_length) - { - memcpy ((caddr_t) buf, oa->oa_base, oa->oa_length); - /* no real need.... - buf = (long *) ((char *) buf + RNDUP(oa->oa_length)); - */ - } - return TRUE; - } - } - if (xdrs->x_op == XDR_DECODE) - { - buf = XDR_INLINE (xdrs, 8 * BYTES_PER_XDR_UNIT); - if (buf != NULL) - { - cmsg->rm_xid = IXDR_GET_LONG (buf); - cmsg->rm_direction = IXDR_GET_ENUM (buf, enum msg_type); - if (cmsg->rm_direction != CALL) - { - return FALSE; - } - cmsg->rm_call.cb_rpcvers = IXDR_GET_LONG (buf); - if (cmsg->rm_call.cb_rpcvers != RPC_MSG_VERSION) - { - return FALSE; - } - cmsg->rm_call.cb_prog = IXDR_GET_LONG (buf); - cmsg->rm_call.cb_vers = IXDR_GET_LONG (buf); - cmsg->rm_call.cb_proc = IXDR_GET_LONG (buf); - oa = &cmsg->rm_call.cb_cred; - oa->oa_flavor = IXDR_GET_ENUM (buf, enum_t); - oa->oa_length = IXDR_GET_INT32 (buf); - if (oa->oa_length) - { - if (oa->oa_length > MAX_AUTH_BYTES) - return FALSE; - if (oa->oa_base == NULL) - { - oa->oa_base = (caddr_t) - mem_alloc (oa->oa_length); - } - buf = XDR_INLINE (xdrs, RNDUP (oa->oa_length)); - if (buf == NULL) - { - if (xdr_opaque (xdrs, oa->oa_base, - oa->oa_length) == FALSE) - return FALSE; - } - else - { - memcpy (oa->oa_base, (caddr_t) buf, oa->oa_length); - /* no real need.... - buf = (long *) ((char *) buf - + RNDUP(oa->oa_length)); - */ - } - } - oa = &cmsg->rm_call.cb_verf; - buf = XDR_INLINE (xdrs, 2 * BYTES_PER_XDR_UNIT); - if (buf == NULL) - { - if (xdr_enum (xdrs, &oa->oa_flavor) == FALSE || - xdr_u_int (xdrs, &oa->oa_length) == FALSE) - { - return FALSE; - } - } - else - { - oa->oa_flavor = IXDR_GET_ENUM (buf, enum_t); - oa->oa_length = IXDR_GET_INT32 (buf); - } - if (oa->oa_length) - { - if (oa->oa_length > MAX_AUTH_BYTES) - return FALSE; - if (oa->oa_base == NULL) - { - oa->oa_base = (caddr_t) - mem_alloc (oa->oa_length); - } - buf = XDR_INLINE (xdrs, RNDUP (oa->oa_length)); - if (buf == NULL) - { - if (xdr_opaque (xdrs, oa->oa_base, - oa->oa_length) == FALSE) - return FALSE; - } - else - { - memcpy (oa->oa_base, (caddr_t) buf, oa->oa_length); - /* no real need... - buf = (long *) ((char *) buf - + RNDUP(oa->oa_length)); - */ - } - } - return TRUE; - } - } - if ( - xdr_u_long (xdrs, &(cmsg->rm_xid)) && - xdr_enum (xdrs, (enum_t *) & (cmsg->rm_direction)) && - (cmsg->rm_direction == CALL) && - xdr_u_long (xdrs, &(cmsg->rm_call.cb_rpcvers)) && - (cmsg->rm_call.cb_rpcvers == RPC_MSG_VERSION) && - xdr_u_long (xdrs, &(cmsg->rm_call.cb_prog)) && - xdr_u_long (xdrs, &(cmsg->rm_call.cb_vers)) && - xdr_u_long (xdrs, &(cmsg->rm_call.cb_proc)) && - xdr_opaque_auth (xdrs, &(cmsg->rm_call.cb_cred))) - return xdr_opaque_auth (xdrs, &(cmsg->rm_call.cb_verf)); - return FALSE; -} -libc_hidden_def(xdr_callmsg) diff --git a/libc/inet/rpc/rpc_cmsg.c b/libc/inet/rpc/rpc_cmsg.c new file mode 100644 index 000000000..b47a67c71 --- /dev/null +++ b/libc/inet/rpc/rpc_cmsg.c @@ -0,0 +1,215 @@ +/* @(#)rpc_callmsg.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[] = "@(#)rpc_callmsg.c 1.4 87/08/11 Copyr 1984 Sun Micro"; +#endif + +/* + * rpc_callmsg.c + * + * Copyright (C) 1984, Sun Microsystems, Inc. + * + */ + +#define __FORCE_GLIBC +#include + +#include +#include +#include + +libc_hidden_proto(memcpy) +libc_hidden_proto(xdr_enum) +libc_hidden_proto(xdr_opaque) +libc_hidden_proto(xdr_u_int) +libc_hidden_proto(xdr_u_long) +libc_hidden_proto(xdr_opaque_auth) + +/* + * XDR a call message + */ +libc_hidden_proto(xdr_callmsg) +bool_t +xdr_callmsg (XDR *xdrs, struct rpc_msg *cmsg) +{ + int32_t *buf; + struct opaque_auth *oa; + + if (xdrs->x_op == XDR_ENCODE) + { + if (cmsg->rm_call.cb_cred.oa_length > MAX_AUTH_BYTES) + { + return (FALSE); + } + if (cmsg->rm_call.cb_verf.oa_length > MAX_AUTH_BYTES) + { + return (FALSE); + } + buf = XDR_INLINE (xdrs, 8 * BYTES_PER_XDR_UNIT + + RNDUP (cmsg->rm_call.cb_cred.oa_length) + + 2 * BYTES_PER_XDR_UNIT + + RNDUP (cmsg->rm_call.cb_verf.oa_length)); + if (buf != NULL) + { + IXDR_PUT_LONG (buf, cmsg->rm_xid); + IXDR_PUT_ENUM (buf, cmsg->rm_direction); + if (cmsg->rm_direction != CALL) + return FALSE; + IXDR_PUT_LONG (buf, cmsg->rm_call.cb_rpcvers); + if (cmsg->rm_call.cb_rpcvers != RPC_MSG_VERSION) + return FALSE; + IXDR_PUT_LONG (buf, cmsg->rm_call.cb_prog); + IXDR_PUT_LONG (buf, cmsg->rm_call.cb_vers); + IXDR_PUT_LONG (buf, cmsg->rm_call.cb_proc); + oa = &cmsg->rm_call.cb_cred; + IXDR_PUT_ENUM (buf, oa->oa_flavor); + IXDR_PUT_INT32 (buf, oa->oa_length); + if (oa->oa_length) + { + memcpy ((caddr_t) buf, oa->oa_base, oa->oa_length); + buf = (int32_t *) ((char *) buf + RNDUP (oa->oa_length)); + } + oa = &cmsg->rm_call.cb_verf; + IXDR_PUT_ENUM (buf, oa->oa_flavor); + IXDR_PUT_INT32 (buf, oa->oa_length); + if (oa->oa_length) + { + memcpy ((caddr_t) buf, oa->oa_base, oa->oa_length); + /* no real need.... + buf = (long *) ((char *) buf + RNDUP(oa->oa_length)); + */ + } + return TRUE; + } + } + if (xdrs->x_op == XDR_DECODE) + { + buf = XDR_INLINE (xdrs, 8 * BYTES_PER_XDR_UNIT); + if (buf != NULL) + { + cmsg->rm_xid = IXDR_GET_LONG (buf); + cmsg->rm_direction = IXDR_GET_ENUM (buf, enum msg_type); + if (cmsg->rm_direction != CALL) + { + return FALSE; + } + cmsg->rm_call.cb_rpcvers = IXDR_GET_LONG (buf); + if (cmsg->rm_call.cb_rpcvers != RPC_MSG_VERSION) + { + return FALSE; + } + cmsg->rm_call.cb_prog = IXDR_GET_LONG (buf); + cmsg->rm_call.cb_vers = IXDR_GET_LONG (buf); + cmsg->rm_call.cb_proc = IXDR_GET_LONG (buf); + oa = &cmsg->rm_call.cb_cred; + oa->oa_flavor = IXDR_GET_ENUM (buf, enum_t); + oa->oa_length = IXDR_GET_INT32 (buf); + if (oa->oa_length) + { + if (oa->oa_length > MAX_AUTH_BYTES) + return FALSE; + if (oa->oa_base == NULL) + { + oa->oa_base = (caddr_t) + mem_alloc (oa->oa_length); + } + buf = XDR_INLINE (xdrs, RNDUP (oa->oa_length)); + if (buf == NULL) + { + if (xdr_opaque (xdrs, oa->oa_base, + oa->oa_length) == FALSE) + return FALSE; + } + else + { + memcpy (oa->oa_base, (caddr_t) buf, oa->oa_length); + /* no real need.... + buf = (long *) ((char *) buf + + RNDUP(oa->oa_length)); + */ + } + } + oa = &cmsg->rm_call.cb_verf; + buf = XDR_INLINE (xdrs, 2 * BYTES_PER_XDR_UNIT); + if (buf == NULL) + { + if (xdr_enum (xdrs, &oa->oa_flavor) == FALSE || + xdr_u_int (xdrs, &oa->oa_length) == FALSE) + { + return FALSE; + } + } + else + { + oa->oa_flavor = IXDR_GET_ENUM (buf, enum_t); + oa->oa_length = IXDR_GET_INT32 (buf); + } + if (oa->oa_length) + { + if (oa->oa_length > MAX_AUTH_BYTES) + return FALSE; + if (oa->oa_base == NULL) + { + oa->oa_base = (caddr_t) + mem_alloc (oa->oa_length); + } + buf = XDR_INLINE (xdrs, RNDUP (oa->oa_length)); + if (buf == NULL) + { + if (xdr_opaque (xdrs, oa->oa_base, + oa->oa_length) == FALSE) + return FALSE; + } + else + { + memcpy (oa->oa_base, (caddr_t) buf, oa->oa_length); + /* no real need... + buf = (long *) ((char *) buf + + RNDUP(oa->oa_length)); + */ + } + } + return TRUE; + } + } + if ( + xdr_u_long (xdrs, &(cmsg->rm_xid)) && + xdr_enum (xdrs, (enum_t *) & (cmsg->rm_direction)) && + (cmsg->rm_direction == CALL) && + xdr_u_long (xdrs, &(cmsg->rm_call.cb_rpcvers)) && + (cmsg->rm_call.cb_rpcvers == RPC_MSG_VERSION) && + xdr_u_long (xdrs, &(cmsg->rm_call.cb_prog)) && + xdr_u_long (xdrs, &(cmsg->rm_call.cb_vers)) && + xdr_u_long (xdrs, &(cmsg->rm_call.cb_proc)) && + xdr_opaque_auth (xdrs, &(cmsg->rm_call.cb_cred))) + return xdr_opaque_auth (xdrs, &(cmsg->rm_call.cb_verf)); + return FALSE; +} +libc_hidden_def(xdr_callmsg) diff --git a/libc/inet/rpc/svc_auth_unix.c b/libc/inet/rpc/svc_auth_unix.c deleted file mode 100644 index 3afcfc5d4..000000000 --- a/libc/inet/rpc/svc_auth_unix.c +++ /dev/null @@ -1,161 +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 - */ - -/* - * svc_auth_unix.c - * Handles UNIX flavor authentication parameters on the service side of rpc. - * There are two svc auth implementations here: AUTH_UNIX and AUTH_SHORT. - * _svcauth_unix does full blown unix style uid,gid+gids auth, - * _svcauth_short uses a shorthand auth to index into a cache of longhand auths. - * Note: the shorthand has been gutted for efficiency. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - */ - -#define __FORCE_GLIBC -#include - -#include -#include -#include -#include - -libc_hidden_proto(memcpy) -libc_hidden_proto(printf) -libc_hidden_proto(xdrmem_create) -libc_hidden_proto(xdr_authunix_parms) - -/* - * Unix longhand authenticator - */ -attribute_hidden -enum auth_stat -_svcauth_unix (struct svc_req *rqst, struct rpc_msg *msg) -{ - enum auth_stat stat; - XDR xdrs; - struct authunix_parms *aup; - int32_t *buf; - struct area - { - struct authunix_parms area_aup; - char area_machname[MAX_MACHINE_NAME + 1]; - gid_t area_gids[NGRPS]; - } - *area; - u_int auth_len; - u_int str_len, gid_len; - u_int i; - - area = (struct area *) rqst->rq_clntcred; - aup = &area->area_aup; - aup->aup_machname = area->area_machname; - aup->aup_gids = area->area_gids; - auth_len = (u_int) msg->rm_call.cb_cred.oa_length; - xdrmem_create (&xdrs, msg->rm_call.cb_cred.oa_base, auth_len, XDR_DECODE); - buf = XDR_INLINE (&xdrs, auth_len); - if (buf != NULL) - { - aup->aup_time = IXDR_GET_LONG (buf); - str_len = IXDR_GET_U_INT32 (buf); - if (str_len > MAX_MACHINE_NAME) - { - stat = AUTH_BADCRED; - goto done; - } - memcpy (aup->aup_machname, (caddr_t) buf, (u_int) str_len); - aup->aup_machname[str_len] = 0; - str_len = RNDUP (str_len); - buf = (int32_t *) ((char *) buf + str_len); - aup->aup_uid = IXDR_GET_LONG (buf); - aup->aup_gid = IXDR_GET_LONG (buf); - gid_len = IXDR_GET_U_INT32 (buf); - if (gid_len > NGRPS) - { - stat = AUTH_BADCRED; - goto done; - } - aup->aup_len = gid_len; - for (i = 0; i < gid_len; i++) - { - aup->aup_gids[i] = IXDR_GET_LONG (buf); - } - /* - * five is the smallest unix credentials structure - - * timestamp, hostname len (0), uid, gid, and gids len (0). - */ - if ((5 + gid_len) * BYTES_PER_XDR_UNIT + str_len > auth_len) - { - (void) printf ("bad auth_len gid %d str %d auth %d\n", - gid_len, str_len, auth_len); - stat = AUTH_BADCRED; - goto done; - } - } - else if (!xdr_authunix_parms (&xdrs, aup)) - { - xdrs.x_op = XDR_FREE; - (void) xdr_authunix_parms (&xdrs, aup); - stat = AUTH_BADCRED; - goto done; - } - - /* get the verifier */ - if ((u_int)msg->rm_call.cb_verf.oa_length) - { - rqst->rq_xprt->xp_verf.oa_flavor = - msg->rm_call.cb_verf.oa_flavor; - rqst->rq_xprt->xp_verf.oa_base = - msg->rm_call.cb_verf.oa_base; - rqst->rq_xprt->xp_verf.oa_length = - msg->rm_call.cb_verf.oa_length; - } - else - { - rqst->rq_xprt->xp_verf.oa_flavor = AUTH_NULL; - rqst->rq_xprt->xp_verf.oa_length = 0; - } - stat = AUTH_OK; -done: - XDR_DESTROY (&xdrs); - return stat; -} - - -/* - * Shorthand unix authenticator - * Looks up longhand in a cache. - */ -/*ARGSUSED */ -attribute_hidden -enum auth_stat -_svcauth_short (struct svc_req *rqst attribute_unused, struct rpc_msg *msg attribute_unused) -{ - return AUTH_REJECTEDCRED; -} diff --git a/libc/inet/rpc/svc_authux.c b/libc/inet/rpc/svc_authux.c new file mode 100644 index 000000000..3afcfc5d4 --- /dev/null +++ b/libc/inet/rpc/svc_authux.c @@ -0,0 +1,161 @@ +/* + * 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 + */ + +/* + * svc_auth_unix.c + * Handles UNIX flavor authentication parameters on the service side of rpc. + * There are two svc auth implementations here: AUTH_UNIX and AUTH_SHORT. + * _svcauth_unix does full blown unix style uid,gid+gids auth, + * _svcauth_short uses a shorthand auth to index into a cache of longhand auths. + * Note: the shorthand has been gutted for efficiency. + * + * Copyright (C) 1984, Sun Microsystems, Inc. + */ + +#define __FORCE_GLIBC +#include + +#include +#include +#include +#include + +libc_hidden_proto(memcpy) +libc_hidden_proto(printf) +libc_hidden_proto(xdrmem_create) +libc_hidden_proto(xdr_authunix_parms) + +/* + * Unix longhand authenticator + */ +attribute_hidden +enum auth_stat +_svcauth_unix (struct svc_req *rqst, struct rpc_msg *msg) +{ + enum auth_stat stat; + XDR xdrs; + struct authunix_parms *aup; + int32_t *buf; + struct area + { + struct authunix_parms area_aup; + char area_machname[MAX_MACHINE_NAME + 1]; + gid_t area_gids[NGRPS]; + } + *area; + u_int auth_len; + u_int str_len, gid_len; + u_int i; + + area = (struct area *) rqst->rq_clntcred; + aup = &area->area_aup; + aup->aup_machname = area->area_machname; + aup->aup_gids = area->area_gids; + auth_len = (u_int) msg->rm_call.cb_cred.oa_length; + xdrmem_create (&xdrs, msg->rm_call.cb_cred.oa_base, auth_len, XDR_DECODE); + buf = XDR_INLINE (&xdrs, auth_len); + if (buf != NULL) + { + aup->aup_time = IXDR_GET_LONG (buf); + str_len = IXDR_GET_U_INT32 (buf); + if (str_len > MAX_MACHINE_NAME) + { + stat = AUTH_BADCRED; + goto done; + } + memcpy (aup->aup_machname, (caddr_t) buf, (u_int) str_len); + aup->aup_machname[str_len] = 0; + str_len = RNDUP (str_len); + buf = (int32_t *) ((char *) buf + str_len); + aup->aup_uid = IXDR_GET_LONG (buf); + aup->aup_gid = IXDR_GET_LONG (buf); + gid_len = IXDR_GET_U_INT32 (buf); + if (gid_len > NGRPS) + { + stat = AUTH_BADCRED; + goto done; + } + aup->aup_len = gid_len; + for (i = 0; i < gid_len; i++) + { + aup->aup_gids[i] = IXDR_GET_LONG (buf); + } + /* + * five is the smallest unix credentials structure - + * timestamp, hostname len (0), uid, gid, and gids len (0). + */ + if ((5 + gid_len) * BYTES_PER_XDR_UNIT + str_len > auth_len) + { + (void) printf ("bad auth_len gid %d str %d auth %d\n", + gid_len, str_len, auth_len); + stat = AUTH_BADCRED; + goto done; + } + } + else if (!xdr_authunix_parms (&xdrs, aup)) + { + xdrs.x_op = XDR_FREE; + (void) xdr_authunix_parms (&xdrs, aup); + stat = AUTH_BADCRED; + goto done; + } + + /* get the verifier */ + if ((u_int)msg->rm_call.cb_verf.oa_length) + { + rqst->rq_xprt->xp_verf.oa_flavor = + msg->rm_call.cb_verf.oa_flavor; + rqst->rq_xprt->xp_verf.oa_base = + msg->rm_call.cb_verf.oa_base; + rqst->rq_xprt->xp_verf.oa_length = + msg->rm_call.cb_verf.oa_length; + } + else + { + rqst->rq_xprt->xp_verf.oa_flavor = AUTH_NULL; + rqst->rq_xprt->xp_verf.oa_length = 0; + } + stat = AUTH_OK; +done: + XDR_DESTROY (&xdrs); + return stat; +} + + +/* + * Shorthand unix authenticator + * Looks up longhand in a cache. + */ +/*ARGSUSED */ +attribute_hidden +enum auth_stat +_svcauth_short (struct svc_req *rqst attribute_unused, struct rpc_msg *msg attribute_unused) +{ + return AUTH_REJECTEDCRED; +} diff --git a/libc/inet/rpc/xdr_mem.c b/libc/inet/rpc/xdr_mem.c index 191672ec4..7613ffc2f 100644 --- a/libc/inet/rpc/xdr_mem.c +++ b/libc/inet/rpc/xdr_mem.c @@ -38,11 +38,9 @@ * */ -#define __FORCE_GLIBC #include - - #include +#include #include libc_hidden_proto(memcpy) @@ -53,7 +51,7 @@ static bool_t xdrmem_getbytes (XDR *, caddr_t, u_int); static bool_t xdrmem_putbytes (XDR *, const char *, u_int); static u_int xdrmem_getpos (const XDR *); static bool_t xdrmem_setpos (XDR *, u_int); -static int32_t *xdrmem_inline (XDR *, int); +static int32_t *xdrmem_inline (XDR *, u_int); static void xdrmem_destroy (XDR *); static bool_t xdrmem_getint32 (XDR *, int32_t *); static bool_t xdrmem_putint32 (XDR *, const int32_t *); @@ -107,8 +105,9 @@ xdrmem_destroy (XDR *xdrs attribute_unused) static bool_t xdrmem_getlong (XDR *xdrs, long *lp) { - if ((xdrs->x_handy -= 4) < 0) + if (xdrs->x_handy < 4) return FALSE; + xdrs->x_handy -= 4; *lp = (int32_t) ntohl ((*((int32_t *) (xdrs->x_private)))); xdrs->x_private += 4; return TRUE; @@ -122,8 +121,9 @@ xdrmem_getlong (XDR *xdrs, long *lp) static bool_t xdrmem_putlong (XDR *xdrs, const long *lp) { - if ((xdrs->x_handy -= 4) < 0) + if (xdrs->x_handy < 4) return FALSE; + xdrs->x_handy -= 4; *(int32_t *) xdrs->x_private = htonl (*lp); xdrs->x_private += 4; return TRUE; @@ -138,8 +138,9 @@ xdrmem_putlong (XDR *xdrs, const long *lp) static bool_t xdrmem_getbytes (XDR *xdrs, caddr_t addr, u_int len) { - if ((xdrs->x_handy -= len) < 0) + if (xdrs->x_handy < len) return FALSE; + xdrs->x_handy -= len; memcpy (addr, xdrs->x_private, len); xdrs->x_private += len; return TRUE; @@ -152,8 +153,9 @@ xdrmem_getbytes (XDR *xdrs, caddr_t addr, u_int len) static bool_t xdrmem_putbytes (XDR *xdrs, const char *addr, u_int len) { - if ((xdrs->x_handy -= len) < 0) + if (xdrs->x_handy < len) return FALSE; + xdrs->x_handy -= len; memcpy (xdrs->x_private, addr, len); xdrs->x_private += len; return TRUE; @@ -180,7 +182,9 @@ xdrmem_setpos (xdrs, pos) caddr_t newaddr = xdrs->x_base + pos; caddr_t lastaddr = xdrs->x_private + xdrs->x_handy; - if ((long) newaddr > (long) lastaddr) + if ((long) newaddr > (long) lastaddr + || (UINT_MAX < LONG_MAX + && (long) UINT_MAX < (long) lastaddr - (long) newaddr)) return FALSE; xdrs->x_private = newaddr; xdrs->x_handy = (long) lastaddr - (long) newaddr; @@ -191,7 +195,7 @@ xdrmem_setpos (xdrs, pos) * xdrs modified */ static int32_t * -xdrmem_inline (XDR *xdrs, int len) +xdrmem_inline (XDR *xdrs, u_int len) { int32_t *buf = 0; @@ -212,8 +216,9 @@ xdrmem_inline (XDR *xdrs, int len) static bool_t xdrmem_getint32 (XDR *xdrs, int32_t *ip) { - if ((xdrs->x_handy -= 4) < 0) + if (xdrs->x_handy < 4) return FALSE; + xdrs->x_handy -= 4; *ip = ntohl ((*((int32_t *) (xdrs->x_private)))); xdrs->x_private += 4; return TRUE; @@ -227,8 +232,9 @@ xdrmem_getint32 (XDR *xdrs, int32_t *ip) static bool_t xdrmem_putint32 (XDR *xdrs, const int32_t *ip) { - if ((xdrs->x_handy -= 4) < 0) + if (xdrs->x_handy < 4) return FALSE; + xdrs->x_handy -= 4; *(int32_t *) xdrs->x_private = htonl (*ip); xdrs->x_private += 4; return TRUE; diff --git a/libc/inet/rpc/xdr_rec.c b/libc/inet/rpc/xdr_rec.c index 4534a83e7..99e6fe9c3 100644 --- a/libc/inet/rpc/xdr_rec.c +++ b/libc/inet/rpc/xdr_rec.c @@ -71,7 +71,7 @@ static bool_t xdrrec_getbytes (XDR *, caddr_t, u_int); static bool_t xdrrec_putbytes (XDR *, const char *, u_int); static u_int xdrrec_getpos (const XDR *); static bool_t xdrrec_setpos (XDR *, u_int); -static int32_t *xdrrec_inline (XDR *, int); +static int32_t *xdrrec_inline (XDR *, u_int); static void xdrrec_destroy (XDR *); static bool_t xdrrec_getint32 (XDR *, int32_t *); static bool_t xdrrec_putint32 (XDR *, const int32_t *); @@ -384,7 +384,7 @@ xdrrec_setpos (XDR *xdrs, u_int pos) } static int32_t * -xdrrec_inline (XDR *xdrs, int len) +xdrrec_inline (XDR *xdrs, u_int len) { RECSTREAM *rstrm = (RECSTREAM *) xdrs->x_private; int32_t *buf = NULL; diff --git a/libc/inet/rpc/xdr_stdio.c b/libc/inet/rpc/xdr_stdio.c index 8bd08590d..32689e132 100644 --- a/libc/inet/rpc/xdr_stdio.c +++ b/libc/inet/rpc/xdr_stdio.c @@ -61,7 +61,7 @@ static bool_t xdrstdio_getbytes (XDR *, caddr_t, u_int); static bool_t xdrstdio_putbytes (XDR *, const char *, u_int); static u_int xdrstdio_getpos (const XDR *); static bool_t xdrstdio_setpos (XDR *, u_int); -static int32_t *xdrstdio_inline (XDR *, int); +static int32_t *xdrstdio_inline (XDR *, u_int); static void xdrstdio_destroy (XDR *); static bool_t xdrstdio_getint32 (XDR *, int32_t *); static bool_t xdrstdio_putint32 (XDR *, const int32_t *); @@ -114,20 +114,20 @@ xdrstdio_destroy (XDR *xdrs) static bool_t xdrstdio_getlong (XDR *xdrs, long *lp) { - int32_t mycopy; + u_int32_t mycopy; - if (fread ((caddr_t) & mycopy, 4, 1, (FILE *) xdrs->x_private) != 1) + if (fread ((caddr_t) &mycopy, 4, 1, (FILE *) xdrs->x_private) != 1) return FALSE; - *lp = (int32_t) ntohl (mycopy); + *lp = (long) ntohl (mycopy); return TRUE; } static bool_t xdrstdio_putlong (XDR *xdrs, const long *lp) { - long mycopy = htonl (*lp); - lp = &mycopy; - if (fwrite ((caddr_t) lp, 4, 1, (FILE *) xdrs->x_private) != 1) + int32_t mycopy = htonl ((u_int32_t) *lp); + + if (fwrite ((caddr_t) &mycopy, 4, 1, (FILE *) xdrs->x_private) != 1) return FALSE; return TRUE; } @@ -163,7 +163,7 @@ xdrstdio_setpos (XDR *xdrs, u_int pos) } static int32_t * -xdrstdio_inline (XDR *xdrs attribute_unused, int len attribute_unused) +xdrstdio_inline (XDR *xdrs attribute_unused, u_int len attribute_unused) { /* * Must do some work to implement this: must insure -- cgit v1.2.3