X-Git-Url: https://gitweb.dragonflybsd.org/~lentferj/dragonfly.git/blobdiff_plain/2f3ceba1445b387358be826c86fd408278857a37..ce0e08e21d42c06c0014fae6b9d27144aa5109b0:/include/rpc/auth.h diff --git a/include/rpc/auth.h b/include/rpc/auth.h index 4573e4951c..71ae812a2a 100644 --- a/include/rpc/auth.h +++ b/include/rpc/auth.h @@ -28,7 +28,9 @@ * * 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 $ + * from: @(#)auth.h 1.43 98/02/02 SMI + * $NetBSD: auth.h,v 1.15 2000/06/02 22:57:55 fvdl Exp $ + * $FreeBSD: src/include/rpc/auth.h,v 1.21 2006/02/28 16:02:26 deischen Exp $ * $DragonFly: src/include/rpc/auth.h,v 1.4 2004/02/26 13:58:26 joerg Exp $ */ @@ -38,18 +40,81 @@ * 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 + * is required to pass an AUTH * to routines that create rpc * "sessions". */ #ifndef _RPC_AUTH_H #define _RPC_AUTH_H +#include +#include #include #include #define MAX_AUTH_BYTES 400 #define MAXNETNAMELEN 255 /* maximum length of network user's name */ +/* + * Client side authentication/security data + */ + +typedef struct sec_data { + u_int secmod; /* security mode number e.g. in nfssec.conf */ + u_int rpcflavor; /* rpc flavors:AUTH_UNIX,AUTH_DES,RPCSEC_GSS */ + int flags; /* AUTH_F_xxx flags */ + caddr_t data; /* opaque data per flavor */ +} sec_data_t; + +#ifdef _SYSCALL32_IMPL +struct sec_data32 { + uint32_t secmod; /* security mode number e.g. in nfssec.conf */ + uint32_t rpcflavor; /* rpc flavors:AUTH_UNIX,AUTH_DES,RPCSEC_GSS */ + int32_t flags; /* AUTH_F_xxx flags */ + caddr32_t data; /* opaque data per flavor */ +}; +#endif /* _SYSCALL32_IMPL */ + +/* + * AUTH_DES flavor specific data from sec_data opaque data field. + * AUTH_KERB has the same structure. + */ +typedef struct des_clnt_data { + struct netbuf syncaddr; /* time sync addr */ + struct knetconfig *knconf; /* knetconfig info that associated */ + /* with the syncaddr. */ + char *netname; /* server's netname */ + int netnamelen; /* server's netname len */ +} dh_k4_clntdata_t; + +#ifdef _SYSCALL32_IMPL +struct des_clnt_data32 { + struct netbuf32 syncaddr; /* time sync addr */ + caddr32_t knconf; /* knetconfig info that associated */ + /* with the syncaddr. */ + caddr32_t netname; /* server's netname */ + int32_t netnamelen; /* server's netname len */ +}; +#endif /* _SYSCALL32_IMPL */ + +#ifdef KERBEROS +/* + * flavor specific data to hold the data for AUTH_DES/AUTH_KERB(v4) + * in sec_data->data opaque field. + */ +typedef struct krb4_svc_data { + int window; /* window option value */ +} krb4_svcdata_t; + +typedef struct krb4_svc_data des_svcdata_t; +#endif /* KERBEROS */ + +/* + * authentication/security specific flags + */ +#define AUTH_F_RPCTIMESYNC 0x001 /* use RPC to do time sync */ +#define AUTH_F_TRYNONE 0x002 /* allow fall back to AUTH_NONE */ + + /* * Status returned from authentication check */ @@ -68,12 +133,23 @@ enum auth_stat { */ AUTH_INVALIDRESP=6, /* bogus response verifier */ AUTH_FAILED=7 /* some unknown reason */ +#ifdef KERBEROS + /* + * kerberos errors + */ + , + AUTH_KERB_GENERIC = 8, /* kerberos generic error */ + AUTH_TIMEEXPIRE = 9, /* time of credential expired */ + AUTH_TKT_FILE = 10, /* something wrong with ticket file */ + AUTH_DECODE = 11, /* can't decode authenticator */ + AUTH_NET_ADDR = 12 /* wrong net address in ticket */ +#endif /* KERBEROS */ }; union des_block { struct { - u_int32_t high; - u_int32_t low; + uint32_t high; + uint32_t low; } key; char c[8]; }; @@ -90,31 +166,28 @@ struct opaque_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(XDR *, struct opaque_auth *); -__END_DECLS /* * Auth handle, interface to client side authenticators. */ -typedef struct __rpc_auth { +typedef struct __auth { struct opaque_auth ah_cred; struct opaque_auth ah_verf; union des_block ah_key; struct auth_ops { - void (*ah_nextverf) (struct __rpc_auth *); + void (*ah_nextverf) (struct __auth *); /* nextverf & serialize */ - int (*ah_marshal) (struct __rpc_auth *, XDR *); + int (*ah_marshal) (struct __auth *, XDR *); /* validate verifier */ - int (*ah_validate) (struct __rpc_auth *, + int (*ah_validate) (struct __auth *, struct opaque_auth *); /* refresh credentials */ - int (*ah_refresh) (struct __rpc_auth *); + int (*ah_refresh) (struct __auth *, void *); /* destroy this structure */ - void (*ah_destroy) (struct __rpc_auth *); + void (*ah_destroy) (struct __auth *); } *ah_ops; - caddr_t ah_private; + void *ah_private; } AUTH; @@ -141,10 +214,10 @@ typedef struct __rpc_auth { #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_REFRESH(auth, msg) \ + ((*((auth)->ah_ops->ah_refresh))(auth, msg)) +#define auth_refresh(auth, msg) \ + ((*((auth)->ah_ops->ah_refresh))(auth, msg)) #define AUTH_DESTROY(auth) \ ((*((auth)->ah_ops->ah_destroy))(auth)) @@ -152,14 +225,16 @@ typedef struct __rpc_auth { ((*((auth)->ah_ops->ah_destroy))(auth)) +__BEGIN_DECLS extern struct opaque_auth _null_auth; +__END_DECLS /* * These are the various implementations of client side authenticators. */ /* - * Unix style authentication + * System style authentication * AUTH *authunix_create(machname, uid, gid, len, aup_gids) * char *machname; * int uid; @@ -168,93 +243,113 @@ extern struct opaque_auth _null_auth; * int *aup_gids; */ __BEGIN_DECLS -struct sockaddr_in; AUTH *authunix_create(char *, int, int, int, int *); AUTH *authunix_create_default(void); AUTH *authnone_create(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) + * AUTH *authsecdes_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 + * const char *timehost; - optional hostname to sync with * des_block *ckey; - optional conversation key to use */ __BEGIN_DECLS AUTH *authdes_create(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. - */ -AUTH *authdes_pk_create(char *, netobj *, u_int, struct sockaddr *, - des_block *, nis_server *); -#endif +AUTH *authdes_seccreate(const char *, const u_int, const char *, + const des_block *); __END_DECLS +__BEGIN_DECLS +bool_t xdr_opaque_auth(XDR *, struct opaque_auth *); +__END_DECLS + +#define authsys_create(c,i1,i2,i3,ip) authunix_create((c),(i1),(i2),(i3),(ip)) +#define authsys_create_default() authunix_create_default() + /* * Netname manipulation routines. */ __BEGIN_DECLS -int netname2user(char *, uid_t *, gid_t *, int *, gid_t *); -int netname2host(char *, char *, int); int getnetname(char *); -int user2netname(char *, uid_t, char *); -int host2netname(char *, char *, char *); +int host2netname(char *, const char *, const char *); +int user2netname(char *, const uid_t, const char *); +int netname2user(char *, uid_t *, gid_t *, int *, gid_t *); +int netname2host(char *, char *, const int); void passwd2des(char *, char *); __END_DECLS /* - * Keyserv interface routines. - * XXX Should not be here. + * + * These routines interface to the keyserv daemon + * */ -#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 int key_decryptsession(const char *, des_block *); -int key_decryptsession_pk(char *, netobj *, des_block *); int key_encryptsession(const char *, des_block *); -int key_encryptsession_pk(char *, netobj *, des_block *); int key_gendes(des_block *); int key_setsecret(const char *); int key_secretkey_is_set(void); -int key_setnet(struct netstarg *); -int key_get_conv(char *, des_block *); __END_DECLS /* * Publickey routines. */ __BEGIN_DECLS -int getpublickey(char *, char *); -int getpublicandprivatekey(char *, char *); +int getpublickey(const char *, char *); +int getpublicandprivatekey(const char *, char *); int getsecretkey(char *, char *, char *); __END_DECLS +#ifdef KERBEROS +/* + * Kerberos style authentication + * AUTH *authkerb_seccreate(service, srv_inst, realm, window, timehost, status) + * const char *service; - service name + * const char *srv_inst; - server instance + * const char *realm; - server realm + * const u_int window; - time to live + * const char *timehost; - optional hostname to sync with + * int *status; - kerberos status returned + */ +__BEGIN_DECLS +AUTH *authkerb_seccreate(const char *, const char *, const char *, + const u_int, const char *, int *); +__END_DECLS + +/* + * Map a kerberos credential into a unix cred. + * + * authkerb_getucred(rqst, uid, gid, grouplen, groups) + * const struct svc_req *rqst; - request pointer + * uid_t *uid; + * gid_t *gid; + * short *grouplen; + * int *groups; + * + */ +__BEGIN_DECLS +int authkerb_getucred(/* struct svc_req *, uid_t *, gid_t *, + short *, int * */); +__END_DECLS +#endif /* KERBEROS */ + +__BEGIN_DECLS +struct svc_req; +struct rpc_msg; +enum auth_stat _svcauth_null (struct svc_req *, struct rpc_msg *); +enum auth_stat _svcauth_short (struct svc_req *, struct rpc_msg *); +enum auth_stat _svcauth_unix (struct svc_req *, struct rpc_msg *); +__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_SYS 1 /* unix style (uid, gids) */ +#define AUTH_UNIX AUTH_SYS #define AUTH_SHORT 2 /* short hand unix style */ -#define AUTH_DES 3 /* des style (encrypted timestamps) */ +#define AUTH_DH 3 /* for Diffie-Hellman mechanism */ +#define AUTH_DES AUTH_DH /* for backward compatibility */ +#define AUTH_KERB 4 /* kerberos style */ #endif /* !_RPC_AUTH_H */