b2bffca2e3
2002-05-11 Jakub Jelinek <jakub@redhat.com> * include/netinet/in.h (bindresvport_internal): Add prototype. * include/rpc/auth.h (authunix_create_internal, authunix_create_default_internal, authnone_create_internal, authdes_pk_create_internal): Add prototypes. * include/rpc/clnt.h (clnt_create_internal, clnttcp_create_internal, clntudp_create_internal, clntudp_bufcreate_internal, clntunix_create_internal): Add prototypes. * include/rpc/svc.h (svc_sendreply_internal, svcerr_decode_internal, svc_getreq_internal, svc_getreq_common_internal, svc_getreqset_internal, svc_getreq_poll_internal, svc_register_internal, svc_unregister_internal, svcudp_create_internal, svcudp_bufcreate_internal): Add prototypes. * include/rpc/svc_auth.h (_authenticate_internal): Add prototype. * include/sys/socket.h (__sendto, __recvfrom, __sendmsg, __recvmsg, __setsockopt, __getsockname, __bind, __listen): Add prototypes. * inet/rexec.c (rexec_af): Use __listen and __getsockname. * inet/rcmd.c (rcmd_af): Use __listen. (rresvport_af): Use __bind. * sunrpc/clnt_udp.c: Use INTUSE calls to bindresvport, authunix_create, authunix_create_default, authnone_create, authdes_pk_create, clnt_create, clnttcp_create, clntudp_create, clntudp_bufcreate, clntunix_create svc_sendreply, svcerr_decode, svc_getreq, svc_getreq_common, svc_getreqset, svc_getreq_poll, svc_register, svc_unregister, svcudp_create, svcudp_bufcreate, _authenticate, add INTDEF after such function definitions. Use __listen, __bind, __sendto, __recvfrom, __sendmsg, __recvmsg, __setsockopt, __getsockname instead of non-__ variants. * sunrpc/pmap_rmt.c: Likewise. * sunrpc/rtime.c: Likewise. * sunrpc/svc_udp.c: Likewise. * sunrpc/clnt_unix.c: Likewise. * sunrpc/svc_unix.c: Likewise. * sunrpc/bindrsvprt.c: Likewise. * sunrpc/svc_tcp.c: Likewise. * sunrpc/auth_none.c: Likewise. * sunrpc/clnt_raw.c: Likewise. * sunrpc/clnt_tcp.c: Likewise. * sunrpc/auth_unix.c: Likewise. * sunrpc/key_call.c: Likewise. * sunrpc/clnt_gen.c: Likewise. * sunrpc/pm_getmaps.c: Likewise. * sunrpc/clnt_simp.c: Likewise. * sunrpc/pmap_clnt.c: Likewise. * sunrpc/svc_run.c: Likewise. * sunrpc/svc.c: Likewise. * sunrpc/svc_simple.c: Likewise. * sunrpc/pm_getport.c: Likewise. * sunrpc/auth_des.c: Likewise. * sunrpc/svc_auth.c: Likewise. * sysdeps/generic/unwind-dw2-fde.c (__register_frame_info_bases, __register_frame_info_table_bases, __deregister_frame_info_bases): Add INTDEF. (__register_frame_info_bases_internal, __register_frame_info_table_bases_internal, __deregister_frame_info_bases_internal): Add prototypes. (__register_frame_info, __register_frame): Use INTUSE in call to __register_frame_info_bases. (__register_frame_info_table): Similarly. (__deregister_frame_info, __deregister_frame): Similarly. * sysdeps/generic/sendto.c (__sendto): Renamed from sendto, add sendto as weak alias. * sysdeps/mach/hurd/sendto.c: Likewise. * sysdeps/generic/recvfrom.c (__recvfrom): Renamed from recvfrom, add recvfrom as weak alias. * sysdeps/mach/hurd/recvfrom.c: Likewise. * sysdeps/unix/sysv/aix/recvfrom.c: Likewise. * sysdeps/generic/recvmsg.c (__recvmsg): Renamed from recvmsg, add recvmsg as weak alias. * sysdeps/unix/sysv/aix/recvmsg.c: Likewise. * sysdeps/generic/sendmsg.c (__sendmsg): Renamed from sendmsg, add sendmsg as weak alias. * sysdeps/unix/sysv/aix/sendmsg.c: Likewise. * sysdeps/generic/setsockopt.c (__setsockopt): Renamed from setsockopt, add setsockopt as weak alias. * sysdeps/mach/hurd/setsockopt.c: Likewise. * sysdeps/generic/bind.c (__bind): Renamed from bind, add bind as weak alias. * sysdeps/mach/hurd/bind.c: Likewise. * sysdeps/generic/listen.c (__listen): Renamed from listen, add listen as weak alias. * sysdeps/mach/hurd/listen.c: Likewise. * sysdeps/generic/getsockname.c (__getsockname): Renamed from getsockname, add getsockname as weak alias. * sysdeps/mach/hurd/getsockname.c: Likewise. * sysdeps/unix/sysv/aix/getsockname.c: Likewise. * sysdeps/mach/hurd/recvmsg.c (__recvmsg): Add weak alias. * sysdeps/mach/hurd/sendmsg.c (__sendmsg): Add weak alias. * sysdeps/unix/inet/syscalls.list (__bind, __listen, __recvmsg, __recvfrom, __sendmsg, __sendto, __setsockopt): Add aliases. * sysdeps/unix/sysv/linux/alpha/syscalls.list (__recvmsg, __sendmsg): Add aliases. * sysdeps/unix/sysv/linux/ia64/syscalls.list: Likewise. * sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list: Likewise. * sysdeps/unix/sysv/linux/hppa/syscalls.list: Likewise. * sysdeps/unix/sysv/linux/x86_64/syscalls.list: Likewise. * sysdeps/unix/sysv/linux/recvfrom.S (__recvfrom): Add weak alias. * sysdeps/unix/sysv/linux/recvmsg.S (__recvmsg): Likewise. * sysdeps/unix/sysv/linux/sendmsg.S (__sendmsg): Likewise. * sysdeps/unix/sysv/linux/sendto.S (__sendto): Likewise. * sysdeps/unix/sysv/linux/setsockopt.S (__setsockopt): Likewise. * sysdeps/unix/sysv/linux/bind.S (__bind): Likewise. * sysdeps/unix/sysv/linux/listen.S (__listen): Likewise. * sysdeps/unix/sysv/linux/getsockname.S (__getsockname): Likewise. 2002-05-10 Jakub Jelinek <jakub@redhat.com> * locale/programs/localedef.h (show_archive_content): Add verbose argument. * locale/programs/localedef.c (main): Adjust caller. * locale/programs/locarchive.c (struct nameent, struct dataent): New. (nameentcmp, dataentcmp): New functions. (xstrcmp): Remove. (show_archive_content): Print verbose listing with --list-archive -v. * locale/programs/locarchive.c (open_archive): Take extra argument readonly. If true open file with O_RDONLY and don't create the archive if it doesn't exist. Adapt all callers. (close_archive): Don't do anything if fd element is -1. * locale/programs/localedef.h (open_archive): Adjust prototype. * locale/programs/locfile.c (write_all_categories): Adjust open_archive call. * malloc/malloc.c (__posix_memalign): Correct check for size of alignment value [PR libc/3444].
257 lines
6.4 KiB
C
257 lines
6.4 KiB
C
/* @(#)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 !defined(lint) && defined(SCCSIDS)
|
|
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 <rpc/rpc.h>
|
|
#include <rpc/svc.h>
|
|
#include <rpc/xdr.h>
|
|
#include <libintl.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 _RPC_THREAD_SAFE_
|
|
#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 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;
|
|
CLIENT *client;
|
|
|
|
if (clp == 0)
|
|
{
|
|
clp = (struct clntraw_private_s *) calloc (1, sizeof (*clp));
|
|
if (clp == 0)
|
|
return (0);
|
|
clntraw_private = clp;
|
|
}
|
|
xdrs = &clp->xdr_stream;
|
|
client = &clp->client_object;
|
|
/*
|
|
* 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;
|
|
INTUSE(xdrmem_create) (xdrs, clp->mashl_callmsg, MCALL_MSG_SIZE, XDR_ENCODE);
|
|
if (!INTUSE(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
|
|
*/
|
|
INTUSE(xdrmem_create) (xdrs, clp->_raw_buf, UDPMSGSIZE, XDR_FREE);
|
|
|
|
/*
|
|
* create client handle
|
|
*/
|
|
client->cl_ops = &client_ops;
|
|
client->cl_auth = INTUSE(authnone_create) ();
|
|
return client;
|
|
}
|
|
|
|
static enum clnt_stat
|
|
clntraw_call (h, proc, xargs, argsp, xresults, resultsp, timeout)
|
|
CLIENT *h;
|
|
u_long proc;
|
|
xdrproc_t xargs;
|
|
caddr_t argsp;
|
|
xdrproc_t xresults;
|
|
caddr_t resultsp;
|
|
struct timeval timeout;
|
|
{
|
|
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.
|
|
*/
|
|
INTUSE(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 (!INTUSE(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) INTUSE(xdr_opaque_auth) (xdrs, &(msg.acpted_rply.ar_verf));
|
|
}
|
|
}
|
|
|
|
return status;
|
|
}
|
|
|
|
static void
|
|
clntraw_geterr (CLIENT *cl, struct rpc_err *err)
|
|
{
|
|
}
|
|
|
|
|
|
static bool_t
|
|
clntraw_freeres (cl, xdr_res, res_ptr)
|
|
CLIENT *cl;
|
|
xdrproc_t xdr_res;
|
|
caddr_t res_ptr;
|
|
{
|
|
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, int i, char *c)
|
|
{
|
|
return FALSE;
|
|
}
|
|
|
|
static void
|
|
clntraw_destroy (CLIENT *cl)
|
|
{
|
|
}
|