2002-06-25 Joel Sherrill <joel@OARcorp.com>

* Per PR233, moved librpc to exec.  Ralf will patch after move.
	The patches associated with this PR are out of date.
	./include/rpc/.cvsignore, ./include/rpc/Makefile.am,
	./include/rpc/auth.h, ./include/rpc/auth_des.h,
	./include/rpc/auth_unix.h, ./include/rpc/clnt.h,
	./include/rpc/des.h, ./include/rpc/des_crypt.h,
	./include/rpc/pmap_clnt.h, ./include/rpc/pmap_prot.h,
	./include/rpc/pmap_rmt.h, ./include/rpc/rpc.h,
	./include/rpc/rpc_com.h, ./include/rpc/rpc_msg.h,
	./include/rpc/svc.h, ./include/rpc/svc_auth.h,
	./include/rpc/types.h, ./include/rpc/xdr.h,
	./include/.cvsignore, ./include/Makefile.am,
	./include/rpcsvc/.cvsignore, ./include/rpcsvc/Makefile.am,
	./include/rpcsvc/bootparam_prot.x, ./include/rpcsvc/crypt.x,
	./include/rpcsvc/key_prot.x, ./include/rpcsvc/klm_prot.x,
	./include/rpcsvc/mount.x, ./include/rpcsvc/nfs_prot.x,
	./include/rpcsvc/nis.x, ./include/rpcsvc/nis_cache.x,
	./include/rpcsvc/nis_callback.x, ./include/rpcsvc/nis_db.h,
	./include/rpcsvc/nis_object.x, ./include/rpcsvc/nis_tags.h,
	./include/rpcsvc/nislib.h, ./include/rpcsvc/nlm_prot.x,
	./include/rpcsvc/pmap_prot.x, ./include/rpcsvc/rex.x,
	./include/rpcsvc/rnusers.x, ./include/rpcsvc/rquota.x,
	./include/rpcsvc/rstat.x, ./include/rpcsvc/rwall.x,
	./include/rpcsvc/sm_inter.x, ./include/rpcsvc/spray.x,
	./include/rpcsvc/yp.x, ./include/rpcsvc/yp_prot.h,
	./include/rpcsvc/ypclnt.h, ./include/rpcsvc/yppasswd.x,
	./include/rpcsvc/ypupdate_prot.x, ./include/rpcsvc/ypxfrd.x,
	./.cvsignore, ./Makefile.am, ./README_RTEMS,
	./configure.ac, ./src/rpc/PSD.doc/.cvsignore,
	./src/rpc/PSD.doc/Makefile.am, ./src/rpc/PSD.doc/nfs.rfc.ms,
	./src/rpc/PSD.doc/rpc.prog.ms, ./src/rpc/PSD.doc/rpc.rfc.ms,
	./src/rpc/PSD.doc/rpcgen.ms, ./src/rpc/PSD.doc/xdr.nts.ms,
	./src/rpc/PSD.doc/xdr.rfc.ms, ./src/rpc/.cvsignore,
	./src/rpc/DISCLAIMER, ./src/rpc/Makefile.am,
	./src/rpc/README, ./src/rpc/auth_des.c,
	./src/rpc/auth_none.c, ./src/rpc/auth_time.c,
	./src/rpc/auth_unix.c, ./src/rpc/authdes_prot.c,
	./src/rpc/authunix_prot.c, ./src/rpc/bindresvport.3,
	./src/rpc/bindresvport.c, ./src/rpc/clnt_generic.c,
	./src/rpc/clnt_perror.c, ./src/rpc/clnt_raw.c,
	./src/rpc/clnt_simple.c, ./src/rpc/clnt_tcp.c,
	./src/rpc/clnt_udp.c, ./src/rpc/clnt_unix.c,
	./src/rpc/crypt_client.c, ./src/rpc/des_crypt.3,
	./src/rpc/des_crypt.c, ./src/rpc/des_soft.c,
	./src/rpc/get_myaddress.c, ./src/rpc/getpublickey.c,
	./src/rpc/getrpcent.3, ./src/rpc/getrpcent.c,
	./src/rpc/getrpcport.3, ./src/rpc/getrpcport.c,
	./src/rpc/key_call.c, ./src/rpc/key_prot_xdr.c,
	./src/rpc/netname.c, ./src/rpc/netnamer.c,
	./src/rpc/pmap_clnt.c, ./src/rpc/pmap_getmaps.c,
	./src/rpc/pmap_getport.c, ./src/rpc/pmap_prot.c,
	./src/rpc/pmap_prot2.c, ./src/rpc/pmap_rmt.c,
	./src/rpc/publickey.3, ./src/rpc/publickey.5,
	./src/rpc/rpc.3, ./src/rpc/rpc.5, ./src/rpc/rpc_callmsg.c,
	./src/rpc/rpc_commondata.c, ./src/rpc/rpc_dtablesize.c,
	./src/rpc/rpc_prot.c, ./src/rpc/rpc_secure.3,
	./src/rpc/rpcdname.c, ./src/rpc/rstat.1,
	./src/rpc/rstat_svc.8, ./src/rpc/rtems_portmapper.c,
	./src/rpc/rtems_rpc.c, ./src/rpc/rtime.3, ./src/rpc/rtime.c,
	./src/rpc/svc.c, ./src/rpc/svc_auth.c,
	./src/rpc/svc_auth_des.c, ./src/rpc/svc_auth_unix.c,
	./src/rpc/svc_raw.c, ./src/rpc/svc_run.c,
	./src/rpc/svc_simple.c, ./src/rpc/svc_tcp.c,
	./src/rpc/svc_udp.c, ./src/rpc/svc_unix.c,
	./src/xdr/.cvsignore, ./src/xdr/Makefile.am, ./src/xdr/xdr.3,
	./src/xdr/xdr.c, ./src/xdr/xdr_array.c,
	./src/xdr/xdr_float.c, ./src/xdr/xdr_mem.c,
	./src/xdr/xdr_rec.c, ./src/xdr/xdr_reference.c,
	./src/xdr/xdr_sizeof.c, ./src/xdr/xdr_stdio.c,
	./src/.cvsignore, ./src/Makefile.am: Moved to exec.
This commit is contained in:
Joel Sherrill
2002-06-25 14:52:37 +00:00
parent 4e987e779f
commit 411e387c27
140 changed files with 73 additions and 36925 deletions

View File

@@ -1,3 +1,76 @@
2002-06-25 Joel Sherrill <joel@OARcorp.com>
* Per PR233, moved librpc to exec. Ralf will patch after move.
The patches associated with this PR are out of date.
./include/rpc/.cvsignore, ./include/rpc/Makefile.am,
./include/rpc/auth.h, ./include/rpc/auth_des.h,
./include/rpc/auth_unix.h, ./include/rpc/clnt.h,
./include/rpc/des.h, ./include/rpc/des_crypt.h,
./include/rpc/pmap_clnt.h, ./include/rpc/pmap_prot.h,
./include/rpc/pmap_rmt.h, ./include/rpc/rpc.h,
./include/rpc/rpc_com.h, ./include/rpc/rpc_msg.h,
./include/rpc/svc.h, ./include/rpc/svc_auth.h,
./include/rpc/types.h, ./include/rpc/xdr.h,
./include/.cvsignore, ./include/Makefile.am,
./include/rpcsvc/.cvsignore, ./include/rpcsvc/Makefile.am,
./include/rpcsvc/bootparam_prot.x, ./include/rpcsvc/crypt.x,
./include/rpcsvc/key_prot.x, ./include/rpcsvc/klm_prot.x,
./include/rpcsvc/mount.x, ./include/rpcsvc/nfs_prot.x,
./include/rpcsvc/nis.x, ./include/rpcsvc/nis_cache.x,
./include/rpcsvc/nis_callback.x, ./include/rpcsvc/nis_db.h,
./include/rpcsvc/nis_object.x, ./include/rpcsvc/nis_tags.h,
./include/rpcsvc/nislib.h, ./include/rpcsvc/nlm_prot.x,
./include/rpcsvc/pmap_prot.x, ./include/rpcsvc/rex.x,
./include/rpcsvc/rnusers.x, ./include/rpcsvc/rquota.x,
./include/rpcsvc/rstat.x, ./include/rpcsvc/rwall.x,
./include/rpcsvc/sm_inter.x, ./include/rpcsvc/spray.x,
./include/rpcsvc/yp.x, ./include/rpcsvc/yp_prot.h,
./include/rpcsvc/ypclnt.h, ./include/rpcsvc/yppasswd.x,
./include/rpcsvc/ypupdate_prot.x, ./include/rpcsvc/ypxfrd.x,
./.cvsignore, ./Makefile.am, ./README_RTEMS,
./configure.ac, ./src/rpc/PSD.doc/.cvsignore,
./src/rpc/PSD.doc/Makefile.am, ./src/rpc/PSD.doc/nfs.rfc.ms,
./src/rpc/PSD.doc/rpc.prog.ms, ./src/rpc/PSD.doc/rpc.rfc.ms,
./src/rpc/PSD.doc/rpcgen.ms, ./src/rpc/PSD.doc/xdr.nts.ms,
./src/rpc/PSD.doc/xdr.rfc.ms, ./src/rpc/.cvsignore,
./src/rpc/DISCLAIMER, ./src/rpc/Makefile.am,
./src/rpc/README, ./src/rpc/auth_des.c,
./src/rpc/auth_none.c, ./src/rpc/auth_time.c,
./src/rpc/auth_unix.c, ./src/rpc/authdes_prot.c,
./src/rpc/authunix_prot.c, ./src/rpc/bindresvport.3,
./src/rpc/bindresvport.c, ./src/rpc/clnt_generic.c,
./src/rpc/clnt_perror.c, ./src/rpc/clnt_raw.c,
./src/rpc/clnt_simple.c, ./src/rpc/clnt_tcp.c,
./src/rpc/clnt_udp.c, ./src/rpc/clnt_unix.c,
./src/rpc/crypt_client.c, ./src/rpc/des_crypt.3,
./src/rpc/des_crypt.c, ./src/rpc/des_soft.c,
./src/rpc/get_myaddress.c, ./src/rpc/getpublickey.c,
./src/rpc/getrpcent.3, ./src/rpc/getrpcent.c,
./src/rpc/getrpcport.3, ./src/rpc/getrpcport.c,
./src/rpc/key_call.c, ./src/rpc/key_prot_xdr.c,
./src/rpc/netname.c, ./src/rpc/netnamer.c,
./src/rpc/pmap_clnt.c, ./src/rpc/pmap_getmaps.c,
./src/rpc/pmap_getport.c, ./src/rpc/pmap_prot.c,
./src/rpc/pmap_prot2.c, ./src/rpc/pmap_rmt.c,
./src/rpc/publickey.3, ./src/rpc/publickey.5,
./src/rpc/rpc.3, ./src/rpc/rpc.5, ./src/rpc/rpc_callmsg.c,
./src/rpc/rpc_commondata.c, ./src/rpc/rpc_dtablesize.c,
./src/rpc/rpc_prot.c, ./src/rpc/rpc_secure.3,
./src/rpc/rpcdname.c, ./src/rpc/rstat.1,
./src/rpc/rstat_svc.8, ./src/rpc/rtems_portmapper.c,
./src/rpc/rtems_rpc.c, ./src/rpc/rtime.3, ./src/rpc/rtime.c,
./src/rpc/svc.c, ./src/rpc/svc_auth.c,
./src/rpc/svc_auth_des.c, ./src/rpc/svc_auth_unix.c,
./src/rpc/svc_raw.c, ./src/rpc/svc_run.c,
./src/rpc/svc_simple.c, ./src/rpc/svc_tcp.c,
./src/rpc/svc_udp.c, ./src/rpc/svc_unix.c,
./src/xdr/.cvsignore, ./src/xdr/Makefile.am, ./src/xdr/xdr.3,
./src/xdr/xdr.c, ./src/xdr/xdr_array.c,
./src/xdr/xdr_float.c, ./src/xdr/xdr_mem.c,
./src/xdr/xdr_rec.c, ./src/xdr/xdr_reference.c,
./src/xdr/xdr_sizeof.c, ./src/xdr/xdr_stdio.c,
./src/.cvsignore, ./src/Makefile.am: Moved to exec.
2002-03-27 Ralf Corsepius <corsepiu@faw.uni-ulm.de>
* configure.ac:

View File

@@ -1,16 +0,0 @@
##
## $Id$
##
ACLOCAL_AMFLAGS = -I ../../../aclocal
if rpc_not_supported
SUBDIRS =
else
SUBDIRS = include src
endif
EXTRA_DIST = README_RTEMS
include $(top_srcdir)/../../../automake/subdirs.am
include $(top_srcdir)/../../../automake/local.am

View File

@@ -1,64 +0,0 @@
USING RPC/XDR ON RTEMS
======================
For the most part, programmers using RPC/XDR routines on RTEMS
can proceed as if they were to be using a POSIX/UNIX system.
The only significant changes are those to start the portmapper
and to allow use of RPC/XDR by multiple threads.
Starting the portmapper
=======================
The SUN portmapper program has been modified to run as an RTEMS
task. Applications which need the portmapper can start this
task by calling:
int rtems_rpc_start_portmapper (int priority);
The return value is an RTEMS status code.
Multi-threaded operation
========================
The RPC/XDR package has been modified to allow for multiple RTEMS
tasks to use RPC/XDR routines. If more than one task is to call
an RPC/XDR routine, the additional tasks must call:
int rtems_rpc_task_init(void);
before calling any RPC/XDR routines. For example, the portmapper
calls this routine since the portmapper uses RPC/XDR routines in
a separate thread.
The return value is an RTEMS status code.
Porting Notes
=============
Most of the FreeBSD rpc library ports to RTEMS with little
or no modification beyond that required to provide for operation
in a multitasking environment. Multitasking operation was
provided by moving all `static persistence' variables into
a single structure and using an RTEMS task variable to point
to that structure.
Some of the library, however, has not made it into the RTEMS
implementation. FreeBSD source files which have been left out include:
- Files which provide RPC to the AF_UNIX address family:
clnt_unix.c
svc_unix.c
An `ifndef __rtems__' was added to clnt_generic.c because clnt_unix.c
was omitted.
- Files which need NIS:
auth_time.c
- Files which provide DES authentication:
auth_des.c
authdes_prot.c
crypt_client.c
des_crypt.c
des_soft.c
getpublickey.c
key_call.c
key_prot_xdr.c
svc_auth_des.c
The FreeBSD xdr source compiles and runs on RTEMS without modification.
The original source was obtained from:
ftp://ftp.FreeBSD.org/pub/FreeBSD/
branches/4.0-stable/src/lib/libc/rpc
branches/4.0-stable/src/lib/libc/xdr
branches/4.0-stable/src/include/rpc
branches/4.0-stable/src/include/rpcsvc

View File

@@ -1,44 +0,0 @@
## Process this file with autoconf to produce a configure script.
##
## $Id$
AC_PREREQ(2.52)
AC_INIT([rtems-c-src-librpc],[_RTEMS_VERSION],[rtems-bugs@OARcorp.com])
AC_CONFIG_SRCDIR([include/rpc])
RTEMS_TOP(../../..)
AC_CONFIG_AUX_DIR(../../..)
RTEMS_CANONICAL_TARGET_CPU
RTEMS_CANONICAL_HOST
AM_INIT_AUTOMAKE([no-define foreign 1.6])
AM_MAINTAINER_MODE
RTEMS_ENABLE_NETWORKING
RTEMS_ENABLE_BARE
RTEMS_ENV_RTEMSBSP
RTEMS_CHECK_CPU
RTEMS_CHECK_CUSTOM_BSP(RTEMS_BSP)
RTEMS_PROG_CC_FOR_TARGET
RTEMS_CANONICALIZE_TOOLS
RTEMS_CHECK_NETWORKING(RTEMS_BSP)
AM_CONDITIONAL(HAS_NETWORKING,test "$HAS_NETWORKING" = "yes")
AM_CONDITIONAL(rpc_not_supported, test "$RTEMS_CPU" = "c4x")
RTEMS_PROJECT_ROOT
# Explicitly list all Makefiles here
AC_CONFIG_FILES([Makefile
include/Makefile
include/rpc/Makefile
include/rpcsvc/Makefile
src/Makefile
src/xdr/Makefile
src/rpc/Makefile
src/rpc/PSD.doc/Makefile
])
AC_OUTPUT

View File

@@ -1,2 +0,0 @@
Makefile
Makefile.in

View File

@@ -1,9 +0,0 @@
##
## $Id$
##
SUBDIRS = rpc rpcsvc
include $(top_srcdir)/../../../automake/subdirs.am
include $(top_srcdir)/../../../automake/local.am

View File

@@ -1,2 +0,0 @@
Makefile
Makefile.in

View File

@@ -1,27 +0,0 @@
##
## $Id$
##
include_rpcdir = $(includedir)/rpc
H_FILES = auth.h auth_des.h auth_unix.h clnt.h des.h des_crypt.h pmap_clnt.h \
pmap_prot.h pmap_rmt.h rpc.h rpc_com.h rpc_msg.h svc.h svc_auth.h \
types.h xdr.h
if HAS_NETWORKING
include_rpc_HEADERS = $(H_FILES)
PREINSTALL_FILES = $(PROJECT_INCLUDE)/rpc \
$(H_FILES:%=$(PROJECT_INCLUDE)/rpc/%)
$(PROJECT_INCLUDE)/rpc:
@$(mkinstalldirs) $@
$(PROJECT_INCLUDE)/rpc/%.h: %.h
$(INSTALL_DATA) $< $@
endif
all-local: $(PREINSTALL_FILES)
EXTRA_DIST = $(H_FILES)
include $(top_srcdir)/../../../automake/local.am

View File

@@ -1,260 +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, MERCHANTABILITY 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
*
* from: @(#)auth.h 1.17 88/02/08 SMI
* from: @(#)auth.h 2.3 88/08/07 4.0 RPCSRC
* $FreeBSD: src/include/rpc/auth.h,v 1.15 1999/08/27 23:45:02 peter Exp $
*/
/*
* auth.h, Authentication interface.
*
* Copyright (C) 1984, Sun Microsystems, Inc.
*
* The data structures are completely opaque to the client. The client
* is required to pass a AUTH * to routines that create rpc
* "sessions".
*/
#ifndef _RPC_AUTH_H
#define _RPC_AUTH_H
#include <sys/cdefs.h>
#include <sys/socket.h>
#define MAX_AUTH_BYTES 400
#define MAXNETNAMELEN 255 /* maximum length of network user's name */
/*
* Status returned from authentication check
*/
enum auth_stat {
AUTH_OK=0,
/*
* failed at remote end
*/
AUTH_BADCRED=1, /* bogus credentials (seal broken) */
AUTH_REJECTEDCRED=2, /* client should begin new session */
AUTH_BADVERF=3, /* bogus verifier (seal broken) */
AUTH_REJECTEDVERF=4, /* verifier expired or was replayed */
AUTH_TOOWEAK=5, /* rejected due to security reasons */
/*
* failed locally
*/
AUTH_INVALIDRESP=6, /* bogus response verifier */
AUTH_FAILED=7 /* some unknown reason */
};
union des_block {
struct {
u_int32_t high;
u_int32_t low;
} key;
char c[8];
};
typedef union des_block des_block;
__BEGIN_DECLS
extern bool_t xdr_des_block __P((XDR *, des_block *));
__END_DECLS
/*
* Authentication info. Opaque to client.
*/
struct opaque_auth {
enum_t oa_flavor; /* flavor of auth */
caddr_t oa_base; /* address of more auth stuff */
u_int oa_length; /* not to exceed MAX_AUTH_BYTES */
};
__BEGIN_DECLS
bool_t xdr_opaque_auth __P((XDR *xdrs, struct opaque_auth *ap));
__END_DECLS
/*
* Auth handle, interface to client side authenticators.
*/
typedef struct __rpc_auth {
struct opaque_auth ah_cred;
struct opaque_auth ah_verf;
union des_block ah_key;
struct auth_ops {
void (*ah_nextverf) __P((struct __rpc_auth *));
/* nextverf & serialize */
int (*ah_marshal) __P((struct __rpc_auth *, XDR *));
/* validate verifier */
int (*ah_validate) __P((struct __rpc_auth *,
struct opaque_auth *));
/* refresh credentials */
int (*ah_refresh) __P((struct __rpc_auth *));
/* destroy this structure */
void (*ah_destroy) __P((struct __rpc_auth *));
} *ah_ops;
caddr_t ah_private;
} AUTH;
/*
* Authentication ops.
* The ops and the auth handle provide the interface to the authenticators.
*
* AUTH *auth;
* XDR *xdrs;
* struct opaque_auth verf;
*/
#define AUTH_NEXTVERF(auth) \
((*((auth)->ah_ops->ah_nextverf))(auth))
#define auth_nextverf(auth) \
((*((auth)->ah_ops->ah_nextverf))(auth))
#define AUTH_MARSHALL(auth, xdrs) \
((*((auth)->ah_ops->ah_marshal))(auth, xdrs))
#define auth_marshall(auth, xdrs) \
((*((auth)->ah_ops->ah_marshal))(auth, xdrs))
#define AUTH_VALIDATE(auth, verfp) \
((*((auth)->ah_ops->ah_validate))((auth), verfp))
#define auth_validate(auth, verfp) \
((*((auth)->ah_ops->ah_validate))((auth), verfp))
#define AUTH_REFRESH(auth) \
((*((auth)->ah_ops->ah_refresh))(auth))
#define auth_refresh(auth) \
((*((auth)->ah_ops->ah_refresh))(auth))
#define AUTH_DESTROY(auth) \
((*((auth)->ah_ops->ah_destroy))(auth))
#define auth_destroy(auth) \
((*((auth)->ah_ops->ah_destroy))(auth))
extern struct opaque_auth _null_auth;
/*
* These are the various implementations of client side authenticators.
*/
/*
* Unix style authentication
* AUTH *authunix_create(machname, uid, gid, len, aup_gids)
* char *machname;
* int uid;
* int gid;
* int len;
* int *aup_gids;
*/
__BEGIN_DECLS
struct sockaddr_in;
extern AUTH *authunix_create __P((char *, int, int, int, int *));
extern AUTH *authunix_create_default __P((void));
extern AUTH *authnone_create __P((void));
__END_DECLS
/* Forward compatibility with TI-RPC */
#define authsys_create authunix_create
#define authsys_create_default authunix_create_default
/*
* DES style authentication
* AUTH *authdes_create(servername, window, timehost, ckey)
* char *servername; - network name of server
* u_int window; - time to live
* struct sockaddr *timehost; - optional hostname to sync with
* des_block *ckey; - optional conversation key to use
*/
__BEGIN_DECLS
extern AUTH *authdes_create __P(( char *, u_int, struct sockaddr *, des_block * ));
#ifdef NOTYET
/*
* TI-RPC supports this call, but it requires the inclusion of
* NIS+-specific headers which would require the inclusion of other
* headers which would result in a tangled mess. For now, the NIS+
* code prototypes this routine internally.
*/
extern AUTH *authdes_pk_create __P(( char *, netobj *, u_int,
struct sockaddr *, des_block *,
nis_server * ));
#endif
__END_DECLS
/*
* Netname manipulation routines.
*/
__BEGIN_DECLS
extern int netname2user __P(( char *, uid_t *, gid_t *, int *, gid_t *));
extern int netname2host __P(( char *, char *, int ));
extern int getnetname __P(( char * ));
extern int user2netname __P(( char *, uid_t, char * ));
extern int host2netname __P(( char *, char *, char * ));
extern void passwd2des __P(( char *, char * ));
__END_DECLS
/*
* Keyserv interface routines.
* XXX Should not be here.
*/
#ifndef HEXKEYBYTES
#define HEXKEYBYTES 48
#endif
typedef char kbuf[HEXKEYBYTES];
typedef char *namestr;
struct netstarg {
kbuf st_priv_key;
kbuf st_pub_key;
namestr st_netname;
};
__BEGIN_DECLS
extern int key_decryptsession __P(( const char *, des_block * ));
extern int key_decryptsession_pk __P(( char *, netobj *, des_block * ));
extern int key_encryptsession __P(( const char *, des_block * ));
extern int key_encryptsession_pk __P(( char *, netobj *, des_block * ));
extern int key_gendes __P(( des_block * ));
extern int key_setsecret __P(( const char * ));
extern int key_secretkey_is_set __P(( void ));
extern int key_setnet __P(( struct netstarg * ));
extern int key_get_conv __P(( char *, des_block * ));
__END_DECLS
/*
* Publickey routines.
*/
__BEGIN_DECLS
extern int getpublickey __P(( char *, char * ));
extern int getpublicandprivatekey __P(( char *, char * ));
extern int getsecretkey __P(( char *, char *, char * ));
__END_DECLS
#define AUTH_NONE 0 /* no authentication */
#define AUTH_NULL 0 /* backward compatibility */
#define AUTH_UNIX 1 /* unix style (uid, gids) */
#define AUTH_SYS 1 /* forward compatibility */
#define AUTH_SHORT 2 /* short hand unix style */
#define AUTH_DES 3 /* des style (encrypted timestamps) */
#endif /* !_RPC_AUTH_H */

View File

@@ -1,109 +0,0 @@
/* @(#)auth_des.h 2.2 88/07/29 4.0 RPCSRC; from 1.3 88/02/08 SMI */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
* unrestricted use provided that this legend is included on all tape
* 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) 1988 by Sun Microsystems, Inc.
*/
/*
* auth_des.h, Protocol for DES style authentication for RPC
*/
#ifndef _AUTH_DES_
#define _AUTH_DES_
/*
* There are two kinds of "names": fullnames and nicknames
*/
enum authdes_namekind {
ADN_FULLNAME,
ADN_NICKNAME
};
/*
* A fullname contains the network name of the client,
* a conversation key and the window
*/
struct authdes_fullname {
char *name; /* network name of client, up to MAXNETNAMELEN */
des_block key; /* conversation key */
u_long window; /* associated window */
};
/*
* A credential
*/
struct authdes_cred {
enum authdes_namekind adc_namekind;
struct authdes_fullname adc_fullname;
u_long adc_nickname;
};
/*
* A des authentication verifier
*/
struct authdes_verf {
union {
struct timeval adv_ctime; /* clear time */
des_block adv_xtime; /* crypt time */
} adv_time_u;
u_long adv_int_u;
};
/*
* des authentication verifier: client variety
*
* adv_timestamp is the current time.
* adv_winverf is the credential window + 1.
* Both are encrypted using the conversation key.
*/
#define adv_timestamp adv_time_u.adv_ctime
#define adv_xtimestamp adv_time_u.adv_xtime
#define adv_winverf adv_int_u
/*
* des authentication verifier: server variety
*
* adv_timeverf is the client's timestamp + client's window
* adv_nickname is the server's nickname for the client.
* adv_timeverf is encrypted using the conversation key.
*/
#define adv_timeverf adv_time_u.adv_ctime
#define adv_xtimeverf adv_time_u.adv_xtime
#define adv_nickname adv_int_u
__BEGIN_DECLS
extern int authdes_getucred __P(( struct authdes_cred *, uid_t *, gid_t *, int *, gid_t * ));
__END_DECLS
#endif /* ndef _AUTH_DES_ */

View File

@@ -1,84 +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, MERCHANTABILITY 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
*
* from: @(#)auth_unix.h 1.8 88/02/08 SMI
* from: @(#)auth_unix.h 2.2 88/07/29 4.0 RPCSRC
* $FreeBSD: src/include/rpc/auth_unix.h,v 1.10 1999/08/27 23:45:03 peter Exp $
*/
/*
* auth_unix.h, Protocol for UNIX style authentication parameters for RPC
*
* Copyright (C) 1984, Sun Microsystems, Inc.
*/
/*
* The system is very weak. The client uses no encryption for it
* 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.
*/
#ifndef _RPC_AUTH_UNIX_H
#define _RPC_AUTH_UNIX_H
#include <sys/cdefs.h>
/* The machine name is part of a credential; it may not exceed 255 bytes */
#define MAX_MACHINE_NAME 255
/* gids compose part of a credential; there may not be more than 16 of them */
#define NGRPS 16
/*
* Unix style credentials.
*/
struct authunix_parms {
u_long aup_time;
char *aup_machname;
int aup_uid;
int aup_gid;
u_int aup_len;
int *aup_gids;
};
#define authsys_parms authunix_parms
__BEGIN_DECLS
extern bool_t xdr_authunix_parms __P((XDR *, struct authunix_parms *));
__END_DECLS
/*
* If a response verifier has flavor AUTH_SHORT,
* then the body of the response verifier encapsulates the following structure;
* again it is serialized in the obvious fashion.
*/
struct short_hand_verf {
struct opaque_auth new_cred;
};
#endif /* !_RPC_AUTH_UNIX_H */

View File

@@ -1,419 +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, MERCHANTABILITY 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
*
* from: @(#)clnt.h 1.31 88/02/08 SMI
* from: @(#)clnt.h 2.1 88/07/29 4.0 RPCSRC
* $FreeBSD: src/include/rpc/clnt.h,v 1.11 1999/08/27 23:45:03 peter Exp $
*/
/*
* clnt.h - Client side remote procedure call interface.
*
* Copyright (C) 1984, Sun Microsystems, Inc.
*/
#ifndef _RPC_CLNT_H_
#define _RPC_CLNT_H_
#include <sys/cdefs.h>
#include <sys/un.h>
/*
* Rpc calls return an enum clnt_stat. This should be looked at more,
* since each implementation is required to live with this (implementation
* independent) list of errors.
*/
enum clnt_stat {
RPC_SUCCESS=0, /* call succeeded */
/*
* local errors
*/
RPC_CANTENCODEARGS=1, /* can't encode arguments */
RPC_CANTDECODERES=2, /* can't decode results */
RPC_CANTSEND=3, /* failure in sending call */
RPC_CANTRECV=4, /* failure in receiving result */
RPC_TIMEDOUT=5, /* call timed out */
/*
* remote errors
*/
RPC_VERSMISMATCH=6, /* rpc versions not compatible */
RPC_AUTHERROR=7, /* authentication error */
RPC_PROGUNAVAIL=8, /* program not available */
RPC_PROGVERSMISMATCH=9, /* program version mismatched */
RPC_PROCUNAVAIL=10, /* procedure unavailable */
RPC_CANTDECODEARGS=11, /* decode arguments error */
RPC_SYSTEMERROR=12, /* generic "other problem" */
/*
* callrpc & clnt_create errors
*/
RPC_UNKNOWNHOST=13, /* unknown host name */
RPC_UNKNOWNPROTO=17, /* unkown protocol */
/*
* _ create errors
*/
RPC_PMAPFAILURE=14, /* the pmapper failed in its call */
RPC_PROGNOTREGISTERED=15, /* remote program is not registered */
/*
* unspecified error
*/
RPC_FAILED=16
};
/*
* Error info.
*/
struct rpc_err {
enum clnt_stat re_status;
union {
int RE_errno; /* related system error */
enum auth_stat RE_why; /* why the auth error occurred */
struct {
u_int32_t low; /* lowest verion supported */
u_int32_t high; /* highest verion supported */
} RE_vers;
struct { /* maybe meaningful if RPC_FAILED */
int32_t s1;
int32_t s2;
} RE_lb; /* life boot & debugging only */
} ru;
#define re_errno ru.RE_errno
#define re_why ru.RE_why
#define re_vers ru.RE_vers
#define re_lb ru.RE_lb
};
/*
* Client rpc handle.
* Created by individual implementations, see e.g. rpc_udp.c.
* Client is responsible for initializing auth, see e.g. auth_none.c.
*/
typedef struct __rpc_client {
AUTH *cl_auth; /* authenticator */
struct clnt_ops {
/* call remote procedure */
enum clnt_stat (*cl_call) __P((struct __rpc_client *,
u_long, xdrproc_t, caddr_t, xdrproc_t,
caddr_t, struct timeval));
/* abort a call */
void (*cl_abort) __P((struct __rpc_client *));
/* get specific error code */
void (*cl_geterr) __P((struct __rpc_client *,
struct rpc_err *));
/* frees results */
bool_t (*cl_freeres) __P((struct __rpc_client *,
xdrproc_t, caddr_t));
/* destroy this structure */
void (*cl_destroy) __P((struct __rpc_client *));
/* the ioctl() of rpc */
bool_t (*cl_control) __P((struct __rpc_client *, u_int,
void *));
} *cl_ops;
caddr_t cl_private; /* private stuff */
} CLIENT;
/*
* client side rpc interface ops
*
* Parameter types are:
*
*/
/*
* enum clnt_stat
* CLNT_CALL(rh, proc, xargs, argsp, xres, resp, timeout)
* CLIENT *rh;
* u_long proc;
* xdrproc_t xargs;
* caddr_t argsp;
* xdrproc_t xres;
* caddr_t resp;
* struct timeval timeout;
*/
#define CLNT_CALL(rh, proc, xargs, argsp, xres, resp, secs) \
((*(rh)->cl_ops->cl_call)(rh, proc, xargs, (caddr_t)argsp, \
xres, (caddr_t)resp, secs))
#define clnt_call(rh, proc, xargs, argsp, xres, resp, secs) \
((*(rh)->cl_ops->cl_call)(rh, proc, xargs, (caddr_t)argsp, \
xres, (caddr_t)resp, secs))
/*
* void
* CLNT_ABORT(rh);
* CLIENT *rh;
*/
#define CLNT_ABORT(rh) ((*(rh)->cl_ops->cl_abort)(rh))
#define clnt_abort(rh) ((*(rh)->cl_ops->cl_abort)(rh))
/*
* struct rpc_err
* CLNT_GETERR(rh);
* CLIENT *rh;
*/
#define CLNT_GETERR(rh,errp) ((*(rh)->cl_ops->cl_geterr)(rh, errp))
#define clnt_geterr(rh,errp) ((*(rh)->cl_ops->cl_geterr)(rh, errp))
/*
* bool_t
* CLNT_FREERES(rh, xres, resp);
* CLIENT *rh;
* xdrproc_t xres;
* caddr_t resp;
*/
#define CLNT_FREERES(rh,xres,resp) ((*(rh)->cl_ops->cl_freeres)(rh,xres,resp))
#define clnt_freeres(rh,xres,resp) ((*(rh)->cl_ops->cl_freeres)(rh,xres,resp))
/*
* bool_t
* CLNT_CONTROL(cl, request, info)
* CLIENT *cl;
* u_int request;
* char *info;
*/
#define CLNT_CONTROL(cl,rq,in) ((*(cl)->cl_ops->cl_control)(cl,rq,in))
#define clnt_control(cl,rq,in) ((*(cl)->cl_ops->cl_control)(cl,rq,in))
/*
* control operations that apply to udp, tcp and unix transports
*
* Note: options marked XXX are no-ops in this implementation of RPC.
* The are present in TI-RPC but can't be implemented here since they
* depend on the presence of STREAMS/TLI, which we don't have.
*
*/
#define CLSET_TIMEOUT 1 /* set timeout (timeval) */
#define CLGET_TIMEOUT 2 /* get timeout (timeval) */
#define CLGET_SERVER_ADDR 3 /* get server's address (sockaddr) */
#define CLGET_FD 6 /* get connections file descriptor */
#define CLGET_SVC_ADDR 7 /* get server's address (netbuf) XXX */
#define CLSET_FD_CLOSE 8 /* close fd while clnt_destroy */
#define CLSET_FD_NCLOSE 9 /* Do not close fd while clnt_destroy */
#define CLGET_XID 10 /* Get xid */
#define CLSET_XID 11 /* Set xid */
#define CLGET_VERS 12 /* Get version number */
#define CLSET_VERS 13 /* Set version number */
#define CLGET_PROG 14 /* Get program number */
#define CLSET_PROG 15 /* Set program number */
#define CLSET_SVC_ADDR 16 /* get server's address (netbuf) XXX */
#define CLSET_PUSH_TIMOD 17 /* push timod if not already present XXX */
#define CLSET_POP_TIMOD 18 /* pop timod XXX */
/*
* udp only control operations
*/
#define CLSET_RETRY_TIMEOUT 4 /* set retry timeout (timeval) */
#define CLGET_RETRY_TIMEOUT 5 /* get retry timeout (timeval) */
/*
* Operations which GSSAPI needs. (Bletch.)
*/
#define CLGET_LOCAL_ADDR 19 /* get local addr (sockaddr) */
/*
* void
* CLNT_DESTROY(rh);
* CLIENT *rh;
*/
#define CLNT_DESTROY(rh) ((*(rh)->cl_ops->cl_destroy)(rh))
#define clnt_destroy(rh) ((*(rh)->cl_ops->cl_destroy)(rh))
/*
* RPCTEST is a test program which is accessible on every rpc
* transport/port. It is used for testing, performance evaluation,
* and network administration.
*/
#define RPCTEST_PROGRAM ((u_long)1)
#define RPCTEST_VERSION ((u_long)1)
#define RPCTEST_NULL_PROC ((u_long)2)
#define RPCTEST_NULL_BATCH_PROC ((u_long)3)
/*
* By convention, procedure 0 takes null arguments and returns them
*/
#define NULLPROC ((u_long)0)
/*
* Below are the client handle creation routines for the various
* implementations of client side rpc. They can return NULL if a
* creation failure occurs.
*/
/*
* Memory based rpc (for speed check and testing)
* CLIENT *
* clntraw_create(prog, vers)
* u_long prog;
* u_long vers;
*/
__BEGIN_DECLS
extern CLIENT *clntraw_create __P((u_long, u_long));
__END_DECLS
/*
* Generic client creation routine. Supported protocols are "udp", "tcp"
* and "unix".
* CLIENT *
* clnt_create(host, prog, vers, prot);
* char *host; -- hostname
* u_long prog; -- program number
* u_long vers; -- version number
* char *prot; -- protocol
*/
__BEGIN_DECLS
extern CLIENT *clnt_create __P((char *, u_long, u_long, char *));
__END_DECLS
/*
* TCP based rpc
* CLIENT *
* clnttcp_create(raddr, prog, vers, sockp, sendsz, recvsz)
* struct sockaddr_in *raddr;
* u_long prog;
* u_long version;
* register int *sockp;
* u_int sendsz;
* u_int recvsz;
*/
__BEGIN_DECLS
extern CLIENT *clnttcp_create __P((struct sockaddr_in *,
u_long,
u_long,
int *,
u_int,
u_int));
__END_DECLS
/*
* UDP based rpc.
* CLIENT *
* clntudp_create(raddr, program, version, wait, sockp)
* struct sockaddr_in *raddr;
* u_long program;
* u_long version;
* struct timeval wait;
* int *sockp;
*
* Same as above, but you specify max packet sizes.
* CLIENT *
* clntudp_bufcreate(raddr, program, version, wait, sockp, sendsz, recvsz)
* struct sockaddr_in *raddr;
* u_long program;
* u_long version;
* struct timeval wait;
* int *sockp;
* u_int sendsz;
* u_int recvsz;
*/
__BEGIN_DECLS
extern CLIENT *clntudp_create __P((struct sockaddr_in *,
u_long,
u_long,
struct timeval,
int *));
extern CLIENT *clntudp_bufcreate __P((struct sockaddr_in *,
u_long,
u_long,
struct timeval,
int *,
u_int,
u_int));
__END_DECLS
/*
* AF_UNIX based rpc
* CLIENT *
* clntunix_create(raddr, prog, vers, sockp, sendsz, recvsz)
* struct sockaddr_un *raddr;
* u_long prog;
* u_long version;
* register int *sockp;
* u_int sendsz;
* u_int recvsz;
*/
__BEGIN_DECLS
extern CLIENT *clntunix_create __P((struct sockaddr_un *,
u_long,
u_long,
int *,
u_int,
u_int));
__END_DECLS
/*
* Print why creation failed
*/
__BEGIN_DECLS
extern void clnt_pcreateerror __P((char *)); /* stderr */
extern char *clnt_spcreateerror __P((char *)); /* string */
__END_DECLS
/*
* Like clnt_perror(), but is more verbose in its output
*/
__BEGIN_DECLS
extern void clnt_perrno __P((enum clnt_stat)); /* stderr */
extern char *clnt_sperrno __P((enum clnt_stat)); /* string */
__END_DECLS
/*
* Print an English error message, given the client error code
*/
__BEGIN_DECLS
extern void clnt_perror __P((CLIENT *, char *)); /* stderr */
extern char *clnt_sperror __P((CLIENT *, char *)); /* string */
__END_DECLS
/*
* If a creation fails, the following allows the user to figure out why.
*/
struct rpc_createerr {
enum clnt_stat cf_stat;
struct rpc_err cf_error; /* useful when cf_stat == RPC_PMAPFAILURE */
};
extern struct rpc_createerr rpc_createerr;
#define UDPMSGSIZE 8800 /* rpc imposed limit on udp msg size */
#define RPCSMALLMSGSIZE 400 /* a more reasonable packet size */
#endif /* !_RPC_CLNT_H */

View File

@@ -1,82 +0,0 @@
/* @(#)des.h 2.2 88/08/10 4.0 RPCSRC; from 2.7 88/02/08 SMI */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
* unrestricted use provided that this legend is included on all tape
* 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
*/
/*
* Generic DES driver interface
* Keep this file hardware independent!
* Copyright (c) 1986 by Sun Microsystems, Inc.
*/
#define DES_MAXLEN 65536 /* maximum # of bytes to encrypt */
#define DES_QUICKLEN 16 /* maximum # of bytes to encrypt quickly */
enum desdir { ENCRYPT, DECRYPT };
enum desmode { CBC, ECB };
/*
* parameters to ioctl call
*/
struct desparams {
u_char des_key[8]; /* key (with low bit parity) */
enum desdir des_dir; /* direction */
enum desmode des_mode; /* mode */
u_char des_ivec[8]; /* input vector */
unsigned des_len; /* number of bytes to crypt */
union {
u_char UDES_data[DES_QUICKLEN];
u_char *UDES_buf;
} UDES;
# define des_data UDES.UDES_data /* direct data here if quick */
# define des_buf UDES.UDES_buf /* otherwise, pointer to data */
};
#ifdef notdef
/*
* These ioctls are only implemented in SunOS. Maybe someday
* if somebody writes a driver for DES hardware that works
* with FreeBSD, we can being that back.
*/
/*
* Encrypt an arbitrary sized buffer
*/
#define DESIOCBLOCK _IOWR(d, 6, struct desparams)
/*
* Encrypt of small amount of data, quickly
*/
#define DESIOCQUICK _IOWR(d, 7, struct desparams)
#endif
/*
* Software DES.
*/
extern int _des_crypt __P(( char *, int, struct desparams * ));

View File

@@ -1,120 +0,0 @@
/*
* @(#)des_crypt.h 2.1 88/08/11 4.0 RPCSRC; from 1.4 88/02/08 (C) 1986 SMI
* $FreeBSD: src/include/rpc/des_crypt.h,v 1.2 1999/12/29 05:00:42 peter Exp $
*
* des_crypt.h, des library routine interface
* Copyright (C) 1986, Sun Microsystems, Inc.
*/
/*
* 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
*/
#include <sys/cdefs.h>
#include <rpc/rpc.h>
#define DES_MAXDATA 8192 /* max bytes encrypted in one call */
#define DES_DIRMASK (1 << 0)
#define DES_ENCRYPT (0*DES_DIRMASK) /* Encrypt */
#define DES_DECRYPT (1*DES_DIRMASK) /* Decrypt */
#define DES_DEVMASK (1 << 1)
#define DES_HW (0*DES_DEVMASK) /* Use hardware device */
#define DES_SW (1*DES_DEVMASK) /* Use software device */
#define DESERR_NONE 0 /* succeeded */
#define DESERR_NOHWDEVICE 1 /* succeeded, but hw device not available */
#define DESERR_HWERROR 2 /* failed, hardware/driver error */
#define DESERR_BADPARAM 3 /* failed, bad parameter to call */
#define DES_FAILED(err) \
((err) > DESERR_NOHWDEVICE)
/*
* cbc_crypt()
* ecb_crypt()
*
* Encrypt (or decrypt) len bytes of a buffer buf.
* The length must be a multiple of eight.
* The key should have odd parity in the low bit of each byte.
* ivec is the input vector, and is updated to the new one (cbc only).
* The mode is created by oring together the appropriate parameters.
* DESERR_NOHWDEVICE is returned if DES_HW was specified but
* there was no hardware to do it on (the data will still be
* encrypted though, in software).
*/
/*
* Cipher Block Chaining mode
*/
__BEGIN_DECLS
#ifdef __STDC__
int cbc_crypt __P(( char *, char *, unsigned int, unsigned int, char *));
#else
cbc_crypt(/* key, buf, len, mode, ivec */); /*
char *key;
char *buf;
unsigned len;
unsigned mode;
char *ivec;
*/
#endif
/*
* Electronic Code Book mode
*/
#ifdef __STDC__
int ecb_crypt __P(( char *, char *, unsigned int, unsigned int ));
#else
ecb_crypt(/* key, buf, len, mode */); /*
char *key;
char *buf;
unsigned len;
unsigned mode;
*/
#endif
__END_DECLS
#ifndef _KERNEL
/*
* Set des parity for a key.
* DES parity is odd and in the low bit of each byte
*/
__BEGIN_DECLS
#ifdef __STDC__
void des_setparity __P(( char *));
#else
void
des_setparity(/* key */); /*
char *key;
*/
#endif
__END_DECLS
#endif

View File

@@ -1,85 +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, MERCHANTABILITY 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
*
* from: @(#)pmap_clnt.h 1.11 88/02/08 SMI
* from: @(#)pmap_clnt.h 2.1 88/07/29 4.0 RPCSRC
* $FreeBSD: src/include/rpc/pmap_clnt.h,v 1.11 1999/08/27 23:45:04 peter Exp $
*/
/*
* pmap_clnt.h
* Supplies C routines to get to portmap services.
*
* Copyright (C) 1984, Sun Microsystems, Inc.
*/
/*
* Usage:
* success = pmap_set(program, version, protocol, port);
* success = pmap_unset(program, version);
* port = pmap_getport(address, program, version, protocol);
* head = pmap_getmaps(address);
* clnt_stat = pmap_rmtcall(address, program, version, procedure,
* xdrargs, argsp, xdrres, resp, tout, port_ptr)
* (works for udp only.)
* clnt_stat = clnt_broadcast(program, version, procedure,
* xdrargs, argsp, xdrres, resp, eachresult)
* (like pmap_rmtcall, except the call is broadcasted to all
* locally connected nets. For each valid response received,
* the procedure eachresult is called. Its form is:
* done = eachresult(resp, raddr)
* bool_t done;
* caddr_t resp;
* struct sockaddr_in raddr;
* where resp points to the results of the call and raddr is the
* address if the responder to the broadcast.
*/
#ifndef _RPC_PMAPCLNT_H
#define _RPC_PMAPCLNT_H
#include <sys/cdefs.h>
__BEGIN_DECLS
extern bool_t pmap_set __P((u_long, u_long, int, int));
extern bool_t pmap_unset __P((u_long, u_long));
extern struct pmaplist *pmap_getmaps __P((struct sockaddr_in *));
extern enum clnt_stat pmap_rmtcall __P((struct sockaddr_in *,
u_long, u_long, u_long,
xdrproc_t, caddr_t,
xdrproc_t, caddr_t,
struct timeval, u_long *));
extern enum clnt_stat clnt_broadcast __P((u_long, u_long, u_long,
xdrproc_t, char *,
xdrproc_t, char *,
bool_t (*) __P((caddr_t,
struct sockaddr_in *))));
extern u_short pmap_getport __P((struct sockaddr_in *,
u_long, u_long, u_int));
__END_DECLS
#endif /* !_RPC_PMAPCLNT_H */

View File

@@ -1,104 +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, MERCHANTABILITY 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
*
* from: @(#)pmap_prot.h 1.14 88/02/08 SMI
* from: @(#)pmap_prot.h 2.1 88/07/29 4.0 RPCSRC
* $FreeBSD: src/include/rpc/pmap_prot.h,v 1.10 1999/08/27 23:45:04 peter Exp $
*/
/*
* pmap_prot.h
* Protocol for the local binder service, or pmap.
*
* Copyright (C) 1984, Sun Microsystems, Inc.
*
* The following procedures are supported by the protocol:
*
* PMAPPROC_NULL() returns ()
* takes nothing, returns nothing
*
* PMAPPROC_SET(struct pmap) returns (bool_t)
* TRUE is success, FALSE is failure. Registers the tuple
* [prog, vers, prot, port].
*
* PMAPPROC_UNSET(struct pmap) returns (bool_t)
* TRUE is success, FALSE is failure. Un-registers pair
* [prog, vers]. prot and port are ignored.
*
* PMAPPROC_GETPORT(struct pmap) returns (long unsigned).
* 0 is failure. Otherwise returns the port number where the pair
* [prog, vers] is registered. It may lie!
*
* PMAPPROC_DUMP() RETURNS (struct pmaplist *)
*
* PMAPPROC_CALLIT(unsigned, unsigned, unsigned, string<>)
* RETURNS (port, string<>);
* usage: encapsulatedresults = PMAPPROC_CALLIT(prog, vers, proc, encapsulatedargs);
* Calls the procedure on the local machine. If it is not registered,
* this procedure is quite; ie it does not return error information!!!
* This procedure only is supported on rpc/udp and calls via
* rpc/udp. This routine only passes null authentication parameters.
* This file has no interface to xdr routines for PMAPPROC_CALLIT.
*
* The service supports remote procedure calls on udp/ip or tcp/ip socket 111.
*/
#ifndef _RPC_PMAPPROT_H
#define _RPC_PMAPPROT_H
#include <sys/cdefs.h>
#define PMAPPORT ((u_short)111)
#define PMAPPROG ((u_long)100000)
#define PMAPVERS ((u_long)2)
#define PMAPVERS_PROTO ((u_long)2)
#define PMAPVERS_ORIG ((u_long)1)
#define PMAPPROC_NULL ((u_long)0)
#define PMAPPROC_SET ((u_long)1)
#define PMAPPROC_UNSET ((u_long)2)
#define PMAPPROC_GETPORT ((u_long)3)
#define PMAPPROC_DUMP ((u_long)4)
#define PMAPPROC_CALLIT ((u_long)5)
struct pmap {
long unsigned pm_prog;
long unsigned pm_vers;
long unsigned pm_prot;
long unsigned pm_port;
};
struct pmaplist {
struct pmap pml_map;
struct pmaplist *pml_next;
};
__BEGIN_DECLS
extern bool_t xdr_pmap __P((XDR *, struct pmap *));
extern bool_t xdr_pmaplist __P((XDR *, struct pmaplist **));
__END_DECLS
#endif /* !_RPC_PMAPPROT_H */

View File

@@ -1,63 +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, MERCHANTABILITY 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
*
* from: @(#)pmap_rmt.h 1.2 88/02/08 SMI
* from: @(#)pmap_rmt.h 2.1 88/07/29 4.0 RPCSRC
* $FreeBSD: src/include/rpc/pmap_rmt.h,v 1.10 1999/08/27 23:45:05 peter Exp $
*/
/*
* Structures and XDR routines for parameters to and replies from
* the portmapper remote-call-service.
*
* Copyright (C) 1986, Sun Microsystems, Inc.
*/
#ifndef _RPC_PMAPRMT_H
#define _RPC_PMAPRMT_H
#include <sys/cdefs.h>
struct rmtcallargs {
u_long prog, vers, proc, arglen;
caddr_t args_ptr;
xdrproc_t xdr_args;
};
struct rmtcallres {
u_long *port_ptr;
u_long resultslen;
caddr_t results_ptr;
xdrproc_t xdr_results;
};
__BEGIN_DECLS
extern bool_t xdr_rmtcall_args __P((XDR *, struct rmtcallargs *));
extern bool_t xdr_rmtcallres __P((XDR *, struct rmtcallres *));
__END_DECLS
#endif /* !_RPC_PMAPRMT_H */

View File

@@ -1,137 +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, MERCHANTABILITY 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
*
* from: @(#)rpc.h 1.9 88/02/08 SMI
* from: @(#)rpc.h 2.4 89/07/11 4.0 RPCSRC
* $FreeBSD: src/include/rpc/rpc.h,v 1.12 2000/01/26 09:02:40 shin Exp $
*/
/*
* rpc.h, Just includes the billions of rpc header files necessary to
* do remote procedure calling.
*
* Copyright (C) 1984, Sun Microsystems, Inc.
*/
#ifndef _RPC_RPC_H
#define _RPC_RPC_H
#include <rpc/types.h> /* some typedefs */
#include <netinet/in.h>
/* external data representation interfaces */
#include <rpc/xdr.h> /* generic (de)serializer */
/* Client side only authentication */
#include <rpc/auth.h> /* generic authenticator (client side) */
/* Client side (mostly) remote procedure call */
#include <rpc/clnt.h> /* generic rpc stuff */
/* semi-private protocol headers */
#include <rpc/rpc_msg.h> /* protocol for rpc messages */
#include <rpc/auth_unix.h> /* protocol for unix style cred */
/*
* Uncomment-out the next line if you are building the rpc library with
* DES Authentication (see the README file in the secure_rpc/ directory).
*/
#include <rpc/auth_des.h> /* protocol for des style cred */
/* Server side only remote procedure callee */
#include <rpc/svc.h> /* service manager and multiplexer */
#include <rpc/svc_auth.h> /* service side authenticator */
/*
* COMMENT OUT THE NEXT INCLUDE (or add to the #ifndef) IF RUNNING ON
* A VERSION OF UNIX THAT USES SUN'S NFS SOURCE. These systems will
* already have the structures defined by <rpc/netdb.h> included in <netdb.h>.
*/
/* routines for parsing /etc/rpc */
struct rpcent {
char *r_name; /* name of server for this rpc program */
char **r_aliases; /* alias list */
int r_number; /* rpc program number */
};
__BEGIN_DECLS
extern struct rpcent *getrpcbyname __P((char *));
extern struct rpcent *getrpcbynumber __P((int));
extern struct rpcent *getrpcent __P((void));
extern int getrpcport __P((char *host, int prognum, int versnum, int proto));
extern void setrpcent __P((int));
extern void endrpcent __P((void));
extern int bindresvport __P((int, struct sockaddr_in *));
extern int bindresvport_sa __P((int, struct sockaddr *));
extern int get_myaddress __P((struct sockaddr_in *));
__END_DECLS
int rtems_rpc_task_init (void);
int rtems_rpc_start_portmapper (int priority);
#ifdef _RTEMS_RPC_INTERNAL_
/*
* Multi-threaded support
* Group all global and static variables into a single spot.
* This area will be allocated on a per-task basis
*/
struct rtems_rpc_task_variables {
int svc_svc_maxfd;
fd_set svc_svc_fdset;
void *svc_xports;
int svc_xportssize;
int svc__svc_fdsetsize;
void *svc__svc_fdset;
void *svc_svc_head;
void *clnt_perror_buf;
void *clnt_raw_private;
void *call_rpc_private;
void *svc_raw_private;
void *svc_simple_proglst;
void *svc_simple_pl;
void *svc_simple_transp;
void *rpcdname_default_domain;
void *svc_auths_Auths;
};
extern void *rtems_rpc_task_variables;
#define svc_maxfd (((struct rtems_rpc_task_variables *)rtems_rpc_task_variables)->svc_svc_maxfd)
#define svc_fdset (((struct rtems_rpc_task_variables *)rtems_rpc_task_variables)->svc_svc_fdset)
#define __svc_fdsetsize (((struct rtems_rpc_task_variables *)rtems_rpc_task_variables)->svc__svc_fdsetsize)
#define __svc_fdset (fd_set *)(((struct rtems_rpc_task_variables *)rtems_rpc_task_variables)->svc__svc_fdset)
#endif /* _RTEMS_RPC_INTERNAL_ */
#endif /* !_RPC_RPC_H */

View File

@@ -1,78 +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) 1986 - 1991 by Sun Microsystems, Inc.
*/
/*
* rpc_com.h, Common definitions for both the server and client side.
* All for the topmost layer of rpc
*
*/
#ifndef _RPC_RPCCOM_H
#define _RPC_RPCCOM_H
/* From: #pragma ident "@(#)rpc_com.h 1.11 93/07/05 SMI" */
#ifdef __cplusplus
extern "C" {
#endif
/*
* File descriptor to be used on xxx_create calls to get default descriptor
*/
#define RPC_ANYSOCK -1
#define RPC_ANYFD RPC_ANYSOCK
/*
* The max size of the transport, if the size cannot be determined
* by other means.
*/
#define RPC_MAXDATASIZE 9000
#define RPC_MAXADDRSIZE 1024
#if defined(__STDC__) || defined(__cplusplus)
extern u_int __rpc_get_t_size (int, long);
extern u_int __rpc_get_a_size (long);
extern int __rpc_dtbsize (void);
extern int _rpc_dtablesize (void);
extern int _rpc_get_default_domain(char **);
#else
extern u_int __rpc_get_t_size ();
extern u_int __rpc_get_a_size ();
extern int __rpc_dtbsize ();
extern int _rpc_dtablesize ();
extern int _rpc_get_default_domain();
#endif
#ifdef __cplusplus
}
#endif
#endif /* _RPC_RPCCOM_H */

View File

@@ -1,196 +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, MERCHANTABILITY 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
*
* from: @(#)rpc_msg.h 1.7 86/07/16 SMI
* from: @(#)rpc_msg.h 2.1 88/07/29 4.0 RPCSRC
* $FreeBSD: src/include/rpc/rpc_msg.h,v 1.12 1999/08/27 23:45:05 peter Exp $
*/
/*
* rpc_msg.h
* rpc message definition
*
* Copyright (C) 1984, Sun Microsystems, Inc.
*/
#ifndef _RPC_RPCMSG_H
#define _RPC_RPCMSG_H
#define RPC_MSG_VERSION ((u_long) 2)
#define RPC_SERVICE_PORT ((u_short) 2048)
/*
* Bottom up definition of an rpc message.
* NOTE: call and reply use the same overall stuct but
* different parts of unions within it.
*/
enum msg_type {
CALL=0,
REPLY=1
};
enum reply_stat {
MSG_ACCEPTED=0,
MSG_DENIED=1
};
enum accept_stat {
SUCCESS=0,
PROG_UNAVAIL=1,
PROG_MISMATCH=2,
PROC_UNAVAIL=3,
GARBAGE_ARGS=4,
SYSTEM_ERR=5
};
enum reject_stat {
RPC_MISMATCH=0,
AUTH_ERROR=1
};
/*
* Reply part of an rpc exchange
*/
/*
* Reply to an rpc request that was accepted by the server.
* Note: there could be an error even though the request was
* accepted.
*/
struct accepted_reply {
struct opaque_auth ar_verf;
enum accept_stat ar_stat;
union {
struct {
u_int32_t low;
u_int32_t high;
} AR_versions;
struct {
caddr_t where;
xdrproc_t proc;
} AR_results;
/* and many other null cases */
} ru;
#define ar_results ru.AR_results
#define ar_vers ru.AR_versions
};
/*
* Reply to an rpc request that was rejected by the server.
*/
struct rejected_reply {
enum reject_stat rj_stat;
union {
struct {
u_int32_t low;
u_int32_t high;
} RJ_versions;
enum auth_stat RJ_why; /* why authentication did not work */
} ru;
#define rj_vers ru.RJ_versions
#define rj_why ru.RJ_why
};
/*
* Body of a reply to an rpc request.
*/
struct reply_body {
enum reply_stat rp_stat;
union {
struct accepted_reply RP_ar;
struct rejected_reply RP_dr;
} ru;
#define rp_acpt ru.RP_ar
#define rp_rjct ru.RP_dr
};
/*
* Body of an rpc request call.
*/
struct call_body {
u_int32_t cb_rpcvers; /* must be equal to two */
u_int32_t cb_prog;
u_int32_t cb_vers;
u_int32_t cb_proc;
struct opaque_auth cb_cred;
struct opaque_auth cb_verf; /* protocol specific - provided by client */
};
/*
* The rpc message
*/
struct rpc_msg {
u_int32_t rm_xid;
enum msg_type rm_direction;
union {
struct call_body RM_cmb;
struct reply_body RM_rmb;
} ru;
#define rm_call ru.RM_cmb
#define rm_reply ru.RM_rmb
};
#define acpted_rply ru.RM_rmb.ru.RP_ar
#define rjcted_rply ru.RM_rmb.ru.RP_dr
__BEGIN_DECLS
/*
* XDR routine to handle a rpc message.
* xdr_callmsg(xdrs, cmsg)
* XDR *xdrs;
* struct rpc_msg *cmsg;
*/
extern bool_t xdr_callmsg __P((XDR *, struct rpc_msg *));
/*
* XDR routine to pre-serialize the static part of a rpc message.
* xdr_callhdr(xdrs, cmsg)
* XDR *xdrs;
* struct rpc_msg *cmsg;
*/
extern bool_t xdr_callhdr __P((XDR *, struct rpc_msg *));
/*
* XDR routine to handle a rpc reply.
* xdr_replymsg(xdrs, rmsg)
* XDR *xdrs;
* struct rpc_msg *rmsg;
*/
extern bool_t xdr_replymsg __P((XDR *, struct rpc_msg *));
/*
* Fills in the error part of a reply message.
* _seterr_reply(msg, error)
* struct rpc_msg *msg;
* struct rpc_err *error;
*/
struct rpc_err;
extern void _seterr_reply __P((struct rpc_msg *, struct rpc_err *));
__END_DECLS
#endif /* !_RPC_RPCMSG_H */

View File

@@ -1,324 +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, MERCHANTABILITY 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
*
* from: @(#)svc.h 1.20 88/02/08 SMI
* from: @(#)svc.h 2.2 88/07/29 4.0 RPCSRC
* $FreeBSD: src/include/rpc/svc.h,v 1.16 1999/12/29 05:00:43 peter Exp $
*/
/*
* svc.h, Server-side remote procedure call interface.
*
* Copyright (C) 1984, Sun Microsystems, Inc.
*/
#ifndef _RPC_SVC_H
#define _RPC_SVC_H
#include <sys/cdefs.h>
/*
* This interface must manage two items concerning remote procedure calling:
*
* 1) An arbitrary number of transport connections upon which rpc requests
* are received. The two most notable transports are TCP and UDP; they are
* created and registered by routines in svc_tcp.c and svc_udp.c, respectively;
* they in turn call xprt_register and xprt_unregister.
*
* 2) An arbitrary number of locally registered services. Services are
* described by the following four data: program number, version number,
* "service dispatch" function, a transport handle, and a boolean that
* indicates whether or not the exported program should be registered with a
* local binder service; if true the program's number and version and the
* port number from the transport handle are registered with the binder.
* These data are registered with the rpc svc system via svc_register.
*
* A service's dispatch function is called whenever an rpc request comes in
* on a transport. The request's program and version numbers must match
* those of the registered service. The dispatch function is passed two
* parameters, struct svc_req * and SVCXPRT *, defined below.
*/
enum xprt_stat {
XPRT_DIED,
XPRT_MOREREQS,
XPRT_IDLE
};
struct rpc_msg;
/*
* Server side transport handle
*/
typedef struct __rpc_svcxprt {
int xp_sock;
u_short xp_port; /* associated port number */
struct xp_ops {
/* receive incoming requests */
bool_t (*xp_recv) __P((struct __rpc_svcxprt *,
struct rpc_msg *));
/* get transport status */
enum xprt_stat (*xp_stat) __P((struct __rpc_svcxprt *));
/* get arguments */
bool_t (*xp_getargs) __P((struct __rpc_svcxprt *, xdrproc_t,
caddr_t));
/* send reply */
bool_t (*xp_reply) __P((struct __rpc_svcxprt *,
struct rpc_msg *));
/* free mem allocated for args */
bool_t (*xp_freeargs) __P((struct __rpc_svcxprt *, xdrproc_t,
caddr_t));
/* destroy this struct */
void (*xp_destroy) __P((struct __rpc_svcxprt *));
} *xp_ops;
int xp_addrlen; /* length of remote address */
struct sockaddr_in xp_raddr; /* remote address */
struct opaque_auth xp_verf; /* raw response verifier */
caddr_t xp_p1; /* private */
caddr_t xp_p2; /* private */
} SVCXPRT;
/*
* Approved way of getting address of caller
*/
#define svc_getcaller(x) (&(x)->xp_raddr)
/*
* Operations defined on an SVCXPRT handle
*
* SVCXPRT *xprt;
* struct rpc_msg *msg;
* xdrproc_t xargs;
* caddr_t argsp;
*/
#define SVC_RECV(xprt, msg) \
(*(xprt)->xp_ops->xp_recv)((xprt), (msg))
#define svc_recv(xprt, msg) \
(*(xprt)->xp_ops->xp_recv)((xprt), (msg))
#define SVC_STAT(xprt) \
(*(xprt)->xp_ops->xp_stat)(xprt)
#define svc_stat(xprt) \
(*(xprt)->xp_ops->xp_stat)(xprt)
#define SVC_GETARGS(xprt, xargs, argsp) \
(*(xprt)->xp_ops->xp_getargs)((xprt), (xargs), (argsp))
#define svc_getargs(xprt, xargs, argsp) \
(*(xprt)->xp_ops->xp_getargs)((xprt), (xargs), (argsp))
#define SVC_REPLY(xprt, msg) \
(*(xprt)->xp_ops->xp_reply) ((xprt), (msg))
#define svc_reply(xprt, msg) \
(*(xprt)->xp_ops->xp_reply) ((xprt), (msg))
#define SVC_FREEARGS(xprt, xargs, argsp) \
(*(xprt)->xp_ops->xp_freeargs)((xprt), (xargs), (argsp))
#define svc_freeargs(xprt, xargs, argsp) \
(*(xprt)->xp_ops->xp_freeargs)((xprt), (xargs), (argsp))
#define SVC_DESTROY(xprt) \
(*(xprt)->xp_ops->xp_destroy)(xprt)
#define svc_destroy(xprt) \
(*(xprt)->xp_ops->xp_destroy)(xprt)
/*
* Service request
*/
struct svc_req {
u_int32_t rq_prog; /* service program number */
u_int32_t rq_vers; /* service protocol version */
u_int32_t rq_proc; /* the desired procedure */
struct opaque_auth rq_cred; /* raw creds from the wire */
caddr_t rq_clntcred; /* read only cooked cred */
SVCXPRT *rq_xprt; /* associated transport */
};
/*
* Service registration
*
* svc_register(xprt, prog, vers, dispatch, protocol)
* SVCXPRT *xprt;
* u_long prog;
* u_long vers;
* void (*dispatch)();
* int protocol; (like TCP or UDP, zero means do not register)
*/
__BEGIN_DECLS
extern bool_t svc_register __P((SVCXPRT *, u_long, u_long,
void (*) __P((struct svc_req *, SVCXPRT *)), int));
__END_DECLS
/*
* Service un-registration
*
* svc_unregister(prog, vers)
* u_long prog;
* u_long vers;
*/
__BEGIN_DECLS
extern void svc_unregister __P((u_long, u_long));
__END_DECLS
/*
* Transport registration.
*
* xprt_register(xprt)
* SVCXPRT *xprt;
*/
__BEGIN_DECLS
extern void xprt_register __P((SVCXPRT *));
__END_DECLS
/*
* Transport un-register
*
* xprt_unregister(xprt)
* SVCXPRT *xprt;
*/
__BEGIN_DECLS
extern void xprt_unregister __P((SVCXPRT *));
__END_DECLS
/*
* When the service routine is called, it must first check to see if it
* knows about the procedure; if not, it should call svcerr_noproc
* and return. If so, it should deserialize its arguments via
* SVC_GETARGS (defined above). If the deserialization does not work,
* svcerr_decode should be called followed by a return. Successful
* decoding of the arguments should be followed the execution of the
* procedure's code and a call to svc_sendreply.
*
* Also, if the service refuses to execute the procedure due to too-
* weak authentication parameters, svcerr_weakauth should be called.
* Note: do not confuse access-control failure with weak authentication!
*
* NB: In pure implementations of rpc, the caller always waits for a reply
* msg. This message is sent when svc_sendreply is called.
* Therefore pure service implementations should always call
* svc_sendreply even if the function logically returns void; use
* xdr.h - xdr_void for the xdr routine. HOWEVER, tcp based rpc allows
* for the abuse of pure rpc via batched calling or pipelining. In the
* case of a batched call, svc_sendreply should NOT be called since
* this would send a return message, which is what batching tries to avoid.
* It is the service/protocol writer's responsibility to know which calls are
* batched and which are not. Warning: responding to batch calls may
* deadlock the caller and server processes!
*/
__BEGIN_DECLS
extern bool_t svc_sendreply __P((SVCXPRT *, xdrproc_t, char *));
extern void svcerr_decode __P((SVCXPRT *));
extern void svcerr_weakauth __P((SVCXPRT *));
extern void svcerr_noproc __P((SVCXPRT *));
extern void svcerr_progvers __P((SVCXPRT *, u_long, u_long));
extern void svcerr_auth __P((SVCXPRT *, enum auth_stat));
extern void svcerr_noprog __P((SVCXPRT *));
extern void svcerr_systemerr __P((SVCXPRT *));
__END_DECLS
/*
* Lowest level dispatching -OR- who owns this process anyway.
* Somebody has to wait for incoming requests and then call the correct
* service routine. The routine svc_run does infinite waiting; i.e.,
* svc_run never returns.
* Since another (co-existant) package may wish to selectively wait for
* incoming calls or other events outside of the rpc architecture, the
* routine svc_getreq is provided. It must be passed readfds, the
* "in-place" results of a select system call (see select, section 2).
*/
/*
* Global keeper of rpc service descriptors in use
* dynamic; must be inspected before each call to select
*/
extern int svc_maxfd;
extern fd_set svc_fdset;
#define svc_fds svc_fdset.fds_bits[0] /* compatibility */
#ifndef _KERNEL
/*
* a small program implemented by the svc_rpc implementation itself;
* also see clnt.h for protocol numbers.
*/
extern void rpctest_service();
#endif
__BEGIN_DECLS
extern void svc_getreq __P((int));
extern void svc_getreqset __P((fd_set *));
extern void svc_getreqset2 __P((fd_set *, int)); /* XXX: nonstd, undoc */
extern void svc_run __P((void));
__END_DECLS
/*
* Socket to use on svcxxx_create call to get default socket
*/
#define RPC_ANYSOCK -1
/*
* These are the existing service side transport implementations
*/
/*
* Memory based rpc for testing and timing.
*/
__BEGIN_DECLS
extern SVCXPRT *svcraw_create __P((void));
__END_DECLS
/*
* Udp based rpc.
*/
__BEGIN_DECLS
extern SVCXPRT *svcudp_create __P((int));
extern SVCXPRT *svcudp_bufcreate __P((int, u_int, u_int));
__END_DECLS
/*
* Tcp based rpc.
*/
__BEGIN_DECLS
extern SVCXPRT *svctcp_create __P((int, u_int, u_int));
extern SVCXPRT *svcfd_create __P((int, u_int, u_int));
__END_DECLS
/*
* AF_UNIX socket based rpc.
*/
__BEGIN_DECLS
extern SVCXPRT *svcunix_create __P((int, u_int, u_int, char *));
extern SVCXPRT *svcunixfd_create __P((int, u_int, u_int));
__END_DECLS
#endif /* !_RPC_SVC_H */

View File

@@ -1,56 +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, MERCHANTABILITY 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
*
* from: @(#)svc_auth.h 1.6 86/07/16 SMI
* from: @(#)svc_auth.h 2.1 88/07/29 4.0 RPCSRC
* $FreeBSD: src/include/rpc/svc_auth.h,v 1.12 1999/08/27 23:45:05 peter Exp $
*/
/*
* svc_auth.h, Service side of rpc authentication.
*
* Copyright (C) 1984, Sun Microsystems, Inc.
*/
#ifndef _RPC_SVCAUTH_H
#define _RPC_SVCAUTH_H
struct rpc_msg;
struct svc_req;
/*
* Server side authenticator
*/
__BEGIN_DECLS
extern enum auth_stat _authenticate __P((struct svc_req *, struct rpc_msg *));
extern int svc_auth_reg __P((int, enum auth_stat (*)(struct svc_req *,
struct rpc_msg *)));
extern enum auth_stat _svcauth_des __P((struct svc_req *, struct rpc_msg *));
__END_DECLS
#endif /* !_RPC_SVCAUTH_H */

View File

@@ -1,62 +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, MERCHANTABILITY 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
*
* from: @(#)types.h 1.18 87/07/24 SMI
* from: @(#)types.h 2.3 88/08/15 4.0 RPCSRC
* $FreeBSD: src/include/rpc/types.h,v 1.9 1999/08/27 23:45:06 peter Exp $
*/
/*
* Rpc additions to <sys/types.h>
*/
#ifndef _RPC_TYPES_H
#define _RPC_TYPES_H
#define bool_t int32_t
#define enum_t int32_t
#define __dontcare__ -1
#ifndef FALSE
# define FALSE (0)
#endif
#ifndef TRUE
# define TRUE (1)
#endif
#ifndef NULL
# define NULL 0
#endif
#define mem_alloc(bsize) malloc(bsize)
#define mem_free(ptr, bsize) free(ptr)
#ifndef makedev /* ie, we haven't already included it */
#include <sys/types.h>
#endif
#include <sys/time.h>
#endif /* !_RPC_TYPES_H */

View File

@@ -1,314 +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, MERCHANTABILITY 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
*
* from: @(#)xdr.h 1.19 87/04/22 SMI
* from: @(#)xdr.h 2.2 88/07/29 4.0 RPCSRC
* $FreeBSD: src/include/rpc/xdr.h,v 1.14 1999/12/29 05:00:44 peter Exp $
*/
/*
* xdr.h, External Data Representation Serialization Routines.
*
* Copyright (C) 1984, Sun Microsystems, Inc.
*/
#ifndef _RPC_XDR_H
#define _RPC_XDR_H
#include <sys/cdefs.h>
/*
* XDR provides a conventional way for converting between C data
* types and an external bit-string representation. Library supplied
* routines provide for the conversion on built-in C data types. These
* routines and utility routines defined here are used to help implement
* a type encode/decode routine for each user-defined type.
*
* Each data type provides a single procedure which takes two arguments:
*
* bool_t
* xdrproc(xdrs, argresp)
* XDR *xdrs;
* <type> *argresp;
*
* xdrs is an instance of a XDR handle, to which or from which the data
* type is to be converted. argresp is a pointer to the structure to be
* converted. The XDR handle contains an operation field which indicates
* which of the operations (ENCODE, DECODE * or FREE) is to be performed.
*
* XDR_DECODE may allocate space if the pointer argresp is null. This
* data can be freed with the XDR_FREE operation.
*
* We write only one procedure per data type to make it easy
* to keep the encode and decode procedures for a data type consistent.
* In many cases the same code performs all operations on a user defined type,
* because all the hard work is done in the component type routines.
* decode as a series of calls on the nested data types.
*/
/*
* Xdr operations. XDR_ENCODE causes the type to be encoded into the
* stream. XDR_DECODE causes the type to be extracted from the stream.
* XDR_FREE can be used to release the space allocated by an XDR_DECODE
* request.
*/
enum xdr_op {
XDR_ENCODE=0,
XDR_DECODE=1,
XDR_FREE=2
};
/*
* This is the number of bytes per unit of external data.
*/
#define BYTES_PER_XDR_UNIT (4)
#define RNDUP(x) ((((x) + BYTES_PER_XDR_UNIT - 1) / BYTES_PER_XDR_UNIT) \
* BYTES_PER_XDR_UNIT)
/*
* The XDR handle.
* Contains operation which is being applied to the stream,
* an operations vector for the particular implementation (e.g. see xdr_mem.c),
* and two private fields for the use of the particular implementation.
*/
typedef struct __rpc_xdr {
enum xdr_op x_op; /* operation; fast additional param */
struct xdr_ops {
/* get a long from underlying stream */
bool_t (*x_getlong) __P((struct __rpc_xdr *, long *));
/* put a long to underlying stream */
bool_t (*x_putlong) __P((struct __rpc_xdr *, long *));
/* get some bytes from underlying stream */
bool_t (*x_getbytes) __P((struct __rpc_xdr *, caddr_t, u_int));
/* put some bytes to underlying stream */
bool_t (*x_putbytes) __P((struct __rpc_xdr *, caddr_t, u_int));
/* returns bytes off from beginning */
u_int (*x_getpostn) __P((struct __rpc_xdr *));
/* lets you reposition the stream */
bool_t (*x_setpostn) __P((struct __rpc_xdr *, u_int));
/* buf quick ptr to buffered data */
int32_t *(*x_inline) __P((struct __rpc_xdr *, u_int));
/* free privates of this xdr_stream */
void (*x_destroy) __P((struct __rpc_xdr *));
} *x_ops;
caddr_t x_public; /* users' data */
caddr_t x_private; /* pointer to private data */
caddr_t x_base; /* private used for position info */
int x_handy; /* extra private word */
} XDR;
/*
* A xdrproc_t exists for each data type which is to be encoded or decoded.
*
* The second argument to the xdrproc_t is a pointer to an opaque pointer.
* The opaque pointer generally points to a structure of the data type
* to be decoded. If this pointer is 0, then the type routines should
* allocate dynamic storage of the appropriate size and return it.
*/
#ifdef _KERNEL
typedef bool_t (*xdrproc_t) __P((XDR *, void *, u_int));
#else
/*
* XXX can't actually prototype it, because some take two args!!!
*/
typedef bool_t (*xdrproc_t) __P((/* XDR *, void *, u_int */));
#endif
/*
* Operations defined on a XDR handle
*
* XDR *xdrs;
* long *longp;
* caddr_t addr;
* u_int len;
* u_int pos;
*/
#define XDR_GETLONG(xdrs, longp) \
(*(xdrs)->x_ops->x_getlong)(xdrs, longp)
#define xdr_getlong(xdrs, longp) \
(*(xdrs)->x_ops->x_getlong)(xdrs, longp)
#define XDR_PUTLONG(xdrs, longp) \
(*(xdrs)->x_ops->x_putlong)(xdrs, longp)
#define xdr_putlong(xdrs, longp) \
(*(xdrs)->x_ops->x_putlong)(xdrs, longp)
#define XDR_GETBYTES(xdrs, addr, len) \
(*(xdrs)->x_ops->x_getbytes)(xdrs, addr, len)
#define xdr_getbytes(xdrs, addr, len) \
(*(xdrs)->x_ops->x_getbytes)(xdrs, addr, len)
#define XDR_PUTBYTES(xdrs, addr, len) \
(*(xdrs)->x_ops->x_putbytes)(xdrs, addr, len)
#define xdr_putbytes(xdrs, addr, len) \
(*(xdrs)->x_ops->x_putbytes)(xdrs, addr, len)
#define XDR_GETPOS(xdrs) \
(*(xdrs)->x_ops->x_getpostn)(xdrs)
#define xdr_getpos(xdrs) \
(*(xdrs)->x_ops->x_getpostn)(xdrs)
#define XDR_SETPOS(xdrs, pos) \
(*(xdrs)->x_ops->x_setpostn)(xdrs, pos)
#define xdr_setpos(xdrs, pos) \
(*(xdrs)->x_ops->x_setpostn)(xdrs, pos)
#define XDR_INLINE(xdrs, len) \
(*(xdrs)->x_ops->x_inline)(xdrs, len)
#define xdr_inline(xdrs, len) \
(*(xdrs)->x_ops->x_inline)(xdrs, len)
#define XDR_DESTROY(xdrs) \
if ((xdrs)->x_ops->x_destroy) \
(*(xdrs)->x_ops->x_destroy)(xdrs)
#define xdr_destroy(xdrs) \
if ((xdrs)->x_ops->x_destroy) \
(*(xdrs)->x_ops->x_destroy)(xdrs)
/*
* Support struct for discriminated unions.
* You create an array of xdrdiscrim structures, terminated with
* a entry with a null procedure pointer. The xdr_union routine gets
* the discriminant value and then searches the array of structures
* for a matching value. If a match is found the associated xdr routine
* is called to handle that part of the union. If there is
* no match, then a default routine may be called.
* If there is no match and no default routine it is an error.
*/
#define NULL_xdrproc_t ((xdrproc_t)0)
struct xdr_discrim {
int value;
xdrproc_t proc;
};
/*
* In-line routines for fast encode/decode of primitive data types.
* Caveat emptor: these use single memory cycles to get the
* data from the underlying buffer, and will fail to operate
* properly if the data is not aligned. The standard way to use these
* is to say:
* if ((buf = XDR_INLINE(xdrs, count)) == NULL)
* return (FALSE);
* <<< macro calls >>>
* where ``count'' is the number of bytes of data occupied
* by the primitive data types.
*
* N.B. and frozen for all time: each data type here uses 4 bytes
* of external representation.
*/
#define IXDR_GET_LONG(buf) ((long)ntohl((u_long)*(buf)++))
#define IXDR_PUT_LONG(buf, v) (*(buf)++ = (long)htonl((u_long)v))
#define IXDR_GET_BOOL(buf) ((bool_t)IXDR_GET_LONG(buf))
#define IXDR_GET_ENUM(buf, t) ((t)IXDR_GET_LONG(buf))
#define IXDR_GET_U_LONG(buf) ((u_long)IXDR_GET_LONG(buf))
#define IXDR_GET_SHORT(buf) ((short)IXDR_GET_LONG(buf))
#define IXDR_GET_U_SHORT(buf) ((u_short)IXDR_GET_LONG(buf))
#define IXDR_PUT_BOOL(buf, v) IXDR_PUT_LONG((buf), ((long)(v)))
#define IXDR_PUT_ENUM(buf, v) IXDR_PUT_LONG((buf), ((long)(v)))
#define IXDR_PUT_U_LONG(buf, v) IXDR_PUT_LONG((buf), ((long)(v)))
#define IXDR_PUT_SHORT(buf, v) IXDR_PUT_LONG((buf), ((long)(v)))
#define IXDR_PUT_U_SHORT(buf, v) IXDR_PUT_LONG((buf), ((long)(v)))
/*
* These are the "generic" xdr routines.
*/
__BEGIN_DECLS
extern bool_t xdr_void __P((void));
extern bool_t xdr_int __P((XDR *, int *));
extern bool_t xdr_u_int __P((XDR *, u_int *));
extern bool_t xdr_long __P((XDR *, long *));
extern bool_t xdr_u_long __P((XDR *, u_long *));
extern bool_t xdr_short __P((XDR *, short *));
extern bool_t xdr_u_short __P((XDR *, u_short *));
extern bool_t xdr_int16_t __P((XDR *, int16_t *));
extern bool_t xdr_u_int16_t __P((XDR *, u_int16_t *));
extern bool_t xdr_int32_t __P((XDR *, int32_t *));
extern bool_t xdr_u_int32_t __P((XDR *, u_int32_t *));
extern bool_t xdr_int64_t __P((XDR *, int64_t *));
extern bool_t xdr_u_int64_t __P((XDR *, u_int64_t *));
extern bool_t xdr_bool __P((XDR *, bool_t *));
extern bool_t xdr_enum __P((XDR *, enum_t *));
extern bool_t xdr_array __P((XDR *, char **, u_int *, u_int, u_int, xdrproc_t));
extern bool_t xdr_bytes __P((XDR *, char **, u_int *, u_int));
extern bool_t xdr_opaque __P((XDR *, caddr_t, u_int));
extern bool_t xdr_string __P((XDR *, char **, u_int));
extern bool_t xdr_union __P((XDR *, enum_t *, char *, struct xdr_discrim *, xdrproc_t));
extern unsigned long xdr_sizeof __P((xdrproc_t, void *));
extern bool_t xdr_char __P((XDR *, char *));
extern bool_t xdr_u_char __P((XDR *, u_char *));
extern bool_t xdr_vector __P((XDR *, char *, u_int, u_int, xdrproc_t));
extern bool_t xdr_float __P((XDR *, float *));
extern bool_t xdr_double __P((XDR *, double *));
extern bool_t xdr_reference __P((XDR *, caddr_t *, u_int, xdrproc_t));
extern bool_t xdr_pointer __P((XDR *, caddr_t *, u_int, xdrproc_t));
extern bool_t xdr_wrapstring __P((XDR *, char **));
extern void xdr_free __P((xdrproc_t, char *));
__END_DECLS
/*
* Common opaque bytes objects used by many rpc protocols;
* declared here due to commonality.
*/
#define MAX_NETOBJ_SZ 1024
struct netobj {
u_int n_len;
char *n_bytes;
};
typedef struct netobj netobj;
extern bool_t xdr_netobj __P((XDR *, struct netobj *));
/*
* These are the public routines for the various implementations of
* xdr streams.
*/
__BEGIN_DECLS
/* XDR using memory buffers */
extern void xdrmem_create __P((XDR *, char *, u_int, enum xdr_op));
#ifdef _STDIO_H_
/* XDR using stdio library */
extern void xdrstdio_create __P((XDR *, FILE *, enum xdr_op));
#endif
/* XDR pseudo records for tcp */
extern void xdrrec_create __P((XDR *, u_int, u_int, char *,
int (*) __P((caddr_t, caddr_t, int)),
int (*) __P((caddr_t, caddr_t, int))));
/* make end of xdr record */
extern bool_t xdrrec_endofrecord __P((XDR *, bool_t));
/* move to beginning of next record */
extern bool_t xdrrec_skiprecord __P((XDR *));
/* true if no more input */
extern bool_t xdrrec_eof __P((XDR *));
__END_DECLS
#endif /* !_RPC_XDR_H */

View File

@@ -1,2 +0,0 @@
Makefile
Makefile.in

View File

@@ -1,12 +0,0 @@
## $Id$
## Currently unused
EXTRA_DIST = bootparam_prot.x crypt.x key_prot.x klm_prot.x mount.x \
nfs_prot.x nis.x nis_cache.x nis_callback.x nis_db.h nis_object.x \
nis_tags.h nislib.h nlm_prot.x pmap_prot.x rex.x rnusers.x rquota.x \
rstat.x rwall.x sm_inter.x spray.x yp.x yp_prot.h ypclnt.h yppasswd.x \
ypupdate_prot.x ypxfrd.x
include $(top_srcdir)/../../../automake/local.am

View File

@@ -1,103 +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
*/
/*
* RPC for bootparms service.
* There are two procedures:
* WHOAMI takes a net address and returns a client name and also a
* likely net address for routing
* GETFILE takes a client name and file identifier and returns the
* server name, server net address and pathname for the file.
* file identifiers typically include root, swap, pub and dump
*/
#ifdef RPC_HDR
%#include <rpc/types.h>
%#include <sys/time.h>
%#include <sys/errno.h>
%#include <sys/param.h>
%#include <sys/syslimits.h>
%#include <sys/ucred.h>
#else
%#ifndef lint
%/*static char sccsid[] = "from: @(#)bootparam_prot.x 1.2 87/06/24 Copyr 1987 Sun Micro";*/
%/*static char sccsid[] = "from: @(#)bootparam_prot.x 2.1 88/08/01 4.0 RPCSRC";*/
%static const char rcsid[] =
% "$FreeBSD: src/include/rpcsvc/bootparam_prot.x,v 1.5 1999/08/27 23:45:07 peter Exp $";
%#endif /* not lint */
#endif
const MAX_MACHINE_NAME = 255;
const MAX_PATH_LEN = 1024;
const MAX_FILEID = 32;
const IP_ADDR_TYPE = 1;
typedef string bp_machine_name_t<MAX_MACHINE_NAME>;
typedef string bp_path_t<MAX_PATH_LEN>;
typedef string bp_fileid_t<MAX_FILEID>;
struct ip_addr_t {
char net;
char host;
char lh;
char impno;
};
union bp_address switch (int address_type) {
case IP_ADDR_TYPE:
ip_addr_t ip_addr;
};
struct bp_whoami_arg {
bp_address client_address;
};
struct bp_whoami_res {
bp_machine_name_t client_name;
bp_machine_name_t domain_name;
bp_address router_address;
};
struct bp_getfile_arg {
bp_machine_name_t client_name;
bp_fileid_t file_id;
};
struct bp_getfile_res {
bp_machine_name_t server_name;
bp_address server_address;
bp_path_t server_path;
};
program BOOTPARAMPROG {
version BOOTPARAMVERS {
bp_whoami_res BOOTPARAMPROC_WHOAMI(bp_whoami_arg) = 1;
bp_getfile_res BOOTPARAMPROC_GETFILE(bp_getfile_arg) = 2;
} = 1;
} = 100026;

View File

@@ -1,91 +0,0 @@
/*
* Copyright (c) 1996
* Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Bill Paul.
* 4. Neither the name of the author nor the names of any co-contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD: src/include/rpcsvc/crypt.x,v 1.3 1999/08/27 23:45:08 peter Exp $
*/
#ifndef RPC_HDR
%#ifndef lint
%static const char rcsid[] =
% "$FreeBSD: src/include/rpcsvc/crypt.x,v 1.3 1999/08/27 23:45:08 peter Exp $";
%#endif
#endif
/*
* This protocol definition exists because of the U.S. government and
* its stupid export laws. We can't export DES code from the United
* States to other countries (even though the code already exists
* outside the U.S. -- go figure that one out) but we need to make
* Secure RPC work. The normal way around this is to break the DES
* code out into a shared library; we can then provide a dummy lib
* in the base OS and provide the real lib in the secure dist, which
* the user can install later. But we need Secure RPC for NIS+, and
* there are several system programs that use NIS+ which are statically
* linked. We would have to provide replacements for these programs
* in the secure dist, but there are a lot, and this is a pain. The
* shared lib trick won't work for these programs, and we can't change
* them once they're compiled.
*
* One solution for this problem is to do the DES encryption as a system
* call; no programs need to be changed and we can even supply the DES
* support as an LKM. But this bloats the kernel. Maybe if we have
* Secure NFS one day this will be worth it, but for now we should keep
* this mess in user space.
*
* So we have this second solution: we provide a server that does the
* DES encryption for us. In this case, the server is keyserv (we need
* it to make Secure RPC work anyway) and we use this protocol to ship
* the data back and forth between keyserv and the application.
*/
enum des_dir { ENCRYPT_DES, DECRYPT_DES };
enum des_mode { CBC_DES, ECB_DES };
struct desargs {
u_char des_key[8]; /* key (with low bit parity) */
des_dir des_dir; /* direction */
des_mode des_mode; /* mode */
u_char des_ivec[8]; /* input vector */
opaque desbuf<>;
};
struct desresp {
opaque desbuf<>;
u_char des_ivec[8];
int stat;
};
program CRYPT_PROG {
version CRYPT_VERS {
desresp
DES_CRYPT(desargs) = 1;
} = 1;
} = 600100029;

View File

@@ -1,284 +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
% */
/*
* Key server protocol definition
* Copyright (C) 1990, 1991 Sun Microsystems, Inc.
*
* The keyserver is a public key storage/encryption/decryption service
* The encryption method used is based on the Diffie-Hellman exponential
* key exchange technology.
*
* The key server is local to each machine, akin to the portmapper.
* Under TI-RPC, communication with the keyserver is through the
* loopback transport.
*
* NOTE: This .x file generates the USER level headers for the keyserver.
* the KERNEL level headers are created by hand as they kernel has special
* requirements.
*/
%/* From: #pragma ident "@(#)key_prot.x 1.7 94/04/29 SMI" */
%
%/* Copyright (c) 1990, 1991 Sun Microsystems, Inc. */
%
%/*
% * Compiled from key_prot.x using rpcgen.
% * DO NOT EDIT THIS FILE!
% * This is NOT source code!
% */
/*
* PROOT and MODULUS define the way the Diffie-Hellman key is generated.
*
* MODULUS should be chosen as a prime of the form: MODULUS == 2*p + 1,
* where p is also prime.
*
* PROOT satisfies the following two conditions:
* (1) (PROOT ** 2) % MODULUS != 1
* (2) (PROOT ** p) % MODULUS != 1
*
*/
const PROOT = 3;
const HEXMODULUS = "d4a0ba0250b6fd2ec626e7efd637df76c716e22d0944b88b";
const HEXKEYBYTES = 48; /* HEXKEYBYTES == strlen(HEXMODULUS) */
const KEYSIZE = 192; /* KEYSIZE == bit length of key */
const KEYBYTES = 24; /* byte length of key */
/*
* The first 16 hex digits of the encrypted secret key are used as
* a checksum in the database.
*/
const KEYCHECKSUMSIZE = 16;
/*
* status of operation
*/
enum keystatus {
KEY_SUCCESS, /* no problems */
KEY_NOSECRET, /* no secret key stored */
KEY_UNKNOWN, /* unknown netname */
KEY_SYSTEMERR /* system error (out of memory, encryption failure) */
};
typedef opaque keybuf[HEXKEYBYTES]; /* store key in hex */
typedef string netnamestr<MAXNETNAMELEN>;
/*
* Argument to ENCRYPT or DECRYPT
*/
struct cryptkeyarg {
netnamestr remotename;
des_block deskey;
};
/*
* Argument to ENCRYPT_PK or DECRYPT_PK
*/
struct cryptkeyarg2 {
netnamestr remotename;
netobj remotekey; /* Contains a length up to 1024 bytes */
des_block deskey;
};
/*
* Result of ENCRYPT, DECRYPT, ENCRYPT_PK, and DECRYPT_PK
*/
union cryptkeyres switch (keystatus status) {
case KEY_SUCCESS:
des_block deskey;
default:
void;
};
const MAXGIDS = 16; /* max number of gids in gid list */
/*
* Unix credential
*/
struct unixcred {
u_int uid;
u_int gid;
u_int gids<MAXGIDS>;
};
/*
* Result returned from GETCRED
*/
union getcredres switch (keystatus status) {
case KEY_SUCCESS:
unixcred cred;
default:
void;
};
/*
* key_netstarg;
*/
struct key_netstarg {
keybuf st_priv_key;
keybuf st_pub_key;
netnamestr st_netname;
};
union key_netstres switch (keystatus status){
case KEY_SUCCESS:
key_netstarg knet;
default:
void;
};
#ifdef RPC_HDR
%
%#ifndef opaque
%#define opaque char
%#endif
%
#endif
program KEY_PROG {
version KEY_VERS {
/*
* This is my secret key.
* Store it for me.
*/
keystatus
KEY_SET(keybuf) = 1;
/*
* I want to talk to X.
* Encrypt a conversation key for me.
*/
cryptkeyres
KEY_ENCRYPT(cryptkeyarg) = 2;
/*
* X just sent me a message.
* Decrypt the conversation key for me.
*/
cryptkeyres
KEY_DECRYPT(cryptkeyarg) = 3;
/*
* Generate a secure conversation key for me
*/
des_block
KEY_GEN(void) = 4;
/*
* Get me the uid, gid and group-access-list associated
* with this netname (for kernel which cannot use NIS)
*/
getcredres
KEY_GETCRED(netnamestr) = 5;
} = 1;
version KEY_VERS2 {
/*
* #######
* Procedures 1-5 are identical to version 1
* #######
*/
/*
* This is my secret key.
* Store it for me.
*/
keystatus
KEY_SET(keybuf) = 1;
/*
* I want to talk to X.
* Encrypt a conversation key for me.
*/
cryptkeyres
KEY_ENCRYPT(cryptkeyarg) = 2;
/*
* X just sent me a message.
* Decrypt the conversation key for me.
*/
cryptkeyres
KEY_DECRYPT(cryptkeyarg) = 3;
/*
* Generate a secure conversation key for me
*/
des_block
KEY_GEN(void) = 4;
/*
* Get me the uid, gid and group-access-list associated
* with this netname (for kernel which cannot use NIS)
*/
getcredres
KEY_GETCRED(netnamestr) = 5;
/*
* I want to talk to X. and I know X's public key
* Encrypt a conversation key for me.
*/
cryptkeyres
KEY_ENCRYPT_PK(cryptkeyarg2) = 6;
/*
* X just sent me a message. and I know X's public key
* Decrypt the conversation key for me.
*/
cryptkeyres
KEY_DECRYPT_PK(cryptkeyarg2) = 7;
/*
* Store my public key, netname and private key.
*/
keystatus
KEY_NET_PUT(key_netstarg) = 8;
/*
* Retrieve my public key, netname and private key.
*/
key_netstres
KEY_NET_GET(void) = 9;
/*
* Return me the conversation key that is constructed
* from my secret key and this publickey.
*/
cryptkeyres
KEY_GET_CONV(keybuf) = 10;
} = 2;
} = 100029;

View File

@@ -1,139 +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
*/
/*
* Kernel/lock manager protocol definition
* Copyright (C) 1986 Sun Microsystems, Inc.
*
* protocol used between the UNIX kernel (the "client") and the
* local lock manager. The local lock manager is a deamon running
* above the kernel.
*/
#ifndef RPC_HDR
%#ifndef lint
%/*static char sccsid[] = "from: @(#)klm_prot.x 1.7 87/07/08 Copyr 1987 Sun Micro";*/
%/*static char sccsid[] = "from: @(#)klm_prot.x 2.1 88/08/01 4.0 RPCSRC";*/
%static const char rcsid[] =
% "$FreeBSD: src/include/rpcsvc/klm_prot.x,v 1.6 1999/08/27 23:45:08 peter Exp $";
%#endif /* not lint */
#endif
const LM_MAXSTRLEN = 1024;
/*
* lock manager status returns
*/
enum klm_stats {
klm_granted = 0, /* lock is granted */
klm_denied = 1, /* lock is denied */
klm_denied_nolocks = 2, /* no lock entry available */
klm_working = 3 /* lock is being processed */
};
/*
* lock manager lock identifier
*/
struct klm_lock {
string server_name<LM_MAXSTRLEN>;
netobj fh; /* a counted file handle */
int pid; /* holder of the lock */
unsigned l_offset; /* beginning offset of the lock */
unsigned l_len; /* byte length of the lock;
* zero means through end of file */
};
/*
* lock holder identifier
*/
struct klm_holder {
bool exclusive; /* FALSE if shared lock */
int svid; /* holder of the lock (pid) */
unsigned l_offset; /* beginning offset of the lock */
unsigned l_len; /* byte length of the lock;
* zero means through end of file */
};
/*
* reply to KLM_LOCK / KLM_UNLOCK / KLM_CANCEL
*/
struct klm_stat {
klm_stats stat;
};
/*
* reply to a KLM_TEST call
*/
union klm_testrply switch (klm_stats stat) {
case klm_denied:
struct klm_holder holder;
default: /* All other cases return no arguments */
void;
};
/*
* arguments to KLM_LOCK
*/
struct klm_lockargs {
bool block;
bool exclusive;
struct klm_lock alock;
};
/*
* arguments to KLM_TEST
*/
struct klm_testargs {
bool exclusive;
struct klm_lock alock;
};
/*
* arguments to KLM_UNLOCK
*/
struct klm_unlockargs {
struct klm_lock alock;
};
program KLM_PROG {
version KLM_VERS {
klm_testrply KLM_TEST (struct klm_testargs) = 1;
klm_stat KLM_LOCK (struct klm_lockargs) = 2;
klm_stat KLM_CANCEL (struct klm_lockargs) = 3;
/* klm_granted=> the cancel request fails due to lock is already granted */
/* klm_denied=> the cancel request successfully aborts
lock request */
klm_stat KLM_UNLOCK (struct klm_unlockargs) = 4;
} = 1;
} = 100020;

View File

@@ -1,257 +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
*/
/*
* Protocol description for the mount program
*/
#ifndef RPC_HDR
%#ifndef lint
%/*static char sccsid[] = "from: @(#)mount.x 1.2 87/09/18 Copyr 1987 Sun Micro";*/
%/*static char sccsid[] = "from: @(#)mount.x 2.1 88/08/01 4.0 RPCSRC";*/
%static const char rcsid[] =
% "$FreeBSD: src/include/rpcsvc/mount.x,v 1.6 1999/08/27 23:45:08 peter Exp $";
%#endif /* not lint */
#endif
const MNTPATHLEN = 1024; /* maximum bytes in a pathname argument */
const MNTNAMLEN = 255; /* maximum bytes in a name argument */
const FHSIZE = 32; /* size in bytes of a file handle */
#ifdef WANT_NFS3
const FHSIZE3 = 64; /* size in bytes of a file handle (v3) */
#endif
/*
* The fhandle is the file handle that the server passes to the client.
* All file operations are done using the file handles to refer to a file
* or a directory. The file handle can contain whatever information the
* server needs to distinguish an individual file.
*/
typedef opaque fhandle[FHSIZE];
#ifdef WANT_NFS3
typedef opaque fhandle3<FHSIZE3>;
#endif
/*
* If a status of zero is returned, the call completed successfully, and
* a file handle for the directory follows. A non-zero status indicates
* some sort of error. The status corresponds with UNIX error numbers.
*/
union fhstatus switch (unsigned fhs_status) {
case 0:
fhandle fhs_fhandle;
default:
void;
};
#ifdef WANT_NFS3
/*
* Status codes returned by the version 3 mount call.
*/
enum mountstat3 {
MNT3_OK = 0, /* no error */
MNT3ERR_PERM = 1, /* Not owner */
MNT3ERR_NOENT = 2, /* No such file or directory */
MNT3ERR_IO = 5, /* I/O error */
MNT3ERR_ACCES = 13, /* Permission denied */
MNT3ERR_NOTDIR = 20, /* Not a directory */
MNT3ERR_INVAL = 22, /* Invalid argument */
MNT3ERR_NAMETOOLONG = 63, /* Filename too long */
MNT3ERR_NOTSUPP = 10004, /* Operation not supported */
MNT3ERR_SERVERFAULT = 10006 /* A failure on the server */
};
struct mountres3_ok {
fhandle3 fhandle;
int auth_flavors<>;
};
union mountres3 switch (mountstat3 fhs_status) {
case 0:
mountres3_ok mountinfo;
default:
void;
};
#endif
/*
* The type dirpath is the pathname of a directory
*/
typedef string dirpath<MNTPATHLEN>;
/*
* The type name is used for arbitrary names (hostnames, groupnames)
*/
typedef string name<MNTNAMLEN>;
/*
* A list of who has what mounted
*/
typedef struct mountbody *mountlist;
struct mountbody {
name ml_hostname;
dirpath ml_directory;
mountlist ml_next;
};
/*
* A list of netgroups
*/
typedef struct groupnode *groups;
struct groupnode {
name gr_name;
groups gr_next;
};
/*
* A list of what is exported and to whom
*/
typedef struct exportnode *exports;
struct exportnode {
dirpath ex_dir;
groups ex_groups;
exports ex_next;
};
program MOUNTPROG {
/*
* Version one of the mount protocol communicates with version two
* of the NFS protocol. Version three communicates with
* version three of the NFS protocol. The only connecting
* point is the fhandle structure, which is the same for both
* protocols.
*/
version MOUNTVERS {
/*
* Does no work. It is made available in all RPC services
* to allow server reponse testing and timing
*/
void
MOUNTPROC_NULL(void) = 0;
/*
* If fhs_status is 0, then fhs_fhandle contains the
* file handle for the directory. This file handle may
* be used in the NFS protocol. This procedure also adds
* a new entry to the mount list for this client mounting
* the directory.
* Unix authentication required.
*/
fhstatus
MOUNTPROC_MNT(dirpath) = 1;
/*
* Returns the list of remotely mounted filesystems. The
* mountlist contains one entry for each hostname and
* directory pair.
*/
mountlist
MOUNTPROC_DUMP(void) = 2;
/*
* Removes the mount list entry for the directory
* Unix authentication required.
*/
void
MOUNTPROC_UMNT(dirpath) = 3;
/*
* Removes all of the mount list entries for this client
* Unix authentication required.
*/
void
MOUNTPROC_UMNTALL(void) = 4;
/*
* Returns a list of all the exported filesystems, and which
* machines are allowed to import it.
*/
exports
MOUNTPROC_EXPORT(void) = 5;
/*
* Identical to MOUNTPROC_EXPORT above
*/
exports
MOUNTPROC_EXPORTALL(void) = 6;
} = 1;
#ifdef WANT_NFS3
version MOUNTVERS3 {
/*
* Does no work. It is made available in all RPC services
* to allow server reponse testing and timing
*/
void
MOUNTPROC_NULL(void) = 0;
/*
* If mountres3.fhs_status is MNT3_OK, then
* mountres3.mountinfo contains the file handle for
* the directory and a list of acceptable
* authentication flavors. This file handle may only
* be used in the NFS version 3 protocol. This
* procedure also results in the server adding a new
* entry to its mount list recording that this client
* has mounted the directory. AUTH_UNIX authentication
* or better is required.
*/
mountres3
MOUNTPROC_MNT(dirpath) = 1;
/*
* Returns the list of remotely mounted filesystems. The
* mountlist contains one entry for each hostname and
* directory pair.
*/
mountlist
MOUNTPROC_DUMP(void) = 2;
/*
* Removes the mount list entry for the directory
* Unix authentication required.
*/
void
MOUNTPROC_UMNT(dirpath) = 3;
/*
* Removes all of the mount list entries for this client
* Unix authentication required.
*/
void
MOUNTPROC_UMNTALL(void) = 4;
/*
* Returns a list of all the exported filesystems, and which
* machines are allowed to import it.
*/
exports
MOUNTPROC_EXPORT(void) = 5;
} = 3;
#endif
} = 100005;

File diff suppressed because it is too large Load Diff

View File

@@ -1,466 +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 or with the express written consent of
% * Sun Microsystems, Inc.
% *
% * 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
% */
#ifndef RPC_HDR
%#ifndef lint
%static const char rcsid[] =
% "$FreeBSD: src/include/rpcsvc/nis.x,v 1.3 1999/08/27 23:45:09 peter Exp $";
%#endif /* not lint */
#endif
/*
* From 4.1 : @(#)nis.x 1.61 Copyright 1989 Sun Microsystems
*
* RPC Language Protocol description file for NIS Plus
* This version : 1.61
* Last Modified : 3/19/91
*/
#ifdef RPC_HDR
%/*
% * nis.h
% *
% * This file is the main include file for NIS clients. It contains
% * both the client library function defines and the various data
% * structures used by the NIS service. It includes the file nis_tags.h
% * which defines the tag values. This allows the tags to change without
% * having to change the nis.x file.
% *
% * NOTE : DO NOT EDIT THIS FILE! It is automatically generated when
% * rpcgen is run on the nis.x file. Note that there is a
% * simple sed script to remove some unneeded lines. (See the
% * Makefile target nis.h)
% *
% */
%#include <rpcsvc/nis_tags.h>
#endif
/* This gets stuffed into the source files. */
#if RPC_HDR
%#include <rpc/xdr.h>
#endif
/*
* This is just pointless.
*/
#ifdef SUN_STUPIDITY
#if RPC_SVC
%#include "nis_svc.h"
#endif
#endif
/* Include the RPC Language description of NIS objects */
#include "nis_object.x"
/* Errors that can be returned by the service */
enum nis_error {
NIS_SUCCESS = 0, /* A-ok, let's rock n roll */
NIS_S_SUCCESS = 1, /* Name found (maybe) */
NIS_NOTFOUND = 2, /* Name definitely not found */
NIS_S_NOTFOUND = 3, /* Name maybe not found */
NIS_CACHEEXPIRED = 4, /* Name exists but cache out of date */
NIS_NAMEUNREACHABLE = 5, /* Can't get there from here */
NIS_UNKNOWNOBJ = 6, /* Object type is bogus */
NIS_TRYAGAIN = 7, /* I'm busy, call back */
NIS_SYSTEMERROR = 8, /* Out of band failure */
NIS_CHAINBROKEN = 9, /* First/Next warning */
NIS_PERMISSION = 10, /* Not enough permission to access */
NIS_NOTOWNER = 11, /* You don't own it, sorry */
NIS_NOT_ME = 12, /* I don't serve this name */
NIS_NOMEMORY = 13, /* Outta VM! Help! */
NIS_NAMEEXISTS = 14, /* Can't create over another name */
NIS_NOTMASTER = 15, /* I'm justa secondaray, don't ask me */
NIS_INVALIDOBJ = 16, /* Object is broken somehow */
NIS_BADNAME = 17, /* Unparsable name */
NIS_NOCALLBACK = 18, /* Couldn't talk to call back proc */
NIS_CBRESULTS = 19, /* Results being called back to you */
NIS_NOSUCHNAME = 20, /* Name unknown */
NIS_NOTUNIQUE = 21, /* Value is not uniques (entry) */
NIS_IBMODERROR = 22, /* Inf. Base. Modify error. */
NIS_NOSUCHTABLE = 23, /* Name for table was wrong */
NIS_TYPEMISMATCH = 24, /* Entry and table type mismatch */
NIS_LINKNAMEERROR = 25, /* Link points to bogus name */
NIS_PARTIAL = 26, /* Partial success, found table */
NIS_TOOMANYATTRS = 27, /* Too many attributes */
NIS_RPCERROR = 28, /* RPC error encountered */
NIS_BADATTRIBUTE = 29, /* Bad or invalid attribute */
NIS_NOTSEARCHABLE = 30, /* Non-searchable object searched */
NIS_CBERROR = 31, /* Error during callback (svc crash) */
NIS_FOREIGNNS = 32, /* Foreign Namespace */
NIS_BADOBJECT = 33, /* Malformed object structure */
NIS_NOTSAMEOBJ = 34, /* Object swapped during deletion */
NIS_MODFAIL = 35, /* Failure during a Modify. */
NIS_BADREQUEST = 36, /* Illegal query for table */
NIS_NOTEMPTY = 37, /* Attempt to remove a non-empty tbl */
NIS_COLDSTART_ERR = 38, /* Error accesing the cold start file */
NIS_RESYNC = 39, /* Transaction log too far out of date */
NIS_FAIL = 40, /* NIS operation failed. */
NIS_UNAVAIL = 41, /* NIS+ service is unavailable (client) */
NIS_RES2BIG = 42, /* NIS+ result too big for datagram */
NIS_SRVAUTH = 43, /* NIS+ server wasn't authenticated. */
NIS_CLNTAUTH = 44, /* NIS+ Client wasn't authenticated. */
NIS_NOFILESPACE = 45, /* NIS+ server ran out of disk space */
NIS_NOPROC = 46, /* NIS+ server couldn't create new proc */
NIS_DUMPLATER = 47 /* NIS+ server already has dump child */
};
/*
* Structure definitions for the parameters and results of the actual
* NIS RPC calls.
*
* This is the standard result (in the protocol) of most of the nis
* requests.
*/
struct nis_result {
nis_error status; /* Status of the response */
nis_object objects<>; /* objects found */
netobj cookie; /* Cookie Data */
u_long zticks; /* server ticks */
u_long dticks; /* DBM ticks. */
u_long aticks; /* Cache (accel) ticks */
u_long cticks; /* Client ticks */
};
/*
* A Name Service request
* This request is used to access the name space, ns_name is the name
* of the object within the namespace and the object is it's value, for
* add/modify, a copy of the original for remove.
*/
struct ns_request {
nis_name ns_name; /* Name in the NIS name space */
nis_object ns_object<1>; /* Optional Object (add/remove) */
};
/*
* An information base request
* This request includes the NIS name of the table we wish to search, the
* search criteria in the form of attribute/value pairs and an optional
* callback program number. If the callback program number is provided
* the server will send back objects one at a time, otherwise it will
* return them all in the response.
*/
struct ib_request {
nis_name ibr_name; /* The name of the Table */
nis_attr ibr_srch<>; /* The search critereia */
u_long ibr_flags; /* Optional flags */
nis_object ibr_obj<1>; /* optional object (add/modify) */
nis_server ibr_cbhost<1>; /* Optional callback info */
u_long ibr_bufsize; /* Optional first/next bufsize */
netobj ibr_cookie; /* The first/next cookie */
};
/*
* This argument to the PING call notifies the replicas that something in
* a directory has changed and this is it's timestamp. The replica will use
* the timestamp to determine if its resync operation was successful.
*/
struct ping_args {
nis_name dir; /* Directory that had the change */
u_long stamp; /* timestamp of the transaction */
};
/*
* These are the type of entries that are stored in the transaction log,
* note that modifications will appear as two entries, for names, they have
* a "OLD" entry followed by a "NEW" entry. For entries in tables, there
* is a remove followed by an add. It is done this way so that we can read
* the log backwards to back out transactions and forwards to propogate
* updated.
*/
enum log_entry_t {
LOG_NOP = 0,
ADD_NAME = 1, /* Name Added to name space */
REM_NAME = 2, /* Name removed from name space */
MOD_NAME_OLD = 3, /* Name was modified in the name space */
MOD_NAME_NEW = 4, /* Name was modified in the name space */
ADD_IBASE = 5, /* Entry added to information base */
REM_IBASE = 6, /* Entry removed from information base */
MOD_IBASE = 7, /* Entry was modified in information base */
UPD_STAMP = 8 /* Update timestamp (used as fenceposts) */
};
/*
* This result is returned from the name service when it is requested to
* dump logged entries from its transaction log. Information base updates
* will have the name of the information base in the le_name field and
* a canonical set of attribute/value pairs to fully specify the entry's
* 'name'.
*/
struct log_entry {
u_long le_time; /* Time in seconds */
log_entry_t le_type; /* Type of log entry */
nis_name le_princp; /* Principal making the change */
nis_name le_name; /* Name of table/dir involved */
nis_attr le_attrs<>; /* List of AV pairs. */
nis_object le_object; /* Actual object value */
};
struct log_result {
nis_error lr_status; /* The status itself */
netobj lr_cookie; /* Used by the dump callback */
log_entry lr_entries<>; /* zero or more entries */
};
struct cp_result {
nis_error cp_status; /* Status of the checkpoint */
u_long cp_zticks; /* Service 'ticks' */
u_long cp_dticks; /* Database 'ticks' */
};
/*
* This structure defines a generic NIS tag list. The taglist contains
* zero or tags, each of which is a type and a value. (u_long).
* These are used to report statistics (see tag definitions below)
* and to set or reset state variables.
*/
struct nis_tag {
u_long tag_type; /* Statistic tag (may vary) */
string tag_val<1024>; /* Statistic value may also vary */
};
struct nis_taglist {
nis_tag tags<>; /* List of tags */
};
struct dump_args {
nis_name da_dir; /* Directory to dump */
u_long da_time; /* From this timestamp */
nis_server da_cbhost<1>; /* Callback to use. */
};
struct fd_args {
nis_name dir_name; /* The directory we're looking for */
nis_name requester; /* Host principal name for signature */
};
struct fd_result {
nis_error status; /* Status returned by function */
nis_name source; /* Source of this answer */
opaque dir_data<>; /* Directory Data (XDR'ed) */
opaque signature<>; /* Signature of the source */
};
/*
* What's going on here? Well, it's like this. When the service
* is being compiled it wants to have the service definition specific
* info included, and when the client is being compiled it wants that
* info. This includes the appropriate file which was generated by
* make in the protocols directory (probably /usr/include/rpcsvc).
*
* Uhm... guys? With RPC, you aren't supposed to have seperate
* server-specific and client-specific header files. You have one header
* file that's suitable for both. If your code doesn't work using just
* the one header file, I submit to you that it's broken.
* -Bill
*/
#ifdef SUN_STUPIDITY
#ifdef RPC_SVC
%#include "nis_svc.h"
#endif
#ifdef RPC_CLNT
%#include "nis_clnt.h"
#endif
#endif
program NIS_PROG {
/* RPC Language description of the NIS+ protocol */
version NIS_VERSION {
/* The name service functions */
nis_result NIS_LOOKUP(ns_request) = 1;
nis_result NIS_ADD(ns_request) = 2;
nis_result NIS_MODIFY(ns_request) = 3;
nis_result NIS_REMOVE(ns_request) = 4;
/* The information base functions */
nis_result NIS_IBLIST(ib_request) = 5;
nis_result NIS_IBADD(ib_request) = 6;
nis_result NIS_IBMODIFY(ib_request) = 7;
nis_result NIS_IBREMOVE(ib_request) = 8;
nis_result NIS_IBFIRST(ib_request) = 9;
nis_result NIS_IBNEXT(ib_request) = 10;
/* NIS Administrative functions */
fd_result NIS_FINDDIRECTORY(fd_args) = 12;
/* If fetch and optionally reset statistics */
nis_taglist NIS_STATUS(nis_taglist) = 14;
/* Dump changes to directory since time in da_time */
log_result NIS_DUMPLOG(dump_args) = 15;
/* Dump contents of directory named */
log_result NIS_DUMP(dump_args) = 16;
/* Check status of callback thread */
bool NIS_CALLBACK(netobj) = 17;
/* Return last update time for named dir */
u_long NIS_CPTIME(nis_name) = 18;
/* Checkpoint directory or table named */
cp_result NIS_CHECKPOINT(nis_name) = 19;
/* Send 'status changed' ping to replicates */
void NIS_PING(ping_args) = 20;
/* Modify server behaviour (such as debugging) */
nis_taglist NIS_SERVSTATE(nis_taglist) = 21;
/* Create a Directory */
nis_error NIS_MKDIR(nis_name) = 22;
/* Remove a Directory */
nis_error NIS_RMDIR(nis_name) = 23;
/* Update public keys of a directory object */
nis_error NIS_UPDKEYS(nis_name) = 24;
} = 3;
} = 100300;
/*
* Included below are the defines that become part of nis.h,
* they are technically not part of the protocol, but do define
* key aspects of the implementation and are therefore useful
* in building a conforming server or client.
*/
#if RPC_HDR
%/*
% * Generic "hash" datastructures, used by all types of hashed data.
% */
%struct nis_hash_data {
% nis_name name; /* NIS name of hashed item */
% int keychain; /* It's hash key (for pop) */
% struct nis_hash_data *next; /* Hash collision pointer */
% struct nis_hash_data *prv_item; /* A serial, doubly linked list */
% struct nis_hash_data *nxt_item; /* of items in the hash table */
%};
%typedef struct nis_hash_data NIS_HASH_ITEM;
%
%struct nis_hash_table {
% NIS_HASH_ITEM *keys[64]; /* A hash table of items */
% NIS_HASH_ITEM *first; /* The first "item" in serial list */
%};
%typedef struct nis_hash_table NIS_HASH_TABLE;
%
%/* Structure for storing dynamically allocated static data */
%struct nis_sdata {
% void *buf; /* Memory allocation pointer */
% u_long size; /* Buffer size */
%};
%
%/* Generic client creating flags */
%#define ZMH_VC 1
%#define ZMH_DG 2
%#define ZMH_AUTH 4
%
%/* Testing Access rights for objects */
%
%#define NIS_READ_ACC 1
%#define NIS_MODIFY_ACC 2
%#define NIS_CREATE_ACC 4
%#define NIS_DESTROY_ACC 8
%/* Test macros. a == access rights, m == desired rights. */
%#define WORLD(a, m) (((a) & (m)) != 0)
%#define GROUP(a, m) (((a) & ((m) << 8)) != 0)
%#define OWNER(a, m) (((a) & ((m) << 16)) != 0)
%#define NOBODY(a, m) (((a) & ((m) << 24)) != 0)
%
%#define OATYPE(d, n) (((d)->do_armask.do_armask_val+n)->oa_otype)
%#define OARIGHTS(d, n) (((d)->do_armask.do_armask_val+n)->oa_rights)
%#define WORLD_DEFAULT (NIS_READ_ACC)
%#define GROUP_DEFAULT (NIS_READ_ACC << 8)
%#define OWNER_DEFAULT ((NIS_READ_ACC +\
NIS_MODIFY_ACC +\
NIS_CREATE_ACC +\
NIS_DESTROY_ACC) << 16)
%#define DEFAULT_RIGHTS (WORLD_DEFAULT | GROUP_DEFAULT | OWNER_DEFAULT)
%
%/* Result manipulation defines ... */
%#define NIS_RES_NUMOBJ(x) ((x)->objects.objects_len)
%#define NIS_RES_OBJECT(x) ((x)->objects.objects_val)
%#define NIS_RES_COOKIE(x) ((x)->cookie)
%#define NIS_RES_STATUS(x) ((x)->status)
%
%/* These defines make getting at the variant part of the object easier. */
%#define TA_data zo_data.objdata_u.ta_data
%#define EN_data zo_data.objdata_u.en_data
%#define DI_data zo_data.objdata_u.di_data
%#define LI_data zo_data.objdata_u.li_data
%#define GR_data zo_data.objdata_u.gr_data
%
%#define __type_of(o) ((o)->zo_data.zo_type)
%
%/* Declarations for the internal subroutines in nislib.c */
%enum name_pos {SAME_NAME, HIGHER_NAME, LOWER_NAME, NOT_SEQUENTIAL, BAD_NAME};
%typedef enum name_pos name_pos;
%
%/*
% * Defines for getting at column data in entry objects. Because RPCGEN
% * generates some rather wordy structures, we create some defines that
% * collapse the needed keystrokes to access a particular value using
% * these definitions they take an nis_object *, and an int and return
% * a u_char * for Value, and an int for length.
% */
%#define ENTRY_VAL(obj, col) \
(obj)->EN_data.en_cols.en_cols_val[col].ec_value.ec_value_val
%#define ENTRY_LEN(obj, col) \
(obj)->EN_data.en_cols.en_cols_val[col].ec_value.ec_value_len
%
%#ifdef __cplusplus
%}
%#endif
%
%/* Prototypes, and extern declarations for the NIS library functions. */
%#include <rpcsvc/nislib.h>
%#endif /* __NIS_RPCGEN_H */
%/* EDIT_START */
%
%/*
% * nis_3.h
% *
% * This file contains definitions that are only of interest to the actual
% * service daemon and client stubs. Normal users of NIS will not include
% * this file.
% *
% * NOTE : This include file is automatically created by a combination
% * of rpcgen and sed. DO NOT EDIT IT, change the nis.x file instead
% * and then remake this file.
% */
%#ifndef __nis_3_h
%#define __nis_3_h
%#ifdef __cplusplus
%extern "C" {
%#endif
#endif

View File

@@ -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 or with the express written consent of
% * Sun Microsystems, Inc.
% *
% * 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
% */
/*
* nis_cache.x
*
* Copyright (c) 1988-1992 Sun Microsystems Inc
* All Rights Reserved.
*/
/* From: %#pragma ident "@(#)nis_cache.x 1.11 94/05/03 SMI" */
#ifndef RPC_HDR
%#ifndef lint
%static const char rcsid[] =
% "$FreeBSD: src/include/rpcsvc/nis_cache.x,v 1.3 1999/08/27 23:45:09 peter Exp $";
%#endif /* not lint */
#endif
#ifdef RPC_HDR
%#include <rpc/types.h>
%#include <rpcsvc/nis.h>
%
%/* default cache file */
%#define CACHEFILE "/var/nis/NIS_SHARED_DIRCACHE"
%
%/* clients have to read-lock the cache file, and SVR4 locking requires that */
%/* the file be writable, but we don't want a world-writable cache file. */
%/* So... everyone agrees to use a different, world-writable file for the */
%/* locking operations, but the data is in CACHEFILE. */
%#define CACHELOCK "/usr/tmp/.NIS_DIR_CACHELOCK"
%
%/* the file containing one trusted XDR'ed directory object.
% * This has to be present for the system to work.
% */
%#define COLD_START_FILE "/var/nis/NIS_COLD_START"
%
%enum pc_status {HIT, MISS, NEAR_MISS};
%
%extern int __nis_debuglevel;
%
%
#endif
#ifdef RPC_CLNT
#ifdef SOLARIS
%#include "../gen/nis_clnt.h"
#else
%#include "nis.h"
#endif
#endif
program CACHEPROG {
version CACHE_VER_1 {
void NIS_CACHE_ADD_ENTRY(fd_result) = 1;
void NIS_CACHE_REMOVE_ENTRY(directory_obj) = 2;
void NIS_CACHE_READ_COLDSTART(void) = 3;
void NIS_CACHE_REFRESH_ENTRY(string<>) = 4;
} = 1;
} = 100301;

View File

@@ -1,76 +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 or with the express written consent of
% * Sun Microsystems, Inc.
% *
% * 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
% */
/*
* nis_callback.x
*
* Copyright (c) 1988-1992 Sun Microsystems Inc
* All Rights Reserved.
*/
/* From: %#pragma ident "@(#)nis_callback.x 1.7 94/05/03 SMI" */
#ifndef RPC_HDR
%#ifndef lint
%static const char rcsid[] =
% "$FreeBSD: src/include/rpcsvc/nis_callback.x,v 1.3 1999/08/27 23:45:09 peter Exp $";
%#endif /* not lint */
#endif
/*
* "@(#)zns_cback.x 1.2 90/09/10 Copyr 1990 Sun Micro"
*
* RPCL description of the Callback Service.
*/
#ifdef RPC_HDR
%#include <rpcsvc/nis.h>
#endif
#ifdef RPC_XDR
#ifdef SOLARIS
%#include "nis_clnt.h"
#else
%#include "nis.h"
#endif
#endif
typedef nis_object *obj_p;
struct cback_data {
obj_p entries<>; /* List of objects */
};
program CB_PROG {
version CB_VERS {
bool CBPROC_RECEIVE(cback_data) = 1;
void CBPROC_FINISH(void) = 2;
void CBPROC_ERROR(nis_error) = 3;
} = 1;
} = 100302;

View File

@@ -1,162 +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
*
* $FreeBSD: src/include/rpcsvc/nis_db.h,v 1.5 1999/08/27 23:45:09 peter Exp $
*/
/*
* Copyright (c) 1991, by Sun Microsystems Inc.
*/
/*
* This header file defines the interface to the NIS database. All
* implementations of the database must export at least these routines.
* They must also follow the conventions set herein. See the implementors
* guide for specific semantics that are required.
*/
#ifndef _RPCSVC_NIS_DB_H
#define _RPCSVC_NIS_DB_H
/* From: #pragma ident "@(#)nis_db.h 1.8 94/05/03 SMI" */
/*
* Note: although the version of <rpcsvc/nis_db.h> shipped with Solaris
* 2.5/2.5.x is actually older than this one (according to the ident
* string), it contains changes and a few added functions. Those changes
* have been hand merged into this file to bring it up to date.
*/
#include <rpc/rpc.h>
#include <rpcsvc/nis.h>
#ifdef __cplusplus
extern "C" {
#endif
enum db_status {
DB_SUCCESS = 0,
DB_NOTFOUND = 1,
DB_NOTUNIQUE = 2,
DB_BADTABLE = 3,
DB_BADQUERY = 4,
DB_BADOBJECT = 5,
DB_MEMORY_LIMIT = 6,
DB_STORAGE_LIMIT = 7,
DB_INTERNAL_ERROR = 8
};
typedef enum db_status db_status;
enum db_action {
DB_LOOKUP = 0,
DB_REMOVE = 1,
DB_ADD = 2,
DB_FIRST = 3,
DB_NEXT = 4,
DB_ALL = 5,
DB_RESET_NEXT = 6
};
typedef enum db_action db_action;
typedef entry_obj *entry_object_p;
typedef struct {
u_int db_next_desc_len;
char *db_next_desc_val;
} db_next_desc;
struct db_result {
db_status status;
db_next_desc nextinfo;
struct {
u_int objects_len;
entry_object_p *objects_val;
} objects;
long ticks;
};
typedef struct db_result db_result;
/*
* Prototypes for the database functions.
*/
#if (__STDC__)
extern bool_t db_initialize(char *);
#ifdef ORIGINAL_DECLS
extern bool_t db_create_table(char *, table_obj *);
extern bool_t db_destroy_table(char *);
#else
extern db_status db_create_table(char *, table_obj *);
extern db_status db_destroy_table(char *);
#endif
extern db_result *db_first_entry(char *, int, nis_attr *);
extern db_result *db_next_entry(char *, db_next_desc *);
extern db_result *db_reset_next_entry(char *, db_next_desc *);
extern db_result *db_list_entries(char *, int, nis_attr *);
extern db_result *db_add_entry(char *, int, nis_attr *, entry_obj *);
extern db_result *db_remove_entry(char *, int, nis_attr *);
extern db_status db_checkpoint(char *);
extern db_status db_standby(char *);
#ifndef ORIGINAL_DECLS
extern db_status db_table_exists(char *);
extern db_status db_unload_table(char *);
extern void db_free_result(db_result *);
#endif
#else /* Non-prototype definitions */
extern bool_t db_initialize();
#ifdef ORIGINAL_DECLS
extern bool_t db_create_table();
extern bool_t db_destroy_table();
#else
extern db_status db_create_table();
extern db_status db_destroy_table();
#endif
extern db_result *db_first_entry();
extern db_result *db_next_entry();
extern db_result *db_reset_next_entry();
extern db_result *db_list_entries();
extern db_result *db_add_entry();
extern db_result *db_remove_entry();
extern db_status db_checkpoint();
extern db_status db_standby();
#ifndef ORIGINAL_DECLS
extern db_status db_table_exists();
extern db_status db_unload_table();
extern void db_free_result();
#endif
#endif /* __STDC__ */
#ifdef __cplusplus
}
#endif
#endif /* _RPCSVC_NIS_DB_H */

View File

@@ -1,317 +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 or with the express written consent of
% * Sun Microsystems, Inc.
% *
% * 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
% */
/*
* nis_object.x
*
* Copyright (c) 1988-1992 Sun Microsystems Inc
* All Rights Reserved.
*/
/* From: %#pragma ident "@(#)nis_object.x 1.10 94/05/03 SMI" */
#if RPC_HDR
%
%#ifndef __nis_object_h
%#define __nis_object_h
%
#endif
/*
* This file defines the format for a NIS object in RPC language.
* It is included by the main .x file and the database access protocol
* file. It is common because both of them need to deal with the same
* type of object. Generating the actual code though is a bit messy because
* the nis.x file and the nis_dba.x file will generate xdr routines to
* encode/decode objects when only one set is needed. Such is life when
* one is using rpcgen.
*
* Note, the protocol doesn't specify any limits on such things as
* maximum name length, number of attributes, etc. These are enforced
* by the database backend. When you hit them you will no. Also see
* the db_getlimits() function for fetching the limit values.
*
*/
/* Some manifest constants, chosen to maximize flexibility without
* plugging the wire full of data.
*/
const NIS_MAXSTRINGLEN = 255;
const NIS_MAXNAMELEN = 1024;
const NIS_MAXATTRNAME = 32;
const NIS_MAXATTRVAL = 2048;
const NIS_MAXCOLUMNS = 64;
const NIS_MAXATTR = 16;
const NIS_MAXPATH = 1024;
const NIS_MAXREPLICAS = 128;
const NIS_MAXLINKS = 16;
const NIS_PK_NONE = 0; /* no public key (unix/sys auth) */
const NIS_PK_DH = 1; /* Public key is Diffie-Hellman type */
const NIS_PK_RSA = 2; /* Public key if RSA type */
const NIS_PK_KERB = 3; /* Use kerberos style authentication */
/*
* The fundamental name type of NIS. The name may consist of two parts,
* the first being the fully qualified name, and the second being an
* optional set of attribute/value pairs.
*/
struct nis_attr {
string zattr_ndx<>; /* name of the index */
opaque zattr_val<>; /* Value for the attribute. */
};
typedef string nis_name<>; /* The NIS name itself. */
/* NIS object types are defined by the following enumeration. The numbers
* they use are based on the following scheme :
* 0 - 1023 are reserved for Sun,
* 1024 - 2047 are defined to be private to a particular tree.
* 2048 - 4095 are defined to be user defined.
* 4096 - ... are reserved for future use.
*/
enum zotypes {
BOGUS_OBJ = 0, /* Uninitialized object structure */
NO_OBJ = 1, /* NULL object (no data) */
DIRECTORY_OBJ = 2, /* Directory object describing domain */
GROUP_OBJ = 3, /* Group object (a list of names) */
TABLE_OBJ = 4, /* Table object (a database schema) */
ENTRY_OBJ = 5, /* Entry object (a database record) */
LINK_OBJ = 6, /* A name link. */
PRIVATE_OBJ = 7 /* Private object (all opaque data) */
};
/*
* The types of Name services NIS knows about. They are enumerated
* here. The Binder code will use this type to determine if it has
* a set of library routines that will access the indicated name service.
*/
enum nstype {
UNKNOWN = 0,
NIS = 1, /* Nis Plus Service */
SUNYP = 2, /* Old NIS Service */
IVY = 3, /* Nis Plus Plus Service */
DNS = 4, /* Domain Name Service */
X500 = 5, /* ISO/CCCIT X.500 Service */
DNANS = 6, /* Digital DECNet Name Service */
XCHS = 7, /* Xerox ClearingHouse Service */
CDS= 8
};
/*
* DIRECTORY - The name service object. These objects identify other name
* servers that are serving some portion of the name space. Each has a
* type associated with it. The resolver library will note whether or not
* is has the needed routines to access that type of service.
* The oarmask structure defines an access rights mask on a per object
* type basis for the name spaces. The only bits currently used are
* create and destroy. By enabling or disabling these access rights for
* a specific object type for a one of the accessor entities (owner,
* group, world) the administrator can control what types of objects
* may be freely added to the name space and which require the
* administrator's approval.
*/
struct oar_mask {
u_long oa_rights; /* Access rights mask */
zotypes oa_otype; /* Object type */
};
struct endpoint {
string uaddr<>;
string family<>; /* Transport family (INET, OSI, etc) */
string proto<>; /* Protocol (TCP, UDP, CLNP, etc) */
};
/*
* Note: pkey is a netobj which is limited to 1024 bytes which limits the
* keysize to 8192 bits. This is consider to be a reasonable limit for
* the expected lifetime of this service.
*/
struct nis_server {
nis_name name; /* Principal name of the server */
endpoint ep<>; /* Universal addr(s) for server */
u_long key_type; /* Public key type */
netobj pkey; /* server's public key */
};
struct directory_obj {
nis_name do_name; /* Name of the directory being served */
nstype do_type; /* one of NIS, DNS, IVY, YP, or X.500 */
nis_server do_servers<>; /* <0> == Primary name server */
u_long do_ttl; /* Time To Live (for caches) */
oar_mask do_armask<>; /* Create/Destroy rights by object type */
};
/*
* ENTRY - This is one row of data from an information base.
* The type value is used by the client library to convert the entry to
* it's internal structure representation. The Table name is a back pointer
* to the table where the entry is stored. This allows the client library
* to determine where to send a request if the client wishes to change this
* entry but got to it through a LINK rather than directly.
* If the entry is a "standalone" entry then this field is void.
*/
const EN_BINARY = 1; /* Indicates value is binary data */
const EN_CRYPT = 2; /* Indicates the value is encrypted */
const EN_XDR = 4; /* Indicates the value is XDR encoded */
const EN_MODIFIED = 8; /* Indicates entry is modified. */
const EN_ASN1 = 64; /* Means contents use ASN.1 encoding */
struct entry_col {
u_long ec_flags; /* Flags for this value */
opaque ec_value<>; /* It's textual value */
};
struct entry_obj {
string en_type<>; /* Type of entry such as "passwd" */
entry_col en_cols<>; /* Value for the entry */
};
/*
* GROUP - The group object contains a list of NIS principal names. Groups
* are used to authorize principals. Each object has a set of access rights
* for members of its group. Principal names in groups are in the form
* name.directory and recursive groups are expressed as @groupname.directory
*/
struct group_obj {
u_long gr_flags; /* Flags controlling group */
nis_name gr_members<>; /* List of names in group */
};
/*
* LINK - This is the LINK object. It is quite similar to a symbolic link
* in the UNIX filesystem. The attributes in the main object structure are
* relative to the LINK data and not what it points to (like the file system)
* "modify" privleges here indicate the right to modify what the link points
* at and not to modify that actual object pointed to by the link.
*/
struct link_obj {
zotypes li_rtype; /* Real type of the object */
nis_attr li_attrs<>; /* Attribute/Values for tables */
nis_name li_name; /* The object's real NIS name */
};
/*
* TABLE - This is the table object. It implements a simple
* data base that applications and use for configuration or
* administration purposes. The role of the table is to group together
* a set of related entries. Tables are the simple database component
* of NIS. Like many databases, tables are logically divided into columns
* and rows. The columns are labeled with indexes and each ENTRY makes
* up a row. Rows may be addressed within the table by selecting one
* or more indexes, and values for those indexes. Each row which has
* a value for the given index that matches the desired value is returned.
* Within the definition of each column there is a flags variable, this
* variable contains flags which determine whether or not the column is
* searchable, contains binary data, and access rights for the entry objects
* column value.
*/
const TA_BINARY = 1; /* Means table data is binary */
const TA_CRYPT = 2; /* Means value should be encrypted */
const TA_XDR = 4; /* Means value is XDR encoded */
const TA_SEARCHABLE = 8; /* Means this column is searchable */
const TA_CASE = 16; /* Means this column is Case Sensitive */
const TA_MODIFIED = 32; /* Means this columns attrs are modified*/
const TA_ASN1 = 64; /* Means contents use ASN.1 encoding */
struct table_col {
string tc_name<64>; /* Column Name */
u_long tc_flags; /* control flags */
u_long tc_rights; /* Access rights mask */
};
struct table_obj {
string ta_type<64>; /* Table type such as "passwd" */
int ta_maxcol; /* Total number of columns */
u_char ta_sep; /* Separator character */
table_col ta_cols<>; /* The number of table indexes */
string ta_path<>; /* A search path for this table */
};
/*
* This union joins together all of the currently known objects.
*/
union objdata switch (zotypes zo_type) {
case DIRECTORY_OBJ :
struct directory_obj di_data;
case GROUP_OBJ :
struct group_obj gr_data;
case TABLE_OBJ :
struct table_obj ta_data;
case ENTRY_OBJ:
struct entry_obj en_data;
case LINK_OBJ :
struct link_obj li_data;
case PRIVATE_OBJ :
opaque po_data<>;
case NO_OBJ :
void;
case BOGUS_OBJ :
void;
default :
void;
};
/*
* This is the basic NIS object data type. It consists of a generic part
* which all objects contain, and a specialized part which varies depending
* on the type of the object. All of the specialized sections have been
* described above. You might have wondered why they all start with an
* integer size, followed by the useful data. The answer is, when the
* server doesn't recognize the type returned it treats it as opaque data.
* And the definition for opaque data is {int size; char *data;}. In this
* way, servers and utility routines that do not understand a given type
* may still pass it around. One has to be careful in setting
* this variable accurately, it must take into account such things as
* XDR padding of structures etc. The best way to set it is to note one's
* position in the XDR encoding stream, encode the structure, look at the
* new position and calculate the size.
*/
struct nis_oid {
u_long ctime; /* Time of objects creation */
u_long mtime; /* Time of objects modification */
};
struct nis_object {
nis_oid zo_oid; /* object identity verifier. */
nis_name zo_name; /* The NIS name for this object */
nis_name zo_owner; /* NIS name of object owner. */
nis_name zo_group; /* NIS name of access group. */
nis_name zo_domain; /* The administrator for the object */
u_long zo_access; /* Access rights (owner, group, world) */
u_long zo_ttl; /* Object's time to live in seconds. */
objdata zo_data; /* Data structure for this type */
};
#if RPC_HDR
%
%#endif /* if __nis_object_h */
%
#endif

View File

@@ -1,137 +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) 1991, Sun Microsystems Inc.
*/
/*
* nis_tags.h
*
* This file contains the tags and statistics definitions. It is
* automatically included by nis.h
*/
#ifndef _RPCSVC_NIS_TAGS_H
#define _RPCSVC_NIS_TAGS_H
/* From: #pragma ident "@(#)nis_tags.h 1.10 94/05/03 SMI" */
/* from file: zns_tags.h 1.7 Copyright (c) 1990 Sun Microsystems */
#ifdef __cplusplus
extern "C" {
#endif
#ifndef ORIGINAL_DECLS
#define NIS_DIR "data"
#endif
/* Lookup and List function flags */
#define FOLLOW_LINKS (1<<0) /* Follow link objects */
#define FOLLOW_PATH (1<<1) /* Follow the path in a table */
#define HARD_LOOKUP (1<<2) /* Block until successful */
#define ALL_RESULTS (1<<3) /* Retrieve all results */
#define NO_CACHE (1<<4) /* Do not return 'cached' results */
#define MASTER_ONLY (1<<5) /* Get value only from master server */
#define EXPAND_NAME (1<<6) /* Expand partitially qualified names */
/* Semantic modification for table operations flags */
#define RETURN_RESULT (1<<7) /* Return resulting object to client */
#define ADD_OVERWRITE (1<<8) /* Allow overwrites on ADD */
#define REM_MULTIPLE (1<<9) /* Allow wildcard deletes */
#define MOD_SAMEOBJ (1<<10) /* Check modified object before write */
#define ADD_RESERVED (1<<11) /* Spare ADD semantic */
#define REM_RESERVED (1<<12) /* Spare REM semantic */
#ifdef ORIGINAL_DECLS
#define MOD_RESERVED (1<<13) /* Spare MOD semantic */
#else
#define MOD_EXCLUSIVE (1<<13) /* Modify no overwrite on modified keys */
#endif
/* Transport specific modifications to the operation */
#define USE_DGRAM (1<<16) /* Use a datagram transport */
#define NO_AUTHINFO (1<<17) /* Don't bother attaching auth info */
/*
* Declarations for "standard" NIS+ tags
* State variable tags have values 0 - 2047
* Statistic tags have values 2048 - 65535
* User Tags have values >2^16
*/
#define TAG_DEBUG 1 /* set debug level */
#define TAG_STATS 2 /* Enable/disable statistics */
#define TAG_GCACHE 3 /* Flush the Group Cache */
#ifndef ORIGINAL_DECLS
#define TAG_GCACHE_ALL TAG_GCACHE
#endif
#define TAG_DCACHE 4 /* Flush the directory cache */
#ifndef ORIGINAL_DECLS
#define TAG_DCACHE_ONE TAG_DCACHE
#endif
#define TAG_OCACHE 5 /* Flush the Object Cache */
#define TAG_SECURE 6 /* Set the security level */
#ifndef ORIGINAL_DECLS
#define TAG_TCACHE_ONE 7 /* Flush the table cache */
#define TAG_DCACHE_ALL 8 /* Flush entire directory cache */
#define TAG_TCACHE_ALL 9 /* Flush entire table cache */
#define TAG_GCACHE_ONE 10 /* Flush one group object */
#define TAG_DCACHE_ONE_REFRESH 11 /* Flush and refresh one DO */
#endif
#define TAG_OPSTATS 2048 /* NIS+ operations statistics */
#define TAG_THREADS 2049 /* Child process/thread status */
#define TAG_HEAP 2050 /* Heap usage statistics */
#define TAG_UPDATES 2051 /* Updates to this service */
#define TAG_VISIBLE 2052 /* First update that isn't replicated */
#define TAG_S_DCACHE 2053 /* Directory cache statistics */
#define TAG_S_OCACHE 2054 /* Object cache statistics */
#define TAG_S_GCACHE 2055 /* Group cache statistics */
#define TAG_S_STORAGE 2056 /* Group cache statistics */
#define TAG_UPTIME 2057 /* Time that server has been up */
#ifndef ORIGINAL_DECLS
#define TAG_DIRLIST 2058 /* Dir served by this server */
#define TAG_NISCOMPAT 2059 /* Whether supports NIS compat mode */
#define TAG_DNSFORWARDING 2060 /* Whether DNS forwarding supported*/
#define TAG_SECURITY_LEVEL 2061 /* Security level of the server */
#define TAG_ROOTSERVER 2062 /* Whether root server */
#endif
/*
* Declarations for the Group object flags. Currently
* there are only 3.
*/
#define IMPMEM_GROUPS 1 /* Implicit Membership allowed */
#define RECURS_GROUPS 2 /* Recursive Groups allowed */
#define NEGMEM_GROUPS 4 /* Negative Groups allowed */
#ifdef __cplusplus
}
#endif
#endif /* _RPCSVC_NIS_TAGS_H */

View File

@@ -1,317 +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) 1991, Sun Microsystems Inc.
*/
/*
* This file contains the interfaces that are visible in the SunOS 5.x
* implementation of NIS Plus. When using C++ the defined __cplusplus and
* __STDC__ should both be true.
*/
#ifndef _RPCSVC_NISLIB_H
#define _RPCSVC_NISLIB_H
/* From: #pragma ident "@(#)nislib.h 1.16 94/05/03 SMI" */
#ifdef __cplusplus
extern "C" {
#endif
struct signature {
int signature_len;
char *signature_val;
};
#ifdef __STDC__
extern void nis_freeresult(nis_result *);
extern nis_result * nis_lookup(nis_name, u_long);
extern nis_result * nis_list(nis_name, u_long,
int (*)(nis_name, nis_object *, void *), void *);
extern nis_result * nis_add(nis_name, nis_object *);
extern nis_result * nis_remove(nis_name, nis_object *);
extern nis_result * nis_modify(nis_name, nis_object *);
extern nis_result * nis_add_entry(nis_name, nis_object *, u_long);
extern nis_result * nis_remove_entry(nis_name, nis_object *, u_long);
extern nis_result * nis_modify_entry(nis_name, nis_object *, u_long);
extern nis_result * nis_first_entry(nis_name);
extern nis_result * nis_next_entry(nis_name, netobj *);
extern nis_error nis_mkdir(nis_name, nis_server *);
extern nis_error nis_rmdir(nis_name, nis_server *);
extern name_pos nis_dir_cmp(nis_name, nis_name);
extern nis_name * nis_getnames(nis_name);
extern void nis_freenames(nis_name *);
extern nis_name nis_domain_of(nis_name);
extern nis_name nis_leaf_of(nis_name);
extern nis_name nis_leaf_of_r(const nis_name, char *, size_t);
extern nis_name nis_name_of(nis_name);
extern nis_name nis_local_group(void);
extern nis_name nis_local_directory(void);
extern nis_name nis_local_principal(void);
extern nis_name nis_local_host(void);
extern void nis_destroy_object(nis_object *);
extern nis_object * nis_clone_object(nis_object *, nis_object *);
extern void nis_print_object(nis_object *);
extern char * nis_sperrno(nis_error);
extern void nis_perror(nis_error, char *);
extern char * nis_sperror(nis_error, char *);
extern void nis_lerror(nis_error, char *);
extern void nis_print_group_entry(nis_name);
extern bool_t nis_ismember(nis_name, nis_name);
extern nis_error nis_creategroup(nis_name, u_long);
extern nis_error nis_destroygroup(nis_name);
extern nis_error nis_addmember(nis_name, nis_name);
extern nis_error nis_removemember(nis_name, nis_name);
extern nis_error nis_verifygroup(nis_name);
extern void nis_freeservlist(nis_server **);
extern nis_server ** nis_getservlist(nis_name);
extern nis_error nis_stats(nis_server *, nis_tag *, int, nis_tag **);
extern nis_error nis_servstate(nis_server *, nis_tag *, int, nis_tag **);
extern void nis_freetags(nis_tag *, int);
extern nis_result * nis_checkpoint(nis_name);
extern void nis_ping(nis_name, u_long, nis_object *);
/*
* XXX: PLEASE NOTE THAT THE FOLLOWING FUNCTIONS ARE INTERNAL
* TO NIS+ AND SHOULD NOT BE USED BY ANY APPLICATION PROGRAM.
* THEIR SEMANTICS AND/OR SIGNATURE CAN CHANGE WITHOUT NOTICE.
* SO, PLEASE DO NOT USE THEM. YOU ARE WARNED!!!!
*/
extern char ** __break_name(nis_name, int *);
extern int __name_distance(char **, char **);
extern nis_result * nis_make_error(nis_error, u_long, u_long, u_long, u_long);
extern nis_attr * __cvt2attr(int *, char **);
extern void nis_free_request(ib_request *);
extern nis_error nis_get_request(nis_name, nis_object *, netobj*, ib_request*);
extern nis_object * nis_read_obj(char *);
extern int nis_write_obj(char *, nis_object *);
extern int nis_in_table(nis_name, NIS_HASH_TABLE *, int *);
extern int nis_insert_item(NIS_HASH_ITEM *, NIS_HASH_TABLE *);
extern NIS_HASH_ITEM * nis_find_item(nis_name, NIS_HASH_TABLE *);
extern NIS_HASH_ITEM * nis_remove_item(nis_name, NIS_HASH_TABLE *);
extern void nis_insert_name(nis_name, NIS_HASH_TABLE *);
extern void nis_remove_name(nis_name, NIS_HASH_TABLE *);
extern CLIENT * nis_make_rpchandle(nis_server *, int, u_long, u_long, u_long,
int, int);
extern void * nis_get_static_storage(struct nis_sdata *, u_long, u_long);
extern char * nis_data(char *);
extern void nis_print_rights(u_long);
extern void nis_print_directory(directory_obj *);
extern void nis_print_group(group_obj *);
extern void nis_print_table(table_obj *);
extern void nis_print_link(link_obj *);
extern void nis_print_entry(entry_obj *);
extern nis_object * nis_get_object(char *, char *, char *, u_long, u_long,
zotypes);
extern nis_server * __nis_init_callback(CLIENT *,
int (*)(nis_name, nis_object *, void *), void *);
extern int nis_getdtblsize(void);
extern int __nis_run_callback(netobj *, u_long, struct timeval *, CLIENT *);
extern log_result *nis_dumplog(nis_server *, nis_name, u_long);
extern log_result *nis_dump(nis_server *, nis_name,
int (*)(nis_name, nis_object *, void *));
extern bool_t __do_ismember(nis_name, nis_name,
nis_result *(*)(nis_name, u_long));
extern nis_name __nis_map_group(nis_name);
extern nis_name __nis_map_group_r(nis_name, char*, size_t);
extern nis_error __nis_CacheBind(char *, directory_obj *);
extern nis_error __nis_CacheSearch(char *, directory_obj *);
extern bool_t __nis_CacheRemoveEntry(directory_obj *);
extern void __nis_CacheRestart(void);
extern void __nis_CachePrint(void);
extern void __nis_CacheDumpStatistics(void);
extern bool_t writeColdStartFile(directory_obj *);
extern CLIENT * __get_ti_clnt(char *, CLIENT *, char **, pid_t *);
extern int __strcmp_case_insens(char *, char *);
extern int __strncmp_case_insens(char *, char *);
extern fd_result * nis_finddirectory(directory_obj *, nis_name);
extern int __start_clock(int);
extern u_long __stop_clock(int);
/*
* This particular function is part of the FreeBSD NIS+ implementation
* only. Ideally it should be somewhere else, but it is used by both
* rpc.nisd and nis_cachemgr, and there aren't that many headers common
* to both programs.
*/
extern struct signature *__nis_calculate_encrypted_cksum(unsigned char *, unsigned int, char *, int);
#else
/* Non-prototype definitions (old fashioned C) */
extern void nis_freeresult();
extern nis_result * nis_lookup();
extern nis_result * nis_list();
extern nis_result * nis_add();
extern nis_result * nis_remove();
extern nis_result * nis_modify();
extern nis_result * nis_add_entry();
extern nis_result * nis_remove_entry();
extern nis_result * nis_modify_entry();
extern nis_result * nis_first_entry();
extern nis_result * nis_next_entry();
extern nis_error nis_mkdir();
extern nis_error nis_rmdir();
extern name_pos nis_dir_cmp();
extern nis_name *nis_getnames();
extern void nis_freenames();
extern nis_name nis_domain_of();
extern nis_name nis_leaf_of();
extern nis_name nis_leaf_of_r();
extern nis_name nis_name_of();
extern nis_name nis_local_group();
extern nis_name nis_local_directory();
extern nis_name nis_local_principal();
extern nis_name nis_local_host();
extern void nis_destroy_object();
extern nis_object * nis_clone_object();
extern void nis_print_object();
extern char * nis_sperrno();
extern void nis_perror();
extern char * nis_sperror();
extern void nis_lerror();
extern void nis_print_group_entry();
extern bool_t nis_ismember();
extern nis_error nis_creategroup();
extern nis_error nis_destroygroup();
extern nis_error nis_addmember();
extern nis_error nis_removemember();
extern nis_error nis_verifygroup();
extern void nis_freeservlist();
extern nis_server ** nis_getservlist();
extern nis_error nis_stats();
extern nis_error nis_servstate();
extern void nis_freetags();
extern nis_result * nis_checkpoint();
extern void nis_ping();
/*
* XXX: PLEASE NOTE THAT THE FOLLOWING FUNCTIONS ARE INTERNAL
* TO NIS+ AND SHOULD NOT BE USED BY ANY APPLICATION PROGRAM.
* THEIR SEMANTICS AND/OR SIGNATURE CAN CHANGE WITHOUT NOTICE.
* SO, PLEASE DO NOT USE THEM. YOU ARE WARNED!!!!
*/
extern char ** __break_name();
extern int __name_distance();
extern nis_result * nis_make_error();
extern nis_attr * __cvt2attr();
extern void nis_free_request();
extern nis_error nis_get_request();
extern nis_object * nis_read_obj();
extern int nis_write_obj();
extern int nis_in_table();
extern int nis_insert_item();
extern NIS_HASH_ITEM * nis_find_item();
extern NIS_HASH_ITEM * nis_remove_item();
extern void nis_insert_name();
extern void nis_remove_name();
extern CLIENT * nis_make_rpchandle();
extern void * nis_get_static_storage();
extern char * nis_data();
extern void nis_print_rights();
extern void nis_print_directory();
extern void nis_print_group();
extern void nis_print_table();
extern void nis_print_link();
extern void nis_print_entry();
extern nis_object * nis_get_object();
extern nis_server * __nis_init_callback();
extern int nis_getdtblsize();
extern int __nis_run_callback();
extern log_result * nis_dump();
extern log_result * nis_dumplog();
extern bool_t __do_ismember();
extern nis_name __nis_map_group();
extern nis_name __nis_map_group_r();
extern nis_error __nis_CacheBind();
extern directory_obj * __nis_CacheSearch();
extern bool_t __nis_CacheRemoveEntry();
extern void __nis_CacheRestart();
extern void __nis_CachePrint();
extern void __nis_CacheDumpStatistics();
extern bool_t writeColdStartFile();
extern CLIENT * __get_ti_clnt();
extern int __strcmp_case_insens();
extern int __strncmp_case_insens();
extern fd_result * nis_finddirectory();
extern int __start_clock();
extern u_long __stop_clock();
/*
* This particular function is part of the FreeBSD NIS+ implementation
* only. Ideally it should be somewhere else, but it is used by both
* rpc.nisd and nis_cachemgr, and there aren't that many headers common
* to both programs.
*/
extern struct signature *__nis_calculate_encrypted_cksum();
#endif
#define NUL '\0'
#ifdef __cplusplus
}
#endif
#endif /* _RPCSVC_NISLIB_H */

View File

@@ -1,184 +0,0 @@
/* @(#)nlm_prot.x 2.1 88/08/01 4.0 RPCSRC */
/* @(#)nlm_prot.x 1.8 87/09/21 Copyr 1987 Sun Micro */
/*
* Network lock manager protocol definition
* Copyright (C) 1986 Sun Microsystems, Inc.
*
* protocol used between local lock manager and remote lock manager
*/
#ifdef RPC_HDR
%#define LM_MAXSTRLEN 1024
%#define MAXNAMELEN LM_MAXSTRLEN+1
#else
%#ifndef lint
%static const char rcsid[] =
% "$FreeBSD: src/include/rpcsvc/nlm_prot.x,v 1.8 1999/08/27 23:45:10 peter Exp $";
%#endif /* not lint */
#endif
/*
* status of a call to the lock manager
*/
enum nlm_stats {
nlm_granted = 0,
nlm_denied = 1,
nlm_denied_nolocks = 2,
nlm_blocked = 3,
nlm_denied_grace_period = 4
};
struct nlm_holder {
bool exclusive;
int svid;
netobj oh;
unsigned l_offset;
unsigned l_len;
};
union nlm_testrply switch (nlm_stats stat) {
case nlm_denied:
struct nlm_holder holder;
default:
void;
};
struct nlm_stat {
nlm_stats stat;
};
struct nlm_res {
netobj cookie;
nlm_stat stat;
};
struct nlm_testres {
netobj cookie;
nlm_testrply stat;
};
struct nlm_lock {
string caller_name<LM_MAXSTRLEN>;
netobj fh; /* identify a file */
netobj oh; /* identify owner of a lock */
int svid; /* generated from pid for svid */
unsigned l_offset;
unsigned l_len;
};
struct nlm_lockargs {
netobj cookie;
bool block;
bool exclusive;
struct nlm_lock alock;
bool reclaim; /* used for recovering locks */
int state; /* specify local status monitor state */
};
struct nlm_cancargs {
netobj cookie;
bool block;
bool exclusive;
struct nlm_lock alock;
};
struct nlm_testargs {
netobj cookie;
bool exclusive;
struct nlm_lock alock;
};
struct nlm_unlockargs {
netobj cookie;
struct nlm_lock alock;
};
#ifdef RPC_HDR
%/*
% * The following enums are actually bit encoded for efficient
% * boolean algebra.... DON'T change them.....
% */
#endif
enum fsh_mode {
fsm_DN = 0, /* deny none */
fsm_DR = 1, /* deny read */
fsm_DW = 2, /* deny write */
fsm_DRW = 3 /* deny read/write */
};
enum fsh_access {
fsa_NONE = 0, /* for completeness */
fsa_R = 1, /* read only */
fsa_W = 2, /* write only */
fsa_RW = 3 /* read/write */
};
struct nlm_share {
string caller_name<LM_MAXSTRLEN>;
netobj fh;
netobj oh;
fsh_mode mode;
fsh_access access;
};
struct nlm_shareargs {
netobj cookie;
nlm_share share;
bool reclaim;
};
struct nlm_shareres {
netobj cookie;
nlm_stats stat;
int sequence;
};
struct nlm_notify {
string name<MAXNAMELEN>;
long state;
};
/*
* Over-the-wire protocol used between the network lock managers
*/
program NLM_PROG {
version NLM_VERS {
nlm_testres NLM_TEST(struct nlm_testargs) = 1;
nlm_res NLM_LOCK(struct nlm_lockargs) = 2;
nlm_res NLM_CANCEL(struct nlm_cancargs) = 3;
nlm_res NLM_UNLOCK(struct nlm_unlockargs) = 4;
/*
* remote lock manager call-back to grant lock
*/
nlm_res NLM_GRANTED(struct nlm_testargs)= 5;
/*
* message passing style of requesting lock
*/
void NLM_TEST_MSG(struct nlm_testargs) = 6;
void NLM_LOCK_MSG(struct nlm_lockargs) = 7;
void NLM_CANCEL_MSG(struct nlm_cancargs) =8;
void NLM_UNLOCK_MSG(struct nlm_unlockargs) = 9;
void NLM_GRANTED_MSG(struct nlm_testargs) = 10;
void NLM_TEST_RES(nlm_testres) = 11;
void NLM_LOCK_RES(nlm_res) = 12;
void NLM_CANCEL_RES(nlm_res) = 13;
void NLM_UNLOCK_RES(nlm_res) = 14;
void NLM_GRANTED_RES(nlm_res) = 15;
} = 1;
version NLM_VERSX {
nlm_shareres NLM_SHARE(nlm_shareargs) = 20;
nlm_shareres NLM_UNSHARE(nlm_shareargs) = 21;
nlm_res NLM_NM_LOCK(nlm_lockargs) = 22;
void NLM_FREE_ALL(nlm_notify) = 23;
} = 3;
} = 100021;

View File

@@ -1,285 +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,1989 by Sun Microsystems, Inc.
% */
%/* from pmap_prot.x */
#ifdef RPC_HDR
%
%#pragma ident "@(#)pmap_prot.x 1.6 94/04/29 SMI"
%
%#ifndef _KERNEL
%
#endif
/*
* Port Mapper Protocol Specification (in RPC Language)
* derived from RFC 1057
*/
%/*
% * Protocol for the local binder service, or pmap.
% *
% * Copyright (C) 1984, Sun Microsystems, Inc.
% *
% * The following procedures are supported by the protocol:
% *
% * PMAPPROC_NULL() returns ()
% * takes nothing, returns nothing
% *
% * PMAPPROC_SET(struct pmap) returns (bool_t)
% * TRUE is success, FALSE is failure. Registers the tuple
% * [prog, vers, prot, port].
% *
% * PMAPPROC_UNSET(struct pmap) returns (bool_t)
% * TRUE is success, FALSE is failure. Un-registers pair
% * [prog, vers]. prot and port are ignored.
% *
% * PMAPPROC_GETPORT(struct pmap) returns (long unsigned).
% * 0 is failure. Otherwise returns the port number where the pair
% * [prog, vers] is registered. It may lie!
% *
% * PMAPPROC_DUMP() RETURNS (struct pmaplist_ptr)
% *
% * PMAPPROC_CALLIT(unsigned, unsigned, unsigned, string<>)
% * RETURNS (port, string<>);
% * usage: encapsulatedresults = PMAPPROC_CALLIT(prog, vers, proc,
% * encapsulatedargs);
% * Calls the procedure on the local machine. If it is not registered,
% * this procedure is quite; ie it does not return error information!!!
% * This procedure only is supported on rpc/udp and calls via
% * rpc/udp. This routine only passes null authentication parameters.
% * This file has no interface to xdr routines for PMAPPROC_CALLIT.
% *
% * The service supports remote procedure calls on udp/ip or tcp/ip socket 111.
% */
%
const PMAPPORT = 111; /* portmapper port number */
%
%
%/*
% * A mapping of (program, version, protocol) to port number
% */
struct pmap {
unsigned long pm_prog;
unsigned long pm_vers;
unsigned long pm_prot;
unsigned long pm_port;
};
#ifdef RPC_HDR
%
%typedef pmap PMAP;
%
#endif
%
%/*
% * Supported values for the "prot" field
% */
%
const PMAP_IPPROTO_TCP = 6; /* protocol number for TCP/IP */
const PMAP_IPPROTO_UDP = 17; /* protocol number for UDP/IP */
%
%
%/*
% * A list of mappings
% *
% * Below are two definitions for the pmaplist structure. This is done because
% * xdr_pmaplist() is specified to take a struct pmaplist **, rather than a
% * struct pmaplist * that rpcgen would produce. One version of the pmaplist
% * structure (actually called pm__list) is used with rpcgen, and the other is
% * defined only in the header file for compatibility with the specified
% * interface.
% */
struct pm__list {
pmap pml_map;
struct pm__list *pml_next;
};
typedef pm__list *pmaplist_ptr; /* results of PMAPPROC_DUMP */
#ifdef RPC_HDR
%
%typedef struct pm__list pmaplist;
%typedef struct pm__list PMAPLIST;
%
%#ifndef __cplusplus
%struct pmaplist {
% PMAP pml_map;
% struct pmaplist *pml_next;
%};
%#endif
%
%#ifdef __cplusplus
%extern "C" {
%#endif
%#ifdef __STDC__
%extern bool_t xdr_pmaplist(XDR *, pmaplist**);
%#else /* K&R C */
%bool_t xdr_pmaplist();
%#endif
%#ifdef __cplusplus
%}
%#endif
%
#endif
%
%/*
% * Arguments to callit
% */
struct rmtcallargs {
unsigned long prog;
unsigned long vers;
unsigned long proc;
opaque args<>;
};
#ifdef RPC_HDR
%
%/*
% * Client-side only representation of rmtcallargs structure.
% *
% * The routine that XDRs the rmtcallargs structure must deal with the
% * opaque arguments in the "args" structure. xdr_rmtcall_args() needs to be
% * passed the XDR routine that knows the args' structure. This routine
% * doesn't need to go over-the-wire (and it wouldn't make sense anyway) since
% * the application being called knows the args structure already. So we use a
% * different "XDR" structure on the client side, p_rmtcallargs, which includes
% * the args' XDR routine.
% */
%struct p_rmtcallargs {
% u_long prog;
% u_long vers;
% u_long proc;
% struct {
% u_int args_len;
% char *args_val;
% } args;
% xdrproc_t xdr_args; /* encodes args */
%};
%
#endif /* def RPC_HDR */
%
%
%/*
% * Results of callit
% */
struct rmtcallres {
unsigned long port;
opaque res<>;
};
#ifdef RPC_HDR
%
%/*
% * Client-side only representation of rmtcallres structure.
% */
%struct p_rmtcallres {
% u_long port;
% struct {
% u_int res_len;
% char *res_val;
% } res;
% xdrproc_t xdr_res; /* decodes res */
%};
%
#endif /* def RPC_HDR */
/*
* Port mapper procedures
*/
program PMAPPROG {
version PMAPVERS {
void
PMAPPROC_NULL(void) = 0;
bool
PMAPPROC_SET(pmap) = 1;
bool
PMAPPROC_UNSET(pmap) = 2;
unsigned long
PMAPPROC_GETPORT(pmap) = 3;
pmaplist_ptr
PMAPPROC_DUMP(void) = 4;
rmtcallres
PMAPPROC_CALLIT(rmtcallargs) = 5;
} = 2;
} = 100000;
%
#ifdef RPC_HDR
%#define PMAPVERS_PROTO ((u_long)2)
%#define PMAPVERS_ORIG ((u_long)1)
%
%#else /* ndef _KERNEL */
%
%#include <rpc/pmap_rmt.h>
%
%#ifdef __cplusplus
%extern "C" {
%#endif
%
%#define PMAPPORT 111
%
%struct pmap {
% long unsigned pm_prog;
% long unsigned pm_vers;
% long unsigned pm_prot;
% long unsigned pm_port;
%};
%typedef struct pmap PMAP;
%#ifdef __STDC__
%extern bool_t xdr_pmap (XDR *, struct pmap *);
%#else
%extern bool_t xdr_pmap ();
%#endif
%
%struct pmaplist {
% struct pmap pml_map;
% struct pmaplist *pml_next;
%};
%typedef struct pmaplist PMAPLIST;
%typedef struct pmaplist *pmaplist_ptr;
%
%
%#ifdef __cplusplus
%}
%#endif
%
%#endif /* ndef _KERNEL */
#endif

View File

@@ -1,235 +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
*/
/*
* Remote execution (rex) protocol specification
*/
#ifndef RPC_HDR
%#ifndef lint
%/*static char sccsid[] = "from: @(#)rex.x 1.3 87/09/18 Copyr 1987 Sun Micro";*/
%/*static char sccsid[] = "from: @(#)rex.x 2.1 88/08/01 4.0 RPCSRC";*/
%static const char rcsid[] =
% "$FreeBSD: src/include/rpcsvc/rex.x,v 1.6 1999/08/27 23:45:10 peter Exp $";
%#endif /* not lint */
#endif
const STRINGSIZE = 1024;
typedef string rexstring<1024>;
/*
* values to pass to REXPROC_SIGNAL
*/
const SIGINT = 2; /* interrupt */
/*
* Values for rst_flags, below
*/
const REX_INTERACTIVE = 1; /* interactive mode */
struct rex_start {
rexstring rst_cmd<>; /* list of command and args */
rexstring rst_host; /* working directory host name */
rexstring rst_fsname; /* working directory file system name */
rexstring rst_dirwithin;/* working directory within file system */
rexstring rst_env<>; /* list of environment */
unsigned int rst_port0; /* port for stdin */
unsigned int rst_port1; /* port for stdout */
unsigned int rst_port2; /* port for stderr */
unsigned int rst_flags; /* options - see const above */
};
struct rex_result {
int rlt_stat; /* integer status code */
rexstring rlt_message; /* string message for human consumption */
};
struct sgttyb {
unsigned four; /* always equals 4 */
opaque chars[4];
/* chars[0] == input speed */
/* chars[1] == output speed */
/* chars[2] == kill character */
/* chars[3] == erase character */
unsigned flags;
};
/* values for speeds above (baud rates) */
const B0 = 0;
const B50 = 1;
const B75 = 2;
const B110 = 3;
const B134 = 4;
const B150 = 5;
const B200 = 6;
const B300 = 7;
const B600 = 8;
const B1200 = 9;
const B1800 = 10;
const B2400 = 11;
const B4800 = 12;
const B9600 = 13;
const B19200 = 14;
const B38400 = 15;
/* values for flags above */
const TANDEM = 0x00000001; /* send stopc on out q full */
const CBREAK = 0x00000002; /* half-cooked mode */
const LCASE = 0x00000004; /* simulate lower case */
const ECHO = 0x00000008; /* echo input */
const CRMOD = 0x00000010; /* map \r to \r\n on output */
const RAW = 0x00000020; /* no i/o processing */
const ODDP = 0x00000040; /* get/send odd parity */
const EVENP = 0x00000080; /* get/send even parity */
const ANYP = 0x000000c0; /* get any parity/send none */
const NLDELAY = 0x00000300; /* \n delay */
const NL0 = 0x00000000;
const NL1 = 0x00000100; /* tty 37 */
const NL2 = 0x00000200; /* vt05 */
const NL3 = 0x00000300;
const TBDELAY = 0x00000c00; /* horizontal tab delay */
const TAB0 = 0x00000000;
const TAB1 = 0x00000400; /* tty 37 */
const TAB2 = 0x00000800;
const XTABS = 0x00000c00; /* expand tabs on output */
const CRDELAY = 0x00003000; /* \r delay */
const CR0 = 0x00000000;
const CR1 = 0x00001000; /* tn 300 */
const CR2 = 0x00002000; /* tty 37 */
const CR3 = 0x00003000; /* concept 100 */
const VTDELAY = 0x00004000; /* vertical tab delay */
const FF0 = 0x00000000;
const FF1 = 0x00004000; /* tty 37 */
const BSDELAY = 0x00008000; /* \b delay */
const BS0 = 0x00000000;
const BS1 = 0x00008000;
const CRTBS = 0x00010000; /* do backspacing for crt */
const PRTERA = 0x00020000; /* \ ... / erase */
const CRTERA = 0x00040000; /* " \b " to wipe out char */
const TILDE = 0x00080000; /* hazeltine tilde kludge */
const MDMBUF = 0x00100000; /* start/stop output on carrier intr */
const LITOUT = 0x00200000; /* literal output */
const TOSTOP = 0x00400000; /* SIGTTOU on background output */
const FLUSHO = 0x00800000; /* flush output to terminal */
const NOHANG = 0x01000000; /* no SIGHUP on carrier drop */
const L001000 = 0x02000000;
const CRTKIL = 0x04000000; /* kill line with " \b " */
const PASS8 = 0x08000000;
const CTLECH = 0x10000000; /* echo control chars as ^X */
const PENDIN = 0x20000000; /* tp->t_rawq needs reread */
const DECCTQ = 0x40000000; /* only ^Q starts after ^S */
const NOFLSH = 0x80000000; /* no output flush on signal */
struct tchars {
unsigned six; /* always equals 6 */
opaque chars[6];
/* chars[0] == interrupt char */
/* chars[1] == quit char */
/* chars[2] == start output char */
/* chars[3] == stop output char */
/* chars[4] == end-of-file char */
/* chars[5] == input delimeter (like nl) */
};
struct ltchars {
unsigned six; /* always equals 6 */
opaque chars[6];
/* chars[0] == stop process signal */
/* chars[1] == delayed stop process signal */
/* chars[2] == reprint line */
/* chars[3] == flush output */
/* chars[4] == word erase */
/* chars[5] == literal next character */
unsigned mode;
};
struct rex_ttysize {
int ts_lines;
int ts_cols;
};
struct rex_ttymode {
sgttyb basic; /* standard unix tty flags */
tchars more; /* interrupt, kill characters, etc. */
ltchars yetmore; /* special Berkeley characters */
unsigned andmore; /* and Berkeley modes */
};
/* values for andmore above */
const LCRTBS = 0x0001; /* do backspacing for crt */
const LPRTERA = 0x0002; /* \ ... / erase */
const LCRTERA = 0x0004; /* " \b " to wipe out char */
const LTILDE = 0x0008; /* hazeltine tilde kludge */
const LMDMBUF = 0x0010; /* start/stop output on carrier intr */
const LLITOUT = 0x0020; /* literal output */
const LTOSTOP = 0x0040; /* SIGTTOU on background output */
const LFLUSHO = 0x0080; /* flush output to terminal */
const LNOHANG = 0x0100; /* no SIGHUP on carrier drop */
const LL001000 = 0x0200;
const LCRTKIL = 0x0400; /* kill line with " \b " */
const LPASS8 = 0x0800;
const LCTLECH = 0x1000; /* echo control chars as ^X */
const LPENDIN = 0x2000; /* needs reread */
const LDECCTQ = 0x4000; /* only ^Q starts after ^S */
const LNOFLSH = 0x8000; /* no output flush on signal */
program REXPROG {
version REXVERS {
/*
* Start remote execution
*/
rex_result
REXPROC_START(rex_start) = 1;
/*
* Wait for remote execution to terminate
*/
rex_result
REXPROC_WAIT(void) = 2;
/*
* Send tty modes
*/
void
REXPROC_MODES(rex_ttymode) = 3;
/*
* Send window size change
*/
void
REXPROC_WINCH(rex_ttysize) = 4;
/*
* Send other signal
*/
void
REXPROC_SIGNAL(int) = 5;
} = 1;
} = 100017;

View File

@@ -1,123 +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
*/
/*
* Find out about remote users
*/
#ifndef RPC_HDR
%#ifndef lint
%/*static char sccsid[] = "from: @(#)rnusers.x 1.2 87/09/20 Copyr 1987 Sun Micro";*/
%/*static char sccsid[] = "from: @(#)rnusers.x 2.1 88/08/01 4.0 RPCSRC";*/
%static const char rcsid[] =
% "$FreeBSD: src/include/rpcsvc/rnusers.x,v 1.6 1999/08/27 23:45:10 peter Exp $";
%#endif /* not lint */
#endif
const MAXUSERS = 100;
const MAXUTLEN = 256;
struct utmp {
string ut_line<MAXUTLEN>;
string ut_name<MAXUTLEN>;
string ut_host<MAXUTLEN>;
int ut_time;
};
struct utmpidle {
utmp ui_utmp;
unsigned int ui_idle;
};
typedef utmp utmparr<MAXUSERS>;
typedef utmpidle utmpidlearr<MAXUSERS>;
const RUSERS_MAXUSERLEN = 32;
const RUSERS_MAXLINELEN = 32;
const RUSERS_MAXHOSTLEN = 257;
struct rusers_utmp {
string ut_user<RUSERS_MAXUSERLEN>; /* aka ut_name */
string ut_line<RUSERS_MAXLINELEN>; /* device */
string ut_host<RUSERS_MAXHOSTLEN>; /* host user logged on from */
int ut_type; /* type of entry */
int ut_time; /* time entry was made */
unsigned int ut_idle; /* minutes idle */
};
typedef rusers_utmp utmp_array<>;
program RUSERSPROG {
/*
* Old version does not include idle information
*/
version RUSERSVERS_ORIG {
int
RUSERSPROC_NUM(void) = 1;
utmparr
RUSERSPROC_NAMES(void) = 2;
utmparr
RUSERSPROC_ALLNAMES(void) = 3;
} = 1;
/*
* Includes idle information
*/
version RUSERSVERS_IDLE {
int
RUSERSPROC_NUM(void) = 1;
utmpidlearr
RUSERSPROC_NAMES(void) = 2;
utmpidlearr
RUSERSPROC_ALLNAMES(void) = 3;
} = 2;
/*
* Version 3 rusers procedures (from Solaris).
* (Thanks a lot Sun.)
*/
version RUSERSVERS_3 {
int
RUSERSPROC_NUM(void) = 1;
utmp_array
RUSERSPROC_NAMES(void) = 2;
utmp_array
RUSERSPROC_ALLNAMES(void) = 3;
} = 3;
} = 100002;

View File

@@ -1,67 +0,0 @@
/*
* Remote quota protocol
* Requires unix authentication
*/
#ifndef RPC_HDR
%#ifndef lint
%/*static char sccsid[] = "from: @(#)rquota.x 1.2 87/09/20 Copyr 1987 Sun Micro";*/
%/*static char sccsid[] = "from: @(#)rquota.x 2.1 88/08/01 4.0 RPCSRC";*/
%static const char rcsid[] =
% "$FreeBSD: src/include/rpcsvc/rquota.x,v 1.6 1999/08/27 23:45:10 peter Exp $";
%#endif /* not lint */
#endif
const RQ_PATHLEN = 1024;
struct getquota_args {
string gqa_pathp<RQ_PATHLEN>; /* path to filesystem of interest */
int gqa_uid; /* inquire about quota for uid */
};
/*
* remote quota structure
*/
struct rquota {
int rq_bsize; /* block size for block counts */
bool rq_active; /* indicates whether quota is active */
unsigned int rq_bhardlimit; /* absolute limit on disk blks alloc */
unsigned int rq_bsoftlimit; /* preferred limit on disk blks */
unsigned int rq_curblocks; /* current block count */
unsigned int rq_fhardlimit; /* absolute limit on allocated files */
unsigned int rq_fsoftlimit; /* preferred file limit */
unsigned int rq_curfiles; /* current # allocated files */
unsigned int rq_btimeleft; /* time left for excessive disk use */
unsigned int rq_ftimeleft; /* time left for excessive files */
};
enum gqr_status {
Q_OK = 1, /* quota returned */
Q_NOQUOTA = 2, /* noquota for uid */
Q_EPERM = 3 /* no permission to access quota */
};
union getquota_rslt switch (gqr_status status) {
case Q_OK:
rquota gqr_rquota; /* valid if status == Q_OK */
case Q_NOQUOTA:
void;
case Q_EPERM:
void;
};
program RQUOTAPROG {
version RQUOTAVERS {
/*
* Get all quotas
*/
getquota_rslt
RQUOTAPROC_GETQUOTA(getquota_args) = 1;
/*
* Get active quotas only
*/
getquota_rslt
RQUOTAPROC_GETACTIVEQUOTA(getquota_args) = 2;
} = 1;
} = 100011;

View File

@@ -1,151 +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
*/
/*
* Gather statistics on remote machines
*/
#ifdef RPC_HDR
%#ifndef FSCALE
%/*
% * Scale factor for scaled integers used to count load averages.
% */
%#define FSHIFT 8 /* bits to right of fixed binary point */
%#define FSCALE (1<<FSHIFT)
%
%#endif /* ndef FSCALE */
#else
%#ifndef lint
%/*static char sccsid[] = "from: @(#)rstat.x 1.2 87/09/18 Copyr 1987 Sun Micro";*/
%/*static char sccsid[] = "from: @(#)rstat.x 2.2 88/08/01 4.0 RPCSRC";*/
%static const char rcsid[] =
% "$FreeBSD: src/include/rpcsvc/rstat.x,v 1.6 1999/08/27 23:45:11 peter Exp $";
%#endif /* not lint */
#endif /* def RPC_HDR */
const RSTAT_CPUSTATES = 4;
const RSTAT_DK_NDRIVE = 4;
/*
* GMT since 0:00, January 1, 1970
*/
struct rstat_timeval {
unsigned int tv_sec; /* seconds */
unsigned int tv_usec; /* and microseconds */
};
struct statstime { /* RSTATVERS_TIME */
int cp_time[RSTAT_CPUSTATES];
int dk_xfer[RSTAT_DK_NDRIVE];
unsigned int v_pgpgin; /* these are cumulative sum */
unsigned int v_pgpgout;
unsigned int v_pswpin;
unsigned int v_pswpout;
unsigned int v_intr;
int if_ipackets;
int if_ierrors;
int if_oerrors;
int if_collisions;
unsigned int v_swtch;
int avenrun[3]; /* scaled by FSCALE */
rstat_timeval boottime;
rstat_timeval curtime;
int if_opackets;
};
struct statsswtch { /* RSTATVERS_SWTCH */
int cp_time[RSTAT_CPUSTATES];
int dk_xfer[RSTAT_DK_NDRIVE];
unsigned int v_pgpgin; /* these are cumulative sum */
unsigned int v_pgpgout;
unsigned int v_pswpin;
unsigned int v_pswpout;
unsigned int v_intr;
int if_ipackets;
int if_ierrors;
int if_oerrors;
int if_collisions;
unsigned int v_swtch;
unsigned int avenrun[3];/* scaled by FSCALE */
rstat_timeval boottime;
int if_opackets;
};
struct stats { /* RSTATVERS_ORIG */
int cp_time[RSTAT_CPUSTATES];
int dk_xfer[RSTAT_DK_NDRIVE];
unsigned int v_pgpgin; /* these are cumulative sum */
unsigned int v_pgpgout;
unsigned int v_pswpin;
unsigned int v_pswpout;
unsigned int v_intr;
int if_ipackets;
int if_ierrors;
int if_oerrors;
int if_collisions;
int if_opackets;
};
program RSTATPROG {
/*
* Newest version includes current time and context switching info
*/
version RSTATVERS_TIME {
statstime
RSTATPROC_STATS(void) = 1;
unsigned int
RSTATPROC_HAVEDISK(void) = 2;
} = 3;
/*
* Does not have current time
*/
version RSTATVERS_SWTCH {
statsswtch
RSTATPROC_STATS(void) = 1;
unsigned int
RSTATPROC_HAVEDISK(void) = 2;
} = 2;
/*
* Old version has no info about current time or context switching
*/
version RSTATVERS_ORIG {
stats
RSTATPROC_STATS(void) = 1;
unsigned int
RSTATPROC_HAVEDISK(void) = 2;
} = 1;
} = 100001;

View File

@@ -1,57 +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 or with the express written consent of
% * Sun Microsystems, Inc.
% *
% * 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, 1990 by Sun Microsystems, Inc.
% */
%
%/* from @(#)rwall.x 1.6 91/03/11 TIRPC 1.0 */
#ifdef RPC_HDR
%
%#ifndef _rpcsvc_rwall_h
%#define _rpcsvc_rwall_h
%
%typedef char *wrapstring;
%
#endif
program WALLPROG {
version WALLVERS {
void
WALLPROC_WALL(wrapstring) = 2;
} = 1;
} = 100008;
#ifdef RPC_HDR
%
%#endif /* ! _rpcsvc_rwall_h */
#endif

View File

@@ -1,122 +0,0 @@
/* @(#)sm_inter.x 2.2 88/08/01 4.0 RPCSRC */
/* @(#)sm_inter.x 1.7 87/06/24 Copyr 1987 Sun Micro */
/*
* 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
*/
/*
* Status monitor protocol specification
* Copyright (C) 1986 Sun Microsystems, Inc.
*
*/
#ifndef RPC_HDR
%#ifndef lint
%static const char rcsid[] =
% "$FreeBSD: src/include/rpcsvc/sm_inter.x,v 1.8 1999/08/27 23:45:11 peter Exp $";
%#endif /* not lint */
#endif
program SM_PROG {
version SM_VERS {
/* res_stat = stat_succ if status monitor agrees to monitor */
/* res_stat = stat_fail if status monitor cannot monitor */
/* if res_stat == stat_succ, state = state number of site sm_name */
struct sm_stat_res SM_STAT(struct sm_name) = 1;
/* res_stat = stat_succ if status monitor agrees to monitor */
/* res_stat = stat_fail if status monitor cannot monitor */
/* stat consists of state number of local site */
struct sm_stat_res SM_MON(struct mon) = 2;
/* stat consists of state number of local site */
struct sm_stat SM_UNMON(struct mon_id) = 3;
/* stat consists of state number of local site */
struct sm_stat SM_UNMON_ALL(struct my_id) = 4;
void SM_SIMU_CRASH(void) = 5;
} = 1;
} = 100024;
const SM_MAXSTRLEN = 1024;
struct sm_name {
string mon_name<SM_MAXSTRLEN>;
};
struct my_id {
string my_name<SM_MAXSTRLEN>; /* name of the site iniates the monitoring request*/
int my_prog; /* rpc program # of the requesting process */
int my_vers; /* rpc version # of the requesting process */
int my_proc; /* rpc procedure # of the requesting process */
};
struct mon_id {
string mon_name<SM_MAXSTRLEN>; /* name of the site to be monitored */
struct my_id my_id;
};
struct mon{
struct mon_id mon_id;
opaque priv[16]; /* private information to store at monitor for requesting process */
};
/*
* state # of status monitor monitonically increases each time
* status of the site changes:
* an even number (>= 0) indicates the site is down and
* an odd number (> 0) indicates the site is up;
*/
struct sm_stat {
int state; /* state # of status monitor */
};
enum res {
stat_succ = 0, /* status monitor agrees to monitor */
stat_fail = 1 /* status monitor cannot monitor */
};
struct sm_stat_res {
res res_stat;
int state;
};
/*
* structure of the status message sent back by the status monitor
* when monitor site status changes
*/
struct status {
string mon_name<SM_MAXSTRLEN>;
int state;
opaque priv[16]; /* stored private information */
};

View File

@@ -1,90 +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
*/
/*
* Spray a server with packets
* Useful for testing flakiness of network interfaces
*/
#ifndef RPC_HDR
%#ifndef lint
%/*static char sccsid[] = "from: @(#)spray.x 1.2 87/09/18 Copyr 1987 Sun Micro";*/
%/*static char sccsid[] = "from: @(#)spray.x 2.1 88/08/01 4.0 RPCSRC";*/
%static const char rcsid[] =
% "$FreeBSD: src/include/rpcsvc/spray.x,v 1.6 1999/08/27 23:45:11 peter Exp $";
%#endif /* not lint */
#endif
const SPRAYMAX = 8845; /* max amount can spray */
/*
* GMT since 0:00, 1 January 1970
*/
struct spraytimeval {
unsigned int sec;
unsigned int usec;
};
/*
* spray statistics
*/
struct spraycumul {
unsigned int counter;
spraytimeval clock;
};
/*
* spray data
*/
typedef opaque sprayarr<SPRAYMAX>;
program SPRAYPROG {
version SPRAYVERS {
/*
* Just throw away the data and increment the counter
* This call never returns, so the client should always
* time it out.
*/
void
SPRAYPROC_SPRAY(sprayarr) = 1;
/*
* Get the value of the counter and elapsed time since
* last CLEAR.
*/
spraycumul
SPRAYPROC_GET(void) = 2;
/*
* Clear the counter and reset the elapsed time
*/
void
SPRAYPROC_CLEAR(void) = 3;
} = 1;
} = 100012;

View File

@@ -1,379 +0,0 @@
/* @(#)yp.x 2.1 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
*/
/*
* Protocol description file for the Yellow Pages Service
*/
#ifndef RPC_HDR
%#ifndef lint
%static const char rcsid[] =
% "$FreeBSD: src/include/rpcsvc/yp.x,v 1.12 1999/08/27 23:45:12 peter Exp $";
%#endif /* not lint */
#endif
const YPMAXRECORD = 1024;
const YPMAXDOMAIN = 64;
const YPMAXMAP = 64;
const YPMAXPEER = 64;
enum ypstat {
YP_TRUE = 1,
YP_NOMORE = 2,
YP_FALSE = 0,
YP_NOMAP = -1,
YP_NODOM = -2,
YP_NOKEY = -3,
YP_BADOP = -4,
YP_BADDB = -5,
YP_YPERR = -6,
YP_BADARGS = -7,
YP_VERS = -8
};
enum ypxfrstat {
YPXFR_SUCC = 1,
YPXFR_AGE = 2,
YPXFR_NOMAP = -1,
YPXFR_NODOM = -2,
YPXFR_RSRC = -3,
YPXFR_RPC = -4,
YPXFR_MADDR = -5,
YPXFR_YPERR = -6,
YPXFR_BADARGS = -7,
YPXFR_DBM = -8,
YPXFR_FILE = -9,
YPXFR_SKEW = -10,
YPXFR_CLEAR = -11,
YPXFR_FORCE = -12,
YPXFR_XFRERR = -13,
YPXFR_REFUSED = -14
};
typedef string domainname<YPMAXDOMAIN>;
typedef string mapname<YPMAXMAP>;
typedef string peername<YPMAXPEER>;
typedef opaque keydat<YPMAXRECORD>;
typedef opaque valdat<YPMAXRECORD>;
struct ypmap_parms {
domainname domain;
mapname map;
unsigned int ordernum;
peername peer;
};
struct ypreq_key {
domainname domain;
mapname map;
keydat key;
};
struct ypreq_nokey {
domainname domain;
mapname map;
};
struct ypreq_xfr {
ypmap_parms map_parms;
unsigned int transid;
unsigned int prog;
unsigned int port;
};
struct ypresp_val {
ypstat stat;
valdat val;
};
struct ypresp_key_val {
ypstat stat;
#ifdef STUPID_SUN_BUG /* These are backwards */
keydat key;
valdat val;
#else
valdat val;
keydat key;
#endif
};
struct ypresp_master {
ypstat stat;
peername peer;
};
struct ypresp_order {
ypstat stat;
unsigned int ordernum;
};
union ypresp_all switch (bool more) {
case TRUE:
ypresp_key_val val;
case FALSE:
void;
};
struct ypresp_xfr {
unsigned int transid;
ypxfrstat xfrstat;
};
struct ypmaplist {
mapname map;
ypmaplist *next;
};
struct ypresp_maplist {
ypstat stat;
ypmaplist *maps;
};
enum yppush_status {
YPPUSH_SUCC = 1, /* Success */
YPPUSH_AGE = 2, /* Master's version not newer */
YPPUSH_NOMAP = -1, /* Can't find server for map */
YPPUSH_NODOM = -2, /* Domain not supported */
YPPUSH_RSRC = -3, /* Local resource alloc failure */
YPPUSH_RPC = -4, /* RPC failure talking to server */
YPPUSH_MADDR = -5, /* Can't get master address */
YPPUSH_YPERR = -6, /* YP server/map db error */
YPPUSH_BADARGS = -7, /* Request arguments bad */
YPPUSH_DBM = -8, /* Local dbm operation failed */
YPPUSH_FILE = -9, /* Local file I/O operation failed */
YPPUSH_SKEW = -10, /* Map version skew during transfer */
YPPUSH_CLEAR = -11, /* Can't send "Clear" req to local ypserv */
YPPUSH_FORCE = -12, /* No local order number in map use -f flag. */
YPPUSH_XFRERR = -13, /* ypxfr error */
YPPUSH_REFUSED = -14 /* Transfer request refused by ypserv */
};
struct yppushresp_xfr {
unsigned transid;
yppush_status status;
};
/*
* Response structure and overall result status codes. Success and failure
* represent two separate response message types.
*/
enum ypbind_resptype {
YPBIND_SUCC_VAL = 1,
YPBIND_FAIL_VAL = 2
};
struct ypbind_binding {
opaque ypbind_binding_addr[4]; /* In network order */
opaque ypbind_binding_port[2]; /* In network order */
};
union ypbind_resp switch (ypbind_resptype ypbind_status) {
case YPBIND_FAIL_VAL:
unsigned ypbind_error;
case YPBIND_SUCC_VAL:
ypbind_binding ypbind_bindinfo;
};
/* Detailed failure reason codes for response field ypbind_error*/
const YPBIND_ERR_ERR = 1; /* Internal error */
const YPBIND_ERR_NOSERV = 2; /* No bound server for passed domain */
const YPBIND_ERR_RESC = 3; /* System resource allocation failure */
/*
* Request data structure for ypbind "Set domain" procedure.
*/
struct ypbind_setdom {
domainname ypsetdom_domain;
ypbind_binding ypsetdom_binding;
unsigned ypsetdom_vers;
};
/*
* NIS v1 support for backwards compatibility
*/
enum ypreqtype {
YPREQ_KEY = 1,
YPREQ_NOKEY = 2,
YPREQ_MAP_PARMS = 3
};
enum ypresptype {
YPRESP_VAL = 1,
YPRESP_KEY_VAL = 2,
YPRESP_MAP_PARMS = 3
};
union yprequest switch (ypreqtype yp_reqtype) {
case YPREQ_KEY:
ypreq_key yp_req_keytype;
case YPREQ_NOKEY:
ypreq_nokey yp_req_nokeytype;
case YPREQ_MAP_PARMS:
ypmap_parms yp_req_map_parmstype;
};
union ypresponse switch (ypresptype yp_resptype) {
case YPRESP_VAL:
ypresp_val yp_resp_valtype;
case YPRESP_KEY_VAL:
ypresp_key_val yp_resp_key_valtype;
case YPRESP_MAP_PARMS:
ypmap_parms yp_resp_map_parmstype;
};
#if !defined(YPBIND_ONLY) && !defined(YPPUSH_ONLY)
/*
* YP access protocol
*/
program YPPROG {
/*
* NIS v1 support for backwards compatibility
*/
version YPOLDVERS {
void
YPOLDPROC_NULL(void) = 0;
bool
YPOLDPROC_DOMAIN(domainname) = 1;
bool
YPOLDPROC_DOMAIN_NONACK(domainname) = 2;
ypresponse
YPOLDPROC_MATCH(yprequest) = 3;
ypresponse
YPOLDPROC_FIRST(yprequest) = 4;
ypresponse
YPOLDPROC_NEXT(yprequest) = 5;
ypresponse
YPOLDPROC_POLL(yprequest) = 6;
ypresponse
YPOLDPROC_PUSH(yprequest) = 7;
ypresponse
YPOLDPROC_PULL(yprequest) = 8;
ypresponse
YPOLDPROC_GET(yprequest) = 9;
} = 1;
version YPVERS {
void
YPPROC_NULL(void) = 0;
bool
YPPROC_DOMAIN(domainname) = 1;
bool
YPPROC_DOMAIN_NONACK(domainname) = 2;
ypresp_val
YPPROC_MATCH(ypreq_key) = 3;
ypresp_key_val
#ifdef STUPID_SUN_BUG /* should be ypreq_nokey */
YPPROC_FIRST(ypreq_key) = 4;
#else
YPPROC_FIRST(ypreq_nokey) = 4;
#endif
ypresp_key_val
YPPROC_NEXT(ypreq_key) = 5;
ypresp_xfr
YPPROC_XFR(ypreq_xfr) = 6;
void
YPPROC_CLEAR(void) = 7;
ypresp_all
YPPROC_ALL(ypreq_nokey) = 8;
ypresp_master
YPPROC_MASTER(ypreq_nokey) = 9;
ypresp_order
YPPROC_ORDER(ypreq_nokey) = 10;
ypresp_maplist
YPPROC_MAPLIST(domainname) = 11;
} = 2;
} = 100004;
#endif
#if !defined(YPSERV_ONLY) && !defined(YPBIND_ONLY)
/*
* YPPUSHPROC_XFRRESP is the callback routine for result of YPPROC_XFR
*/
program YPPUSH_XFRRESPPROG {
version YPPUSH_XFRRESPVERS {
void
YPPUSHPROC_NULL(void) = 0;
#ifdef STUPID_SUN_BUG /* argument and return value are backwards */
yppushresp_xfr
YPPUSHPROC_XFRRESP(void) = 1;
#else
void
YPPUSHPROC_XFRRESP(yppushresp_xfr) = 1;
#endif
} = 1;
} = 0x40000000; /* transient: could be anything up to 0x5fffffff */
#endif
#if !defined(YPSERV_ONLY) && !defined(YPPUSH_ONLY)
/*
* YP binding protocol
*/
program YPBINDPROG {
version YPBINDVERS {
void
YPBINDPROC_NULL(void) = 0;
ypbind_resp
YPBINDPROC_DOMAIN(domainname) = 1;
void
YPBINDPROC_SETDOM(ypbind_setdom) = 2;
} = 2;
} = 100007;
#endif

View File

@@ -1,329 +0,0 @@
/*
* Copyright (c) 1992/3 Theo de Raadt <deraadt@fsa.ca>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote
* products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD: src/include/rpcsvc/yp_prot.h,v 1.10 1999/08/27 23:45:12 peter Exp $
*/
#ifndef _RPCSVC_YP_PROT_H_
#define _RPCSVC_YP_PROT_H_
/*
* YPSERV PROTOCOL:
*
* ypserv supports the following procedures:
*
* YPPROC_NULL takes (void), returns (void).
* called to check if server is alive.
* YPPROC_DOMAIN takes (char *), returns (bool_t).
* true if ypserv serves the named domain.
* YPPROC_DOMAIN_NOACK takes (char *), returns (bool_t).
* true if ypserv serves the named domain.
* used for broadcasts, does not ack if ypserv
* doesn't handle named domain.
* YPPROC_MATCH takes (struct ypreq_key), returns (struct ypresp_val)
* does a lookup.
* YPPROC_FIRST takes (struct ypreq_nokey) returns (ypresp_key_val).
* gets the first key/datum from the map.
* YPPROC_NEXT takes (struct ypreq_key) returns (ypresp_key_val).
* gets the next key/datum from the map.
* YPPROC_XFR takes (struct ypreq_xfr), returns (void).
* tells ypserv to check if there is a new version of
* the map.
* YPPROC_CLEAR takes (void), returns (void).
* tells ypserv to flush it's file cache, so that
* newly transferred files will get read.
* YPPROC_ALL takes (struct ypreq_nokey), returns (bool_t and
* struct ypresp_key_val).
* returns an array of data, with the bool_t being
* false on the last datum. read the source, it's
* convoluted.
* YPPROC_MASTER takes (struct ypreq_nokey), returns (ypresp_master).
* YPPROC_ORDER takes (struct ypreq_nokey), returns (ypresp_order).
* YPPROC_MAPLIST takes (char *), returns (struct ypmaplist *).
*/
#ifndef BOOL_DEFINED
typedef u_int bool;
#define BOOL_DEFINED
#endif
/* Program and version symbols, magic numbers */
#define YPPROG ((u_long)100004)
#define YPVERS ((u_long)2)
#define YPVERS_ORIG ((u_long)1)
#define YPMAXRECORD ((u_long)1024)
#define YPMAXDOMAIN ((u_long)64)
#define YPMAXMAP ((u_long)64)
#define YPMAXPEER ((u_long)256)
/*
* I don't know if anything of sun's depends on this, or if they
* simply defined it so that their own code wouldn't try to send
* packets over the ethernet MTU. This YP code doesn't use it.
*/
#define YPMSGSZ 1600
#ifndef DATUM
typedef struct {
char *dptr;
int dsize;
} datum;
#define DATUM
#endif
struct ypmap_parms {
char *domain;
char *map;
u_long ordernum;
char *owner;
};
struct ypreq_key {
char *domain;
char *map;
datum keydat;
};
struct ypreq_nokey {
char *domain;
char *map;
};
struct ypreq_xfr {
struct ypmap_parms map_parms;
u_long transid;
u_long proto;
u_short port;
};
#define ypxfr_domain map_parms.domain
#define ypxfr_map map_parms.map
#define ypxfr_ordernum map_parms.ordernum
#define ypxfr_owner map_parms.owner
struct ypresp_val {
u_long status;
datum valdat;
};
struct ypresp_key_val {
u_long status;
datum keydat;
datum valdat;
};
struct ypresp_master {
u_long status;
char *master;
};
struct ypresp_order {
u_long status;
u_long ordernum;
};
struct ypmaplist {
char ypml_name[YPMAXMAP + 1];
struct ypmaplist *ypml_next;
};
struct ypresp_maplist {
u_long status;
struct ypmaplist *list;
};
/* ypserv procedure numbers */
#define YPPROC_NULL ((u_long)0)
#define YPPROC_DOMAIN ((u_long)1)
#define YPPROC_DOMAIN_NONACK ((u_long)2)
#define YPPROC_MATCH ((u_long)3)
#define YPPROC_FIRST ((u_long)4)
#define YPPROC_NEXT ((u_long)5)
#define YPPROC_XFR ((u_long)6)
#define YPPROC_CLEAR ((u_long)7)
#define YPPROC_ALL ((u_long)8)
#define YPPROC_MASTER ((u_long)9)
#define YPPROC_ORDER ((u_long)10)
#define YPPROC_MAPLIST ((u_long)11)
/* ypserv procedure return status values */
#define YP_TRUE ((long)1) /* general purpose success code */
#define YP_NOMORE ((long)2) /* no more entries in map */
#define YP_FALSE ((long)0) /* general purpose failure code */
#define YP_NOMAP ((long)-1) /* no such map in domain */
#define YP_NODOM ((long)-2) /* domain not supported */
#define YP_NOKEY ((long)-3) /* no such key in map */
#define YP_BADOP ((long)-4) /* invalid operation */
#define YP_BADDB ((long)-5) /* server data base is bad */
#define YP_YPERR ((long)-6) /* YP server error */
#define YP_BADARGS ((long)-7) /* request arguments bad */
#define YP_VERS ((long)-8) /* YP server version mismatch */
/*
* Sun's header file says:
* "Domain binding data structure, used by ypclnt package and ypserv modules.
* Users of the ypclnt package (or of this protocol) don't HAVE to know about
* it, but it must be available to users because _yp_dobind is a public
* interface."
*
* This is totally bogus! Nowhere else does Sun state that _yp_dobind() is
* a public interface, and I don't know any reason anyone would want to call
* it. But, just in case anyone does actually expect it to be available..
* we provide this.. exactly as Sun wants it.
*/
struct dom_binding {
struct dom_binding *dom_pnext;
char dom_domain[YPMAXDOMAIN + 1];
struct sockaddr_in dom_server_addr;
u_short dom_server_port;
int dom_socket;
CLIENT *dom_client;
u_short dom_local_port;
long dom_vers;
};
/*
* YPBIND PROTOCOL:
*
* ypbind supports the following procedures:
*
* YPBINDPROC_NULL takes (void), returns (void).
* to check if ypbind is running.
* YPBINDPROC_DOMAIN takes (char *), returns (struct ypbind_resp).
* requests that ypbind start to serve the
* named domain (if it doesn't already)
* YPBINDPROC_SETDOM takes (struct ypbind_setdom), returns (void).
* used by ypset.
*/
#define YPBINDPROG ((u_long)100007)
#define YPBINDVERS ((u_long)2)
#define YPBINDVERS_ORIG ((u_long)1)
/* ypbind procedure numbers */
#define YPBINDPROC_NULL ((u_long)0)
#define YPBINDPROC_DOMAIN ((u_long)1)
#define YPBINDPROC_SETDOM ((u_long)2)
/* error code in ypbind_resp.ypbind_status */
enum ypbind_resptype {
YPBIND_SUCC_VAL = 1,
YPBIND_FAIL_VAL = 2
};
/* network order, of course */
struct ypbind_binding {
struct in_addr ypbind_binding_addr;
u_short ypbind_binding_port;
};
struct ypbind_resp {
enum ypbind_resptype ypbind_status;
union {
u_long ypbind_error;
struct ypbind_binding ypbind_bindinfo;
} ypbind_respbody;
};
/* error code in ypbind_resp.ypbind_respbody.ypbind_error */
#define YPBIND_ERR_ERR 1 /* internal error */
#define YPBIND_ERR_NOSERV 2 /* no bound server for passed domain */
#define YPBIND_ERR_RESC 3 /* system resource allocation failure */
/*
* Request data structure for ypbind "Set domain" procedure.
*/
struct ypbind_setdom {
char ypsetdom_domain[YPMAXDOMAIN + 1];
struct ypbind_binding ypsetdom_binding;
u_short ypsetdom_vers;
};
#define ypsetdom_addr ypsetdom_binding.ypbind_binding_addr
#define ypsetdom_port ypsetdom_binding.ypbind_binding_port
/*
* YPPUSH PROTOCOL:
*
* Sun says:
* "Protocol between clients (ypxfr, only) and yppush
* yppush speaks a protocol in the transient range, which
* is supplied to ypxfr as a command-line parameter when it
* is activated by ypserv."
*
* This protocol is not implemented, naturally, because this YP
* implementation only does the client side.
*/
#define YPPUSHVERS ((u_long)1)
#define YPPUSHVERS_ORIG ((u_long)1)
/* yppush procedure numbers */
#define YPPUSHPROC_NULL ((u_long)0)
#define YPPUSHPROC_XFRRESP ((u_long)1)
struct yppushresp_xfr {
u_long transid;
u_long status;
};
/* yppush status value in yppushresp_xfr.status */
#define YPPUSH_SUCC ((long)1) /* Success */
#define YPPUSH_AGE ((long)2) /* Master's version not newer */
#define YPPUSH_NOMAP ((long)-1) /* Can't find server for map */
#define YPPUSH_NODOM ((long)-2) /* Domain not supported */
#define YPPUSH_RSRC ((long)-3) /* Local resource alloc failure */
#define YPPUSH_RPC ((long)-4) /* RPC failure talking to server */
#define YPPUSH_MADDR ((long)-5) /* Can't get master address */
#define YPPUSH_YPERR ((long)-6) /* YP server/map db error */
#define YPPUSH_BADARGS ((long)-7) /* Request arguments bad */
#define YPPUSH_DBM ((long)-8) /* Local dbm operation failed */
#define YPPUSH_FILE ((long)-9) /* Local file I/O operation failed */
#define YPPUSH_SKEW ((long)-10) /* Map version skew during transfer */
#define YPPUSH_CLEAR ((long)-11) /* Can't send "Clear" req to local ypserv */
#define YPPUSH_FORCE ((long)-12) /* No local order number in map - use -f */
#define YPPUSH_XFRERR ((long)-13) /* ypxfr error */
#define YPPUSH_REFUSED ((long)-14) /* Transfer request refused by ypserv */
struct inaddr;
__BEGIN_DECLS
bool_t xdr_datum __P((XDR *, datum *));
bool_t xdr_ypreq_key __P((XDR *, struct ypreq_key *));
bool_t xdr_ypreq_nokey __P((XDR *, struct ypreq_nokey *));
bool_t xdr_ypreq_xfr __P((XDR *, struct ypreq_xfr *));
bool_t xdr_ypresp_val __P((XDR *, struct ypresp_val *));
bool_t xdr_ypresp_key_val __P((XDR *, struct ypresp_key_val *));
bool_t xdr_ypbind_resp __P((XDR *, struct ypbind_resp *));
bool_t xdr_ypbind_setdom __P((XDR *, struct ypbind_setdom *));
bool_t xdr_yp_inaddr __P((XDR *, struct inaddr *));
bool_t xdr_ypmap_parms __P((XDR *, struct ypmap_parms *));
bool_t xdr_yppushresp_xfr __P((XDR *, struct yppushresp_xfr *));
bool_t xdr_ypresp_order __P((XDR *, struct ypresp_order *));
bool_t xdr_ypresp_master __P((XDR *, struct ypresp_master *));
bool_t xdr_ypresp_maplist __P((XDR *, struct ypresp_maplist *));
__END_DECLS
#endif /* _RPCSVC_YP_PROT_H_ */

View File

@@ -1,94 +0,0 @@
/*
* Copyright (c) 1992/3 Theo de Raadt <deraadt@fsa.ca>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote
* products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD: src/include/rpcsvc/ypclnt.h,v 1.11 1999/08/27 23:45:12 peter Exp $
*/
#ifndef _RPCSVC_YPCLNT_H_
#define _RPCSVC_YPCLNT_H_
#include <sys/cdefs.h>
#define YPERR_BADARGS 1 /* args to function are bad */
#define YPERR_RPC 2 /* RPC failure */
#define YPERR_DOMAIN 3 /* can't bind to a server for domain */
#define YPERR_MAP 4 /* no such map in server's domain */
#define YPERR_KEY 5 /* no such key in map */
#define YPERR_YPERR 6 /* some internal YP server or client error */
#define YPERR_RESRC 7 /* local resource allocation failure */
#define YPERR_NOMORE 8 /* no more records in map database */
#define YPERR_PMAP 9 /* can't communicate with portmapper */
#define YPERR_YPBIND 10 /* can't communicate with ypbind */
#define YPERR_YPSERV 11 /* can't communicate with ypserv */
#define YPERR_NODOM 12 /* local domain name not set */
#define YPERR_BADDB 13 /* YP data base is bad */
#define YPERR_VERS 14 /* YP version mismatch */
#define YPERR_ACCESS 15 /* access violation */
#define YPERR_BUSY 16 /* database is busy */
/*
* Types of update operations
*/
#define YPOP_CHANGE 1 /* change, do not add */
#define YPOP_INSERT 2 /* add, do not change */
#define YPOP_DELETE 3 /* delete this entry */
#define YPOP_STORE 4 /* add, or change */
struct ypall_callback {
/* return non-0 to stop getting called */
int (*foreach) __P((unsigned long, char *, int, char *, int, void *));
char *data; /* opaque pointer for use of callback fn */
};
struct dom_binding;
__BEGIN_DECLS
int yp_bind __P((char *dom));
int _yp_dobind __P((char *dom, struct dom_binding **ypdb));
void yp_unbind __P((char *dom));
int yp_get_default_domain __P((char **domp));
int yp_match __P((char *indomain, char *inmap,
const char *inkey, int inkeylen, char **outval,
int *outvallen));
int yp_first __P((char *indomain, char *inmap,
char **outkey, int *outkeylen, char **outval,
int *outvallen));
int yp_next __P((char *indomain, char *inmap,
char *inkey, int inkeylen, char **outkey,
int *outkeylen, char **outval, int *outvallen));
int yp_master __P((char *indomain, char *inmap, char **outname));
int yp_order __P((char *indomain, char *inmap, int *outorder));
int yp_all __P((char *indomain, char *inmap,
struct ypall_callback *incallback));
char * yperr_string __P((int incode));
char * ypbinderr_string __P((int incode));
int ypprot_err __P((unsigned int incode));
__END_DECLS
#endif /* _RPCSVC_YPCLNT_H_ */

View File

@@ -1,75 +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
*/
/*
* YP password update protocol
* Requires unix authentication
*/
#ifndef RPC_HDR
%#ifndef lint
%/*static char sccsid[] = "from: @(#)yppasswd.x 1.1 87/04/13 Copyr 1987 Sun Micro";*/
%/*static char sccsid[] = "from: @(#)yppasswd.x 2.1 88/08/01 4.0 RPCSRC";*/
%static const char rcsid[] =
% "$FreeBSD: src/include/rpcsvc/yppasswd.x,v 1.6 1999/08/27 23:45:12 peter Exp $";
%#endif /* not lint */
#endif
program YPPASSWDPROG {
version YPPASSWDVERS {
/*
* Update my passwd entry
*/
int
YPPASSWDPROC_UPDATE(yppasswd) = 1;
} = 1;
} = 100009;
struct x_passwd {
string pw_name<>; /* username */
string pw_passwd<>; /* encrypted password */
int pw_uid; /* user id */
int pw_gid; /* group id */
string pw_gecos<>; /* in real life name */
string pw_dir<>; /* home directory */
string pw_shell<>; /* default shell */
};
struct yppasswd {
string oldpass<>; /* unencrypted old password */
x_passwd newpw; /* new passwd entry */
};
#ifdef RPC_HDR
%#include <sys/cdefs.h>
%extern int _yppasswd __P(( char * , struct x_passwd * ));
%#define yppasswd(x,y) _yppasswd(x,y)
#endif

View File

@@ -1,88 +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 or with the express written consent of
% * Sun Microsystems, Inc.
% *
% * 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) 1986, 1990 by Sun Microsystems, Inc.
% */
%
%/* from @(#)ypupdate_prot.x 1.3 91/03/11 TIRPC 1.0 */
#ifndef RPC_HDR
%#ifndef lint
%static const char rcsid[] =
% "$FreeBSD: src/include/rpcsvc/ypupdate_prot.x,v 1.3 1999/08/27 23:45:13 peter Exp $";
%#endif
#endif
%
%/*
% * Compiled from ypupdate_prot.x using rpcgen
% * This is NOT source code!
% * DO NOT EDIT THIS FILE!
% */
/*
* YP update service protocol
*/
#ifdef RPC_HDR
%
%#ifndef _rpcsvc_ypupdate_prot_h
%#define _rpcsvc_ypupdate_prot_h
%
#endif
const MAXMAPNAMELEN = 255;
const MAXYPDATALEN = 1023;
const MAXERRMSGLEN = 255;
program YPU_PROG {
version YPU_VERS {
u_int YPU_CHANGE(ypupdate_args) = 1;
u_int YPU_INSERT(ypupdate_args) = 2;
u_int YPU_DELETE(ypdelete_args) = 3;
u_int YPU_STORE(ypupdate_args) = 4;
} = 1;
} = 100028;
typedef opaque yp_buf<MAXYPDATALEN>;
struct ypupdate_args {
string mapname<MAXMAPNAMELEN>;
yp_buf key;
yp_buf datum;
};
struct ypdelete_args {
string mapname<MAXMAPNAMELEN>;
yp_buf key;
};
#ifdef RPC_HDR
%
%#endif /* !_rpcsvc_ypupdate_prot_h */
#endif

View File

@@ -1,173 +0,0 @@
/*
* Copyright (c) 1995, 1996
* Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Bill Paul.
* 4. Neither the name of the author nor the names of any co-contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD: src/include/rpcsvc/ypxfrd.x,v 1.7 1999/08/27 23:45:13 peter Exp $
*/
/*
* This protocol definition file describes a file transfer
* system used to very quickly move NIS maps from one host to
* another. This is similar to what Sun does with their ypxfrd
* protocol, but it must be stressed that this protocol is _NOT_
* compatible with Sun's. There are a couple of reasons for this:
*
* 1) Sun's protocol is proprietary. The protocol definition is
* not freely available in any of the SunRPC source distributions,
* even though the NIS v2 protocol is.
*
* 2) The idea here is to transfer entire raw files rather than
* sending just the records. Sun uses ndbm for its NIS map files,
* while FreeBSD uses Berkeley DB. Both are hash databases, but the
* formats are incompatible, making it impossible for them to
* use each others' files. Even if FreeBSD adopted ndbm for its
* database format, FreeBSD/i386 is a little-endian OS and
* SunOS/SPARC is big-endian; ndbm is byte-order sensitive and
* not very smart about it, which means an attempt to read a
* database on a little-endian box that was created on a big-endian
* box (or vice-versa) can cause the ndbm code to eat itself.
* Luckily, Berkeley DB is able to deal with this situation in
* a more graceful manner.
*
* While the protocol is incompatible, the idea is the same: we just open
* up a TCP pipe to the client and transfer the raw map database
* from the master server to the slave. This is many times faster than
* the standard yppush/ypxfr transfer method since it saves us from
* having to recreate the map databases via the DB library each time.
* For example: creating a passwd database with 30,000 entries with yp_mkdb
* can take a couple of minutes, but to just copy the file takes only a few
* seconds.
*/
#ifndef RPC_HDR
%#ifndef lint
%static const char rcsid[] =
% "$FreeBSD: src/include/rpcsvc/ypxfrd.x,v 1.7 1999/08/27 23:45:13 peter Exp $";
%#endif /* not lint */
#endif
/* XXX cribbed from yp.x */
const _YPMAXRECORD = 1024;
const _YPMAXDOMAIN = 64;
const _YPMAXMAP = 64;
const _YPMAXPEER = 64;
/* Suggested default -- not necesarrily the one used. */
const YPXFRBLOCK = 32767;
/*
* Possible return codes from the remote server.
*/
enum xfrstat {
XFR_REQUEST_OK = 1, /* Transfer request granted */
XFR_DENIED = 2, /* Transfer request denied */
XFR_NOFILE = 3, /* Requested map file doesn't exist */
XFR_ACCESS = 4, /* File exists, but I couldn't access it */
XFR_BADDB = 5, /* File is not a hash database */
XFR_READ_OK = 6, /* Block read successfully */
XFR_READ_ERR = 7, /* Read error during transfer */
XFR_DONE = 8, /* Transfer completed */
XFR_DB_ENDIAN_MISMATCH = 9, /* Database byte order mismatch */
XFR_DB_TYPE_MISMATCH = 10 /* Database type mismatch */
};
/*
* Database type specifications. The client can use this to ask
* the server for a particular type of database or just take whatever
* the server has to offer.
*/
enum xfr_db_type {
XFR_DB_ASCII = 1, /* Flat ASCII text */
XFR_DB_BSD_HASH = 2, /* Berkeley DB, hash method */
XFR_DB_BSD_BTREE = 3, /* Berkeley DB, btree method */
XFR_DB_BSD_RECNO = 4, /* Berkeley DB, recno method */
XFR_DB_BSD_MPOOL = 5, /* Berkeley DB, mpool method */
XFR_DB_BSD_NDBM = 6, /* Berkeley DB, hash, ndbm compat */
XFR_DB_GNU_GDBM = 7, /* GNU GDBM */
XFR_DB_DBM = 8, /* Old, deprecated dbm format */
XFR_DB_NDBM = 9, /* ndbm format (used by Sun's NISv2) */
XFR_DB_OPAQUE = 10, /* Mystery format -- just pass along */
XFR_DB_ANY = 11, /* I'll take any format you've got */
XFR_DB_UNKNOWN = 12 /* Unknown format */
};
/*
* Machine byte order specification. This allows the client to check
* that it's copying a map database from a machine of similar byte sex.
* This is necessary for handling database libraries that are fatally
* byte order sensitive.
*
* The XFR_ENDIAN_ANY type is for use with the Berkeley DB database
* formats; Berkeley DB is smart enough to make up for byte order
* differences, so byte sex isn't important.
*/
enum xfr_byte_order {
XFR_ENDIAN_BIG = 1, /* We want big endian */
XFR_ENDIAN_LITTLE = 2, /* We want little endian */
XFR_ENDIAN_ANY = 3 /* We'll take whatever you got */
};
typedef string xfrdomain<_YPMAXDOMAIN>;
typedef string xfrmap<_YPMAXMAP>;
typedef string xfrmap_filename<_YPMAXMAP>; /* actual name of map file */
/*
* Ask the remote ypxfrd for a map using this structure.
* Note: we supply both a map name and a map file name. These are not
* the same thing. In the case of ndbm, maps are stored in two files:
* map.bykey.pag and may.bykey.dir. We may also have to deal with
* file extensions (on the off chance that the remote server is supporting
* multiple DB formats). To handle this, we tell the remote server both
* what map we want and, in the case of ndbm, whether we want the .dir
* or the .pag part. This name should not be a fully qualified path:
* it's up to the remote server to decide which directories to look in.
*/
struct ypxfr_mapname {
xfrmap xfrmap;
xfrdomain xfrdomain;
xfrmap_filename xfrmap_filename;
xfr_db_type xfr_db_type;
xfr_byte_order xfr_byte_order;
};
/* Read response using this structure. */
union xfr switch (bool ok) {
case TRUE:
opaque xfrblock_buf<>;
case FALSE:
xfrstat xfrstat;
};
program YPXFRD_FREEBSD_PROG {
version YPXFRD_FREEBSD_VERS {
union xfr
YPXFRD_GETMAP(ypxfr_mapname) = 1;
} = 1;
} = 600100069; /* 100069 + 60000000 -- 100069 is the Sun ypxfrd prog number */

View File

@@ -1,2 +0,0 @@
Makefile
Makefile.in

View File

@@ -1,9 +0,0 @@
##
## $Id$
##
SUBDIRS = xdr rpc
include $(top_srcdir)/../../../automake/subdirs.am
include $(top_srcdir)/../../../automake/local.am

View File

@@ -1,2 +0,0 @@
Makefile
Makefile.in

View File

@@ -1,28 +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
*/

View File

@@ -1,57 +0,0 @@
##
## $Id$
##
SUBDIRS = PSD.doc
LIBNAME = librpc
LIB = $(ARCH)/$(LIBNAME).a
C_FILES = 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 get_myaddress.c getrpcent.c getrpcport.c netname.c netnamer.c \
pmap_clnt.c pmap_getmaps.c pmap_getport.c pmap_prot.c pmap_prot2.c \
pmap_rmt.c rpc_callmsg.c rpc_commondata.c rpc_dtablesize.c rpc_prot.c \
rpcdname.c rtime.c svc.c svc_auth.c svc_auth_unix.c svc_raw.c svc_run.c \
svc_simple.c svc_tcp.c svc_udp.c rtems_portmapper.c rtems_rpc.c
UNUSED_C_FILES = auth_des.c auth_time.c authdes_prot.c clnt_unix.c \
crypt_client.c des_crypt.c des_soft.c getpublickey.c key_call.c \
key_prot_xdr.c svc_auth_des.c svc_unix.c
C_O_FILES = $(C_FILES:%.c=$(ARCH)/%.o)
OBJS = $(C_O_FILES)
include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
include $(top_srcdir)/../../../automake/compile.am
include $(top_srcdir)/../../../automake/lib.am
TMPINSTALL_FILES += $(PROJECT_RELEASE)/lib/$(LIBNAME)$(LIB_VARIANT).a
#
# Add local stuff here using +=
#
AM_CPPFLAGS += '-D__P(x)=x' -D_RPC_read=read -D_RPC_write=write -D_RPC_close=close -D_RTEMS_RPC_INTERNAL_
$(LIB): $(OBJS)
$(make-library)
$(PROJECT_RELEASE)/lib/$(LIBNAME)$(LIB_VARIANT).a: $(LIB)
$(INSTALL_DATA) $< $@
noinst_MANS = bindresvport.3 getrpcent.3 publickey.3 rpc.3 rpc_secure.3 \
rstat_svc.8 des_crypt.3 getrpcport.3 publickey.5 rpc.5 rstat.1 rtime.3
if HAS_NETWORKING
man_MANS = $(noinst_MANS)
all-local: $(ARCH) $(OBJS) $(TMPINSTALL_FILES)
endif
.PRECIOUS: $(LIB)
EXTRA_DIST = $(C_FILES) DISCLAIMER $(UNUSED_C_FILES) $(noinst_MANS)
include $(top_srcdir)/../../../automake/subdirs.am
include $(top_srcdir)/../../../automake/local.am

View File

@@ -1,2 +0,0 @@
Makefile
Makefile.in

View File

@@ -1,7 +0,0 @@
## $Id$
EXTRA_DIST = nfs.rfc.ms rpc.prog.ms rpc.rfc.ms rpcgen.ms xdr.nts.ms \
xdr.rfc.ms
include $(top_srcdir)/../../../automake/local.am

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,233 +0,0 @@
RPCSRC 4.0 7/11/89
This distribution contains Sun Microsystem's implementation of the
RPC and XDR protocols and is compatible with 4.2BSD and 4.3BSD. Also
included is complete documentation, utilities, RPC service
specification files, and demonstration services in the format used by
the RPC protocol compiler (rpcgen). See WHAT'S NEW below for
details.
NOTE ABOUT SECURE RPC:
This release of RPCSRC contains most of the code needed to implement
Secure RPC (see "DES Authentication" in the RPC Protocol Specification,
doc/rpc.rfc.ms). Due to legal considerations, we are unable to
distribute an implementation of DES, the Data Encryption Standard, which
Secure RPC requires. For this reason, all of the files, documentation, and
programs associated with Secure RPC have been placed into a separate
directory, secure_rpc. The RPC library contained in the main body of this
release *DOES NOT* support Secure RPC. See secure_rpc/README for more
details. (A DES library was posted in Volume 18 of comp.sources.unix.)
If you wish to report bugs found in this release, send mail to:
Portable ONC/NFS
Sun Microsystems, Inc
MS 12-33
2550 Garcia Avenue
Mountain View, CA 94043
or send Email to nfsnet@sun.com (the Internet) or sun!nfsnet (Usenet).
ROADMAP
The directory hierarchy is as follows:
demo/ Various demonstration services
demo/dir Remote directory lister
demo/msg Remote console message delivery service
demo/sort Remote sort service
doc/ Documentation for RPC, XDR and NFS in "-ms" format.
etc/ Utilities (rpcinfo and portmap). portmap must be
started by root before any other RPC network services are
used. SEE BELOW FOR BUGFIX TO 4.3BSD COMPILER.
man/ Manual pages for RPC library, rpcgen, and utilities.
rpc/ The RPC and XDR library. SEE BELOW
FOR BUGFIX TO 4.2BSD COMPILER.
rpcgen/ The RPC Language compiler (for .x files)
rpcsvc/ Service definition files for various services and the
server and client code for the Remote Status service.
secure_rpc/ The files in this directory are used to build a version of
the RPC library with DES Authentication. See the README
file in that directory for more details.
BUILD INSTRUCTIONS
Makefiles can be found in all directories except for man. The
Makefile in the top directory will cause these others to be invoked
(except for in the doc, man and demo directories), in turn building the
entire release.
WARNING! THE DEFAULT INSTALLATION PROCEDURES WILL INSTALL FILES
IN /usr/include, /usr/lib, /usr/bin and /etc.
The master RPC include file, rpc/rpc.h, is used by all programs and
routines that use RPC. It includes other RPC and system include files
needed by the RPC system. PLEASE NOTE: If your system has NFS, it
may have been based on Sun's NFS Source. The include files installed
by this package may duplicate include files you will find on your NFS
system. The RPCSRC 4.0 include files are upwardly compatible to all
NFS Source include files as of the date of this distribution (not
including any new definitions or declarations added by your system
vendor). HOWEVER: Please read the comments towards the end of
rpc/rpc.h regarding rpc/netdb.h. You may need to uncomment the
inclusion of that file if the structures it defines are already
defined by your system's include files.
After making any compiler fixes that are needed (see below), at
the top directory, type:
make install
For all installations, the Makefile macro DESTDIR is prepended to the
installation path. It is defined to be null in the Makefiles, so
installations are relative to root. (You will probably need root
privileges for installing the files under the default path.) To
install the files under some other tree (e.g., /usr/local), use the
command:
make install DESTDIR=/usr/local
This will place the include files in /usr/local/usr/include, the RPC
library in /usr/local/usr/lib, rpcgen in /usr/local/usr/bin, and the
utilities in /usr/local/etc. You'll have to edit the Makefiles or
install the files by hand if you want to do anything other than this
kind of relocation of the installation tree.
The RPC library will be built and installed first. By default it is
installed in /usr/lib as "librpclib.a". The directory
/usr/include/rpc will also be created, and several header files will
be installed there. ALL RPC SERVICES INCLUDE THESE HEADER FILES.
The programs in etc/ link in routines from librpclib.a. If you change
where it is installed, be sure to edit etc/'s Makefile to reflect this.
These programs are installed in /etc. PORTMAP MUST BE RUNNING ON
YOUR SYSTEM BEFORE YOU START ANY OTHER RPC SERVICE.
rpcgen is installed in /usr/bin. This program is required to build
the demonstration services in demo and the rstat client and server in
rpcsvc/.
The rpcsvc/ directory will install its files in the directory
/usr/include/rpcsvc. The Remote Status service (rstat_svc) will be
compiled and installed in /etc. If you wish to make this service
available, you should either start this service when needed or have
it started at boot time by invoking it in your /etc/rc.local script.
(Be sure that portmap is started first!) Sun has modified its
version of inetd to automatically start RPC services. (Use "make
LIB=" when building rstat on a Sun Workstation.) The Remote Status
client (rstat) will be installed in /usr/bin. This program queries
the rstat_svc on a remote host and prints a system status summary
similar to the one printed by "uptime".
The documentation is not built during the "make install" command.
Typing "make" in the doc directory will cause all of the manuals to
be formatted using nroff into a single file. We have had a report
that certain "troff" equivalents have trouble processing the full
manual. If you have trouble, try building the manuals individually
(see the Makefile).
The demonstration services in the demo directory are not built by the
top-level "make install" command. To build these, cd to the demo
directory and enter "make". The three services will be built.
RPCGEN MUST BE INSTALLED in a path that make can find. To run the
services, start the portmap program as root and invoke the service
(you probably will want to put it in the background). rpcinfo can be
used to check that the service succeeded in getting registered with
portmap, and to ping the service (see rpcinfo's man page). You can
then use the corresponding client program to exercise the service.
To build these services on a Sun workstation, you must prevent the
Makefile from trying to link the RPC library (as these routines are
already a part of Sun's libc). Use: "make LIB=".
BUGFIX FOR 4.3BSD COMPILER
The use of a 'void *' declaration for one of the arguments in
the reply_proc() procedure in etc/rpcinfo.c will trigger a bug
in the 4.3BSD compiler. The bug is fixed by the following change to
the compiler file mip/manifest.h:
*** manifest.h.r1.1 Thu Apr 30 13:52:25 1987
--- manifest.h.r1.2 Mon Nov 23 18:58:17 1987
***************
*** 21,27 ****
/*
* Bogus type values
*/
! #define TNULL PTR /* pointer to UNDEF */
#define TVOID FTN /* function returning UNDEF (for void) */
/*
--- 21,27 ----
/*
* Bogus type values
*/
! #define TNULL INCREF(MOETY) /* pointer to MOETY -- impossible type */
#define TVOID FTN /* function returning UNDEF (for void) */
/*
If you cannot fix your compiler, change the declaration in reply_proc()
from 'void *' to 'char *'.
BUGFIX FOR 4.2BSD COMPILER
Unpatched 4.2BSD compilers complain about valid C. You can make old
compilers happy by changing some voids to ints. However, the fix to
the 4.2 VAX compiler is as follows (to mip/trees.c):
*** trees.c.r1.1 Mon May 11 13:47:58 1987
--- trees.c.r1.2 Wed Jul 2 18:28:52 1986
***************
*** 1247,1253 ****
if(o==CAST && mt1==0)return(TYPL+TYMATCH);
if( mt12 & MDBI ) return( TYPL+LVAL+TYMATCH );
else if( (mt1&MENU)||(mt2&MENU) ) return( LVAL+NCVT+TYPL+PTMATCH+PUN );
! else if( mt12 == 0 ) break;
else if( mt1 & MPTR ) return( LVAL+PTMATCH+PUN );
else if( mt12 & MPTI ) return( TYPL+LVAL+TYMATCH+PUN );
break;
--- 1261,1269 ----
if(o==CAST && mt1==0)return(TYPL+TYMATCH);
if( mt12 & MDBI ) return( TYPL+LVAL+TYMATCH );
else if( (mt1&MENU)||(mt2&MENU) ) return( LVAL+NCVT+TYPL+PTMATCH+PUN );
! /* if right is TVOID and looks like a CALL, is not ok */
! else if (mt2 == 0 && (p->in.right->in.op == CALL || p->in.right->in.op == UNARY CALL))
! break;
else if( mt1 & MPTR ) return( LVAL+PTMATCH+PUN );
else if( mt12 & MPTI ) return( TYPL+LVAL+TYMATCH+PUN );
break;
WHAT'S NEW IN THIS RELEASE: RPCSRC 4.0
The previous release was RPCSRC 3.9. As with all previous releases,
this release is based directly on files from Sun Microsystem's
implementation.
Upgrade from RPCSRC 3.9
1) RPCSRC 4.0 upgrades RPCSRC 3.9. Improvements from SunOS 4.0 have
been integrated into this release.
Secure RPC (in the secure_rpc/ directory)
2) DES Authentication routines and programs are provided.
3) A new manual, "Secure NFS" is provided, which describes Secure RPC
and Secure NFS.
4) Skeleton routines and manual pages are provided which describe the
DES encryption procedures required by Secure RPC. HOWEVER, NO DES
ROUTINE IS PROVIDED.
New Functionality
5) rpcinfo can now be used to de-register services from the portmapper
which may have terminated abnormally.
6) A new client, rstat, is provided which queries the rstat_svc and
prints a status line similar to the one displayed by "uptime".

View File

@@ -1,554 +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) 1988 by Sun Microsystems, Inc.
*/
/*
* auth_des.c, client-side implementation of DES authentication
*/
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/cdefs.h>
#include <rpc/des_crypt.h>
#include <rpc/types.h>
#include <rpc/xdr.h>
#include <rpc/auth.h>
#include <rpc/auth_des.h>
#include <netinet/in.h> /* XXX: just to get htonl() and ntohl() */
#include <sys/socket.h>
#undef NIS
#include <rpcsvc/nis.h>
#if defined(LIBC_SCCS) && !defined(lint)
/* from: static char sccsid[] = "@(#)auth_des.c 2.2 88/07/29 4.0 RPCSRC; from 1.9 88/02/08 SMI"; */
static const char rcsid[] = "$FreeBSD: src/lib/libc/rpc/auth_des.c,v 1.3 1999/08/28 00:00:32 peter Exp $";
#endif
extern bool_t __rpc_get_time_offset __P(( struct timeval *, nis_server *,
char *, char **, struct sockaddr_in * ));
extern int rtime __P(( struct sockaddr_in *, struct timeval *, struct timeval *));
extern bool_t xdr_authdes_cred __P(( XDR *, struct authdes_cred * ));
extern bool_t xdr_authdes_verf __P(( XDR *, struct authdes_verf * ));
#define MILLION 1000000L
#define RTIME_TIMEOUT 5 /* seconds to wait for sync */
#define AUTH_PRIVATE(auth) (struct ad_private *) auth->ah_private
#define ALLOC(object_type) (object_type *) mem_alloc(sizeof(object_type))
#define FREE(ptr, size) mem_free((char *)(ptr), (int) size)
#define ATTEMPT(xdr_op) if (!(xdr_op)) return (FALSE)
#define debug(msg) /*printf("%s\n", msg) */
/*
* DES authenticator operations vector
*/
static void authdes_nextverf();
static bool_t authdes_marshal();
static bool_t authdes_validate();
static bool_t authdes_refresh();
static void authdes_destroy();
static struct auth_ops authdes_ops = {
authdes_nextverf,
authdes_marshal,
authdes_validate,
authdes_refresh,
authdes_destroy
};
#ifdef foo
static bool_t synchronize __P(( struct sockaddr *, struct timeval *));
#endif
/*
* This struct is pointed to by the ah_private field of an "AUTH *"
*/
struct ad_private {
char *ad_fullname; /* client's full name */
u_int ad_fullnamelen; /* length of name, rounded up */
char *ad_servername; /* server's full name */
u_int ad_servernamelen; /* length of name, rounded up */
u_int ad_window; /* client specified window */
bool_t ad_dosync; /* synchronize? */
struct sockaddr ad_syncaddr; /* remote host to synch with */
char *ad_timehost; /* remote host to synch with */
struct timeval ad_timediff; /* server's time - client's time */
u_long ad_nickname; /* server's nickname for client */
struct authdes_cred ad_cred; /* storage for credential */
struct authdes_verf ad_verf; /* storage for verifier */
struct timeval ad_timestamp; /* timestamp sent */
des_block ad_xkey; /* encrypted conversation key */
u_char ad_pkey[1024]; /* Server's actual public key */
char *ad_netid; /* Timehost netid */
char *ad_uaddr; /* Timehost uaddr */
nis_server *ad_nis_srvr; /* NIS+ server struct */
};
/*
* Create the client des authentication object
*/
AUTH *
authdes_create(servername, window, syncaddr, ckey)
char *servername; /* network name of server */
u_int window; /* time to live */
struct sockaddr *syncaddr; /* optional addr of host to sync with */
des_block *ckey; /* optional conversation key to use*/
{
AUTH *auth;
struct ad_private *ad;
char namebuf[MAXNETNAMELEN+1];
u_char pkey_data[1024];
if (!getpublickey(servername, pkey_data))
return(NULL);
/*
* Allocate everything now
*/
auth = ALLOC(AUTH);
ad = ALLOC(struct ad_private);
(void) getnetname(namebuf);
ad->ad_fullnamelen = RNDUP(strlen(namebuf));
ad->ad_fullname = (char *)mem_alloc(ad->ad_fullnamelen + 1);
ad->ad_servernamelen = strlen(servername);
ad->ad_servername = (char *)mem_alloc(ad->ad_servernamelen + 1);
if (auth == NULL || ad == NULL || ad->ad_fullname == NULL ||
ad->ad_servername == NULL) {
debug("authdes_create: out of memory");
goto failed;
}
/*
* Set up private data
*/
bcopy(namebuf, ad->ad_fullname, ad->ad_fullnamelen + 1);
bcopy(servername, ad->ad_servername, ad->ad_servernamelen + 1);
bcopy(pkey_data, ad->ad_pkey, strlen(pkey_data) + 1);
if (syncaddr != NULL) {
ad->ad_syncaddr = *syncaddr;
ad->ad_dosync = TRUE;
} else {
ad->ad_dosync = FALSE;
}
ad->ad_window = window;
if (ckey == NULL) {
if (key_gendes(&auth->ah_key) < 0) {
debug("authdes_create: unable to gen conversation key");
return (NULL);
}
} else {
auth->ah_key = *ckey;
}
/*
* Set up auth handle
*/
auth->ah_cred.oa_flavor = AUTH_DES;
auth->ah_verf.oa_flavor = AUTH_DES;
auth->ah_ops = &authdes_ops;
auth->ah_private = (caddr_t)ad;
if (!authdes_refresh(auth)) {
goto failed;
}
return (auth);
failed:
if (auth != NULL)
FREE(auth, sizeof(AUTH));
if (ad != NULL)
FREE(ad, sizeof(struct ad_private));
if (ad->ad_fullname != NULL)
FREE(ad->ad_fullname, ad->ad_fullnamelen + 1);
if (ad->ad_servername != NULL)
FREE(ad->ad_servername, ad->ad_servernamelen + 1);
return (NULL);
}
/*
* Slightly modified version of authdes_create which takes the public key
* of the server principal as an argument. This spares us a call to
* getpublickey() which in the nameserver context can cause a deadlock.
*/
AUTH *
authdes_pk_create(servername, pkey, window, timehost, ckey, srvr)
char *servername; /* network name of server */
netobj *pkey; /* public key of server */
u_int window; /* time to live */
char *timehost; /* optional hostname to sync with */
des_block *ckey; /* optional conversation key to use */
nis_server *srvr; /* optional NIS+ server struct */
{
AUTH *auth;
struct ad_private *ad;
char namebuf[MAXNETNAMELEN+1];
/*
* Allocate everything now
*/
auth = ALLOC(AUTH);
if (auth == NULL) {
debug("authdes_pk_create: out of memory");
return (NULL);
}
ad = ALLOC(struct ad_private);
if (ad == NULL) {
debug("authdes_pk_create: out of memory");
goto failed;
}
ad->ad_fullname = ad->ad_servername = NULL; /* Sanity reasons */
ad->ad_timehost = NULL;
ad->ad_netid = NULL;
ad->ad_uaddr = NULL;
ad->ad_nis_srvr = NULL;
ad->ad_timediff.tv_sec = 0;
ad->ad_timediff.tv_usec = 0;
memcpy(ad->ad_pkey, pkey->n_bytes, pkey->n_len);
if (!getnetname(namebuf))
goto failed;
ad->ad_fullnamelen = RNDUP((u_int) strlen(namebuf));
ad->ad_fullname = (char *)mem_alloc(ad->ad_fullnamelen + 1);
ad->ad_servernamelen = strlen(servername);
ad->ad_servername = (char *)mem_alloc(ad->ad_servernamelen + 1);
if (ad->ad_fullname == NULL || ad->ad_servername == NULL) {
debug("authdes_pk_create: out of memory");
goto failed;
}
if (timehost != NULL) {
ad->ad_timehost = (char *)mem_alloc(strlen(timehost) + 1);
if (ad->ad_timehost == NULL) {
debug("authdes_pk_create: out of memory");
goto failed;
}
memcpy(ad->ad_timehost, timehost, strlen(timehost) + 1);
ad->ad_dosync = TRUE;
} else if (srvr != NULL) {
ad->ad_nis_srvr = srvr; /* transient */
ad->ad_dosync = TRUE;
} else {
ad->ad_dosync = FALSE;
}
memcpy(ad->ad_fullname, namebuf, ad->ad_fullnamelen + 1);
memcpy(ad->ad_servername, servername, ad->ad_servernamelen + 1);
ad->ad_window = window;
if (ckey == NULL) {
if (key_gendes(&auth->ah_key) < 0) {
debug("authdes_pk_create: unable to gen conversation key");
goto failed;
}
} else {
auth->ah_key = *ckey;
}
/*
* Set up auth handle
*/
auth->ah_cred.oa_flavor = AUTH_DES;
auth->ah_verf.oa_flavor = AUTH_DES;
auth->ah_ops = &authdes_ops;
auth->ah_private = (caddr_t)ad;
if (!authdes_refresh(auth)) {
goto failed;
}
ad->ad_nis_srvr = NULL; /* not needed any longer */
return (auth);
failed:
if (auth)
FREE(auth, sizeof (AUTH));
if (ad) {
if (ad->ad_fullname)
FREE(ad->ad_fullname, ad->ad_fullnamelen + 1);
if (ad->ad_servername)
FREE(ad->ad_servername, ad->ad_servernamelen + 1);
if (ad->ad_timehost)
FREE(ad->ad_timehost, strlen(ad->ad_timehost) + 1);
if (ad->ad_netid)
free(ad->ad_netid);
if (ad->ad_uaddr)
free(ad->ad_uaddr);
FREE(ad, sizeof (struct ad_private));
}
return (NULL);
}
/*
* Implement the five authentication operations
*/
/*
* 1. Next Verifier
*/
/*ARGSUSED*/
static void
authdes_nextverf(auth)
AUTH *auth;
{
/* what the heck am I supposed to do??? */
}
/*
* 2. Marshal
*/
static bool_t
authdes_marshal(auth, xdrs)
AUTH *auth;
XDR *xdrs;
{
struct ad_private *ad = AUTH_PRIVATE(auth);
struct authdes_cred *cred = &ad->ad_cred;
struct authdes_verf *verf = &ad->ad_verf;
des_block cryptbuf[2];
des_block ivec;
int status;
long len;
int32_t *ixdr;
/*
* Figure out the "time", accounting for any time difference
* with the server if necessary.
*/
(void) gettimeofday(&ad->ad_timestamp, (struct timezone *)NULL);
ad->ad_timestamp.tv_sec += ad->ad_timediff.tv_sec;
ad->ad_timestamp.tv_usec += ad->ad_timediff.tv_usec;
if (ad->ad_timestamp.tv_usec >= MILLION) {
ad->ad_timestamp.tv_usec -= MILLION;
ad->ad_timestamp.tv_sec += 1;
}
/*
* XDR the timestamp and possibly some other things, then
* encrypt them.
*/
ixdr = (int32_t *)cryptbuf;
IXDR_PUT_LONG(ixdr, ad->ad_timestamp.tv_sec);
IXDR_PUT_LONG(ixdr, ad->ad_timestamp.tv_usec);
if (ad->ad_cred.adc_namekind == ADN_FULLNAME) {
IXDR_PUT_U_LONG(ixdr, ad->ad_window);
IXDR_PUT_U_LONG(ixdr, ad->ad_window - 1);
ivec.key.high = ivec.key.low = 0;
status = cbc_crypt((char *)&auth->ah_key, (char *)cryptbuf,
2*sizeof(des_block), DES_ENCRYPT | DES_HW, (char *)&ivec);
} else {
status = ecb_crypt((char *)&auth->ah_key, (char *)cryptbuf,
sizeof(des_block), DES_ENCRYPT | DES_HW);
}
if (DES_FAILED(status)) {
debug("authdes_marshal: DES encryption failure");
return (FALSE);
}
ad->ad_verf.adv_xtimestamp = cryptbuf[0];
if (ad->ad_cred.adc_namekind == ADN_FULLNAME) {
ad->ad_cred.adc_fullname.window = cryptbuf[1].key.high;
ad->ad_verf.adv_winverf = cryptbuf[1].key.low;
} else {
ad->ad_cred.adc_nickname = ad->ad_nickname;
ad->ad_verf.adv_winverf = 0;
}
/*
* Serialize the credential and verifier into opaque
* authentication data.
*/
if (ad->ad_cred.adc_namekind == ADN_FULLNAME) {
len = ((1 + 1 + 2 + 1)*BYTES_PER_XDR_UNIT + ad->ad_fullnamelen);
} else {
len = (1 + 1)*BYTES_PER_XDR_UNIT;
}
if ((ixdr = xdr_inline(xdrs, 2*BYTES_PER_XDR_UNIT))) {
IXDR_PUT_LONG(ixdr, AUTH_DES);
IXDR_PUT_LONG(ixdr, len);
} else {
ATTEMPT(xdr_putlong(xdrs, (long *)&auth->ah_cred.oa_flavor));
ATTEMPT(xdr_putlong(xdrs, &len));
}
ATTEMPT(xdr_authdes_cred(xdrs, cred));
len = (2 + 1)*BYTES_PER_XDR_UNIT;
if ((ixdr = xdr_inline(xdrs, 2*BYTES_PER_XDR_UNIT))) {
IXDR_PUT_LONG(ixdr, AUTH_DES);
IXDR_PUT_LONG(ixdr, len);
} else {
ATTEMPT(xdr_putlong(xdrs, (long *)&auth->ah_verf.oa_flavor));
ATTEMPT(xdr_putlong(xdrs, &len));
}
ATTEMPT(xdr_authdes_verf(xdrs, verf));
return (TRUE);
}
/*
* 3. Validate
*/
static bool_t
authdes_validate(auth, rverf)
AUTH *auth;
struct opaque_auth *rverf;
{
struct ad_private *ad = AUTH_PRIVATE(auth);
struct authdes_verf verf;
int status;
register u_long *ixdr;
if (rverf->oa_length != (2 + 1) * BYTES_PER_XDR_UNIT) {
return (FALSE);
}
ixdr = (u_long *)rverf->oa_base;
verf.adv_xtimestamp.key.high = (u_long)*ixdr++;
verf.adv_xtimestamp.key.low = (u_long)*ixdr++;
verf.adv_int_u = (u_long)*ixdr++; /* nickname not XDR'd ! */
/*
* Decrypt the timestamp
*/
status = ecb_crypt((char *)&auth->ah_key, (char *)&verf.adv_xtimestamp,
sizeof(des_block), DES_DECRYPT | DES_HW);
if (DES_FAILED(status)) {
debug("authdes_validate: DES decryption failure");
return (FALSE);
}
/*
* xdr the decrypted timestamp
*/
ixdr = (u_long *)verf.adv_xtimestamp.c;
verf.adv_timestamp.tv_sec = IXDR_GET_LONG(ixdr) + 1;
verf.adv_timestamp.tv_usec = IXDR_GET_LONG(ixdr);
/*
* validate
*/
if (bcmp((char *)&ad->ad_timestamp, (char *)&verf.adv_timestamp,
sizeof(struct timeval)) != 0) {
debug("authdes_validate: verifier mismatch\n");
return (FALSE);
}
/*
* We have a nickname now, let's use it
*/
ad->ad_nickname = verf.adv_nickname;
ad->ad_cred.adc_namekind = ADN_NICKNAME;
return (TRUE);
}
/*
* 4. Refresh
*/
static bool_t
authdes_refresh(auth)
AUTH *auth;
{
struct ad_private *ad = AUTH_PRIVATE(auth);
struct authdes_cred *cred = &ad->ad_cred;
netobj pkey;
if (ad->ad_dosync &&
#ifdef old
!synchronize(&ad->ad_syncaddr, &ad->ad_timediff)) {
#else
!__rpc_get_time_offset(&ad->ad_timediff,ad->ad_nis_srvr,
ad->ad_timehost, &(ad->ad_uaddr),
(struct sockaddr_in *)&(ad->ad_syncaddr))) {
#endif
/*
* Hope the clocks are synced!
*/
ad->ad_timediff.tv_sec = ad->ad_timediff.tv_usec = 0;
ad->ad_dosync = 0;
debug("authdes_refresh: unable to synchronize with server");
}
ad->ad_xkey = auth->ah_key;
pkey.n_bytes = (char *)(ad->ad_pkey);
pkey.n_len = strlen((char *)ad->ad_pkey) + 1;
if (key_encryptsession_pk(ad->ad_servername, &pkey, &ad->ad_xkey) < 0) {
debug("authdes_create: unable to encrypt conversation key");
return (FALSE);
}
cred->adc_fullname.key = ad->ad_xkey;
cred->adc_namekind = ADN_FULLNAME;
cred->adc_fullname.name = ad->ad_fullname;
return (TRUE);
}
/*
* 5. Destroy
*/
static void
authdes_destroy(auth)
AUTH *auth;
{
struct ad_private *ad = AUTH_PRIVATE(auth);
FREE(ad->ad_fullname, ad->ad_fullnamelen + 1);
FREE(ad->ad_servername, ad->ad_servernamelen + 1);
FREE(ad, sizeof(struct ad_private));
FREE(auth, sizeof(AUTH));
}
#ifdef old
/*
* Synchronize with the server at the given address, that is,
* adjust timep to reflect the delta between our clocks
*/
static bool_t
synchronize(syncaddr, timep)
struct sockaddr *syncaddr;
struct timeval *timep;
{
struct timeval mytime;
struct timeval timeout;
timeout.tv_sec = RTIME_TIMEOUT;
timeout.tv_usec = 0;
if (rtime((struct sockaddr_in *)syncaddr, timep, NULL /*&timeout*/) < 0) {
return (FALSE);
}
(void) gettimeofday(&mytime, (struct timezone *)NULL);
timep->tv_sec -= mytime.tv_sec;
if (mytime.tv_usec > timep->tv_usec) {
timep->tv_sec -= 1;
timep->tv_usec += MILLION;
}
timep->tv_usec -= mytime.tv_usec;
return (TRUE);
}
#endif

View File

@@ -1,136 +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
*/
#if defined(LIBC_SCCS) && !defined(lint)
/*static char *sccsid = "from: @(#)auth_none.c 1.19 87/08/11 Copyr 1984 Sun Micro";*/
/*static char *sccsid = "from: @(#)auth_none.c 2.1 88/07/29 4.0 RPCSRC";*/
static char *rcsid = "$FreeBSD: src/lib/libc/rpc/auth_none.c,v 1.9 1999/08/28 00:00:32 peter Exp $";
#endif
/*
* auth_none.c
* Creates a client authentication handle for passing "null"
* credentials and verifiers to remote systems.
*
* Copyright (C) 1984, Sun Microsystems, Inc.
*/
#include <stdlib.h>
#include <rpc/types.h>
#include <rpc/xdr.h>
#include <rpc/auth.h>
#define MAX_MARSHEL_SIZE 20
/*
* Authenticator operations routines
*/
static void authnone_verf();
static void authnone_destroy();
static bool_t authnone_marshal();
static bool_t authnone_validate();
static bool_t authnone_refresh();
static struct auth_ops ops = {
authnone_verf,
authnone_marshal,
authnone_validate,
authnone_refresh,
authnone_destroy
};
static struct authnone_private {
AUTH no_client;
char marshalled_client[MAX_MARSHEL_SIZE];
u_int mcnt;
} *authnone_private;
AUTH *
authnone_create()
{
register struct authnone_private *ap = authnone_private;
XDR xdr_stream;
register XDR *xdrs;
if (ap == 0) {
ap = (struct authnone_private *)calloc(1, sizeof (*ap));
if (ap == 0)
return (0);
authnone_private = ap;
}
if (!ap->mcnt) {
ap->no_client.ah_cred = ap->no_client.ah_verf = _null_auth;
ap->no_client.ah_ops = &ops;
xdrs = &xdr_stream;
xdrmem_create(xdrs, ap->marshalled_client, (u_int)MAX_MARSHEL_SIZE,
XDR_ENCODE);
(void)xdr_opaque_auth(xdrs, &ap->no_client.ah_cred);
(void)xdr_opaque_auth(xdrs, &ap->no_client.ah_verf);
ap->mcnt = XDR_GETPOS(xdrs);
XDR_DESTROY(xdrs);
}
return (&ap->no_client);
}
/*ARGSUSED*/
static bool_t
authnone_marshal(client, xdrs)
AUTH *client;
XDR *xdrs;
{
register struct authnone_private *ap = authnone_private;
if (ap == 0)
return (0);
return ((*xdrs->x_ops->x_putbytes)(xdrs,
ap->marshalled_client, ap->mcnt));
}
static void
authnone_verf()
{
}
static bool_t
authnone_validate()
{
return (TRUE);
}
static bool_t
authnone_refresh()
{
return (FALSE);
}
static void
authnone_destroy()
{
}

View File

@@ -1,503 +0,0 @@
#pragma ident "@(#)auth_time.c 1.4 92/11/10 SMI"
/*
* auth_time.c
*
* This module contains the private function __rpc_get_time_offset()
* which will return the difference in seconds between the local system's
* notion of time and a remote server's notion of time. This must be
* possible without calling any functions that may invoke the name
* service. (netdir_getbyxxx, getXbyY, etc). The function is used in the
* synchronize call of the authdes code to synchronize clocks between
* NIS+ clients and their servers.
*
* Note to minimize the amount of duplicate code, portions of the
* synchronize() function were folded into this code, and the synchronize
* call becomes simply a wrapper around this function. Further, if this
* function is called with a timehost it *DOES* recurse to the name
* server so don't use it in that mode if you are doing name service code.
*
* Copyright (c) 1992 Sun Microsystems Inc.
* All rights reserved.
*
* Side effects :
* When called a client handle to a RPCBIND process is created
* and destroyed. Two strings "netid" and "uaddr" are malloc'd
* and returned. The SIGALRM processing is modified only if
* needed to deal with TCP connections.
*
* NOTE: This code has had the crap beaten out it in order to convert
* it from TI-RPC back to TD-RPC for use on FreeBSD.
*
* $FreeBSD: src/lib/libc/rpc/auth_time.c,v 1.4 2000/01/27 23:06:35 jasone Exp $
*/
#include <stdio.h>
#include <syslog.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <netdb.h>
#include <sys/signal.h>
#include <sys/errno.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <rpc/rpc.h>
#include <rpc/rpc_com.h>
#undef NIS
#include <rpcsvc/nis.h>
/*
* FreeBSD currently uses RPC 4.0, which uses portmap rather than
* rpcbind. Consequently, we need to fake up these values here.
* Luckily, the RPCB_GETTIME procedure uses only base XDR data types
* so we don't need anything besides these magic numbers.
*/
#define RPCBPROG (u_long)100000
#define RPCBVERS (u_long)3
#define RPCBPROC_GETTIME (u_long)6
#ifdef TESTING
#define msg(x) printf("ERROR: %s\n", x)
/* #define msg(x) syslog(LOG_ERR, "%s", x) */
#else
#define msg(x)
#endif
static int saw_alarm = 0;
static void
alarm_hndler(s)
int s;
{
saw_alarm = 1;
return;
}
/*
* The internet time server defines the epoch to be Jan 1, 1900
* whereas UNIX defines it to be Jan 1, 1970. To adjust the result
* from internet time-service time, into UNIX time we subtract the
* following offset :
*/
#define NYEARS (1970 - 1900)
#define TOFFSET ((u_long)60*60*24*(365*NYEARS + (NYEARS/4)))
/*
* Stolen from rpc.nisd:
* Turn a 'universal address' into a struct sockaddr_in.
* Bletch.
*/
static int uaddr_to_sockaddr(uaddr, sin)
#ifdef foo
endpoint *endpt;
#endif
char *uaddr;
struct sockaddr_in *sin;
{
unsigned char p_bytes[2];
int i;
unsigned long a[6];
i = sscanf(uaddr, "%lu.%lu.%lu.%lu.%lu.%lu", &a[0], &a[1], &a[2],
&a[3], &a[4], &a[5]);
if (i < 6)
return(1);
for (i = 0; i < 4; i++)
sin->sin_addr.s_addr |= (a[i] & 0x000000FF) << (8 * i);
p_bytes[0] = (unsigned char)a[4] & 0x000000FF;
p_bytes[1] = (unsigned char)a[5] & 0x000000FF;
sin->sin_family = AF_INET; /* always */
bcopy((char *)&p_bytes, (char *)&sin->sin_port, 2);
return (0);
}
/*
* free_eps()
*
* Free the strings that were strduped into the eps structure.
*/
static void
free_eps(eps, num)
endpoint eps[];
int num;
{
int i;
for (i = 0; i < num; i++) {
free(eps[i].uaddr);
free(eps[i].proto);
free(eps[i].family);
}
return;
}
/*
* get_server()
*
* This function constructs a nis_server structure description for the
* indicated hostname.
*
* NOTE: There is a chance we may end up recursing here due to the
* fact that gethostbyname() could do an NIS search. Ideally, the
* NIS+ server will call __rpc_get_time_offset() with the nis_server
* structure already populated.
*/
static nis_server *
get_server(sin, host, srv, eps, maxep)
struct sockaddr_in *sin;
char *host; /* name of the time host */
nis_server *srv; /* nis_server struct to use. */
endpoint eps[]; /* array of endpoints */
int maxep; /* max array size */
{
char hname[256];
int num_ep = 0, i;
struct hostent *he;
struct hostent dummy;
char *ptr[2];
if (host == NULL && sin == NULL)
return (NULL);
if (sin == NULL) {
he = gethostbyname(host);
if (he == NULL)
return(NULL);
} else {
he = &dummy;
ptr[0] = (char *)&sin->sin_addr.s_addr;
ptr[1] = NULL;
dummy.h_addr_list = ptr;
}
/*
* This is lame. We go around once for TCP, then again
* for UDP.
*/
for (i = 0; (he->h_addr_list[i] != NULL) && (num_ep < maxep);
i++, num_ep++) {
struct in_addr *a;
a = (struct in_addr *)he->h_addr_list[i];
snprintf(hname, sizeof(hname), "%s.0.111", inet_ntoa(*a));
eps[num_ep].uaddr = strdup(hname);
eps[num_ep].family = strdup("inet");
eps[num_ep].proto = strdup("tcp");
}
for (i = 0; (he->h_addr_list[i] != NULL) && (num_ep < maxep);
i++, num_ep++) {
struct in_addr *a;
a = (struct in_addr *)he->h_addr_list[i];
snprintf(hname, sizeof(hname), "%s.0.111", inet_ntoa(*a));
eps[num_ep].uaddr = strdup(hname);
eps[num_ep].family = strdup("inet");
eps[num_ep].proto = strdup("udp");
}
srv->name = (nis_name) host;
srv->ep.ep_len = num_ep;
srv->ep.ep_val = eps;
srv->key_type = NIS_PK_NONE;
srv->pkey.n_bytes = NULL;
srv->pkey.n_len = 0;
return (srv);
}
/*
* __rpc_get_time_offset()
*
* This function uses a nis_server structure to contact the a remote
* machine (as named in that structure) and returns the offset in time
* between that machine and this one. This offset is returned in seconds
* and may be positive or negative.
*
* The first time through, a lot of fiddling is done with the netconfig
* stuff to find a suitable transport. The function is very aggressive
* about choosing UDP or at worst TCP if it can. This is because
* those transports support both the RCPBIND call and the internet
* time service.
*
* Once through, *uaddr is set to the universal address of
* the machine and *netid is set to the local netid for the transport
* that uaddr goes with. On the second call, the netconfig stuff
* is skipped and the uaddr/netid pair are used to fetch the netconfig
* structure and to then contact the machine for the time.
*
* td = "server" - "client"
*/
int
__rpc_get_time_offset(td, srv, thost, uaddr, netid)
struct timeval *td; /* Time difference */
nis_server *srv; /* NIS Server description */
char *thost; /* if no server, this is the timehost */
char **uaddr; /* known universal address */
struct sockaddr_in *netid; /* known network identifier */
{
CLIENT *clnt; /* Client handle */
endpoint *ep, /* useful endpoints */
*useep = NULL; /* endpoint of xp */
char *useua = NULL; /* uaddr of selected xp */
int epl, i; /* counters */
enum clnt_stat status; /* result of clnt_call */
u_long thetime, delta;
int needfree = 0;
struct timeval tv;
int time_valid;
int udp_ep = -1, tcp_ep = -1;
int a1, a2, a3, a4;
char ut[64], ipuaddr[64];
endpoint teps[32];
nis_server tsrv;
void (*oldsig)() = NULL; /* old alarm handler */
struct sockaddr_in sin;
int s = RPC_ANYSOCK, len;
int type = 0;
td->tv_sec = 0;
td->tv_usec = 0;
/*
* First check to see if we need to find and address for this
* server.
*/
if (*uaddr == NULL) {
if ((srv != NULL) && (thost != NULL)) {
msg("both timehost and srv pointer used!");
return (0);
}
if (! srv) {
srv = get_server(netid, thost, &tsrv, teps, 32);
if (srv == NULL) {
msg("unable to contruct server data.");
return (0);
}
needfree = 1; /* need to free data in endpoints */
}
ep = srv->ep.ep_val;
epl = srv->ep.ep_len;
/* Identify the TCP and UDP endpoints */
for (i = 0;
(i < epl) && ((udp_ep == -1) || (tcp_ep == -1)); i++) {
if (strcasecmp(ep[i].proto, "udp") == 0)
udp_ep = i;
if (strcasecmp(ep[i].proto, "tcp") == 0)
tcp_ep = i;
}
/* Check to see if it is UDP or TCP */
if (tcp_ep > -1) {
useep = &ep[tcp_ep];
useua = ep[tcp_ep].uaddr;
type = SOCK_STREAM;
} else if (udp_ep > -1) {
useep = &ep[udp_ep];
useua = ep[udp_ep].uaddr;
type = SOCK_DGRAM;
}
if (useep == NULL) {
msg("no acceptable transport endpoints.");
if (needfree)
free_eps(teps, tsrv.ep.ep_len);
return (0);
}
}
/*
* Create a sockaddr from the uaddr.
*/
if (*uaddr != NULL)
useua = *uaddr;
/* Fixup test for NIS+ */
sscanf(useua, "%d.%d.%d.%d.", &a1, &a2, &a3, &a4);
sprintf(ipuaddr, "%d.%d.%d.%d.0.111", a1, a2, a3, a4);
useua = &ipuaddr[0];
bzero((char *)&sin, sizeof(sin));
if (uaddr_to_sockaddr(useua, &sin)) {
msg("unable to translate uaddr to sockaddr.");
if (needfree)
free_eps(teps, tsrv.ep.ep_len);
return (0);
}
/*
* Create the client handle to rpcbind. Note we always try
* version 3 since that is the earliest version that supports
* the RPCB_GETTIME call. Also it is the version that comes
* standard with SVR4. Since most everyone supports TCP/IP
* we could consider trying the rtime call first.
*/
clnt = clnttcp_create(&sin, RPCBPROG, RPCBVERS, &s, 0, 0);
if (clnt == NULL) {
msg("unable to create client handle to rpcbind.");
if (needfree)
free_eps(teps, tsrv.ep.ep_len);
return (0);
}
tv.tv_sec = 5;
tv.tv_usec = 0;
time_valid = 0;
status = clnt_call(clnt, RPCBPROC_GETTIME, xdr_void, NULL,
xdr_u_long, (char *)&thetime, tv);
/*
* The only error we check for is anything but success. In
* fact we could have seen PROGMISMATCH if talking to a 4.1
* machine (pmap v2) or TIMEDOUT if the net was busy.
*/
if (status == RPC_SUCCESS)
time_valid = 1;
else {
int save;
/* Blow away possible stale CLNT handle. */
if (clnt != NULL) {
clnt_destroy(clnt);
clnt = NULL;
}
/*
* Convert PMAP address into timeservice address
* We take advantage of the fact that we "know" what
* the universal address looks like for inet transports.
*
* We also know that the internet timeservice is always
* listening on port 37.
*/
sscanf(useua, "%d.%d.%d.%d.", &a1, &a2, &a3, &a4);
sprintf(ut, "%d.%d.%d.%d.0.37", a1, a2, a3, a4);
if (uaddr_to_sockaddr(ut, &sin)) {
msg("cannot convert timeservice uaddr to sockaddr.");
goto error;
}
s = socket(AF_INET, type, 0);
if (s == -1) {
msg("unable to open fd to network.");
goto error;
}
/*
* Now depending on whether or not we're talking to
* UDP we set a timeout or not.
*/
if (type == SOCK_DGRAM) {
struct timeval timeout = { 20, 0 };
struct sockaddr_in from;
fd_set readfds;
int res;
if (sendto(s, &thetime, sizeof(thetime), 0,
(struct sockaddr *)&sin, sizeof(sin)) == -1) {
msg("udp : sendto failed.");
goto error;
}
do {
FD_ZERO(&readfds);
FD_SET(s, &readfds);
res = select(_rpc_dtablesize(), &readfds,
(fd_set *)NULL, (fd_set *)NULL, &timeout);
} while (res < 0 && errno == EINTR);
if (res <= 0)
goto error;
len = sizeof(from);
res = recvfrom(s, (char *)&thetime, sizeof(thetime), 0,
(struct sockaddr *)&from, &len);
if (res == -1) {
msg("recvfrom failed on udp transport.");
goto error;
}
time_valid = 1;
} else {
int res;
oldsig = (void (*)())signal(SIGALRM, alarm_hndler);
saw_alarm = 0; /* global tracking the alarm */
alarm(20); /* only wait 20 seconds */
res = connect(s, (struct sockaddr *)&sin, sizeof(sin));
if (res == -1) {
msg("failed to connect to tcp endpoint.");
goto error;
}
if (saw_alarm) {
msg("alarm caught it, must be unreachable.");
goto error;
}
res = _RPC_read(s, (char *)&thetime, sizeof(thetime));
if (res != sizeof(thetime)) {
if (saw_alarm)
msg("timed out TCP call.");
else
msg("wrong size of results returned");
goto error;
}
time_valid = 1;
}
save = errno;
(void)_RPC_close(s);
errno = save;
s = RPC_ANYSOCK;
if (time_valid) {
thetime = ntohl(thetime);
thetime = thetime - TOFFSET; /* adjust to UNIX time */
} else
thetime = 0;
}
gettimeofday(&tv, 0);
error:
/*
* clean up our allocated data structures.
*/
if (s != RPC_ANYSOCK)
(void)_RPC_close(s);
if (clnt != NULL)
clnt_destroy(clnt);
alarm(0); /* reset that alarm if its outstanding */
if (oldsig) {
signal(SIGALRM, oldsig);
}
/*
* note, don't free uaddr strings until after we've made a
* copy of them.
*/
if (time_valid) {
if (*uaddr == NULL)
*uaddr = strdup(useua);
/* Round to the nearest second */
tv.tv_sec += (tv.tv_sec > 500000) ? 1 : 0;
delta = (thetime > tv.tv_sec) ? thetime - tv.tv_sec :
tv.tv_sec - thetime;
td->tv_sec = (thetime < tv.tv_sec) ? - delta : delta;
td->tv_usec = 0;
} else {
msg("unable to get the server's time.");
}
if (needfree)
free_eps(teps, tsrv.ep.ep_len);
return (time_valid);
}

View File

@@ -1,349 +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
*/
#if defined(LIBC_SCCS) && !defined(lint)
/*static char *sccsid = "from: @(#)auth_unix.c 1.19 87/08/11 Copyr 1984 Sun Micro";*/
/*static char *sccsid = "from: @(#)auth_unix.c 2.2 88/08/01 4.0 RPCSRC";*/
static char *rcsid = "$FreeBSD: src/lib/libc/rpc/auth_unix.c,v 1.12 1999/12/29 05:04:16 peter Exp $";
#endif
/*
* auth_unix.c, Implements UNIX style authentication parameters.
*
* Copyright (C) 1984, Sun Microsystems, Inc.
*
* 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 <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.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();
static bool_t authunix_marshal();
static bool_t authunix_validate();
static bool_t authunix_refresh();
static void authunix_destroy();
static struct auth_ops auth_unix_ops = {
authunix_nextverf,
authunix_marshal,
authunix_validate,
authunix_refresh,
authunix_destroy
};
/*
* 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 void marshal_new_auth();
/*
* This goop is here because some servers refuse to accept a
* credential with more than some number (usually 8) supplementary
* groups. Blargh!
*/
static int authunix_maxgrouplist = 0;
void
set_rpc_maxgrouplist(int num)
{
authunix_maxgrouplist = num;
}
/*
* Create a unix style authenticator.
* Returns an auth handle with the given stuff in it.
*/
AUTH *
authunix_create(machname, uid, gid, len, aup_gids)
char *machname;
int uid;
int gid;
register int len;
int *aup_gids;
{
struct authunix_parms aup;
char mymem[MAX_AUTH_BYTES];
struct timeval now;
XDR xdrs;
register AUTH *auth;
register struct audata *au;
/*
* Allocate and set up auth handle
*/
auth = (AUTH *)mem_alloc(sizeof(*auth));
#ifndef _KERNEL
if (auth == NULL) {
(void)fprintf(stderr, "authunix_create: out of memory\n");
return (NULL);
}
#endif
au = (struct audata *)mem_alloc(sizeof(*au));
#ifndef _KERNEL
if (au == NULL) {
(void)fprintf(stderr, "authunix_create: out of memory\n");
return (NULL);
}
#endif
auth->ah_ops = &auth_unix_ops;
auth->ah_private = (caddr_t)au;
auth->ah_verf = au->au_shcred = _null_auth;
au->au_shfaults = 0;
/*
* fill in param struct from the given params
*/
(void)gettimeofday(&now, (struct timezone *)0);
aup.aup_time = now.tv_sec;
aup.aup_machname = machname;
aup.aup_uid = uid;
aup.aup_gid = gid;
/* GW: continuation of max group list hack */
if(authunix_maxgrouplist != 0) {
aup.aup_len = ((len < authunix_maxgrouplist) ? len
: authunix_maxgrouplist);
} else {
aup.aup_len = (u_int)len;
}
aup.aup_gids = aup_gids;
/*
* Serialize the parameters into origcred
*/
xdrmem_create(&xdrs, mymem, MAX_AUTH_BYTES, XDR_ENCODE);
if (! xdr_authunix_parms(&xdrs, &aup))
abort();
au->au_origcred.oa_length = len = XDR_GETPOS(&xdrs);
au->au_origcred.oa_flavor = AUTH_UNIX;
#ifdef _KERNEL
au->au_origcred.oa_base = mem_alloc((u_int) len);
#else
if ((au->au_origcred.oa_base = mem_alloc((u_int) len)) == NULL) {
(void)fprintf(stderr, "authunix_create: out of memory\n");
return (NULL);
}
#endif
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);
}
/*
* Returns an auth handle with parameters determined by doing lots of
* syscalls.
*/
AUTH *
authunix_create_default()
{
register int len;
char machname[MAX_MACHINE_NAME + 1];
register int uid;
register int gid;
int gids[NGRPS];
int i;
gid_t real_gids[NGROUPS];
if (gethostname(machname, MAX_MACHINE_NAME) == -1)
abort();
machname[MAX_MACHINE_NAME] = 0;
uid = (int)geteuid();
gid = (int)getegid();
if ((len = getgroups(NGROUPS, real_gids)) < 0)
abort();
if(len > NGRPS) len = NGRPS; /* GW: turn `gid_t's into `int's */
for(i = 0; i < len; i++) {
gids[i] = (int)real_gids[i];
}
return (authunix_create(machname, uid, gid, len, gids));
}
/*
* authunix operations
*/
static void
authunix_nextverf(auth)
AUTH *auth;
{
/* no action necessary */
}
static bool_t
authunix_marshal(auth, xdrs)
AUTH *auth;
XDR *xdrs;
{
register struct audata *au = AUTH_PRIVATE(auth);
return (XDR_PUTBYTES(xdrs, au->au_marshed, au->au_mpos));
}
static bool_t
authunix_validate(auth, verf)
register AUTH *auth;
struct opaque_auth verf;
{
register struct audata *au;
XDR xdrs;
if (verf.oa_flavor == AUTH_SHORT) {
au = AUTH_PRIVATE(auth);
xdrmem_create(&xdrs, verf.oa_base, verf.oa_length, XDR_DECODE);
if (au->au_shcred.oa_base != NULL) {
mem_free(au->au_shcred.oa_base,
au->au_shcred.oa_length);
au->au_shcred.oa_base = NULL;
}
if (xdr_opaque_auth(&xdrs, &au->au_shcred)) {
auth->ah_cred = au->au_shcred;
} else {
xdrs.x_op = XDR_FREE;
(void)xdr_opaque_auth(&xdrs, &au->au_shcred);
au->au_shcred.oa_base = NULL;
auth->ah_cred = au->au_origcred;
}
marshal_new_auth(auth);
}
return (TRUE);
}
static bool_t
authunix_refresh(auth)
register AUTH *auth;
{
register struct audata *au = AUTH_PRIVATE(auth);
struct authunix_parms aup;
struct timeval now;
XDR xdrs;
register int stat;
if (auth->ah_cred.oa_base == au->au_origcred.oa_base) {
/* there is no hope. Punt */
return (FALSE);
}
au->au_shfaults ++;
/* first deserialize the creds back into a struct authunix_parms */
aup.aup_machname = NULL;
aup.aup_gids = (int *)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)
register AUTH *auth;
{
register 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 void
marshal_new_auth(auth)
register AUTH *auth;
{
XDR xdr_stream;
register XDR *xdrs = &xdr_stream;
register struct audata *au = AUTH_PRIVATE(auth);
xdrmem_create(xdrs, au->au_marshed, MAX_AUTH_BYTES, XDR_ENCODE);
if ((! xdr_opaque_auth(xdrs, &(auth->ah_cred))) ||
(! xdr_opaque_auth(xdrs, &(auth->ah_verf)))) {
perror("auth_none.c - Fatal marshalling problem");
} else {
au->au_mpos = XDR_GETPOS(xdrs);
}
XDR_DESTROY(xdrs);
}

View File

@@ -1,82 +0,0 @@
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)authdes_prot.c 2.1 88/07/29 4.0 RPCSRC; from 1.6 88/02/08 SMI";
#endif
/*
* 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) 1988 by Sun Microsystems, Inc.
*/
/*
* authdes_prot.c, XDR routines for DES authentication
*/
#include <rpc/types.h>
#include <rpc/xdr.h>
#include <rpc/auth.h>
#include <rpc/auth_des.h>
#define ATTEMPT(xdr_op) if (!(xdr_op)) return (FALSE)
bool_t
xdr_authdes_cred(xdrs, cred)
XDR *xdrs;
struct authdes_cred *cred;
{
/*
* Unrolled xdr
*/
ATTEMPT(xdr_enum(xdrs, (enum_t *)&cred->adc_namekind));
switch (cred->adc_namekind) {
case ADN_FULLNAME:
ATTEMPT(xdr_string(xdrs, &cred->adc_fullname.name, MAXNETNAMELEN));
ATTEMPT(xdr_opaque(xdrs, (caddr_t)&cred->adc_fullname.key, sizeof(des_block)));
ATTEMPT(xdr_opaque(xdrs, (caddr_t)&cred->adc_fullname.window, sizeof(cred->adc_fullname.window)));
return (TRUE);
case ADN_NICKNAME:
ATTEMPT(xdr_opaque(xdrs, (caddr_t)&cred->adc_nickname, sizeof(cred->adc_nickname)));
return (TRUE);
default:
return (FALSE);
}
}
bool_t
xdr_authdes_verf(xdrs, verf)
register XDR *xdrs;
register struct authdes_verf *verf;
{
/*
* Unrolled xdr
*/
ATTEMPT(xdr_opaque(xdrs, (caddr_t)&verf->adv_xtimestamp, sizeof(des_block)));
ATTEMPT(xdr_opaque(xdrs, (caddr_t)&verf->adv_int_u, sizeof(verf->adv_int_u)));
return (TRUE);
}

View File

@@ -1,68 +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
*/
#if defined(LIBC_SCCS) && !defined(lint)
/*static char *sccsid = "from: @(#)authunix_prot.c 1.15 87/08/11 Copyr 1984 Sun Micro";*/
/*static char *sccsid = "from: @(#)authunix_prot.c 2.1 88/07/29 4.0 RPCSRC";*/
static char *rcsid = "$FreeBSD: src/lib/libc/rpc/authunix_prot.c,v 1.6 1999/08/28 00:00:33 peter Exp $";
#endif
/*
* authunix_prot.c
* XDR for UNIX style authentication parameters for RPC
*
* Copyright (C) 1984, Sun Microsystems, Inc.
*/
#include <rpc/types.h>
#include <rpc/xdr.h>
#include <rpc/auth.h>
#include <rpc/auth_unix.h>
/*
* XDR for unix authentication parameters.
*/
bool_t
xdr_authunix_parms(xdrs, p)
register XDR *xdrs;
register struct authunix_parms *p;
{
if (xdr_u_long(xdrs, &(p->aup_time))
&& xdr_string(xdrs, &(p->aup_machname), MAX_MACHINE_NAME)
&& xdr_int(xdrs, &(p->aup_uid))
&& xdr_int(xdrs, &(p->aup_gid))
&& xdr_array(xdrs, (caddr_t *)&(p->aup_gids),
&(p->aup_len), NGRPS, sizeof(int), xdr_int) ) {
return (TRUE);
}
return (FALSE);
}

View File

@@ -1,106 +0,0 @@
.\" @(#)bindresvport.3n 2.2 88/08/02 4.0 RPCSRC; from 1.7 88/03/14 SMI
.\" $FreeBSD: src/lib/libc/rpc/bindresvport.3,v 1.10 2000/01/27 02:55:01 bde Exp $
.\"
.Dd January 27, 2000
.Dt BINDRESVPORT 3
.Os
.Sh NAME
.Nm bindresvport ,
.Nm bindresvport_sa
.Ndbind a socket to a privileged IP port
.Sh SYNOPSIS
.Fd #include <rpc/rpc.h>
.Ft int
.Fn bindresvport "int sd" "struct sockaddr_in *sin"
.Ft int
.Fn bindresvport_sa "int sd" "struct sockaddr *sa"
.Sh DESCRIPTION
.Fn bindresvport
and
.Fn bindresvport_sa
are used to bind a socket descriptor to a privileged
.Tn IP
port, that is, a
port number in the range 0-1023.
.Pp
Only root can bind to a privileged port; this call will fail for any
other users.
.Pp
When
.Va sin
is not null,
.Va sin->sin_family
must be initialized to the address family of the socket, passed by
.Va sd .
If the value of sin->sin_port is non-zero
.Fn bindresvport
will attempt to use that specific port. If it fails, it chooses another
privileged port automatically.
.Pp
It is legal to pass null pointer to
.Va sin .
In this case, the caller cannot get the port number
.Fn bindresvport
has picked.
.Pp
Function prototype of
.Fn bindresvport
is biased to
.Dv AF_INET
socket.
.Fn bindresvport_sa
acts exactly the same, with more neutral function prototype.
Note that both functions behave exactly the same, and
both support
.Dv AF_INET6
sockets as well as
.Dv AF_INET
sockets.
.Sh RETURN VALUES
.Fn bindresvport
and
.Fn bindresvport_sa
return 0 if they are successful, otherwise \-1 is returned and
.Va errno
set to reflect the cause of the error.
.Sh ERRORS
The
.Fn bindresvport
and
.Fn bindresvport_sa
functions fail if:
.Bl -tag -width Er
.It Bq Er EBADF
.Fa sd
is not a valid descriptor.
.It Bq Er ENOTSOCK
.Fa sd
is not a socket.
.It Bq Er EADDRNOTAVAIL
The specified address is not available from the local machine.
.It Bq Er EADDRINUSE
The specified address is already in use.
.It Bq Er EINVAL
The socket is already bound to an address,
or the socket family and the family of specified address mismatch.
.It Bq Er EACCES
The requested address is protected, and the current user
has inadequate permission to access it.
.It Bq Er EFAULT
The
.Fa name
parameter is not in a valid part of the user
address space.
.It Bq Er ENOBUFS
Insufficient resources were available in the system
to perform the operation.
.It Bq Er EPFNOSUPPORT
The protocol family has not been configured into the
system, no implementation for it exists,
or address family did not match between arguments.
.El
.Sh "SEE ALSO"
.Xr bind 2 ,
.Xr socket 2 ,
.Xr rresvport 3 ,
.Xr rresvport_af 3

View File

@@ -1,147 +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
*/
#if defined(LIBC_SCCS) && !defined(lint)
/*static char *sccsid = "from: @(#)bindresvport.c 1.8 88/02/08 SMI";*/
/*static char *sccsid = "from: @(#)bindresvport.c 2.2 88/07/29 4.0 RPCSRC";*/
/*from: OpenBSD: bindresvport.c,v 1.7 1996/07/30 16:25:47 downsj Exp */
static char *rcsid = "$FreeBSD: src/lib/libc/rpc/bindresvport.c,v 1.12 2000/01/26 09:02:42 shin Exp $";
#endif
/*
* Copyright (c) 1987 by Sun Microsystems, Inc.
*
* Portions Copyright(C) 1996, Jason Downs. All rights reserved.
*/
#include <sys/types.h>
#include <sys/errno.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <unistd.h>
#include <string.h>
/*
* Bind a socket to a privileged port for whatever protocol.
*/
int
bindresvport_sa(sd, sa)
int sd;
struct sockaddr *sa;
{
int old, error, af;
struct sockaddr myaddr;
struct sockaddr_in *sin;
#if (defined(AF_INET6) && defined(IPPROTO_IPV6))
struct sockaddr_in6 *sin6;
#endif
int proto, portrange, portlow;
u_int16_t port;
int salen;
if (sa == NULL) {
salen = sizeof(myaddr);
sa = (struct sockaddr *)&myaddr;
if (getsockname(sd, sa, &salen) == -1)
return -1; /* errno is correctly set */
af = sa->sa_family;
memset(&myaddr, 0, salen);
} else
af = sa->sa_family;
if (af == AF_INET) {
proto = IPPROTO_IP;
portrange = IP_PORTRANGE;
portlow = IP_PORTRANGE_LOW;
sin = (struct sockaddr_in *)sa;
salen = sizeof(struct sockaddr_in);
port = sin->sin_port;
#if (defined(AF_INET6) && defined(IPPROTO_IPV6))
} else if (af == AF_INET6) {
proto = IPPROTO_IPV6;
portrange = IPV6_PORTRANGE;
portlow = IPV6_PORTRANGE_LOW;
sin6 = (struct sockaddr_in6 *)sa;
salen = sizeof(struct sockaddr_in6);
port = sin6->sin6_port;
#endif
} else {
errno = EPFNOSUPPORT;
return (-1);
}
sa->sa_family = af;
sa->sa_len = salen;
if (port == 0) {
int oldlen = sizeof(old);
error = getsockopt(sd, proto, portrange, &old, &oldlen);
if (error < 0)
return (error);
error = setsockopt(sd, proto, portrange, &portlow,
sizeof(portlow));
if (error < 0)
return (error);
}
error = bind(sd, sa, salen);
if (port == 0) {
int saved_errno = errno;
if (error) {
if (setsockopt(sd, proto, portrange, &old,
sizeof(old)) < 0)
errno = saved_errno;
return (error);
}
if (sa != (struct sockaddr *)&myaddr) {
/* Hmm, what did the kernel assign... */
if (getsockname(sd, sa, &salen) < 0)
errno = saved_errno;
return (error);
}
}
return (error);
}
/*
* Bind a socket to a privileged IP port
*/
int
bindresvport(sd, sin)
int sd;
struct sockaddr_in *sin;
{
return bindresvport_sa(sd, (struct sockaddr *)sin);
}

View File

@@ -1,141 +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
*/
#if defined(LIBC_SCCS) && !defined(lint)
/*static char *sccsid = "from: @(#)clnt_generic.c 1.4 87/08/11 (C) 1987 SMI";*/
/*static char *sccsid = "from: @(#)clnt_generic.c 2.2 88/08/01 4.0 RPCSRC";*/
static char *rcsid = "$FreeBSD: src/lib/libc/rpc/clnt_generic.c,v 1.9 1999/08/28 00:00:35 peter Exp $";
#endif
/*
* Copyright (C) 1987, Sun Microsystems, Inc.
*/
#include <rpc/rpc.h>
#include <sys/socket.h>
#include <sys/errno.h>
#include <netdb.h>
#include <string.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(hostname, prog, vers, proto)
char *hostname;
u_long prog;
u_long vers;
char *proto;
{
struct hostent *h;
struct protoent *p;
struct sockaddr_in sin;
#ifndef __rtems__
struct sockaddr_un sun;
#endif
int sock;
struct timeval tv;
CLIENT *client;
#ifndef __rtems__
if (!strcmp(proto, "unix")) {
bzero((char *)&sun, sizeof(sun));
sun.sun_family = AF_UNIX;
strcpy(sun.sun_path, hostname);
sun.sun_len = sizeof(sun.sun_len) + sizeof(sun.sun_family) +
strlen(sun.sun_path) + 1;
sock = RPC_ANYSOCK;
client = clntunix_create(&sun, prog, vers, &sock, 0, 0);
if (client == NULL)
return(NULL);
tv.tv_sec = 25;
tv.tv_usec = 0;
clnt_control(client, CLSET_TIMEOUT, &tv);
return(client);
}
#endif
h = gethostbyname(hostname);
if (h == NULL) {
rpc_createerr.cf_stat = RPC_UNKNOWNHOST;
return (NULL);
}
if (h->h_addrtype != AF_INET) {
/*
* Only support INET for now
*/
rpc_createerr.cf_stat = RPC_SYSTEMERROR;
rpc_createerr.cf_error.re_errno = EAFNOSUPPORT;
return (NULL);
}
memset(&sin, 0, sizeof(sin));
sin.sin_len = sizeof(struct sockaddr_in);
sin.sin_family = h->h_addrtype;
sin.sin_port = 0;
memcpy((char*)&sin.sin_addr, h->h_addr, h->h_length);
p = getprotobyname(proto);
if (p == NULL) {
rpc_createerr.cf_stat = RPC_UNKNOWNPROTO;
rpc_createerr.cf_error.re_errno = EPFNOSUPPORT;
return (NULL);
}
sock = RPC_ANYSOCK;
switch (p->p_proto) {
case IPPROTO_UDP:
tv.tv_sec = 5;
tv.tv_usec = 0;
client = clntudp_create(&sin, prog, vers, tv, &sock);
if (client == NULL) {
return (NULL);
}
#if 0 /* XXX do we need this? */
tv.tv_sec = 25;
tv.tv_usec = 0;
clnt_control(client, CLSET_TIMEOUT, &tv);
#endif
break;
case IPPROTO_TCP:
client = clnttcp_create(&sin, prog, vers, &sock, 0, 0);
if (client == NULL) {
return (NULL);
}
#if 0 /* XXX do we need this? */
tv.tv_sec = 25;
tv.tv_usec = 0;
clnt_control(client, CLSET_TIMEOUT, &tv);
#endif
break;
default:
rpc_createerr.cf_stat = RPC_SYSTEMERROR;
rpc_createerr.cf_error.re_errno = EPFNOSUPPORT;
return (NULL);
}
return (client);
}

View File

@@ -1,254 +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
*/
#if defined(LIBC_SCCS) && !defined(lint)
/*static char *sccsid = "from: @(#)clnt_perror.c 1.15 87/10/07 Copyr 1984 Sun Micro";*/
/*static char *sccsid = "from: @(#)clnt_perror.c 2.1 88/07/29 4.0 RPCSRC";*/
static char *rcsid = "$FreeBSD: src/lib/libc/rpc/clnt_perror.c,v 1.11 1999/08/28 00:00:35 peter Exp $";
#endif
/*
* clnt_perror.c
*
* Copyright (C) 1984, Sun Microsystems, Inc.
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <rpc/rpc.h>
#include <rpc/types.h>
#include <rpc/auth.h>
#include <rpc/clnt.h>
static char *auth_errmsg();
#define CLNT_PERROR_BUFLEN 256
#define buf ((char *)((struct rtems_rpc_task_variables *)rtems_rpc_task_variables)->clnt_perror_buf)
static char *
_buf()
{
if (buf == 0)
buf = (char *)malloc(CLNT_PERROR_BUFLEN);
return (buf);
}
/*
* Print reply error info
*/
char *
clnt_sperror(rpch, s)
CLIENT *rpch;
char *s;
{
struct rpc_err e;
char *err;
char *str = _buf();
char *strstart = str;
if (str == 0)
return (0);
CLNT_GETERR(rpch, &e);
(void) sprintf(str, "%s: %s", s, clnt_sperrno(e.re_status));
str += strlen(str);
switch (e.re_status) {
case RPC_SUCCESS:
case RPC_CANTENCODEARGS:
case RPC_CANTDECODERES:
case RPC_TIMEDOUT:
case RPC_PROGUNAVAIL:
case RPC_PROCUNAVAIL:
case RPC_CANTDECODEARGS:
case RPC_SYSTEMERROR:
case RPC_UNKNOWNHOST:
case RPC_UNKNOWNPROTO:
case RPC_PMAPFAILURE:
case RPC_PROGNOTREGISTERED:
case RPC_FAILED:
break;
case RPC_CANTSEND:
case RPC_CANTRECV:
(void) snprintf(str, CLNT_PERROR_BUFLEN - (str - strstart),
"; errno = %s\n", strerror(e.re_errno));
break;
case RPC_VERSMISMATCH:
(void) sprintf(str,
"; low version = %lu, high version = %lu\n",
(u_long)e.re_vers.low, (u_long)e.re_vers.high);
break;
case RPC_AUTHERROR:
err = auth_errmsg(e.re_why);
(void) sprintf(str,"; why = ");
str += strlen(str);
if (err != NULL) {
(void) sprintf(str, "%s\n",err);
} else {
(void) sprintf(str,
"(unknown authentication error - %d)\n",
(int) e.re_why);
}
break;
case RPC_PROGVERSMISMATCH:
(void) sprintf(str,
"; low version = %lu, high version = %lu\n",
(u_long)e.re_vers.low, (u_long)e.re_vers.high);
break;
default: /* unknown */
(void) sprintf(str,
"; s1 = %lu, s2 = %lu\n",
(long)e.re_lb.s1, (long)e.re_lb.s2);
break;
}
strstart[CLNT_PERROR_BUFLEN-2] = '\n';
strstart[CLNT_PERROR_BUFLEN-1] = '\0';
return(strstart) ;
}
void
clnt_perror(rpch, s)
CLIENT *rpch;
char *s;
{
(void) fprintf(stderr,"%s\n",clnt_sperror(rpch,s));
}
static const char *const rpc_errlist[] = {
"RPC: Success", /* 0 - RPC_SUCCESS */
"RPC: Can't encode arguments", /* 1 - RPC_CANTENCODEARGS */
"RPC: Can't decode result", /* 2 - RPC_CANTDECODERES */
"RPC: Unable to send", /* 3 - RPC_CANTSEND */
"RPC: Unable to receive", /* 4 - RPC_CANTRECV */
"RPC: Timed out", /* 5 - RPC_TIMEDOUT */
"RPC: Incompatible versions of RPC", /* 6 - RPC_VERSMISMATCH */
"RPC: Authentication error", /* 7 - RPC_AUTHERROR */
"RPC: Program unavailable", /* 8 - RPC_PROGUNAVAIL */
"RPC: Program/version mismatch", /* 9 - RPC_PROGVERSMISMATCH */
"RPC: Procedure unavailable", /* 10 - RPC_PROCUNAVAIL */
"RPC: Server can't decode arguments", /* 11 - RPC_CANTDECODEARGS */
"RPC: Remote system error", /* 12 - RPC_SYSTEMERROR */
"RPC: Unknown host", /* 13 - RPC_UNKNOWNHOST */
"RPC: Port mapper failure", /* 14 - RPC_PMAPFAILURE */
"RPC: Program not registered", /* 15 - RPC_PROGNOTREGISTERED */
"RPC: Failed (unspecified error)", /* 16 - RPC_FAILED */
"RPC: Unknown protocol" /* 17 - RPC_UNKNOWNPROTO */
};
/*
* This interface for use by clntrpc
*/
char *
clnt_sperrno(stat)
enum clnt_stat stat;
{
unsigned int errnum = stat;
if (errnum < (sizeof(rpc_errlist)/sizeof(rpc_errlist[0])))
return (char *)rpc_errlist[errnum];
return ("RPC: (unknown error code)");
}
void
clnt_perrno(num)
enum clnt_stat num;
{
(void) fprintf(stderr,"%s\n",clnt_sperrno(num));
}
char *
clnt_spcreateerror(s)
char *s;
{
char *str = _buf();
if (str == 0)
return(0);
switch (rpc_createerr.cf_stat) {
case RPC_PMAPFAILURE:
(void) snprintf(str, CLNT_PERROR_BUFLEN, "%s: %s - %s\n", s,
clnt_sperrno(rpc_createerr.cf_stat),
clnt_sperrno(rpc_createerr.cf_error.re_status));
break;
case RPC_SYSTEMERROR:
(void) snprintf(str, CLNT_PERROR_BUFLEN, "%s: %s - %s\n", s,
clnt_sperrno(rpc_createerr.cf_stat),
strerror(rpc_createerr.cf_error.re_errno));
break;
default:
(void) snprintf(str, CLNT_PERROR_BUFLEN, "%s: %s\n", s,
clnt_sperrno(rpc_createerr.cf_stat));
break;
}
str[CLNT_PERROR_BUFLEN-2] = '\n';
str[CLNT_PERROR_BUFLEN-1] = '\0';
return (str);
}
void
clnt_pcreateerror(s)
char *s;
{
(void) fprintf(stderr,"%s\n",clnt_spcreateerror(s));
}
static const char *const auth_errlist[] = {
"Authentication OK", /* 0 - AUTH_OK */
"Invalid client credential", /* 1 - AUTH_BADCRED */
"Server rejected credential", /* 2 - AUTH_REJECTEDCRED */
"Invalid client verifier", /* 3 - AUTH_BADVERF */
"Server rejected verifier", /* 4 - AUTH_REJECTEDVERF */
"Client credential too weak", /* 5 - AUTH_TOOWEAK */
"Invalid server verifier", /* 6 - AUTH_INVALIDRESP */
"Failed (unspecified error)" /* 7 - AUTH_FAILED */
};
static char *
auth_errmsg(stat)
enum auth_stat stat;
{
unsigned int errnum = stat;
if (errnum < (sizeof(auth_errlist)/sizeof(auth_errlist[0])))
return (char *)auth_errlist[errnum];
return(NULL);
}

View File

@@ -1,243 +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
*/
#if defined(LIBC_SCCS) && !defined(lint)
/*static char *sccsid = "from: @(#)clnt_raw.c 1.22 87/08/11 Copyr 1984 Sun Micro";*/
/*static char *sccsid = "from: @(#)clnt_raw.c 2.2 88/08/01 4.0 RPCSRC";*/
static char *rcsid = "$FreeBSD: src/lib/libc/rpc/clnt_raw.c,v 1.10 1999/08/28 00:00:36 peter Exp $";
#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 similate rpc and get round trip overhead, without
* any interference from the kernal.
*/
#include <rpc/rpc.h>
#include <stdlib.h>
#include <stdio.h>
#define MCALL_MSG_SIZE 24
/*
* This is the "network" we will be moving stuff over.
*/
struct clnt_raw_private {
CLIENT client_object;
XDR xdr_stream;
char _raw_buf[UDPMSGSIZE];
char mashl_callmsg[MCALL_MSG_SIZE];
u_int mcnt;
};
#define clntraw_private ((struct clnt_raw_private *)((struct rtems_rpc_task_variables *)rtems_rpc_task_variables)->clnt_raw_private)
static enum clnt_stat clntraw_call();
static void clntraw_abort();
static void clntraw_geterr();
static bool_t clntraw_freeres();
static bool_t clntraw_control();
static void clntraw_destroy();
static struct clnt_ops client_ops = {
clntraw_call,
clntraw_abort,
clntraw_geterr,
clntraw_freeres,
clntraw_destroy,
clntraw_control
};
void svc_getreq();
/*
* Create a client handle for memory based rpc.
*/
CLIENT *
clntraw_create(prog, vers)
u_long prog;
u_long vers;
{
register struct clnt_raw_private *clp = clntraw_private;
struct rpc_msg call_msg;
XDR *xdrs = &clp->xdr_stream;
CLIENT *client = &clp->client_object;
if (clp == 0) {
clp = (struct clnt_raw_private *)calloc(1, sizeof (*clp));
if (clp == 0)
return (0);
clntraw_private = clp;
}
/*
* pre-serialize the static part of the call msg and stash it away
*/
call_msg.rm_direction = CALL;
call_msg.rm_call.cb_rpcvers = RPC_MSG_VERSION;
call_msg.rm_call.cb_prog = prog;
call_msg.rm_call.cb_vers = vers;
xdrmem_create(xdrs, clp->mashl_callmsg, MCALL_MSG_SIZE, XDR_ENCODE);
if (! xdr_callhdr(xdrs, &call_msg)) {
perror("clnt_raw.c - Fatal header serialization error.");
}
clp->mcnt = XDR_GETPOS(xdrs);
XDR_DESTROY(xdrs);
/*
* Set xdrmem for client/server shared buffer
*/
xdrmem_create(xdrs, clp->_raw_buf, UDPMSGSIZE, XDR_FREE);
/*
* create client handle
*/
client->cl_ops = &client_ops;
client->cl_auth = authnone_create();
return (client);
}
static enum clnt_stat
clntraw_call(h, proc, xargs, argsp, xresults, resultsp, timeout)
CLIENT *h;
u_long proc;
xdrproc_t xargs;
caddr_t argsp;
xdrproc_t xresults;
caddr_t resultsp;
struct timeval timeout;
{
register struct clnt_raw_private *clp = clntraw_private;
register XDR *xdrs = &clp->xdr_stream;
struct rpc_msg msg;
enum clnt_stat status;
struct rpc_err error;
if (clp == 0)
return (RPC_FAILED);
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()
{
}
static bool_t
clntraw_freeres(cl, xdr_res, res_ptr)
CLIENT *cl;
xdrproc_t xdr_res;
caddr_t res_ptr;
{
register struct clnt_raw_private *clp = clntraw_private;
register XDR *xdrs = &clp->xdr_stream;
bool_t rval;
if (clp == 0)
{
rval = (bool_t) RPC_FAILED;
return (rval);
}
xdrs->x_op = XDR_FREE;
return ((*xdr_res)(xdrs, res_ptr));
}
static void
clntraw_abort()
{
}
static bool_t
clntraw_control()
{
return (FALSE);
}
static void
clntraw_destroy()
{
}

View File

@@ -1,123 +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
*/
#if defined(LIBC_SCCS) && !defined(lint)
/*static char *sccsid = "from: @(#)clnt_simple.c 1.35 87/08/11 Copyr 1984 Sun Micro";*/
/*static char *sccsid = "from: @(#)clnt_simple.c 2.2 88/08/01 4.0 RPCSRC";*/
static char *rcsid = "$FreeBSD: src/lib/libc/rpc/clnt_simple.c,v 1.12 2000/01/27 23:06:35 jasone Exp $";
#endif
/*
* clnt_simple.c
* Simplified front end to rpc.
*
* Copyright (C) 1984, Sun Microsystems, Inc.
*/
#include <sys/param.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <rpc/rpc.h>
#include <sys/socket.h>
#include <netdb.h>
struct call_rpc_private {
CLIENT *client;
int socket;
int oldprognum, oldversnum, valid;
char *oldhost;
};
#define callrpc_private ((struct call_rpc_private *)((struct rtems_rpc_task_variables *)rtems_rpc_task_variables)->call_rpc_private)
int
callrpc(host, prognum, versnum, procnum, inproc, in, outproc, out)
char *host;
int prognum, versnum, procnum;
xdrproc_t inproc, outproc;
char *in, *out;
{
register struct call_rpc_private *crp = callrpc_private;
struct sockaddr_in server_addr;
enum clnt_stat clnt_stat;
struct hostent *hp;
struct timeval timeout, tottimeout;
if (crp == 0) {
crp = (struct call_rpc_private *)calloc(1, sizeof (*crp));
if (crp == 0)
return (0);
callrpc_private = crp;
}
if (crp->oldhost == NULL) {
crp->oldhost = malloc(MAXHOSTNAMELEN);
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 {
crp->valid = 0;
if (crp->socket != -1)
(void)_RPC_close(crp->socket);
crp->socket = RPC_ANYSOCK;
if (crp->client) {
clnt_destroy(crp->client);
crp->client = NULL;
}
if ((hp = gethostbyname(host)) == NULL)
return ((int) RPC_UNKNOWNHOST);
timeout.tv_usec = 0;
timeout.tv_sec = 5;
memset(&server_addr, 0, sizeof(server_addr));
memcpy((char *)&server_addr.sin_addr, hp->h_addr, hp->h_length);
server_addr.sin_len = sizeof(struct sockaddr_in);
server_addr.sin_family = AF_INET;
server_addr.sin_port = 0;
if ((crp->client = clntudp_create(&server_addr, (u_long)prognum,
(u_long)versnum, timeout, &crp->socket)) == NULL)
return ((int) rpc_createerr.cf_stat);
crp->valid = 1;
crp->oldprognum = prognum;
crp->oldversnum = versnum;
(void) strcpy(crp->oldhost, host);
}
tottimeout.tv_sec = 25;
tottimeout.tv_usec = 0;
clnt_stat = clnt_call(crp->client, procnum, inproc, in,
outproc, out, tottimeout);
/*
* if call failed, empty cache
*/
if (clnt_stat != RPC_SUCCESS)
crp->valid = 0;
return ((int) clnt_stat);
}

View File

@@ -1,580 +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
*/
#if defined(LIBC_SCCS) && !defined(lint)
/*static char *sccsid = "from: @(#)clnt_tcp.c 1.37 87/10/05 Copyr 1984 Sun Micro";*/
/*static char *sccsid = "from: @(#)clnt_tcp.c 2.2 88/08/01 4.0 RPCSRC";*/
static char *rcsid = "$FreeBSD: src/lib/libc/rpc/clnt_tcp.c,v 1.14 2000/01/27 23:06:36 jasone Exp $";
#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 <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <rpc/rpc.h>
#include <sys/socket.h>
#include <netdb.h>
#include <errno.h>
#include <rpc/pmap_clnt.h>
#define MCALL_MSG_SIZE 24
static int readtcp();
static int writetcp();
static enum clnt_stat clnttcp_call();
static void clnttcp_abort();
static void clnttcp_geterr();
static bool_t clnttcp_freeres();
static bool_t clnttcp_control();
static void clnttcp_destroy();
static struct clnt_ops tcp_ops = {
clnttcp_call,
clnttcp_abort,
clnttcp_geterr,
clnttcp_freeres,
clnttcp_destroy,
clnttcp_control
};
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;
};
/*
* 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(raddr, prog, vers, sockp, sendsz, recvsz)
struct sockaddr_in *raddr;
u_long prog;
u_long vers;
register int *sockp;
u_int sendsz;
u_int recvsz;
{
CLIENT *h;
register struct ct_data *ct = NULL;
struct timeval now;
struct rpc_msg call_msg;
static u_int32_t disrupt;
if (disrupt == 0)
disrupt = (u_int32_t)(long)raddr;
h = (CLIENT *)mem_alloc(sizeof(*h));
if (h == NULL) {
(void)fprintf(stderr, "clnttcp_create: out of memory\n");
rpc_createerr.cf_stat = RPC_SYSTEMERROR;
rpc_createerr.cf_error.re_errno = errno;
goto fooy;
}
ct = (struct ct_data *)mem_alloc(sizeof(*ct));
if (ct == NULL) {
(void)fprintf(stderr, "clnttcp_create: out of memory\n");
rpc_createerr.cf_stat = RPC_SYSTEMERROR;
rpc_createerr.cf_error.re_errno = errno;
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)) {
rpc_createerr.cf_stat = RPC_SYSTEMERROR;
rpc_createerr.cf_error.re_errno = errno;
if (*sockp != -1)
(void)_RPC_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
*/
(void)gettimeofday(&now, (struct timezone *)0);
call_msg.rm_xid = (++disrupt) ^ getpid() ^ now.tv_sec ^ now.tv_usec;
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)_RPC_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
*/
if (ct)
mem_free((caddr_t)ct, sizeof(struct ct_data));
if (h)
mem_free((caddr_t)h, sizeof(CLIENT));
return ((CLIENT *)NULL);
}
static enum clnt_stat
clnttcp_call(h, proc, xdr_args, args_ptr, xdr_results, results_ptr, timeout)
register CLIENT *h;
u_long proc;
xdrproc_t xdr_args;
caddr_t args_ptr;
xdrproc_t xdr_results;
caddr_t results_ptr;
struct timeval timeout;
{
register struct ct_data *ct = (struct ct_data *) h->cl_private;
register 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 */
register bool_t shipnow;
int refreshes = 2;
if (!ct->ct_waitset) {
ct->ct_wait = timeout;
}
shipnow =
(xdr_results == (xdrproc_t)0 && timeout.tv_sec == 0
&& timeout.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 (timeout.tv_sec == 0 && timeout.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 = xdr_void;
if (! xdrrec_skiprecord(xdrs))
return (ct->ct_error.re_status);
/* now decode and validate the response header */
if (! xdr_replymsg(xdrs, &reply_msg)) {
if (ct->ct_error.re_status == RPC_SUCCESS)
continue;
return (ct->ct_error.re_status);
}
if (reply_msg.rm_xid == x_id)
break;
}
/*
* process header
*/
_seterr_reply(&reply_msg, &(ct->ct_error));
if (ct->ct_error.re_status == RPC_SUCCESS) {
if (! AUTH_VALIDATE(h->cl_auth, &reply_msg.acpted_rply.ar_verf)) {
ct->ct_error.re_status = RPC_AUTHERROR;
ct->ct_error.re_why = AUTH_INVALIDRESP;
} else if (! (*xdr_results)(xdrs, results_ptr)) {
if (ct->ct_error.re_status == RPC_SUCCESS)
ct->ct_error.re_status = RPC_CANTDECODERES;
}
/* free verifier ... */
if (reply_msg.acpted_rply.ar_verf.oa_base != NULL) {
xdrs->x_op = XDR_FREE;
(void)xdr_opaque_auth(xdrs, &(reply_msg.acpted_rply.ar_verf));
}
} /* end successful completion */
else {
/* maybe our credentials need to be refreshed ... */
if (refreshes-- && AUTH_REFRESH(h->cl_auth))
goto call_again;
} /* end of unsuccessful completion */
return (ct->ct_error.re_status);
}
static void
clnttcp_geterr(h, errp)
CLIENT *h;
struct rpc_err *errp;
{
register struct ct_data *ct =
(struct ct_data *) h->cl_private;
*errp = ct->ct_error;
}
static bool_t
clnttcp_freeres(cl, xdr_res, res_ptr)
CLIENT *cl;
xdrproc_t xdr_res;
caddr_t res_ptr;
{
register struct ct_data *ct = (struct ct_data *)cl->cl_private;
register XDR *xdrs = &(ct->ct_xdrs);
xdrs->x_op = XDR_FREE;
return ((*xdr_res)(xdrs, res_ptr));
}
static void
clnttcp_abort()
{
}
static bool_t
clnttcp_control(cl, request, info)
CLIENT *cl;
int request;
char *info;
{
register struct ct_data *ct = (struct ct_data *)cl->cl_private;
register struct timeval *tv;
int len;
switch (request) {
case CLSET_FD_CLOSE:
ct->ct_closeit = TRUE;
break;
case CLSET_FD_NCLOSE:
ct->ct_closeit = FALSE;
break;
case CLSET_TIMEOUT:
if (info == NULL)
return(FALSE);
tv = (struct timeval *)info;
ct->ct_wait.tv_sec = tv->tv_sec;
ct->ct_wait.tv_usec = tv->tv_usec;
ct->ct_waitset = TRUE;
break;
case CLGET_TIMEOUT:
if (info == NULL)
return(FALSE);
*(struct timeval *)info = ct->ct_wait;
break;
case CLGET_SERVER_ADDR:
if (info == NULL)
return(FALSE);
*(struct sockaddr_in *)info = ct->ct_addr;
break;
case CLGET_FD:
if (info == NULL)
return(FALSE);
*(int *)info = ct->ct_sock;
break;
case CLGET_XID:
/*
* use the knowledge that xid is the
* first element in the call structure *.
* This will get the xid of the PREVIOUS call
*/
if (info == NULL)
return(FALSE);
*(u_long *)info = ntohl(*(u_long *)ct->ct_mcall);
break;
case CLSET_XID:
/* This will set the xid of the NEXT call */
if (info == NULL)
return(FALSE);
*(u_long *)ct->ct_mcall = htonl(*(u_long *)info - 1);
/* decrement by 1 as clnttcp_call() increments once */
case CLGET_VERS:
/*
* This RELIES on the information that, in the call body,
* the version number field is the fifth field from the
* begining of the RPC header. MUST be changed if the
* call_struct is changed
*/
if (info == NULL)
return(FALSE);
*(u_long *)info = ntohl(*(u_long *)(ct->ct_mcall +
4 * BYTES_PER_XDR_UNIT));
break;
case CLSET_VERS:
if (info == NULL)
return(FALSE);
*(u_long *)(ct->ct_mcall + 4 * BYTES_PER_XDR_UNIT)
= htonl(*(u_long *)info);
break;
case CLGET_PROG:
/*
* This RELIES on the information that, in the call body,
* the program number field is the field from the
* begining of the RPC header. MUST be changed if the
* call_struct is changed
*/
if (info == NULL)
return(FALSE);
*(u_long *)info = ntohl(*(u_long *)(ct->ct_mcall +
3 * BYTES_PER_XDR_UNIT));
break;
case CLSET_PROG:
if (info == NULL)
return(FALSE);
*(u_long *)(ct->ct_mcall + 3 * BYTES_PER_XDR_UNIT)
= htonl(*(u_long *)info);
break;
case CLGET_LOCAL_ADDR:
len = sizeof(struct sockaddr);
if (getsockname(ct->ct_sock, (struct sockaddr *)info, &len) <0)
return(FALSE);
break;
case CLGET_RETRY_TIMEOUT:
case CLSET_RETRY_TIMEOUT:
case CLGET_SVC_ADDR:
case CLSET_SVC_ADDR:
case CLSET_PUSH_TIMOD:
case CLSET_POP_TIMOD:
default:
return (FALSE);
}
return (TRUE);
}
static void
clnttcp_destroy(h)
CLIENT *h;
{
register struct ct_data *ct =
(struct ct_data *) h->cl_private;
if (ct->ct_closeit) {
(void)_RPC_close(ct->ct_sock);
}
XDR_DESTROY(&(ct->ct_xdrs));
mem_free((caddr_t)ct, sizeof(struct ct_data));
mem_free((caddr_t)h, sizeof(CLIENT));
}
/*
* Interface between xdr serializer and tcp connection.
* Behaves like the system calls, read & write, but keeps some error state
* around for the rpc level.
*/
static int
readtcp(ct, buf, len)
register struct ct_data *ct;
caddr_t buf;
register int len;
{
fd_set *fds, readfds;
struct timeval start, after, duration, delta, tmp, tv;
int r, save_errno;
if (len == 0)
return (0);
if (ct->ct_sock + 1 > FD_SETSIZE) {
int bytes = howmany(ct->ct_sock + 1, NFDBITS) * sizeof(fd_mask);
fds = (fd_set *)malloc(bytes);
if (fds == NULL)
return (-1);
memset(fds, 0, bytes);
} else {
fds = &readfds;
FD_ZERO(fds);
}
gettimeofday(&start, NULL);
delta = ct->ct_wait;
while (TRUE) {
/* XXX we know the other bits are still clear */
FD_SET(ct->ct_sock, fds);
tv = delta; /* in case select writes back */
r = select(ct->ct_sock+1, fds, NULL, NULL, &tv);
save_errno = errno;
gettimeofday(&after, NULL);
timersub(&start, &after, &duration);
timersub(&ct->ct_wait, &duration, &tmp);
delta = tmp;
if (delta.tv_sec < 0 || !timerisset(&delta))
r = 0;
switch (r) {
case 0:
if (fds != &readfds)
free(fds);
ct->ct_error.re_status = RPC_TIMEDOUT;
return (-1);
case -1:
if (errno == EINTR)
continue;
if (fds != &readfds)
free(fds);
ct->ct_error.re_status = RPC_CANTRECV;
ct->ct_error.re_errno = save_errno;
return (-1);
}
break;
}
switch (len = _RPC_read(ct->ct_sock, buf, len)) {
case 0:
/* premature eof */
ct->ct_error.re_errno = ECONNRESET;
ct->ct_error.re_status = RPC_CANTRECV;
len = -1; /* it's really an error */
break;
case -1:
ct->ct_error.re_errno = errno;
ct->ct_error.re_status = RPC_CANTRECV;
break;
}
return (len);
}
static int
writetcp(ct, buf, len)
struct ct_data *ct;
caddr_t buf;
int len;
{
register int i, cnt;
for (cnt = len; cnt > 0; cnt -= i, buf += i) {
if ((i = _RPC_write(ct->ct_sock, buf, cnt)) == -1) {
ct->ct_error.re_errno = errno;
ct->ct_error.re_status = RPC_CANTSEND;
return (-1);
}
}
return (len);
}

View File

@@ -1,567 +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
*/
#if defined(LIBC_SCCS) && !defined(lint)
/*static char *sccsid = "from: @(#)clnt_udp.c 1.39 87/08/11 Copyr 1984 Sun Micro";*/
/*static char *sccsid = "from: @(#)clnt_udp.c 2.2 88/08/01 4.0 RPCSRC";*/
static char *rcsid = "$FreeBSD: src/lib/libc/rpc/clnt_udp.c,v 1.15 2000/01/27 23:06:36 jasone Exp $";
#endif
/*
* clnt_udp.c, Implements a UDP/IP based, client side RPC.
*
* Copyright (C) 1984, Sun Microsystems, Inc.
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <rpc/rpc.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <netdb.h>
#include <errno.h>
#include <rpc/pmap_clnt.h>
/*
* UDP bases client side rpc operations
*/
static enum clnt_stat clntudp_call();
static void clntudp_abort();
static void clntudp_geterr();
static bool_t clntudp_freeres();
static bool_t clntudp_control();
static void clntudp_destroy();
static struct clnt_ops udp_ops = {
clntudp_call,
clntudp_abort,
clntudp_geterr,
clntudp_freeres,
clntudp_destroy,
clntudp_control
};
/*
* Private data kept per client handle
*/
struct cu_data {
int cu_sock;
bool_t cu_closeit;
struct sockaddr_in cu_raddr;
int cu_rlen;
struct timeval cu_wait;
struct timeval cu_total;
struct rpc_err cu_error;
XDR cu_outxdrs;
u_int cu_xdrpos;
u_int cu_sendsz;
char *cu_outbuf;
u_int cu_recvsz;
char cu_inbuf[1];
};
/*
* Create a UDP based client handle.
* If *sockp<0, *sockp is set to a newly created UPD socket.
* If raddr->sin_port is 0 a binder on the remote machine
* is consulted for the correct port number.
* NB: It is the clients responsibility to close *sockp.
* NB: The rpch->cl_auth is initialized to null authentication.
* Caller may wish to set this something more useful.
*
* wait is the amount of time used between retransmitting a call if
* no response has been heard; retransmition occurs until the actual
* rpc call times out.
*
* sendsz and recvsz are the maximum allowable packet sizes that can be
* sent and received.
*/
CLIENT *
clntudp_bufcreate(raddr, program, version, wait, sockp, sendsz, recvsz)
struct sockaddr_in *raddr;
u_long program;
u_long version;
struct timeval wait;
register int *sockp;
u_int sendsz;
u_int recvsz;
{
CLIENT *cl;
register struct cu_data *cu = NULL;
struct timeval now;
struct rpc_msg call_msg;
static u_int32_t disrupt;
if (disrupt == 0)
disrupt = (u_int32_t)(long)raddr;
cl = (CLIENT *)mem_alloc(sizeof(CLIENT));
if (cl == NULL) {
(void) fprintf(stderr, "clntudp_create: out of memory\n");
rpc_createerr.cf_stat = RPC_SYSTEMERROR;
rpc_createerr.cf_error.re_errno = errno;
goto fooy;
}
sendsz = ((sendsz + 3) / 4) * 4;
recvsz = ((recvsz + 3) / 4) * 4;
cu = (struct cu_data *)mem_alloc(sizeof(*cu) + sendsz + recvsz);
if (cu == NULL) {
(void) fprintf(stderr, "clntudp_create: out of memory\n");
rpc_createerr.cf_stat = RPC_SYSTEMERROR;
rpc_createerr.cf_error.re_errno = errno;
goto fooy;
}
cu->cu_outbuf = &cu->cu_inbuf[recvsz];
(void)gettimeofday(&now, (struct timezone *)0);
if (raddr->sin_port == 0) {
u_short port;
if ((port =
pmap_getport(raddr, program, version, IPPROTO_UDP)) == 0) {
goto fooy;
}
raddr->sin_port = htons(port);
}
cl->cl_ops = &udp_ops;
cl->cl_private = (caddr_t)cu;
cu->cu_raddr = *raddr;
cu->cu_rlen = sizeof (cu->cu_raddr);
cu->cu_wait = wait;
cu->cu_total.tv_sec = -1;
cu->cu_total.tv_usec = -1;
cu->cu_sendsz = sendsz;
cu->cu_recvsz = recvsz;
call_msg.rm_xid = (++disrupt) ^ getpid() ^ now.tv_sec ^ now.tv_usec;
call_msg.rm_direction = CALL;
call_msg.rm_call.cb_rpcvers = RPC_MSG_VERSION;
call_msg.rm_call.cb_prog = program;
call_msg.rm_call.cb_vers = version;
xdrmem_create(&(cu->cu_outxdrs), cu->cu_outbuf,
sendsz, XDR_ENCODE);
if (! xdr_callhdr(&(cu->cu_outxdrs), &call_msg)) {
goto fooy;
}
cu->cu_xdrpos = XDR_GETPOS(&(cu->cu_outxdrs));
if (*sockp < 0) {
int dontblock = 1;
*sockp = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if (*sockp < 0) {
rpc_createerr.cf_stat = RPC_SYSTEMERROR;
rpc_createerr.cf_error.re_errno = errno;
goto fooy;
}
/* attempt to bind to priv port */
(void)bindresvport(*sockp, (struct sockaddr_in *)0);
/* the sockets rpc controls are non-blocking */
(void)ioctl(*sockp, FIONBIO, (char *) &dontblock);
cu->cu_closeit = TRUE;
} else {
cu->cu_closeit = FALSE;
}
cu->cu_sock = *sockp;
cl->cl_auth = authnone_create();
return (cl);
fooy:
if (cu)
mem_free((caddr_t)cu, sizeof(*cu) + sendsz + recvsz);
if (cl)
mem_free((caddr_t)cl, sizeof(CLIENT));
return ((CLIENT *)NULL);
}
CLIENT *
clntudp_create(raddr, program, version, wait, sockp)
struct sockaddr_in *raddr;
u_long program;
u_long version;
struct timeval wait;
register int *sockp;
{
return(clntudp_bufcreate(raddr, program, version, wait, sockp,
UDPMSGSIZE, UDPMSGSIZE));
}
static enum clnt_stat
clntudp_call(cl, proc, xargs, argsp, xresults, resultsp, utimeout)
register CLIENT *cl; /* client handle */
u_long proc; /* procedure number */
xdrproc_t xargs; /* xdr routine for args */
caddr_t argsp; /* pointer to args */
xdrproc_t xresults; /* xdr routine for results */
caddr_t resultsp; /* pointer to results */
struct timeval utimeout; /* seconds to wait before giving up */
{
register struct cu_data *cu = (struct cu_data *)cl->cl_private;
register XDR *xdrs;
register int outlen;
register int inlen;
int fromlen;
fd_set *fds, readfds;
struct sockaddr_in from;
struct rpc_msg reply_msg;
XDR reply_xdrs;
struct timeval time_waited, start, after, tmp1, tmp2, tv;
bool_t ok;
int nrefreshes = 2; /* number of times to refresh cred */
struct timeval timeout;
if (cu->cu_total.tv_usec == -1)
timeout = utimeout; /* use supplied timeout */
else
timeout = cu->cu_total; /* use default timeout */
if (cu->cu_sock + 1 > FD_SETSIZE) {
int bytes = howmany(cu->cu_sock + 1, NFDBITS) * sizeof(fd_mask);
fds = (fd_set *)malloc(bytes);
if (fds == NULL)
return (cu->cu_error.re_status = RPC_CANTSEND);
memset(fds, 0, bytes);
} else {
fds = &readfds;
FD_ZERO(fds);
}
timerclear(&time_waited);
call_again:
xdrs = &(cu->cu_outxdrs);
xdrs->x_op = XDR_ENCODE;
XDR_SETPOS(xdrs, cu->cu_xdrpos);
/*
* the transaction is the first thing in the out buffer
*/
(*(u_short *)(cu->cu_outbuf))++;
if ((! XDR_PUTLONG(xdrs, (long *)&proc)) ||
(! AUTH_MARSHALL(cl->cl_auth, xdrs)) ||
(! (*xargs)(xdrs, argsp))) {
if (fds != &readfds)
free(fds);
return (cu->cu_error.re_status = RPC_CANTENCODEARGS);
}
outlen = (int)XDR_GETPOS(xdrs);
send_again:
if (sendto(cu->cu_sock, cu->cu_outbuf, outlen, 0,
(struct sockaddr *)&(cu->cu_raddr), cu->cu_rlen) != outlen) {
cu->cu_error.re_errno = errno;
if (fds != &readfds)
free(fds);
return (cu->cu_error.re_status = RPC_CANTSEND);
}
/*
* Hack to provide rpc-based message passing
*/
if (!timerisset(&timeout)) {
if (fds != &readfds)
free(fds);
return (cu->cu_error.re_status = RPC_TIMEDOUT);
}
/*
* sub-optimal code appears here because we have
* some clock time to spare while the packets are in flight.
* (We assume that this is actually only executed once.)
*/
reply_msg.acpted_rply.ar_verf = _null_auth;
reply_msg.acpted_rply.ar_results.where = resultsp;
reply_msg.acpted_rply.ar_results.proc = xresults;
gettimeofday(&start, NULL);
for (;;) {
/* XXX we know the other bits are still clear */
FD_SET(cu->cu_sock, fds);
tv = cu->cu_wait;
switch (select(cu->cu_sock+1, fds, NULL, NULL, &tv)) {
case 0:
timeradd(&time_waited, &cu->cu_wait, &tmp1);
time_waited = tmp1;
if (timercmp(&time_waited, &timeout, <))
goto send_again;
if (fds != &readfds)
free(fds);
return (cu->cu_error.re_status = RPC_TIMEDOUT);
case -1:
if (errno == EINTR) {
gettimeofday(&after, NULL);
timersub(&after, &start, &tmp1);
timeradd(&time_waited, &tmp1, &tmp2);
time_waited = tmp2;
if (timercmp(&time_waited, &timeout, <))
continue;
if (fds != &readfds)
free(fds);
return (cu->cu_error.re_status = RPC_TIMEDOUT);
}
cu->cu_error.re_errno = errno;
if (fds != &readfds)
free(fds);
return (cu->cu_error.re_status = RPC_CANTRECV);
}
do {
fromlen = sizeof(struct sockaddr);
inlen = recvfrom(cu->cu_sock, cu->cu_inbuf,
(int) cu->cu_recvsz, 0,
(struct sockaddr *)&from, &fromlen);
} while (inlen < 0 && errno == EINTR);
if (inlen < 0) {
if (errno == EWOULDBLOCK)
continue;
cu->cu_error.re_errno = errno;
if (fds != &readfds)
free(fds);
return (cu->cu_error.re_status = RPC_CANTRECV);
}
if (inlen < sizeof(u_int32_t))
continue;
/* see if reply transaction id matches sent id */
if (*((u_int32_t *)(cu->cu_inbuf)) != *((u_int32_t *)(cu->cu_outbuf)))
continue;
/* we now assume we have the proper reply */
break;
}
/*
* now decode and validate the response
*/
xdrmem_create(&reply_xdrs, cu->cu_inbuf, (u_int)inlen, XDR_DECODE);
ok = xdr_replymsg(&reply_xdrs, &reply_msg);
/* XDR_DESTROY(&reply_xdrs); save a few cycles on noop destroy */
if (ok) {
_seterr_reply(&reply_msg, &(cu->cu_error));
if (cu->cu_error.re_status == RPC_SUCCESS) {
if (! AUTH_VALIDATE(cl->cl_auth,
&reply_msg.acpted_rply.ar_verf)) {
cu->cu_error.re_status = RPC_AUTHERROR;
cu->cu_error.re_why = AUTH_INVALIDRESP;
}
if (reply_msg.acpted_rply.ar_verf.oa_base != NULL) {
xdrs->x_op = XDR_FREE;
(void)xdr_opaque_auth(xdrs,
&(reply_msg.acpted_rply.ar_verf));
}
} /* end successful completion */
else {
/* maybe our credentials need to be refreshed ... */
if (nrefreshes > 0 && AUTH_REFRESH(cl->cl_auth)) {
nrefreshes--;
goto call_again;
}
} /* end of unsuccessful completion */
} /* end of valid reply message */
else {
/*
* It's possible for xdr_replymsg() to fail partway
* through its attempt to decode the result from the
* server. If this happens, it will leave the reply
* structure partially populated with dynamically
* allocated memory. (This can happen if someone uses
* clntudp_bufcreate() to create a CLIENT handle and
* specifies a receive buffer size that is too small.)
* This memory must be free()ed to avoid a leak.
*/
int op = reply_xdrs.x_op;
reply_xdrs.x_op = XDR_FREE;
xdr_replymsg(&reply_xdrs, &reply_msg);
reply_xdrs.x_op = op;
cu->cu_error.re_status = RPC_CANTDECODERES;
}
if (fds != &readfds)
free(fds);
return (cu->cu_error.re_status);
}
static void
clntudp_geterr(cl, errp)
CLIENT *cl;
struct rpc_err *errp;
{
register struct cu_data *cu = (struct cu_data *)cl->cl_private;
*errp = cu->cu_error;
}
static bool_t
clntudp_freeres(cl, xdr_res, res_ptr)
CLIENT *cl;
xdrproc_t xdr_res;
caddr_t res_ptr;
{
register struct cu_data *cu = (struct cu_data *)cl->cl_private;
register XDR *xdrs = &(cu->cu_outxdrs);
xdrs->x_op = XDR_FREE;
return ((*xdr_res)(xdrs, res_ptr));
}
static void
clntudp_abort(/*h*/)
/*CLIENT *h;*/
{
}
static bool_t
clntudp_control(cl, request, info)
CLIENT *cl;
int request;
char *info;
{
register struct cu_data *cu = (struct cu_data *)cl->cl_private;
register struct timeval *tv;
int len;
switch (request) {
case CLSET_FD_CLOSE:
cu->cu_closeit = TRUE;
break;
case CLSET_FD_NCLOSE:
cu->cu_closeit = FALSE;
break;
case CLSET_TIMEOUT:
if (info == NULL)
return(FALSE);
tv = (struct timeval *)info;
cu->cu_total.tv_sec = tv->tv_sec;
cu->cu_total.tv_usec = tv->tv_usec;
break;
case CLGET_TIMEOUT:
if (info == NULL)
return(FALSE);
*(struct timeval *)info = cu->cu_total;
break;
case CLSET_RETRY_TIMEOUT:
if (info == NULL)
return(FALSE);
tv = (struct timeval *)info;
cu->cu_wait.tv_sec = tv->tv_sec;
cu->cu_wait.tv_usec = tv->tv_usec;
break;
case CLGET_RETRY_TIMEOUT:
if (info == NULL)
return(FALSE);
*(struct timeval *)info = cu->cu_wait;
break;
case CLGET_SERVER_ADDR:
if (info == NULL)
return(FALSE);
*(struct sockaddr_in *)info = cu->cu_raddr;
break;
case CLGET_FD:
if (info == NULL)
return(FALSE);
*(int *)info = cu->cu_sock;
break;
case CLGET_XID:
/*
* use the knowledge that xid is the
* first element in the call structure *.
* This will get the xid of the PREVIOUS call
*/
if (info == NULL)
return(FALSE);
*(u_long *)info = ntohl(*(u_long *)cu->cu_outbuf);
break;
case CLSET_XID:
/* This will set the xid of the NEXT call */
if (info == NULL)
return(FALSE);
*(u_long *)cu->cu_outbuf = htonl(*(u_long *)info - 1);
/* decrement by 1 as clntudp_call() increments once */
case CLGET_VERS:
/*
* This RELIES on the information that, in the call body,
* the version number field is the fifth field from the
* begining of the RPC header. MUST be changed if the
* call_struct is changed
*/
if (info == NULL)
return(FALSE);
*(u_long *)info = ntohl(*(u_long *)(cu->cu_outbuf +
4 * BYTES_PER_XDR_UNIT));
break;
case CLSET_VERS:
if (info == NULL)
return(FALSE);
*(u_long *)(cu->cu_outbuf + 4 * BYTES_PER_XDR_UNIT)
= htonl(*(u_long *)info);
break;
case CLGET_PROG:
/*
* This RELIES on the information that, in the call body,
* the program number field is the field from the
* begining of the RPC header. MUST be changed if the
* call_struct is changed
*/
if (info == NULL)
return(FALSE);
*(u_long *)info = ntohl(*(u_long *)(cu->cu_outbuf +
3 * BYTES_PER_XDR_UNIT));
break;
case CLSET_PROG:
if (info == NULL)
return(FALSE);
*(u_long *)(cu->cu_outbuf + 3 * BYTES_PER_XDR_UNIT)
= htonl(*(u_long *)info);
break;
case CLGET_LOCAL_ADDR:
len = sizeof(struct sockaddr);
if (getsockname(cu->cu_sock, (struct sockaddr *)info, &len) <0)
return(FALSE);
break;
case CLGET_SVC_ADDR:
case CLSET_SVC_ADDR:
case CLSET_PUSH_TIMOD:
case CLSET_POP_TIMOD:
default:
return (FALSE);
}
return (TRUE);
}
static void
clntudp_destroy(cl)
CLIENT *cl;
{
register struct cu_data *cu = (struct cu_data *)cl->cl_private;
if (cu->cu_closeit) {
(void)_RPC_close(cu->cu_sock);
}
XDR_DESTROY(&(cu->cu_outxdrs));
mem_free((caddr_t)cu, (sizeof(*cu) + cu->cu_sendsz + cu->cu_recvsz));
mem_free((caddr_t)cl, sizeof(CLIENT));
}

View File

@@ -1,635 +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
*/
#if defined(LIBC_SCCS) && !defined(lint)
/*static char *sccsid = "from: @(#)clnt_unix.c 1.37 87/10/05 Copyr 1984 Sun Micro";*/
/*static char *sccsid = "from: @(#)clnt_unix.c 2.2 88/08/01 4.0 RPCSRC";*/
static char *rcsid = "$FreeBSD: src/lib/libc/rpc/clnt_unix.c,v 1.5 2000/01/27 23:06:37 jasone Exp $";
#endif
/*
* clnt_unix.c, Implements a AF_UNIX based, client side RPC.
*
* Copyright (C) 1984, Sun Microsystems, Inc.
*
* AF_UNIX 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 <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <rpc/rpc.h>
#include <sys/uio.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <netdb.h>
#include <errno.h>
#include <rpc/pmap_clnt.h>
#define MCALL_MSG_SIZE 24
static int readunix();
static int writeunix();
static enum clnt_stat clntunix_call();
static void clntunix_abort();
static void clntunix_geterr();
static bool_t clntunix_freeres();
static bool_t clntunix_control();
static void clntunix_destroy();
static struct clnt_ops unix_ops = {
clntunix_call,
clntunix_abort,
clntunix_geterr,
clntunix_freeres,
clntunix_destroy,
clntunix_control
};
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_un 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;
};
/*
* Create a client handle for a unix/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/unix 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 *
clntunix_create(raddr, prog, vers, sockp, sendsz, recvsz)
struct sockaddr_un *raddr;
u_long prog;
u_long vers;
register int *sockp;
u_int sendsz;
u_int recvsz;
{
CLIENT *h;
register struct ct_data *ct = NULL;
struct timeval now;
struct rpc_msg call_msg;
static u_int32_t disrupt;
int len;
if (disrupt == 0)
disrupt = (u_int32_t)(long)raddr;
h = (CLIENT *)mem_alloc(sizeof(*h));
if (h == NULL) {
(void)fprintf(stderr, "clntunix_create: out of memory\n");
rpc_createerr.cf_stat = RPC_SYSTEMERROR;
rpc_createerr.cf_error.re_errno = errno;
goto fooy;
}
ct = (struct ct_data *)mem_alloc(sizeof(*ct));
if (ct == NULL) {
(void)fprintf(stderr, "clntunix_create: out of memory\n");
rpc_createerr.cf_stat = RPC_SYSTEMERROR;
rpc_createerr.cf_error.re_errno = errno;
goto fooy;
}
/*
* If no socket given, open one
*/
if (*sockp < 0) {
*sockp = socket(AF_UNIX, SOCK_STREAM, 0);
len = strlen(raddr->sun_path) + sizeof(raddr->sun_family) +
sizeof(raddr->sun_len) + 1;
raddr->sun_len = len;
if ((*sockp < 0)
|| (connect(*sockp, (struct sockaddr *)raddr, len) < 0)) {
rpc_createerr.cf_stat = RPC_SYSTEMERROR;
rpc_createerr.cf_error.re_errno = errno;
if (*sockp != -1)
(void)_RPC_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
*/
(void)gettimeofday(&now, (struct timezone *)0);
call_msg.rm_xid = (++disrupt) ^ getpid() ^ now.tv_sec ^ now.tv_usec;
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)_RPC_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, readunix, writeunix);
h->cl_ops = &unix_ops;
h->cl_private = (caddr_t) ct;
h->cl_auth = authnone_create();
return (h);
fooy:
/*
* Something goofed, free stuff and barf
*/
if (ct)
mem_free((caddr_t)ct, sizeof(struct ct_data));
if (h)
mem_free((caddr_t)h, sizeof(CLIENT));
return ((CLIENT *)NULL);
}
static enum clnt_stat
clntunix_call(h, proc, xdr_args, args_ptr, xdr_results, results_ptr, timeout)
register CLIENT *h;
u_long proc;
xdrproc_t xdr_args;
caddr_t args_ptr;
xdrproc_t xdr_results;
caddr_t results_ptr;
struct timeval timeout;
{
register struct ct_data *ct = (struct ct_data *) h->cl_private;
register 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 */
register bool_t shipnow;
int refreshes = 2;
if (!ct->ct_waitset) {
ct->ct_wait = timeout;
}
shipnow =
(xdr_results == (xdrproc_t)0 && timeout.tv_sec == 0
&& timeout.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 (timeout.tv_sec == 0 && timeout.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 = xdr_void;
if (! xdrrec_skiprecord(xdrs))
return (ct->ct_error.re_status);
/* now decode and validate the response header */
if (! xdr_replymsg(xdrs, &reply_msg)) {
if (ct->ct_error.re_status == RPC_SUCCESS)
continue;
return (ct->ct_error.re_status);
}
if (reply_msg.rm_xid == x_id)
break;
}
/*
* process header
*/
_seterr_reply(&reply_msg, &(ct->ct_error));
if (ct->ct_error.re_status == RPC_SUCCESS) {
if (! AUTH_VALIDATE(h->cl_auth, &reply_msg.acpted_rply.ar_verf)) {
ct->ct_error.re_status = RPC_AUTHERROR;
ct->ct_error.re_why = AUTH_INVALIDRESP;
} else if (! (*xdr_results)(xdrs, results_ptr)) {
if (ct->ct_error.re_status == RPC_SUCCESS)
ct->ct_error.re_status = RPC_CANTDECODERES;
}
/* free verifier ... */
if (reply_msg.acpted_rply.ar_verf.oa_base != NULL) {
xdrs->x_op = XDR_FREE;
(void)xdr_opaque_auth(xdrs, &(reply_msg.acpted_rply.ar_verf));
}
} /* end successful completion */
else {
/* maybe our credentials need to be refreshed ... */
if (refreshes-- && AUTH_REFRESH(h->cl_auth))
goto call_again;
} /* end of unsuccessful completion */
return (ct->ct_error.re_status);
}
static void
clntunix_geterr(h, errp)
CLIENT *h;
struct rpc_err *errp;
{
register struct ct_data *ct =
(struct ct_data *) h->cl_private;
*errp = ct->ct_error;
}
static bool_t
clntunix_freeres(cl, xdr_res, res_ptr)
CLIENT *cl;
xdrproc_t xdr_res;
caddr_t res_ptr;
{
register struct ct_data *ct = (struct ct_data *)cl->cl_private;
register XDR *xdrs = &(ct->ct_xdrs);
xdrs->x_op = XDR_FREE;
return ((*xdr_res)(xdrs, res_ptr));
}
static void
clntunix_abort()
{
}
static bool_t
clntunix_control(cl, request, info)
CLIENT *cl;
int request;
char *info;
{
register struct ct_data *ct = (struct ct_data *)cl->cl_private;
register struct timeval *tv;
int len;
switch (request) {
case CLSET_FD_CLOSE:
ct->ct_closeit = TRUE;
break;
case CLSET_FD_NCLOSE:
ct->ct_closeit = FALSE;
break;
case CLSET_TIMEOUT:
if (info == NULL)
return(FALSE);
tv = (struct timeval *)info;
ct->ct_wait.tv_sec = tv->tv_sec;
ct->ct_wait.tv_usec = tv->tv_usec;
ct->ct_waitset = TRUE;
break;
case CLGET_TIMEOUT:
if (info == NULL)
return(FALSE);
*(struct timeval *)info = ct->ct_wait;
break;
case CLGET_SERVER_ADDR:
if (info == NULL)
return(FALSE);
*(struct sockaddr_un *)info = ct->ct_addr;
break;
case CLGET_FD:
if (info == NULL)
return(FALSE);
*(int *)info = ct->ct_sock;
break;
case CLGET_XID:
/*
* use the knowledge that xid is the
* first element in the call structure *.
* This will get the xid of the PREVIOUS call
*/
if (info == NULL)
return(FALSE);
*(u_long *)info = ntohl(*(u_long *)ct->ct_mcall);
break;
case CLSET_XID:
/* This will set the xid of the NEXT call */
if (info == NULL)
return(FALSE);
*(u_long *)ct->ct_mcall = htonl(*(u_long *)info - 1);
/* decrement by 1 as clntunix_call() increments once */
case CLGET_VERS:
/*
* This RELIES on the information that, in the call body,
* the version number field is the fifth field from the
* begining of the RPC header. MUST be changed if the
* call_struct is changed
*/
if (info == NULL)
return(FALSE);
*(u_long *)info = ntohl(*(u_long *)(ct->ct_mcall +
4 * BYTES_PER_XDR_UNIT));
break;
case CLSET_VERS:
if (info == NULL)
return(FALSE);
*(u_long *)(ct->ct_mcall + 4 * BYTES_PER_XDR_UNIT)
= htonl(*(u_long *)info);
break;
case CLGET_PROG:
/*
* This RELIES on the information that, in the call body,
* the program number field is the field from the
* begining of the RPC header. MUST be changed if the
* call_struct is changed
*/
if (info == NULL)
return(FALSE);
*(u_long *)info = ntohl(*(u_long *)(ct->ct_mcall +
3 * BYTES_PER_XDR_UNIT));
break;
case CLSET_PROG:
if (info == NULL)
return(FALSE);
*(u_long *)(ct->ct_mcall + 3 * BYTES_PER_XDR_UNIT)
= htonl(*(u_long *)info);
break;
case CLGET_LOCAL_ADDR:
len = sizeof(struct sockaddr);
if (getsockname(ct->ct_sock, (struct sockaddr *)info, &len) <0)
return(FALSE);
break;
case CLGET_RETRY_TIMEOUT:
case CLSET_RETRY_TIMEOUT:
case CLGET_SVC_ADDR:
case CLSET_SVC_ADDR:
case CLSET_PUSH_TIMOD:
case CLSET_POP_TIMOD:
default:
return (FALSE);
}
return (TRUE);
}
static void
clntunix_destroy(h)
CLIENT *h;
{
register struct ct_data *ct =
(struct ct_data *) h->cl_private;
if (ct->ct_closeit) {
(void)_RPC_close(ct->ct_sock);
}
XDR_DESTROY(&(ct->ct_xdrs));
mem_free((caddr_t)ct, sizeof(struct ct_data));
mem_free((caddr_t)h, sizeof(CLIENT));
}
/*
* read() and write() are replaced with recvmsg()/sendmsg() so that
* we can pass ancillary control data. In this case, the data constists
* of credential information which the kernel will fill in for us.
* XXX: This code is specific to FreeBSD and will not work on other
* platforms without the requisite kernel modifications.
*/
struct cmessage {
struct cmsghdr cmsg;
struct cmsgcred cmcred;
};
static int __msgread(sock, buf, cnt)
int sock;
void *buf;
size_t cnt;
{
struct iovec iov[1];
struct msghdr msg;
struct cmessage cm;
bzero((char *)&cm, sizeof(cm));
iov[0].iov_base = buf;
iov[0].iov_len = cnt;
msg.msg_iov = iov;
msg.msg_iovlen = 1;
msg.msg_name = NULL;
msg.msg_namelen = 0;
msg.msg_control = (caddr_t)&cm;
msg.msg_controllen = sizeof(struct cmessage);
msg.msg_flags = 0;
return(recvmsg(sock, &msg, 0));
}
static int __msgwrite(sock, buf, cnt)
int sock;
void *buf;
size_t cnt;
{
struct iovec iov[1];
struct msghdr msg;
struct cmessage cm;
bzero((char *)&cm, sizeof(cm));
iov[0].iov_base = buf;
iov[0].iov_len = cnt;
cm.cmsg.cmsg_type = SCM_CREDS;
cm.cmsg.cmsg_level = SOL_SOCKET;
cm.cmsg.cmsg_len = sizeof(struct cmessage);
msg.msg_iov = iov;
msg.msg_iovlen = 1;
msg.msg_name = NULL;
msg.msg_namelen = 0;
msg.msg_control = (caddr_t)&cm;
msg.msg_controllen = sizeof(struct cmessage);
msg.msg_flags = 0;
return(sendmsg(sock, &msg, 0));
}
/*
* Interface between xdr serializer and unix connection.
* Behaves like the system calls, read & write, but keeps some error state
* around for the rpc level.
*/
static int
readunix(ct, buf, len)
register struct ct_data *ct;
caddr_t buf;
register int len;
{
fd_set *fds, readfds;
struct timeval start, after, duration, delta, tmp, tv;
int r, save_errno;
if (len == 0)
return (0);
if (ct->ct_sock + 1 > FD_SETSIZE) {
int bytes = howmany(ct->ct_sock + 1, NFDBITS) * sizeof(fd_mask);
fds = (fd_set *)malloc(bytes);
if (fds == NULL)
return (-1);
memset(fds, 0, bytes);
} else {
fds = &readfds;
FD_ZERO(fds);
}
gettimeofday(&start, NULL);
delta = ct->ct_wait;
while (TRUE) {
/* XXX we know the other bits are still clear */
FD_SET(ct->ct_sock, fds);
tv = delta; /* in case select writes back */
r = select(ct->ct_sock+1, fds, NULL, NULL, &tv);
save_errno = errno;
gettimeofday(&after, NULL);
timersub(&start, &after, &duration);
timersub(&delta, &duration, &tmp);
delta = tmp;
if (delta.tv_sec < 0 || !timerisset(&delta))
r = 0;
switch (r) {
case 0:
if (fds != &readfds)
free(fds);
ct->ct_error.re_status = RPC_TIMEDOUT;
return (-1);
case -1:
if (errno == EINTR)
continue;
if (fds != &readfds)
free(fds);
ct->ct_error.re_status = RPC_CANTRECV;
ct->ct_error.re_errno = save_errno;
return (-1);
}
break;
}
switch (len = __msgread(ct->ct_sock, buf, len)) {
case 0:
/* premature eof */
ct->ct_error.re_errno = ECONNRESET;
ct->ct_error.re_status = RPC_CANTRECV;
len = -1; /* it's really an error */
break;
case -1:
ct->ct_error.re_errno = errno;
ct->ct_error.re_status = RPC_CANTRECV;
break;
}
return (len);
}
static int
writeunix(ct, buf, len)
struct ct_data *ct;
caddr_t buf;
int len;
{
register int i, cnt;
for (cnt = len; cnt > 0; cnt -= i, buf += i) {
if ((i = __msgwrite(ct->ct_sock, buf, cnt)) == -1) {
ct->ct_error.re_errno = errno;
ct->ct_error.re_status = RPC_CANTSEND;
return (-1);
}
}
return (len);
}

View File

@@ -1,90 +0,0 @@
/*
* Copyright (c) 1996
* Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Bill Paul.
* 4. Neither the name of the author nor the names of any co-contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD: src/lib/libc/rpc/crypt_client.c,v 1.4 1999/08/28 00:00:37 peter Exp $
*/
#include <sys/types.h>
#include <rpc/des_crypt.h>
#include <rpc/des.h>
#include <string.h>
#include <rpcsvc/crypt.h>
#ifndef lint
static const char rcsid[] = "$FreeBSD: src/lib/libc/rpc/crypt_client.c,v 1.4 1999/08/28 00:00:37 peter Exp $";
#endif
#ifndef KEYSERVSOCK
#define KEYSERVSOCK "/var/run/keyservsock"
#endif
int
_des_crypt_call(buf, len, dparms)
char *buf;
int len;
struct desparams *dparms;
{
CLIENT *clnt;
desresp *result_1;
desargs des_crypt_1_arg;
int stat;
clnt = clnt_create(KEYSERVSOCK, CRYPT_PROG, CRYPT_VERS, "unix");
if (clnt == (CLIENT *) NULL) {
return(DESERR_HWERROR);
}
des_crypt_1_arg.desbuf.desbuf_len = len;
des_crypt_1_arg.desbuf.desbuf_val = buf;
des_crypt_1_arg.des_dir = dparms->des_dir;
des_crypt_1_arg.des_mode = dparms->des_mode;
bcopy(dparms->des_ivec, des_crypt_1_arg.des_ivec, 8);
bcopy(dparms->des_key, des_crypt_1_arg.des_key, 8);
result_1 = des_crypt_1(&des_crypt_1_arg, clnt);
if (result_1 == (desresp *) NULL) {
clnt_destroy(clnt);
return(DESERR_HWERROR);
}
stat = result_1->stat;
if (result_1->stat == DESERR_NONE ||
result_1->stat == DESERR_NOHWDEVICE) {
bcopy(result_1->desbuf.desbuf_val, buf, len);
bcopy(result_1->des_ivec, dparms->des_ivec, 8);
}
clnt_freeres(clnt, xdr_desresp, (char *)result_1);
clnt_destroy(clnt);
return(stat);
}

View File

@@ -1,130 +0,0 @@
.\" @(#)des_crypt.3 2.1 88/08/11 4.0 RPCSRC; from 1.16 88/03/02 SMI;
.\" $FreeBSD: src/lib/libc/rpc/des_crypt.3,v 1.4 2000/03/02 09:13:45 sheldonh Exp $
.\"
.TH DES_CRYPT 3 "6 October 1987"
.SH NAME
des_crypt, ecb_crypt, cbc_crypt, des_setparity \- fast DES encryption
.SH SYNOPSIS
.nf
.B #include <des_crypt.h>
.LP
.B int ecb_crypt(key, data, datalen, mode)
.B char *key;
.B char *data;
.B unsigned datalen;
.B unsigned mode;
.LP
.B int cbc_crypt(key, data, datalen, mode, ivec)
.B char *key;
.B char *data;
.B unsigned datalen;
.B unsigned mode;
.B char *ivec;
.LP
.B void des_setparity(key)
.B char *key;
.fi
.SH DESCRIPTION
.IX encryption cbc_crypt "" \fLcbc_crypt\fP
.IX "des encryption" cbc_crypt "DES encryption" \fLcbc_crypt\fP
.IX encryption des_setparity "" \fLdes_setparity\fP
.IX "des encryption" des_setparity "DES encryption" \fLdes_setparity\fP
.B ecb_crypt(\|)
and
.B cbc_crypt(\|)
implement the
.SM NBS
.SM DES
(Data Encryption Standard).
These routines are faster and more general purpose than
.BR crypt (3).
They also are able to utilize
.SM DES
hardware if it is available.
.B ecb_crypt(\|)
encrypts in
.SM ECB
(Electronic Code Book)
mode, which encrypts blocks of data independently.
.B cbc_crypt(\|)
encrypts in
.SM CBC
(Cipher Block Chaining)
mode, which chains together
successive blocks.
.SM CBC
mode protects against insertions, deletions and
substitutions of blocks.
Also, regularities in the clear text will
not appear in the cipher text.
.LP
Here is how to use these routines. The first parameter,
.IR key ,
is the 8-byte encryption key with parity.
To set the key's parity, which for
.SM DES
is in the low bit of each byte, use
.IR des_setparity .
The second parameter,
.IR data ,
contains the data to be encrypted or decrypted.
The
third parameter,
.IR datalen ,
is the length in bytes of
.IR data ,
which must be a multiple of 8. The fourth parameter,
.IR mode ,
is formed by
.SM OR\s0'ing
together some things. For the encryption direction 'or' in either
.SM DES_ENCRYPT
or
.SM DES_DECRYPT\s0.
For software versus hardware
encryption, 'or' in either
.SM DES_HW
or
.SM DES_SW\s0.
If
.SM DES_HW
is specified, and there is no hardware, then the encryption is performed
in software and the routine returns
.SM DESERR_NOHWDEVICE\s0.
For
.IR cbc_crypt ,
the parameter
.I ivec
is the the 8-byte initialization
vector for the chaining. It is updated to the next initialization
vector upon return.
.LP
.SH "SEE ALSO"
.BR des (1),
.BR crypt (3)
.SH DIAGNOSTICS
.PD 0
.TP 20
.SM DESERR_NONE
No error.
.TP
.SM DESERR_NOHWDEVICE
Encryption succeeded, but done in software instead of the requested hardware.
.TP
.SM DESERR_HWERR
An error occurred in the hardware or driver.
.TP
.SM DESERR_BADPARAM
Bad parameter to routine.
.PD
.LP
Given a result status
.IR stat ,
the macro
.SM DES_FAILED\c
.BR ( stat )
is false only for the first two statuses.
.SH RESTRICTIONS
These routines are not available in RPCSRC 4.0.
This information is provided to describe the DES interface expected by
Secure RPC.

View File

@@ -1,153 +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
*/
/*
* des_crypt.c, DES encryption library routines
* Copyright (C) 1986, Sun Microsystems, Inc.
*/
#include <sys/types.h>
#include <rpc/des_crypt.h>
#include <rpc/des.h>
#ifndef lint
/* from: static char sccsid[] = "@(#)des_crypt.c 2.2 88/08/10 4.0 RPCSRC; from 1.13 88/02/08 SMI"; */
static const char rcsid[] = "$FreeBSD: src/lib/libc/rpc/des_crypt.c,v 1.3 1999/08/28 00:00:38 peter Exp $";
#endif
static int common_crypt __P(( char *, char *, register unsigned, unsigned, struct desparams * ));
int (*__des_crypt_LOCAL)() = 0;
extern _des_crypt_call __P(( char *, int, struct desparams * ));
/*
* Copy 8 bytes
*/
#define COPY8(src, dst) { \
register char *a = (char *) dst; \
register char *b = (char *) src; \
*a++ = *b++; *a++ = *b++; *a++ = *b++; *a++ = *b++; \
*a++ = *b++; *a++ = *b++; *a++ = *b++; *a++ = *b++; \
}
/*
* Copy multiple of 8 bytes
*/
#define DESCOPY(src, dst, len) { \
register char *a = (char *) dst; \
register char *b = (char *) src; \
register int i; \
for (i = (int) len; i > 0; i -= 8) { \
*a++ = *b++; *a++ = *b++; *a++ = *b++; *a++ = *b++; \
*a++ = *b++; *a++ = *b++; *a++ = *b++; *a++ = *b++; \
} \
}
/*
* CBC mode encryption
*/
int
cbc_crypt(key, buf, len, mode, ivec)
char *key;
char *buf;
unsigned len;
unsigned mode;
char *ivec;
{
int err;
struct desparams dp;
#ifdef BROKEN_DES
dp.UDES.UDES_buf = buf;
dp.des_mode = ECB;
#else
dp.des_mode = CBC;
#endif
COPY8(ivec, dp.des_ivec);
err = common_crypt(key, buf, len, mode, &dp);
COPY8(dp.des_ivec, ivec);
return(err);
}
/*
* ECB mode encryption
*/
int
ecb_crypt(key, buf, len, mode)
char *key;
char *buf;
unsigned len;
unsigned mode;
{
struct desparams dp;
#ifdef BROKEN_DES
dp.UDES.UDES_buf = buf;
dp.des_mode = CBC;
#else
dp.des_mode = ECB;
#endif
return(common_crypt(key, buf, len, mode, &dp));
}
/*
* Common code to cbc_crypt() & ecb_crypt()
*/
static int
common_crypt(key, buf, len, mode, desp)
char *key;
char *buf;
register unsigned len;
unsigned mode;
register struct desparams *desp;
{
register int desdev;
if ((len % 8) != 0 || len > DES_MAXDATA) {
return(DESERR_BADPARAM);
}
desp->des_dir =
((mode & DES_DIRMASK) == DES_ENCRYPT) ? ENCRYPT : DECRYPT;
desdev = mode & DES_DEVMASK;
COPY8(key, desp->des_key);
/*
* software
*/
if (__des_crypt_LOCAL != NULL) {
if (!__des_crypt_LOCAL(buf, len, desp)) {
return (DESERR_HWERROR);
}
} else {
if (!_des_crypt_call(buf, len, desp)) {
return (DESERR_HWERROR);
}
}
return(desdev == DES_SW ? DESERR_NONE : DESERR_NOHWDEVICE);
}

View File

@@ -1,67 +0,0 @@
#if !defined(lint) && defined(SCCSIDS)
static char sccsid[] = "@(#)des_soft.c 2.2 88/08/10 4.0 RPCSRC; from 1.13 88/02/08 SMI";
#endif
/*
* 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
*/
/*
* Table giving odd parity in the low bit for ASCII characters
*/
static char partab[128] = {
0x01, 0x01, 0x02, 0x02, 0x04, 0x04, 0x07, 0x07,
0x08, 0x08, 0x0b, 0x0b, 0x0d, 0x0d, 0x0e, 0x0e,
0x10, 0x10, 0x13, 0x13, 0x15, 0x15, 0x16, 0x16,
0x19, 0x19, 0x1a, 0x1a, 0x1c, 0x1c, 0x1f, 0x1f,
0x20, 0x20, 0x23, 0x23, 0x25, 0x25, 0x26, 0x26,
0x29, 0x29, 0x2a, 0x2a, 0x2c, 0x2c, 0x2f, 0x2f,
0x31, 0x31, 0x32, 0x32, 0x34, 0x34, 0x37, 0x37,
0x38, 0x38, 0x3b, 0x3b, 0x3d, 0x3d, 0x3e, 0x3e,
0x40, 0x40, 0x43, 0x43, 0x45, 0x45, 0x46, 0x46,
0x49, 0x49, 0x4a, 0x4a, 0x4c, 0x4c, 0x4f, 0x4f,
0x51, 0x51, 0x52, 0x52, 0x54, 0x54, 0x57, 0x57,
0x58, 0x58, 0x5b, 0x5b, 0x5d, 0x5d, 0x5e, 0x5e,
0x61, 0x61, 0x62, 0x62, 0x64, 0x64, 0x67, 0x67,
0x68, 0x68, 0x6b, 0x6b, 0x6d, 0x6d, 0x6e, 0x6e,
0x70, 0x70, 0x73, 0x73, 0x75, 0x75, 0x76, 0x76,
0x79, 0x79, 0x7a, 0x7a, 0x7c, 0x7c, 0x7f, 0x7f,
};
/*
* Add odd parity to low bit of 8 byte key
*/
void
des_setparity(p)
char *p;
{
int i;
for (i = 0; i < 8; i++) {
*p = partab[*p & 0x7f];
p++;
}
}

View File

@@ -1,112 +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
*/
#if defined(LIBC_SCCS) && !defined(lint)
/*static char *sccsid = "from: @(#)get_myaddress.c 1.4 87/08/11 Copyr 1984 Sun Micro";*/
/*static char *sccsid = "from: @(#)get_myaddress.c 2.1 88/07/29 4.0 RPCSRC";*/
static char *rcsid = "$FreeBSD: src/lib/libc/rpc/get_myaddress.c,v 1.17 2000/01/27 23:06:37 jasone Exp $";
#endif
/*
* get_myaddress.c
*
* Get client's IP address via ioctl. This avoids using the yellowpages.
* Copyright (C) 1984, Sun Microsystems, Inc.
*/
#include <rpc/types.h>
#include <rpc/xdr.h>
#include <rpc/pmap_prot.h>
#include <sys/socket.h>
#include <stdio.h>
#include <unistd.h>
#include <net/if.h>
#include <sys/ioctl.h>
#include <netinet/in.h>
#include <arpa/inet.h>
/*
* don't use gethostbyname, which would invoke yellow pages
*
* Avoid loopback interfaces. We return information from a loopback
* interface only if there are no other possible interfaces.
*/
int
get_myaddress(addr)
struct sockaddr_in *addr;
{
int s;
char buf[BUFSIZ];
struct ifconf ifc;
struct ifreq ifreq, *ifr, *end;
int loopback = 0, gotit = 0;
if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
return(-1);
}
ifc.ifc_len = sizeof (buf);
ifc.ifc_buf = buf;
if (ioctl(s, SIOCGIFCONF, (char *)&ifc) < 0) {
_RPC_close(s);
return(-1);
}
again:
ifr = ifc.ifc_req;
end = (struct ifreq *) (ifc.ifc_buf + ifc.ifc_len);
while (ifr < end) {
ifreq = *ifr;
if (ioctl(s, SIOCGIFFLAGS, (char *)&ifreq) < 0) {
_RPC_close(s);
return(-1);
}
if (((ifreq.ifr_flags & IFF_UP) &&
ifr->ifr_addr.sa_family == AF_INET &&
!(ifreq.ifr_flags & IFF_LOOPBACK)) ||
(loopback == 1 && (ifreq.ifr_flags & IFF_LOOPBACK)
&& (ifr->ifr_addr.sa_family == AF_INET)
&& (ifreq.ifr_flags & IFF_UP))) {
*addr = *((struct sockaddr_in *)&ifr->ifr_addr);
addr->sin_port = htons(PMAPPORT);
gotit = 1;
break;
}
if (ifr->ifr_addr.sa_len)
ifr = (struct ifreq *) ((caddr_t) ifr +
ifr->ifr_addr.sa_len -
sizeof(struct sockaddr));
ifr++;
}
if (gotit == 0 && loopback == 0) {
loopback = 1;
goto again;
}
(void)_RPC_close(s);
return (gotit ? 0 : -1);
}

View File

@@ -1,172 +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 or with the express written consent of
* Sun Microsystems, Inc.
*
* 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[] = "@(#)publickey.c 1.10 91/03/11 Copyr 1986 Sun Micro";
#endif
/*
* publickey.c
* Copyright (C) 1986, Sun Microsystems, Inc.
*/
/*
* Public key lookup routines
*/
#include <stdio.h>
#include <pwd.h>
#include <rpc/rpc.h>
#include <rpc/key_prot.h>
#include <rpcsvc/yp_prot.h>
#include <rpcsvc/ypclnt.h>
#include <string.h>
#include <stdlib.h>
#define PKFILE "/etc/publickey"
/*
* Hack to let ypserv/rpc.nisd use AUTH_DES.
*/
int (*__getpublickey_LOCAL)() = 0;
/*
* Get somebody's public key
*/
int
__getpublickey_real(netname, publickey)
char *netname;
char *publickey;
{
char lookup[3 * HEXKEYBYTES];
char *p;
if (publickey == NULL)
return (0);
if (!getpublicandprivatekey(netname, lookup))
return (0);
p = strchr(lookup, ':');
if (p == NULL) {
return (0);
}
*p = '\0';
(void) strncpy(publickey, lookup, HEXKEYBYTES);
publickey[HEXKEYBYTES] = '\0';
return (1);
}
/*
* reads the file /etc/publickey looking for a + to optionally go to the
* yellow pages
*/
int
getpublicandprivatekey(key, ret)
char *key;
char *ret;
{
char buf[1024]; /* big enough */
char *res;
FILE *fd;
char *mkey;
char *mval;
fd = fopen(PKFILE, "r");
if (fd == (FILE *) 0)
return (0);
for (;;) {
res = fgets(buf, 1024, fd);
if (res == 0) {
fclose(fd);
return (0);
}
if (res[0] == '#')
continue;
else if (res[0] == '+') {
#ifdef YP
char *PKMAP = "publickey.byname";
char *lookup;
char *domain;
int err;
int len;
err = yp_get_default_domain(&domain);
if (err) {
continue;
}
lookup = NULL;
err = yp_match(domain, PKMAP, key, strlen(key), &lookup, &len);
if (err) {
#ifdef DEBUG
fprintf(stderr, "match failed error %d\n", err);
#endif
continue;
}
lookup[len] = 0;
strcpy(ret, lookup);
fclose(fd);
free(lookup);
return (2);
#else /* YP */
#ifdef DEBUG
fprintf(stderr,
"Bad record in %s '+' -- NIS not supported in this library copy\n", PKFILE);
#endif /* DEBUG */
continue;
#endif /* YP */
} else {
mkey = strtok(buf, "\t ");
if (mkey == NULL) {
fprintf(stderr,
"Bad record in %s -- %s", PKFILE, buf);
continue;
}
mval = strtok((char *)NULL, " \t#\n");
if (mval == NULL) {
fprintf(stderr,
"Bad record in %s val problem - %s", PKFILE, buf);
continue;
}
if (strcmp(mkey, key) == 0) {
strcpy(ret, mval);
fclose(fd);
return (1);
}
}
}
}
int getpublickey(netname, publickey)
char *netname;
char *publickey;
{
if (__getpublickey_LOCAL != NULL)
return(__getpublickey_LOCAL(netname, publickey));
else
return(__getpublickey_real(netname, publickey));
}

View File

@@ -1,98 +0,0 @@
.\" @(#)getrpcent.3n 2.2 88/08/02 4.0 RPCSRC; from 1.11 88/03/14 SMI
.\" $FreeBSD: src/lib/libc/rpc/getrpcent.3,v 1.11 1999/08/28 00:00:39 peter Exp $
.\"
.Dd December 14, 1987
.Dt GETRPCENT 3
.Os
.Sh NAME
.Nm getrpcent ,
.Nm getrpcbyname ,
.Nm getrpcbynumber ,
.Nm endrpcent ,
.Nm setrpcent
.Nd get RPC entry
.Sh SYNOPSIS
.Fd #include <rpc/rpc.h>
.Ft struct rpcent *
.Fn getrpcent void
.Ft struct rpcent *
.Fn getrpcbyname "char *name"
.Ft struct rpcent *
.Fn getrpcbynumber "int number"
.Ft void
.Fn setrpcent "int stayopen"
.Ft void
.Fn endrpcent void
.Sh DESCRIPTION
The
.Fn getrpcent ,
.Fn getrpcbyname ,
and
.Fn getrpcbynumber
functions each return a pointer to an object with the
following structure
containing the broken-out
fields of a line in the rpc program number data base,
.Pa /etc/rpc .
.Bd -literal
struct rpcent {
char *r_name; /* name of server for this rpc program */
char **r_aliases; /* alias list */
long r_number; /* rpc program number */
};
.Ed
.Pp
The members of this structure are:
.Bl -tag -width r_aliasesxxx
.It Fa r_name
The name of the server for this rpc program.
.It Fa r_aliases
A zero terminated list of alternate names for the rpc program.
.It Fa r_number
The rpc program number for this service.
.El
.Pp
The
.Fn getrpcent
function reads the next line of the file, opening the file if necessary.
The
.Nm getrpcent
function opens and rewinds the file. If the
.Fa stayopen
flag is non-zero,
the net data base will not be closed after each call to
.Fn getrpcent
(either directly, or indirectly through one of
the other
.Fn getrpcent
function family.
.Pp
.Fn endrpcent
closes the file.
.Pp
.Fn getrpcbyname
and
.Fn getrpcbynumber
sequentially search from the beginning
of the file until a matching rpc program name or
program number is found, or until end-of-file is encountered.
.Sh FILES
.Bl -tag -width /etc/rpc -compact
.It Pa /etc/rpc
.El
.Sh "SEE ALSO"
.Xr rpc 5 ,
.Xr rpcinfo 8 ,
.Xr ypserv 8
.Sh DIAGNOSTICS
A
.Dv NULL
pointer is returned on
.Dv EOF
or error.
.Sh BUGS
All information
is contained in a static area
so it must be copied if it is
to be saved.

View File

@@ -1,303 +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 or with the express written consent of
* Sun Microsystems, Inc.
*
* 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(LIBC_SCCS) && !defined(lint)
/*static char *sccsid = "from: @(#)getrpcent.c 1.14 91/03/11 Copyr 1984 Sun Micro";*/
static char *rcsid = "$FreeBSD: src/lib/libc/rpc/getrpcent.c,v 1.10 1999/08/28 00:00:39 peter Exp $";
#endif
/*
* Copyright (c) 1984 by Sun Microsystems, Inc.
*/
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <string.h>
#include <rpc/rpc.h>
#ifdef YP
#include <rpcsvc/yp_prot.h>
#include <rpcsvc/ypclnt.h>
#endif
/*
* Internet version.
*/
struct rpcdata {
FILE *rpcf;
int stayopen;
#define MAXALIASES 35
char *rpc_aliases[MAXALIASES];
struct rpcent rpc;
char line[BUFSIZ+1];
#ifdef YP
char *domain;
char *current;
int currentlen;
#endif
} *rpcdata;
#ifdef YP
static int __yp_nomap = 0;
extern int _yp_check(char **);
#endif /* YP */
static struct rpcent *interpret();
struct hostent *gethostent();
char *inet_ntoa();
static char RPCDB[] = "/etc/rpc";
static struct rpcdata *
_rpcdata()
{
register struct rpcdata *d = rpcdata;
if (d == 0) {
d = (struct rpcdata *)calloc(1, sizeof (struct rpcdata));
rpcdata = d;
}
return (d);
}
struct rpcent *
getrpcbynumber(number)
register int number;
{
register struct rpcdata *d = _rpcdata();
register struct rpcent *p;
#ifdef YP
int reason;
char adrstr[16];
#endif
if (d == 0)
return (0);
#ifdef YP
if (!__yp_nomap && _yp_check(&d->domain)) {
sprintf(adrstr, "%d", number);
reason = yp_match(d->domain, "rpc.bynumber", adrstr, strlen(adrstr),
&d->current, &d->currentlen);
switch(reason) {
case 0:
break;
case YPERR_MAP:
__yp_nomap = 1;
goto no_yp;
break;
default:
return(0);
break;
}
d->current[d->currentlen] = '\0';
p = interpret(d->current, d->currentlen);
(void) free(d->current);
return p;
}
no_yp:
#endif /* YP */
setrpcent(0);
while ((p = getrpcent())) {
if (p->r_number == number)
break;
}
endrpcent();
return (p);
}
struct rpcent *
getrpcbyname(name)
char *name;
{
struct rpcent *rpc = NULL;
char **rp;
setrpcent(0);
while ((rpc = getrpcent())) {
if (strcmp(rpc->r_name, name) == 0)
goto done;
for (rp = rpc->r_aliases; *rp != NULL; rp++) {
if (strcmp(*rp, name) == 0)
goto done;
}
}
done:
endrpcent();
return (rpc);
}
void
setrpcent(f)
int f;
{
register struct rpcdata *d = _rpcdata();
if (d == 0)
return;
#ifdef YP
if (!__yp_nomap && _yp_check(NULL)) {
if (d->current)
free(d->current);
d->current = NULL;
d->currentlen = 0;
return;
}
__yp_nomap = 0;
#endif /* YP */
if (d->rpcf == NULL)
d->rpcf = fopen(RPCDB, "r");
else
rewind(d->rpcf);
d->stayopen |= f;
}
void
endrpcent()
{
register struct rpcdata *d = _rpcdata();
if (d == 0)
return;
#ifdef YP
if (!__yp_nomap && _yp_check(NULL)) {
if (d->current && !d->stayopen)
free(d->current);
d->current = NULL;
d->currentlen = 0;
return;
}
__yp_nomap = 0;
#endif /* YP */
if (d->rpcf && !d->stayopen) {
fclose(d->rpcf);
d->rpcf = NULL;
}
}
struct rpcent *
getrpcent()
{
register struct rpcdata *d = _rpcdata();
#ifdef YP
struct rpcent *hp;
int reason;
char *val = NULL;
int vallen;
#endif
if (d == 0)
return(NULL);
#ifdef YP
if (!__yp_nomap && _yp_check(&d->domain)) {
if (d->current == NULL && d->currentlen == 0) {
reason = yp_first(d->domain, "rpc.bynumber",
&d->current, &d->currentlen,
&val, &vallen);
} else {
reason = yp_next(d->domain, "rpc.bynumber",
d->current, d->currentlen,
&d->current, &d->currentlen,
&val, &vallen);
}
switch(reason) {
case 0:
break;
case YPERR_MAP:
__yp_nomap = 1;
goto no_yp;
break;
default:
return(0);
break;
}
val[vallen] = '\0';
hp = interpret(val, vallen);
(void) free(val);
return hp;
}
no_yp:
#endif /* YP */
if (d->rpcf == NULL && (d->rpcf = fopen(RPCDB, "r")) == NULL)
return (NULL);
/* -1 so there is room to append a \n below */
if (fgets(d->line, BUFSIZ - 1, d->rpcf) == NULL)
return (NULL);
return (interpret(d->line, strlen(d->line)));
}
static struct rpcent *
interpret(val, len)
char *val;
int len;
{
register struct rpcdata *d = _rpcdata();
char *p;
register char *cp, **q;
if (d == 0)
return (0);
(void) strncpy(d->line, val, BUFSIZ);
d->line[BUFSIZ] = '\0';
p = d->line;
p[len] = '\n';
if (*p == '#')
return (getrpcent());
cp = strpbrk(p, "#\n");
if (cp == NULL)
return (getrpcent());
*cp = '\0';
cp = strpbrk(p, " \t");
if (cp == NULL)
return (getrpcent());
*cp++ = '\0';
/* THIS STUFF IS INTERNET SPECIFIC */
d->rpc.r_name = d->line;
while (*cp == ' ' || *cp == '\t')
cp++;
d->rpc.r_number = atoi(cp);
q = d->rpc.r_aliases = d->rpc_aliases;
cp = strpbrk(cp, " \t");
if (cp != NULL)
*cp++ = '\0';
while (cp && *cp) {
if (*cp == ' ' || *cp == '\t') {
cp++;
continue;
}
if (q < &(d->rpc_aliases[MAXALIASES - 1]))
*q++ = cp;
cp = strpbrk(cp, " \t");
if (cp != NULL)
*cp++ = '\0';
}
*q = NULL;
return (&d->rpc);
}

View File

@@ -1,31 +0,0 @@
.\" @(#)getrpcport.3r 2.2 88/08/02 4.0 RPCSRC; from 1.12 88/02/26 SMI
.\" $FreeBSD: src/lib/libc/rpc/getrpcport.3,v 1.6 1999/08/28 00:00:40 peter Exp $
.\"
.Dd October 6, 1987
.Dt GETRPCPORT 3
.Os
.Sh NAME
.Nm getrpcport
.Nd get RPC port number
.Sh SYNOPSIS
.Ft int
.Fn getrpcport "char *host" "int prognum" "int versnum" "int proto"
.Sh DESCRIPTION
.Fn getrpcport
returns the port number for version
.Fa versnum
of the RPC program
.Fa prognum
running on
.Fa host
and using protocol
.Fa proto .
It returns 0 if it cannot contact the portmapper, or if
.Fa prognum
is not registered. If
.Fa prognum
is registered but not with version
.Fa versnum ,
it will still return a port number (for some version of the program)
indicating that the program is indeed registered.
The version mismatch will be detected upon the first call to the service.

View File

@@ -1,63 +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
*/
#if defined(LIBC_SCCS) && !defined(lint)
/*static char *sccsid = "from: @(#)getrpcport.c 1.3 87/08/11 SMI";*/
/*static char *sccsid = "from: @(#)getrpcport.c 2.1 88/07/29 4.0 RPCSRC";*/
static char *rcsid = "$FreeBSD: src/lib/libc/rpc/getrpcport.c,v 1.10 1999/08/28 00:00:40 peter Exp $";
#endif
/*
* Copyright (c) 1985 by Sun Microsystems, Inc.
*/
#include <stdio.h>
#include <string.h>
#include <rpc/rpc.h>
#include <rpc/pmap_clnt.h>
#include <netdb.h>
#include <sys/socket.h>
int
getrpcport(host, prognum, versnum, proto)
char *host;
int prognum, versnum, proto;
{
struct sockaddr_in addr;
struct hostent *hp;
if ((hp = gethostbyname(host)) == NULL)
return (0);
memset(&addr, 0, sizeof(addr));
addr.sin_len = sizeof(struct sockaddr_in);
addr.sin_family = AF_INET;
addr.sin_port = 0;
memcpy((char *)&addr.sin_addr, hp->h_addr, hp->h_length);
return (pmap_getport(&addr, prognum, versnum, proto));
}

View File

@@ -1,427 +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) 1986-1991 by Sun Microsystems Inc.
*
* $FreeBSD: src/lib/libc/rpc/key_call.c,v 1.3 2000/01/27 23:06:39 jasone Exp $
*/
#ident "@(#)key_call.c 1.25 94/04/24 SMI"
/*
* key_call.c, Interface to keyserver
*
* setsecretkey(key) - set your secret key
* encryptsessionkey(agent, deskey) - encrypt a session key to talk to agent
* decryptsessionkey(agent, deskey) - decrypt ditto
* gendeskey(deskey) - generate a secure des key
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <rpc/rpc.h>
#include <rpc/auth.h>
#include <rpc/auth_unix.h>
#include <rpc/key_prot.h>
#include <string.h>
#include <sys/utsname.h>
#include <stdlib.h>
#include <signal.h>
#include <sys/wait.h>
#include <sys/fcntl.h>
#define KEY_TIMEOUT 5 /* per-try timeout in seconds */
#define KEY_NRETRY 12 /* number of retries */
#ifdef DEBUG
#define debug(msg) (void) fprintf(stderr, "%s\n", msg);
#else
#define debug(msg)
#endif /* DEBUG */
/*
* Hack to allow the keyserver to use AUTH_DES (for authenticated
* NIS+ calls, for example). The only functions that get called
* are key_encryptsession_pk, key_decryptsession_pk, and key_gendes.
*
* The approach is to have the keyserver fill in pointers to local
* implementations of these functions, and to call those in key_call().
*/
cryptkeyres *(*__key_encryptsession_pk_LOCAL)() = 0;
cryptkeyres *(*__key_decryptsession_pk_LOCAL)() = 0;
des_block *(*__key_gendes_LOCAL)() = 0;
static int key_call __P(( u_long, xdrproc_t, char *, xdrproc_t, char * ));
int
key_setsecret(secretkey)
const char *secretkey;
{
keystatus status;
if (!key_call((u_long) KEY_SET, xdr_keybuf, (char *) secretkey,
xdr_keystatus, (char *)&status)) {
return (-1);
}
if (status != KEY_SUCCESS) {
debug("set status is nonzero");
return (-1);
}
return (0);
}
/* key_secretkey_is_set() returns 1 if the keyserver has a secret key
* stored for the caller's effective uid; it returns 0 otherwise
*
* N.B.: The KEY_NET_GET key call is undocumented. Applications shouldn't
* be using it, because it allows them to get the user's secret key.
*/
int
key_secretkey_is_set(void)
{
struct key_netstres kres;
memset((void*)&kres, 0, sizeof (kres));
if (key_call((u_long) KEY_NET_GET, xdr_void, (char *)NULL,
xdr_key_netstres, (char *) &kres) &&
(kres.status == KEY_SUCCESS) &&
(kres.key_netstres_u.knet.st_priv_key[0] != 0)) {
/* avoid leaving secret key in memory */
memset(kres.key_netstres_u.knet.st_priv_key, 0, HEXKEYBYTES);
return (1);
}
return (0);
}
int
key_encryptsession_pk(remotename, remotekey, deskey)
char *remotename;
netobj *remotekey;
des_block *deskey;
{
cryptkeyarg2 arg;
cryptkeyres res;
arg.remotename = remotename;
arg.remotekey = *remotekey;
arg.deskey = *deskey;
if (!key_call((u_long)KEY_ENCRYPT_PK, xdr_cryptkeyarg2, (char *)&arg,
xdr_cryptkeyres, (char *)&res)) {
return (-1);
}
if (res.status != KEY_SUCCESS) {
debug("encrypt status is nonzero");
return (-1);
}
*deskey = res.cryptkeyres_u.deskey;
return (0);
}
int
key_decryptsession_pk(remotename, remotekey, deskey)
char *remotename;
netobj *remotekey;
des_block *deskey;
{
cryptkeyarg2 arg;
cryptkeyres res;
arg.remotename = remotename;
arg.remotekey = *remotekey;
arg.deskey = *deskey;
if (!key_call((u_long)KEY_DECRYPT_PK, xdr_cryptkeyarg2, (char *)&arg,
xdr_cryptkeyres, (char *)&res)) {
return (-1);
}
if (res.status != KEY_SUCCESS) {
debug("decrypt status is nonzero");
return (-1);
}
*deskey = res.cryptkeyres_u.deskey;
return (0);
}
int
key_encryptsession(remotename, deskey)
const char *remotename;
des_block *deskey;
{
cryptkeyarg arg;
cryptkeyres res;
arg.remotename = (char *) remotename;
arg.deskey = *deskey;
if (!key_call((u_long)KEY_ENCRYPT, xdr_cryptkeyarg, (char *)&arg,
xdr_cryptkeyres, (char *)&res)) {
return (-1);
}
if (res.status != KEY_SUCCESS) {
debug("encrypt status is nonzero");
return (-1);
}
*deskey = res.cryptkeyres_u.deskey;
return (0);
}
int
key_decryptsession(remotename, deskey)
const char *remotename;
des_block *deskey;
{
cryptkeyarg arg;
cryptkeyres res;
arg.remotename = (char *) remotename;
arg.deskey = *deskey;
if (!key_call((u_long)KEY_DECRYPT, xdr_cryptkeyarg, (char *)&arg,
xdr_cryptkeyres, (char *)&res)) {
return (-1);
}
if (res.status != KEY_SUCCESS) {
debug("decrypt status is nonzero");
return (-1);
}
*deskey = res.cryptkeyres_u.deskey;
return (0);
}
int
key_gendes(key)
des_block *key;
{
if (!key_call((u_long)KEY_GEN, xdr_void, (char *)NULL,
xdr_des_block, (char *)key)) {
return (-1);
}
return (0);
}
int
key_setnet(arg)
struct netstarg *arg;
{
keystatus status;
if (!key_call((u_long) KEY_NET_PUT, xdr_key_netstarg, (char *) arg,
xdr_keystatus, (char *) &status)){
return (-1);
}
if (status != KEY_SUCCESS) {
debug("key_setnet status is nonzero");
return (-1);
}
return (1);
}
int
key_get_conv(pkey, deskey)
char *pkey;
des_block *deskey;
{
cryptkeyres res;
if (!key_call((u_long) KEY_GET_CONV, xdr_keybuf, pkey,
xdr_cryptkeyres, (char *)&res)) {
return (-1);
}
if (res.status != KEY_SUCCESS) {
debug("get_conv status is nonzero");
return (-1);
}
*deskey = res.cryptkeyres_u.deskey;
return (0);
}
struct key_call_private {
CLIENT *client; /* Client handle */
pid_t pid; /* process-id at moment of creation */
uid_t uid; /* user-id at last authorization */
};
static struct key_call_private *key_call_private_main = NULL;
#ifdef foo
static void
key_call_destroy(void *vp)
{
register struct key_call_private *kcp = (struct key_call_private *)vp;
if (kcp) {
if (kcp->client)
clnt_destroy(kcp->client);
free(kcp);
}
}
#endif
/*
* Keep the handle cached. This call may be made quite often.
*/
static CLIENT *
getkeyserv_handle(vers)
int vers;
{
struct key_call_private *kcp = key_call_private_main;
struct timeval wait_time;
int fd;
struct sockaddr_un name;
int namelen = sizeof(struct sockaddr_un);
#define TOTAL_TIMEOUT 30 /* total timeout talking to keyserver */
#define TOTAL_TRIES 5 /* Number of tries */
if (kcp == (struct key_call_private *)NULL) {
kcp = (struct key_call_private *)malloc(sizeof (*kcp));
if (kcp == (struct key_call_private *)NULL) {
return ((CLIENT *) NULL);
}
key_call_private_main = kcp;
kcp->client = NULL;
}
/* if pid has changed, destroy client and rebuild */
if (kcp->client != NULL && kcp->pid != getpid()) {
clnt_destroy(kcp->client);
kcp->client = NULL;
}
if (kcp->client != NULL) {
/* if other side closed socket, build handle again */
clnt_control(kcp->client, CLGET_FD, (char *)&fd);
if (getpeername(fd,(struct sockaddr *)&name,&namelen) == -1) {
auth_destroy(kcp->client->cl_auth);
clnt_destroy(kcp->client);
kcp->client = NULL;
}
}
if (kcp->client != NULL) {
/* if uid has changed, build client handle again */
if (kcp->uid != geteuid()) {
kcp->uid = geteuid();
auth_destroy(kcp->client->cl_auth);
kcp->client->cl_auth =
authsys_create("", kcp->uid, 0, 0, NULL);
if (kcp->client->cl_auth == NULL) {
clnt_destroy(kcp->client);
kcp->client = NULL;
return ((CLIENT *) NULL);
}
}
/* Change the version number to the new one */
clnt_control(kcp->client, CLSET_VERS, (void *)&vers);
return (kcp->client);
}
if ((kcp->client == (CLIENT *) NULL))
/* Use the AF_UNIX transport */
kcp->client = clnt_create("/var/run/keyservsock", KEY_PROG,
vers, "unix");
if (kcp->client == (CLIENT *) NULL) {
return ((CLIENT *) NULL);
}
kcp->uid = geteuid();
kcp->pid = getpid();
kcp->client->cl_auth = authsys_create("", kcp->uid, 0, 0, NULL);
if (kcp->client->cl_auth == NULL) {
clnt_destroy(kcp->client);
kcp->client = NULL;
return ((CLIENT *) NULL);
}
wait_time.tv_sec = TOTAL_TIMEOUT/TOTAL_TRIES;
wait_time.tv_usec = 0;
(void) clnt_control(kcp->client, CLSET_RETRY_TIMEOUT,
(char *)&wait_time);
if (clnt_control(kcp->client, CLGET_FD, (char *)&fd))
_fcntl(fd, F_SETFD, 1); /* make it "close on exec" */
return (kcp->client);
}
/* returns 0 on failure, 1 on success */
static int
key_call(proc, xdr_arg, arg, xdr_rslt, rslt)
u_long proc;
xdrproc_t xdr_arg;
char *arg;
xdrproc_t xdr_rslt;
char *rslt;
{
CLIENT *clnt;
struct timeval wait_time;
if (proc == KEY_ENCRYPT_PK && __key_encryptsession_pk_LOCAL) {
cryptkeyres *res;
res = (*__key_encryptsession_pk_LOCAL)(geteuid(), arg);
*(cryptkeyres*)rslt = *res;
return (1);
} else if (proc == KEY_DECRYPT_PK && __key_decryptsession_pk_LOCAL) {
cryptkeyres *res;
res = (*__key_decryptsession_pk_LOCAL)(geteuid(), arg);
*(cryptkeyres*)rslt = *res;
return (1);
} else if (proc == KEY_GEN && __key_gendes_LOCAL) {
des_block *res;
res = (*__key_gendes_LOCAL)(geteuid(), 0);
*(des_block*)rslt = *res;
return (1);
}
if ((proc == KEY_ENCRYPT_PK) || (proc == KEY_DECRYPT_PK) ||
(proc == KEY_NET_GET) || (proc == KEY_NET_PUT) ||
(proc == KEY_GET_CONV))
clnt = getkeyserv_handle(2); /* talk to version 2 */
else
clnt = getkeyserv_handle(1); /* talk to version 1 */
if (clnt == NULL) {
return (0);
}
wait_time.tv_sec = TOTAL_TIMEOUT;
wait_time.tv_usec = 0;
if (clnt_call(clnt, proc, xdr_arg, arg, xdr_rslt, rslt,
wait_time) == RPC_SUCCESS) {
return (1);
} else {
return (0);
}
}

View File

@@ -1,166 +0,0 @@
/*
* Please do not edit this file.
* It was generated using rpcgen.
*/
#include <rpc/key_prot.h>
/*
* 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
*/
#pragma ident "@(#)key_prot.x 1.7 94/04/29 SMI"
/* Copyright (c) 1990, 1991 Sun Microsystems, Inc. */
/*
* Compiled from key_prot.x using rpcgen.
* DO NOT EDIT THIS FILE!
* This is NOT source code!
*/
bool_t
xdr_keystatus(register XDR *xdrs, keystatus *objp)
{
if (!xdr_enum(xdrs, (enum_t *)objp))
return (FALSE);
return (TRUE);
}
bool_t
xdr_keybuf(register XDR *xdrs, keybuf objp)
{
if (!xdr_opaque(xdrs, objp, HEXKEYBYTES))
return (FALSE);
return (TRUE);
}
bool_t
xdr_netnamestr(register XDR *xdrs, netnamestr *objp)
{
if (!xdr_string(xdrs, objp, MAXNETNAMELEN))
return (FALSE);
return (TRUE);
}
bool_t
xdr_cryptkeyarg(register XDR *xdrs, cryptkeyarg *objp)
{
if (!xdr_netnamestr(xdrs, &objp->remotename))
return (FALSE);
if (!xdr_des_block(xdrs, &objp->deskey))
return (FALSE);
return (TRUE);
}
bool_t
xdr_cryptkeyarg2(register XDR *xdrs, cryptkeyarg2 *objp)
{
if (!xdr_netnamestr(xdrs, &objp->remotename))
return (FALSE);
if (!xdr_netobj(xdrs, &objp->remotekey))
return (FALSE);
if (!xdr_des_block(xdrs, &objp->deskey))
return (FALSE);
return (TRUE);
}
bool_t
xdr_cryptkeyres(register XDR *xdrs, cryptkeyres *objp)
{
if (!xdr_keystatus(xdrs, &objp->status))
return (FALSE);
switch (objp->status) {
case KEY_SUCCESS:
if (!xdr_des_block(xdrs, &objp->cryptkeyres_u.deskey))
return (FALSE);
break;
}
return (TRUE);
}
bool_t
xdr_unixcred(register XDR *xdrs, unixcred *objp)
{
if (!xdr_u_int(xdrs, &objp->uid))
return (FALSE);
if (!xdr_u_int(xdrs, &objp->gid))
return (FALSE);
if (!xdr_array(xdrs, (char **)&objp->gids.gids_val, (u_int *) &objp->gids.gids_len, MAXGIDS,
sizeof (u_int), (xdrproc_t) xdr_u_int))
return (FALSE);
return (TRUE);
}
bool_t
xdr_getcredres(register XDR *xdrs, getcredres *objp)
{
if (!xdr_keystatus(xdrs, &objp->status))
return (FALSE);
switch (objp->status) {
case KEY_SUCCESS:
if (!xdr_unixcred(xdrs, &objp->getcredres_u.cred))
return (FALSE);
break;
}
return (TRUE);
}
bool_t
xdr_key_netstarg(register XDR *xdrs, key_netstarg *objp)
{
if (!xdr_keybuf(xdrs, objp->st_priv_key))
return (FALSE);
if (!xdr_keybuf(xdrs, objp->st_pub_key))
return (FALSE);
if (!xdr_netnamestr(xdrs, &objp->st_netname))
return (FALSE);
return (TRUE);
}
bool_t
xdr_key_netstres(register XDR *xdrs, key_netstres *objp)
{
if (!xdr_keystatus(xdrs, &objp->status))
return (FALSE);
switch (objp->status) {
case KEY_SUCCESS:
if (!xdr_key_netstarg(xdrs, &objp->key_netstres_u.knet))
return (FALSE);
break;
}
return (TRUE);
}

View File

@@ -1,136 +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 or with the express written consent of
* Sun Microsystems, Inc.
*
* 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[] = "@(#)netname.c 1.8 91/03/11 Copyr 1986 Sun Micro";
#endif
/*
* netname utility routines
* convert from unix names to network names and vice-versa
* This module is operating system dependent!
* What we define here will work with any unix system that has adopted
* the sun NIS domain architecture.
*/
#include <sys/param.h>
#include <rpc/rpc.h>
#include <rpc/rpc_com.h>
#ifdef YP
#include <rpcsvc/yp_prot.h>
#include <rpcsvc/ypclnt.h>
#endif
#include <ctype.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <stdio.h>
#ifndef MAXHOSTNAMELEN
#define MAXHOSTNAMELEN 256
#endif
#ifndef NGROUPS
#define NGROUPS 16
#endif
static char *OPSYS = "unix";
/*
* Figure out my fully qualified network name
*/
int
getnetname(name)
char name[MAXNETNAMELEN+1];
{
uid_t uid;
uid = geteuid();
if (uid == 0) {
return (host2netname(name, (char *) NULL, (char *) NULL));
} else {
return (user2netname(name, uid, (char *) NULL));
}
}
/*
* Convert unix cred to network-name
*/
int
user2netname(netname, uid, domain)
char netname[MAXNETNAMELEN + 1];
uid_t uid;
char *domain;
{
char *dfltdom;
#define MAXIPRINT (11) /* max length of printed integer */
if (domain == NULL) {
if (_rpc_get_default_domain(&dfltdom) != 0) {
return (0);
}
domain = dfltdom;
}
if (strlen(domain) + 1 + MAXIPRINT > MAXNETNAMELEN) {
return (0);
}
(void) sprintf(netname, "%s.%ld@%s", OPSYS, (u_long)uid, domain);
return (1);
}
/*
* Convert host to network-name
*/
int
host2netname(netname, host, domain)
char netname[MAXNETNAMELEN + 1];
char *host;
char *domain;
{
char *dfltdom;
char hostname[MAXHOSTNAMELEN+1];
if (domain == NULL) {
if (_rpc_get_default_domain(&dfltdom) != 0) {
return (0);
}
domain = dfltdom;
}
if (host == NULL) {
(void) gethostname(hostname, sizeof(hostname));
host = hostname;
}
if (strlen(domain) + 1 + strlen(host) > MAXNETNAMELEN) {
return (0);
}
(void) sprintf(netname, "%s.%s@%s", OPSYS, host, domain);
return (1);
}

View File

@@ -1,326 +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 or with the express written consent of
* Sun Microsystems, Inc.
*
* 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[] = "@(#)netnamer.c 1.13 91/03/11 Copyr 1986 Sun Micro";
#endif
/*
* netname utility routines convert from unix names to network names and
* vice-versa This module is operating system dependent! What we define here
* will work with any unix system that has adopted the sun NIS domain
* architecture.
*/
#include <sys/param.h>
#include <rpc/rpc.h>
#include <rpc/rpc_com.h>
#ifdef YP
#include <rpcsvc/yp_prot.h>
#include <rpcsvc/ypclnt.h>
#endif
#include <ctype.h>
#include <stdio.h>
#include <grp.h>
#include <pwd.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
static char *OPSYS = "unix";
#ifdef YP
static char *NETID = "netid.byname";
#endif
static char *NETIDFILE = "/etc/netid";
static int getnetid __P(( char *, char * ));
static int _getgroups __P(( char *, gid_t * ));
#ifndef NGROUPS
#define NGROUPS 16
#endif
/*
* Convert network-name into unix credential
*/
int
netname2user(netname, uidp, gidp, gidlenp, gidlist)
char netname[MAXNETNAMELEN + 1];
uid_t *uidp;
gid_t *gidp;
int *gidlenp;
gid_t *gidlist;
{
char *p;
int gidlen;
uid_t uid;
long luid;
struct passwd *pwd;
char val[1024];
char *val1, *val2;
char *domain;
int vallen;
int err;
if (getnetid(netname, val)) {
p = strtok(val, ":");
if (p == NULL)
return (0);
*uidp = (uid_t) atol(val);
p = strtok(NULL, "\n,");
*gidp = (gid_t) atol(p);
if (p == NULL) {
return (0);
}
gidlen = 0;
for (gidlen = 0; gidlen < NGROUPS; gidlen++) {
p = strtok(NULL, "\n,");
if (p == NULL)
break;
gidlist[gidlen] = (gid_t) atol(p);
}
*gidlenp = gidlen;
return (1);
}
val1 = strchr(netname, '.');
if (val1 == NULL)
return (0);
if (strncmp(netname, OPSYS, (val1-netname)))
return (0);
val1++;
val2 = strchr(val1, '@');
if (val2 == NULL)
return (0);
vallen = val2 - val1;
if (vallen > (1024 - 1))
vallen = 1024 - 1;
(void) strncpy(val, val1, 1024);
val[vallen] = 0;
err = _rpc_get_default_domain(&domain); /* change to rpc */
if (err)
return (0);
if (strcmp(val2 + 1, domain))
return (0); /* wrong domain */
if (sscanf(val, "%ld", &luid) != 1)
return (0);
uid = luid;
/* use initgroups method */
pwd = getpwuid(uid);
if (pwd == NULL)
return (0);
*uidp = pwd->pw_uid;
*gidp = pwd->pw_gid;
*gidlenp = _getgroups(pwd->pw_name, gidlist);
return (1);
}
/*
* initgroups
*/
static int
_getgroups(uname, groups)
char *uname;
gid_t groups[NGROUPS];
{
gid_t ngroups = 0;
register struct group *grp;
register int i;
register int j;
int filter;
setgrent();
while ((grp = getgrent())) {
for (i = 0; grp->gr_mem[i]; i++)
if (!strcmp(grp->gr_mem[i], uname)) {
if (ngroups == NGROUPS) {
#ifdef DEBUG
fprintf(stderr,
"initgroups: %s is in too many groups\n", uname);
#endif
goto toomany;
}
/* filter out duplicate group entries */
filter = 0;
for (j = 0; j < ngroups; j++)
if (groups[j] == grp->gr_gid) {
filter++;
break;
}
if (!filter)
groups[ngroups++] = grp->gr_gid;
}
}
toomany:
endgrent();
return (ngroups);
}
/*
* Convert network-name to hostname
*/
int
netname2host(netname, hostname, hostlen)
char netname[MAXNETNAMELEN + 1];
char *hostname;
int hostlen;
{
int err;
char valbuf[1024];
char *val;
char *val2;
int vallen;
char *domain;
if (getnetid(netname, valbuf)) {
val = valbuf;
if ((*val == '0') && (val[1] == ':')) {
(void) strncpy(hostname, val + 2, hostlen);
return (1);
}
}
val = strchr(netname, '.');
if (val == NULL)
return (0);
if (strncmp(netname, OPSYS, (val - netname)))
return (0);
val++;
val2 = strchr(val, '@');
if (val2 == NULL)
return (0);
vallen = val2 - val;
if (vallen > (hostlen - 1))
vallen = hostlen - 1;
(void) strncpy(hostname, val, vallen);
hostname[vallen] = 0;
err = _rpc_get_default_domain(&domain); /* change to rpc */
if (err)
return (0);
if (strcmp(val2 + 1, domain))
return (0); /* wrong domain */
else
return (1);
}
/*
* reads the file /etc/netid looking for a + to optionally go to the
* network information service.
*/
int
getnetid(key, ret)
char *key, *ret;
{
char buf[1024]; /* big enough */
char *res;
char *mkey;
char *mval;
FILE *fd;
#ifdef YP
char *domain;
int err;
char *lookup;
int len;
#endif
fd = fopen(NETIDFILE, "r");
if (fd == (FILE *) 0) {
#ifdef YP
res = "+";
goto getnetidyp;
#else
return (0);
#endif
}
for (;;) {
if (fd == (FILE *) 0)
return (0); /* getnetidyp brings us here */
res = fgets(buf, 1024, fd);
if (res == 0) {
fclose(fd);
return (0);
}
if (res[0] == '#')
continue;
else if (res[0] == '+') {
#ifdef YP
getnetidyp:
err = yp_get_default_domain(&domain);
if (err) {
continue;
}
lookup = NULL;
err = yp_match(domain, NETID, key,
strlen(key), &lookup, &len);
if (err) {
#ifdef DEBUG
fprintf(stderr, "match failed error %d\n", err);
#endif
continue;
}
lookup[len] = 0;
strcpy(ret, lookup);
free(lookup);
if (fd != NULL)
fclose(fd);
return (2);
#else /* YP */
#ifdef DEBUG
fprintf(stderr,
"Bad record in %s '+' -- NIS not supported in this library copy\n",
NETIDFILE);
#endif
continue;
#endif /* YP */
} else {
mkey = strtok(buf, "\t ");
if (mkey == NULL) {
fprintf(stderr,
"Bad record in %s -- %s", NETIDFILE, buf);
continue;
}
mval = strtok(NULL, " \t#\n");
if (mval == NULL) {
fprintf(stderr,
"Bad record in %s val problem - %s", NETIDFILE, buf);
continue;
}
if (strcmp(mkey, key) == 0) {
strcpy(ret, mval);
fclose(fd);
return (1);
}
}
}
}

View File

@@ -1,149 +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
*/
#if defined(LIBC_SCCS) && !defined(lint)
/*static char *sccsid = "from: @(#)pmap_clnt.c 1.37 87/08/11 Copyr 1984 Sun Micro";*/
/*static char *sccsid = "from: @(#)pmap_clnt.c 2.2 88/08/01 4.0 RPCSRC";*/
static char *rcsid = "$FreeBSD: src/lib/libc/rpc/pmap_clnt.c,v 1.11 2000/01/27 23:06:39 jasone Exp $";
#endif
/*
* pmap_clnt.c
* Client interface to pmap rpc service.
*
* Copyright (C) 1984, Sun Microsystems, Inc.
*/
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <rpc/rpc.h>
#include <rpc/pmap_prot.h>
#include <rpc/pmap_clnt.h>
#include <netinet/in.h>
static struct timeval timeout = { 5, 0 };
static struct timeval tottimeout = { 60, 0 };
void clnt_perror();
#ifndef PORTMAPSOCK
#define PORTMAPSOCK "/var/run/portmapsock"
#endif
/*
* Set a mapping between program,version and port.
* Calls the pmap service remotely to do the mapping.
*/
bool_t
pmap_set(program, version, protocol, port)
u_long program;
u_long version;
int protocol;
u_short port;
{
struct sockaddr_in myaddress;
int socket = -1;
register CLIENT *client;
struct pmap parms;
bool_t rslt;
struct stat st;
/*
* Temporary hack for backwards compatibility. Eventually
* this test will go away and we'll use only the "unix" transport.
*/
if (stat(PORTMAPSOCK, &st) == 0 && st.st_mode & S_IFSOCK)
client = clnt_create(PORTMAPSOCK, PMAPPROG, PMAPVERS, "unix");
else {
if (get_myaddress(&myaddress) != 0)
return (FALSE);
myaddress.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
client = clntudp_bufcreate(&myaddress, PMAPPROG, PMAPVERS,
timeout, &socket, RPCSMALLMSGSIZE, RPCSMALLMSGSIZE);
}
if (client == (CLIENT *)NULL)
return (FALSE);
parms.pm_prog = program;
parms.pm_vers = version;
parms.pm_prot = protocol;
parms.pm_port = port;
if (CLNT_CALL(client, PMAPPROC_SET, xdr_pmap, &parms, xdr_bool, &rslt,
tottimeout) != RPC_SUCCESS) {
clnt_perror(client, "Cannot register service");
return (FALSE);
}
CLNT_DESTROY(client);
if (socket != -1)
(void)_RPC_close(socket);
return (rslt);
}
/*
* Remove the mapping between program,version and port.
* Calls the pmap service remotely to do the un-mapping.
*/
bool_t
pmap_unset(program, version)
u_long program;
u_long version;
{
struct sockaddr_in myaddress;
int socket = -1;
register CLIENT *client;
struct pmap parms;
bool_t rslt;
struct stat st;
/*
* Temporary hack for backwards compatibility. Eventually
* this test will go away and we'll use only the "unix" transport.
*/
if (stat(PORTMAPSOCK, &st) == 0 && st.st_mode & S_IFSOCK)
client = clnt_create(PORTMAPSOCK, PMAPPROG, PMAPVERS, "unix");
else {
if (get_myaddress(&myaddress) != 0)
return (FALSE);
myaddress.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
client = clntudp_bufcreate(&myaddress, PMAPPROG, PMAPVERS,
timeout, &socket, RPCSMALLMSGSIZE, RPCSMALLMSGSIZE);
}
if (client == (CLIENT *)NULL)
return (FALSE);
parms.pm_prog = program;
parms.pm_vers = version;
parms.pm_port = parms.pm_prot = 0;
CLNT_CALL(client, PMAPPROC_UNSET, xdr_pmap, &parms, xdr_bool, &rslt,
tottimeout);
CLNT_DESTROY(client);
if (socket != -1)
(void)_RPC_close(socket);
return (rslt);
}

View File

@@ -1,86 +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
*/
#if defined(LIBC_SCCS) && !defined(lint)
/*static char *sccsid = "from: @(#)pmap_getmaps.c 1.10 87/08/11 Copyr 1984 Sun Micro";*/
/*static char *sccsid = "from: @(#)pmap_getmaps.c 2.2 88/08/01 4.0 RPCSRC";*/
static char *rcsid = "$FreeBSD: src/lib/libc/rpc/pmap_getmaps.c,v 1.11 2000/01/27 23:06:39 jasone Exp $";
#endif
/*
* pmap_getmap.c
* Client interface to pmap rpc service.
* contains pmap_getmaps, which is only tcp service involved
*
* Copyright (C) 1984, Sun Microsystems, Inc.
*/
#include <rpc/rpc.h>
#include <rpc/pmap_prot.h>
#include <rpc/pmap_clnt.h>
#include <sys/socket.h>
#include <netdb.h>
#include <stdio.h>
#include <unistd.h>
#include <errno.h>
#include <net/if.h>
#include <sys/ioctl.h>
#define NAMELEN 255
#define MAX_BROADCAST_SIZE 1400
/*
* Get a copy of the current port maps.
* Calls the pmap service remotely to do get the maps.
*/
struct pmaplist *
pmap_getmaps(address)
struct sockaddr_in *address;
{
struct pmaplist *head = (struct pmaplist *)NULL;
int socket = -1;
struct timeval minutetimeout;
register CLIENT *client;
minutetimeout.tv_sec = 60;
minutetimeout.tv_usec = 0;
address->sin_port = htons(PMAPPORT);
client = clnttcp_create(address, PMAPPROG,
PMAPVERS, &socket, 50, 500);
if (client != (CLIENT *)NULL) {
if (CLNT_CALL(client, PMAPPROC_DUMP, xdr_void, NULL, xdr_pmaplist,
&head, minutetimeout) != RPC_SUCCESS) {
clnt_perror(client, "pmap_getmaps rpc problem");
}
CLNT_DESTROY(client);
}
if (socket != -1)
(void)_RPC_close(socket);
address->sin_port = 0;
return (head);
}

View File

@@ -1,91 +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
*/
#if defined(LIBC_SCCS) && !defined(lint)
/*static char *sccsid = "from: @(#)pmap_getport.c 1.9 87/08/11 Copyr 1984 Sun Micro";*/
/*static char *sccsid = "from: @(#)pmap_getport.c 2.2 88/08/01 4.0 RPCSRC";*/
static char *rcsid = "$FreeBSD: src/lib/libc/rpc/pmap_getport.c,v 1.10 2000/01/27 23:06:40 jasone Exp $";
#endif
/*
* pmap_getport.c
* Client interface to pmap rpc service.
*
* Copyright (C) 1984, Sun Microsystems, Inc.
*/
#include <rpc/rpc.h>
#include <rpc/pmap_prot.h>
#include <rpc/pmap_clnt.h>
#include <sys/socket.h>
#include <net/if.h>
#include <unistd.h>
static struct timeval timeout = { 5, 0 };
static struct timeval tottimeout = { 60, 0 };
/*
* Find the mapped port for program,version.
* Calls the pmap service remotely to do the lookup.
* Returns 0 if no map exists.
*/
u_short
pmap_getport(address, program, version, protocol)
struct sockaddr_in *address;
u_long program;
u_long version;
u_int protocol;
{
u_short port = 0;
int socket = -1;
register CLIENT *client;
struct pmap parms;
address->sin_port = htons(PMAPPORT);
client = clntudp_bufcreate(address, PMAPPROG,
PMAPVERS, timeout, &socket, RPCSMALLMSGSIZE, RPCSMALLMSGSIZE);
if (client != (CLIENT *)NULL) {
parms.pm_prog = program;
parms.pm_vers = version;
parms.pm_prot = protocol;
parms.pm_port = 0; /* not needed or used */
if (CLNT_CALL(client, PMAPPROC_GETPORT, xdr_pmap, &parms,
xdr_u_short, &port, tottimeout) != RPC_SUCCESS){
rpc_createerr.cf_stat = RPC_PMAPFAILURE;
clnt_geterr(client, &rpc_createerr.cf_error);
} else if (port == 0) {
rpc_createerr.cf_stat = RPC_PROGNOTREGISTERED;
}
CLNT_DESTROY(client);
}
if (socket != -1)
(void)_RPC_close(socket);
address->sin_port = 0;
return (port);
}

Some files were not shown because too many files have changed in this diff Show More