Home | History | Annotate | Line # | Download | only in rpc
auth.h revision 1.13
      1  1.13   mycroft /*	$NetBSD: auth.h,v 1.13 1998/07/26 11:37:23 mycroft Exp $	*/
      2   1.5       cgd 
      3   1.1   deraadt /*
      4   1.1   deraadt  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
      5   1.1   deraadt  * unrestricted use provided that this legend is included on all tape
      6   1.1   deraadt  * media and as a part of the software program in whole or part.  Users
      7   1.1   deraadt  * may copy or modify Sun RPC without charge, but are not authorized
      8   1.1   deraadt  * to license or distribute it to anyone else except as part of a product or
      9   1.1   deraadt  * program developed by the user.
     10   1.1   deraadt  *
     11   1.1   deraadt  * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
     12   1.1   deraadt  * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
     13   1.1   deraadt  * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
     14   1.1   deraadt  *
     15   1.1   deraadt  * Sun RPC is provided with no support and without any obligation on the
     16   1.1   deraadt  * part of Sun Microsystems, Inc. to assist in its use, correction,
     17   1.1   deraadt  * modification or enhancement.
     18   1.1   deraadt  *
     19   1.1   deraadt  * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
     20   1.1   deraadt  * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
     21   1.1   deraadt  * OR ANY PART THEREOF.
     22   1.1   deraadt  *
     23   1.1   deraadt  * In no event will Sun Microsystems, Inc. be liable for any lost revenue
     24   1.1   deraadt  * or profits or other special, indirect and consequential damages, even if
     25   1.1   deraadt  * Sun has been advised of the possibility of such damages.
     26   1.1   deraadt  *
     27   1.1   deraadt  * Sun Microsystems, Inc.
     28   1.1   deraadt  * 2550 Garcia Avenue
     29   1.1   deraadt  * Mountain View, California  94043
     30   1.3   mycroft  *
     31   1.3   mycroft  *	from: @(#)auth.h 1.17 88/02/08 SMI
     32   1.5       cgd  *	@(#)auth.h	2.3 88/08/07 4.0 RPCSRC
     33   1.1   deraadt  */
     34   1.1   deraadt 
     35   1.1   deraadt /*
     36   1.1   deraadt  * auth.h, Authentication interface.
     37   1.1   deraadt  *
     38   1.1   deraadt  * Copyright (C) 1984, Sun Microsystems, Inc.
     39   1.1   deraadt  *
     40   1.1   deraadt  * The data structures are completely opaque to the client.  The client
     41   1.1   deraadt  * is required to pass a AUTH * to routines that create rpc
     42   1.1   deraadt  * "sessions".
     43   1.1   deraadt  */
     44   1.1   deraadt 
     45   1.9     perry #ifndef _RPC_AUTH_H_
     46   1.9     perry #define _RPC_AUTH_H_
     47   1.2    brezak #include <sys/cdefs.h>
     48   1.1   deraadt 
     49   1.1   deraadt #define MAX_AUTH_BYTES	400
     50   1.1   deraadt #define MAXNETNAMELEN	255	/* maximum length of network user's name */
     51   1.1   deraadt 
     52   1.1   deraadt /*
     53   1.1   deraadt  * Status returned from authentication check
     54   1.1   deraadt  */
     55   1.1   deraadt enum auth_stat {
     56   1.1   deraadt 	AUTH_OK=0,
     57   1.1   deraadt 	/*
     58   1.1   deraadt 	 * failed at remote end
     59   1.1   deraadt 	 */
     60   1.1   deraadt 	AUTH_BADCRED=1,			/* bogus credentials (seal broken) */
     61   1.1   deraadt 	AUTH_REJECTEDCRED=2,		/* client should begin new session */
     62   1.1   deraadt 	AUTH_BADVERF=3,			/* bogus verifier (seal broken) */
     63   1.1   deraadt 	AUTH_REJECTEDVERF=4,		/* verifier expired or was replayed */
     64   1.1   deraadt 	AUTH_TOOWEAK=5,			/* rejected due to security reasons */
     65   1.1   deraadt 	/*
     66   1.1   deraadt 	 * failed locally
     67   1.1   deraadt 	*/
     68   1.1   deraadt 	AUTH_INVALIDRESP=6,		/* bogus response verifier */
     69   1.1   deraadt 	AUTH_FAILED=7			/* some unknown reason */
     70   1.1   deraadt };
     71   1.1   deraadt 
     72   1.7       cgd typedef u_int32_t u_int32;	/* 32-bit unsigned integers */
     73   1.1   deraadt 
     74   1.1   deraadt union des_block {
     75   1.1   deraadt 	struct {
     76   1.1   deraadt 		u_int32 high;
     77   1.1   deraadt 		u_int32 low;
     78   1.1   deraadt 	} key;
     79   1.1   deraadt 	char c[8];
     80   1.1   deraadt };
     81   1.1   deraadt typedef union des_block des_block;
     82   1.2    brezak __BEGIN_DECLS
     83   1.2    brezak extern bool_t xdr_des_block __P((XDR *, des_block *));
     84   1.2    brezak __END_DECLS
     85   1.1   deraadt 
     86   1.1   deraadt /*
     87   1.1   deraadt  * Authentication info.  Opaque to client.
     88   1.1   deraadt  */
     89   1.1   deraadt struct opaque_auth {
     90  1.12     lukem 	enum_t	oa_flavor;		/* flavor of auth */
     91  1.12     lukem 	caddr_t	oa_base;		/* address of more auth stuff */
     92  1.12     lukem 	u_int	oa_length;		/* not to exceed MAX_AUTH_BYTES */
     93   1.1   deraadt };
     94   1.1   deraadt 
     95   1.1   deraadt 
     96   1.1   deraadt /*
     97   1.1   deraadt  * Auth handle, interface to client side authenticators.
     98   1.1   deraadt  */
     99   1.6       cgd typedef struct __rpc_auth {
    100   1.1   deraadt 	struct	opaque_auth	ah_cred;
    101   1.1   deraadt 	struct	opaque_auth	ah_verf;
    102   1.1   deraadt 	union	des_block	ah_key;
    103  1.13   mycroft 	const struct auth_ops {
    104   1.6       cgd 		void	(*ah_nextverf) __P((struct __rpc_auth *));
    105  1.12     lukem 		/* nextverf & serialize */
    106   1.6       cgd 		int	(*ah_marshal) __P((struct __rpc_auth *, XDR *));
    107  1.12     lukem 		/* validate varifier */
    108   1.6       cgd 		int	(*ah_validate) __P((struct __rpc_auth *,
    109   1.6       cgd 			    struct opaque_auth *));
    110  1.12     lukem 		/* refresh credentials */
    111   1.6       cgd 		int	(*ah_refresh) __P((struct __rpc_auth *));
    112  1.12     lukem 		/* destroy this structure */
    113   1.6       cgd 		void	(*ah_destroy) __P((struct __rpc_auth *));
    114   1.1   deraadt 	} *ah_ops;
    115   1.1   deraadt 	caddr_t ah_private;
    116   1.1   deraadt } AUTH;
    117   1.1   deraadt 
    118   1.1   deraadt 
    119   1.1   deraadt /*
    120   1.1   deraadt  * Authentication ops.
    121   1.1   deraadt  * The ops and the auth handle provide the interface to the authenticators.
    122   1.1   deraadt  *
    123   1.1   deraadt  * AUTH	*auth;
    124   1.1   deraadt  * XDR	*xdrs;
    125   1.1   deraadt  * struct opaque_auth verf;
    126   1.1   deraadt  */
    127   1.1   deraadt #define AUTH_NEXTVERF(auth)		\
    128   1.1   deraadt 		((*((auth)->ah_ops->ah_nextverf))(auth))
    129   1.1   deraadt #define auth_nextverf(auth)		\
    130   1.1   deraadt 		((*((auth)->ah_ops->ah_nextverf))(auth))
    131   1.1   deraadt 
    132   1.1   deraadt #define AUTH_MARSHALL(auth, xdrs)	\
    133   1.1   deraadt 		((*((auth)->ah_ops->ah_marshal))(auth, xdrs))
    134   1.1   deraadt #define auth_marshall(auth, xdrs)	\
    135   1.1   deraadt 		((*((auth)->ah_ops->ah_marshal))(auth, xdrs))
    136   1.1   deraadt 
    137   1.1   deraadt #define AUTH_VALIDATE(auth, verfp)	\
    138   1.1   deraadt 		((*((auth)->ah_ops->ah_validate))((auth), verfp))
    139   1.1   deraadt #define auth_validate(auth, verfp)	\
    140   1.1   deraadt 		((*((auth)->ah_ops->ah_validate))((auth), verfp))
    141   1.1   deraadt 
    142   1.1   deraadt #define AUTH_REFRESH(auth)		\
    143   1.1   deraadt 		((*((auth)->ah_ops->ah_refresh))(auth))
    144   1.1   deraadt #define auth_refresh(auth)		\
    145   1.1   deraadt 		((*((auth)->ah_ops->ah_refresh))(auth))
    146   1.1   deraadt 
    147   1.1   deraadt #define AUTH_DESTROY(auth)		\
    148   1.1   deraadt 		((*((auth)->ah_ops->ah_destroy))(auth))
    149   1.1   deraadt #define auth_destroy(auth)		\
    150   1.1   deraadt 		((*((auth)->ah_ops->ah_destroy))(auth))
    151   1.1   deraadt 
    152   1.1   deraadt 
    153   1.1   deraadt extern struct opaque_auth _null_auth;
    154   1.1   deraadt 
    155   1.1   deraadt 
    156   1.1   deraadt /*
    157   1.1   deraadt  * These are the various implementations of client side authenticators.
    158   1.1   deraadt  */
    159   1.1   deraadt 
    160   1.1   deraadt /*
    161   1.1   deraadt  * Unix style authentication
    162   1.1   deraadt  * AUTH *authunix_create(machname, uid, gid, len, aup_gids)
    163  1.12     lukem  *	char *machname;
    164  1.12     lukem  *	int uid;
    165  1.12     lukem  *	int gid;
    166  1.12     lukem  *	int len;
    167  1.12     lukem  *	int *aup_gids;
    168   1.1   deraadt  */
    169   1.2    brezak __BEGIN_DECLS
    170   1.6       cgd struct sockaddr_in;
    171  1.12     lukem extern AUTH *authunix_create		__P((char *, int, int, int, int *));
    172   1.2    brezak extern AUTH *authunix_create_default	__P((void));
    173   1.2    brezak extern AUTH *authnone_create		__P((void));
    174  1.12     lukem extern AUTH *authdes_create		__P((char *, u_int,
    175   1.6       cgd 					    struct sockaddr_in *, des_block *));
    176   1.8  christos extern bool_t xdr_opaque_auth		__P((XDR *, struct opaque_auth *));
    177   1.8  christos 
    178   1.8  christos struct svc_req;
    179   1.8  christos struct rpc_msg;
    180   1.8  christos enum auth_stat _svcauth_null __P((struct svc_req *, struct rpc_msg *));
    181   1.8  christos enum auth_stat _svcauth_short __P((struct svc_req *, struct rpc_msg *));
    182   1.8  christos enum auth_stat _svcauth_unix __P((struct svc_req *, struct rpc_msg *));
    183   1.2    brezak __END_DECLS
    184   1.1   deraadt 
    185   1.1   deraadt #define AUTH_NONE	0		/* no authentication */
    186   1.1   deraadt #define	AUTH_NULL	0		/* backward compatibility */
    187   1.1   deraadt #define	AUTH_UNIX	1		/* unix style (uid, gids) */
    188   1.1   deraadt #define	AUTH_SHORT	2		/* short hand unix style */
    189   1.1   deraadt #define AUTH_DES	3		/* des style (encrypted timestamps) */
    190   1.2    brezak 
    191   1.9     perry #endif /* !_RPC_AUTH_H_ */
    192