Home | History | Annotate | Line # | Download | only in rpc
      1  1.20  christos /*	$NetBSD: auth.h,v 1.20 2020/10/03 18:30:39 christos 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.1   deraadt union des_block {
     73   1.1   deraadt 	struct {
     74  1.17     perry 		uint32_t high;
     75  1.17     perry 		uint32_t low;
     76   1.1   deraadt 	} key;
     77   1.1   deraadt 	char c[8];
     78   1.1   deraadt };
     79   1.1   deraadt typedef union des_block des_block;
     80   1.2    brezak __BEGIN_DECLS
     81  1.16     perry extern bool_t xdr_des_block(XDR *, des_block *);
     82   1.2    brezak __END_DECLS
     83   1.1   deraadt 
     84   1.1   deraadt /*
     85   1.1   deraadt  * Authentication info.  Opaque to client.
     86   1.1   deraadt  */
     87   1.1   deraadt struct opaque_auth {
     88  1.12     lukem 	enum_t	oa_flavor;		/* flavor of auth */
     89  1.12     lukem 	caddr_t	oa_base;		/* address of more auth stuff */
     90  1.19  dholland 	unsigned int oa_length;		/* not to exceed MAX_AUTH_BYTES */
     91   1.1   deraadt };
     92   1.1   deraadt 
     93   1.1   deraadt 
     94   1.1   deraadt /*
     95   1.1   deraadt  * Auth handle, interface to client side authenticators.
     96   1.1   deraadt  */
     97   1.6       cgd typedef struct __rpc_auth {
     98   1.1   deraadt 	struct	opaque_auth	ah_cred;
     99   1.1   deraadt 	struct	opaque_auth	ah_verf;
    100   1.1   deraadt 	union	des_block	ah_key;
    101  1.13   mycroft 	const struct auth_ops {
    102  1.16     perry 		void	(*ah_nextverf)(struct __rpc_auth *);
    103  1.12     lukem 		/* nextverf & serialize */
    104  1.16     perry 		int	(*ah_marshal)(struct __rpc_auth *, XDR *);
    105  1.12     lukem 		/* validate varifier */
    106  1.16     perry 		int	(*ah_validate)(struct __rpc_auth *,
    107  1.16     perry 			    struct opaque_auth *);
    108  1.12     lukem 		/* refresh credentials */
    109  1.16     perry 		int	(*ah_refresh)(struct __rpc_auth *);
    110  1.12     lukem 		/* destroy this structure */
    111  1.16     perry 		void	(*ah_destroy)(struct __rpc_auth *);
    112   1.1   deraadt 	} *ah_ops;
    113  1.14  christos 	void *ah_private;
    114   1.1   deraadt } AUTH;
    115   1.1   deraadt 
    116   1.1   deraadt 
    117   1.1   deraadt /*
    118   1.1   deraadt  * Authentication ops.
    119   1.1   deraadt  * The ops and the auth handle provide the interface to the authenticators.
    120   1.1   deraadt  *
    121   1.1   deraadt  * AUTH	*auth;
    122   1.1   deraadt  * XDR	*xdrs;
    123   1.1   deraadt  * struct opaque_auth verf;
    124   1.1   deraadt  */
    125   1.1   deraadt #define AUTH_NEXTVERF(auth)		\
    126   1.1   deraadt 		((*((auth)->ah_ops->ah_nextverf))(auth))
    127   1.1   deraadt #define auth_nextverf(auth)		\
    128   1.1   deraadt 		((*((auth)->ah_ops->ah_nextverf))(auth))
    129   1.1   deraadt 
    130   1.1   deraadt #define AUTH_MARSHALL(auth, xdrs)	\
    131   1.1   deraadt 		((*((auth)->ah_ops->ah_marshal))(auth, xdrs))
    132   1.1   deraadt #define auth_marshall(auth, xdrs)	\
    133   1.1   deraadt 		((*((auth)->ah_ops->ah_marshal))(auth, xdrs))
    134   1.1   deraadt 
    135   1.1   deraadt #define AUTH_VALIDATE(auth, verfp)	\
    136   1.1   deraadt 		((*((auth)->ah_ops->ah_validate))((auth), verfp))
    137   1.1   deraadt #define auth_validate(auth, verfp)	\
    138   1.1   deraadt 		((*((auth)->ah_ops->ah_validate))((auth), verfp))
    139   1.1   deraadt 
    140   1.1   deraadt #define AUTH_REFRESH(auth)		\
    141   1.1   deraadt 		((*((auth)->ah_ops->ah_refresh))(auth))
    142   1.1   deraadt #define auth_refresh(auth)		\
    143   1.1   deraadt 		((*((auth)->ah_ops->ah_refresh))(auth))
    144   1.1   deraadt 
    145   1.1   deraadt #define AUTH_DESTROY(auth)		\
    146   1.1   deraadt 		((*((auth)->ah_ops->ah_destroy))(auth))
    147   1.1   deraadt #define auth_destroy(auth)		\
    148   1.1   deraadt 		((*((auth)->ah_ops->ah_destroy))(auth))
    149   1.1   deraadt 
    150   1.1   deraadt 
    151   1.1   deraadt extern struct opaque_auth _null_auth;
    152   1.1   deraadt 
    153   1.1   deraadt 
    154   1.1   deraadt /*
    155   1.1   deraadt  * These are the various implementations of client side authenticators.
    156   1.1   deraadt  */
    157   1.1   deraadt 
    158   1.1   deraadt /*
    159   1.1   deraadt  * Unix style authentication
    160   1.1   deraadt  * AUTH *authunix_create(machname, uid, gid, len, aup_gids)
    161  1.12     lukem  *	char *machname;
    162  1.12     lukem  *	int uid;
    163  1.12     lukem  *	int gid;
    164  1.12     lukem  *	int len;
    165  1.12     lukem  *	int *aup_gids;
    166   1.1   deraadt  */
    167   1.2    brezak __BEGIN_DECLS
    168   1.6       cgd struct sockaddr_in;
    169  1.16     perry extern AUTH *authunix_create		(char *, int, int, int, int *);
    170  1.16     perry extern AUTH *authunix_create_default	(void);
    171  1.16     perry extern AUTH *authnone_create		(void);
    172  1.19  dholland extern AUTH *authdes_create		(char *, unsigned int,
    173  1.16     perry 					    struct sockaddr_in *, des_block *);
    174  1.16     perry extern bool_t xdr_opaque_auth		(XDR *, struct opaque_auth *);
    175  1.20  christos extern void set_rpc_maxgrouplist	(int);
    176   1.8  christos 
    177  1.15      fvdl #define authsys_create(c,i1,i2,i3,ip) authunix_create((c),(i1),(i2),(i3),(ip))
    178  1.15      fvdl #define authsys_create_default() authunix_create_default()
    179  1.15      fvdl 
    180   1.8  christos struct svc_req;
    181   1.8  christos struct rpc_msg;
    182  1.16     perry enum auth_stat _svcauth_null(struct svc_req *, struct rpc_msg *);
    183  1.16     perry enum auth_stat _svcauth_short(struct svc_req *, struct rpc_msg *);
    184  1.16     perry enum auth_stat _svcauth_unix(struct svc_req *, struct rpc_msg *);
    185   1.2    brezak __END_DECLS
    186   1.1   deraadt 
    187   1.1   deraadt #define AUTH_NONE	0		/* no authentication */
    188   1.1   deraadt #define	AUTH_NULL	0		/* backward compatibility */
    189  1.15      fvdl #define	AUTH_SYS	1		/* unix style (uid, gids) */
    190  1.15      fvdl #define AUTH_UNIX	AUTH_SYS	/* backward compatibility */
    191   1.1   deraadt #define	AUTH_SHORT	2		/* short hand unix style */
    192   1.1   deraadt #define AUTH_DES	3		/* des style (encrypted timestamps) */
    193   1.2    brezak 
    194   1.9     perry #endif /* !_RPC_AUTH_H_ */
    195