auth.h revision f48205be61a214698b763ff550ab9e657525104c
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/*
* Portions of this source code were derived from Berkeley
* 4.3 BSD under license from the Regents of the University of
* California.
*/
/*
* auth.h, Authentication interface.
*
* 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
#pragma ident "%Z%%M% %I% %E% SMI"
#include <rpc/clnt_stat.h>
#ifdef _KERNEL
#endif
#ifdef __cplusplus
extern "C" {
#endif
#define MAX_AUTH_BYTES 400
/*
* Client side authentication/security data
*/
typedef struct sec_data {
int flags; /* AUTH_F_xxx flags */
} sec_data_t;
#ifdef _SYSCALL32_IMPL
struct sec_data32 {
};
#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 {
/* with the syncaddr. */
char *netname; /* server's netname */
int netnamelen; /* server's netname len */
#ifdef _SYSCALL32_IMPL
struct des_clnt_data32 {
/* with the syncaddr. */
};
#endif /* _SYSCALL32_IMPL */
/*
* in sec_data->data opaque field.
*/
typedef struct krb4_svc_data {
int window; /* window option value */
typedef struct krb4_svc_data des_svcdata_t;
/*
* authentication/security specific flags
*/
/*
* Status returned from authentication check
*/
enum auth_stat {
AUTH_OK = 0,
/*
* failed at remote end
*/
/*
* failed locally
*/
/*
* kerberos errors
*/
/*
* GSS related errors
*/
};
union des_block {
struct {
} key;
char c[8];
};
#ifdef __STDC__
#else
extern bool_t xdr_des_block();
#endif
/*
* Authentication info. Opaque to client.
*/
struct opaque_auth {
};
/*
* Auth handle, interface to client side authenticators.
*/
typedef struct __auth {
struct opaque_auth ah_cred;
struct opaque_auth ah_verf;
struct auth_ops {
#ifdef __STDC__
void (*ah_nextverf)(struct __auth *);
#ifdef _KERNEL
#else
#endif
/* nextverf & serialize */
int (*ah_validate)(struct __auth *,
struct opaque_auth *);
/* validate varifier */
#ifdef _KERNEL
cred_t *);
#else
int (*ah_refresh)(struct __auth *, void *);
/* refresh credentials */
#endif
void (*ah_destroy)(struct __auth *);
/* destroy this structure */
#ifdef _KERNEL
caddr_t);
#endif
#else
void (*ah_nextverf)();
int (*ah_marshal)(); /* nextverf & serialize */
int (*ah_validate)(); /* validate verifier */
int (*ah_refresh)(); /* refresh credentials */
void (*ah_destroy)(); /* destroy this structure */
#ifdef _KERNEL
int (*ah_wrap)(); /* encode XDR data */
int (*ah_unwrap)(); /* decode XDR data */
#endif
#endif
} *ah_ops;
} 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) \
#define auth_nextverf(auth) \
#ifdef _KERNEL
#else
#endif
#ifdef _KERNEL
#else
#endif
#define AUTH_DESTROY(auth) \
#define auth_destroy(auth) \
/*
* Auth flavors can now apply a transformation in addition to simple XDR
* used. These interfaces provide a generic interface between the
* internal RPC frame and the auth flavor specific code to allow the
* auth flavor to encode (WRAP) or decode (UNWRAP) the body.
*/
#ifdef _KERNEL
#endif
extern struct opaque_auth _null_auth;
/*
* These are the various implementations of client side authenticators.
*/
/*
* System style authentication
* AUTH *authsys_create(machname, uid, gid, len, aup_gids)
* const char *machname;
* const uid_t uid;
* const gid_t gid;
* const int len;
* const gid_t *aup_gids;
*/
#ifdef _KERNEL
extern int authkern_init(void *, void *, int);
extern struct kmem_cache *authkern_cache;
extern int authloopback_init(void *, void *, int);
extern struct kmem_cache *authloopback_cache;
#else /* _KERNEL */
#ifdef __STDC__
const gid_t *);
#else /* __STDC__ */
extern AUTH *authsys_create();
#endif /* __STDC__ */
/* Will get obsolete in near future */
#define authunix_create authsys_create
#endif /* _KERNEL */
/*
* DES style authentication
* AUTH *authdes_seccreate(servername, window, timehost, ckey)
* const char *servername; - network name of server
* const uint_t window; - time to live
* const char *timehost; - optional hostname to sync with
* const des_block *ckey; - optional conversation key to use
*/
/* Will get obsolete in near future */
#ifdef _KERNEL
#else /* _KERNEL */
#ifdef __STDC__
const des_block *);
#else
extern AUTH *authdes_seccreate();
#endif /* __STDC__ */
#endif /* _KERNEL */
/*
* Netname manipulating functions
*/
#ifdef _KERNEL
#endif
#ifdef __STDC__
extern int getnetname(char *);
extern int host2netname(char *, const char *, const char *);
extern int user2netname(char *, const uid_t, const char *);
#ifndef _KERNEL
#endif
extern int netname2host(const char *, char *, const int);
#else
extern int getnetname();
extern int host2netname();
extern int user2netname();
extern int netname2host();
#endif
/*
* These routines interface to the keyserv daemon
*/
#ifdef _KERNEL
extern enum clnt_stat key_decryptsession();
extern enum clnt_stat key_encryptsession();
extern enum clnt_stat key_gendes();
extern enum clnt_stat key_getnetname();
#endif
#ifndef _KERNEL
#ifdef __STDC__
extern int key_decryptsession(const char *, des_block *);
extern int key_encryptsession(const char *, des_block *);
extern int key_gendes(des_block *);
extern int key_setsecret(const char *);
extern int key_secretkey_is_set(void);
/*
* The following routines are private.
*/
extern int key_setnet_ruid();
extern int key_setnet_g_ruid();
extern int key_removesecret_g_ruid();
extern int key_secretkey_is_set_g_ruid();
extern AUTH *authsys_create_ruid();
#else
extern int key_decryptsession();
extern int key_encryptsession();
extern int key_gendes();
extern int key_setsecret();
extern int key_secretkey_is_set();
#endif
#endif
/*
* 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 uint_t window; - time to live
* const char *timehost; - optional hostname to sync with
* int *status; - kerberos status returned
*/
#ifdef _KERNEL
extern int authkerb_create(char *, char *, char *, uint_t,
#else
#ifdef __STDC__
extern AUTH *authkerb_seccreate(const char *, const char *, const char *,
const uint_t, const char *, int *);
#else
extern AUTH *authkerb_seccreate();
#endif
#endif /* _KERNEL */
/*
* 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;
*
*/
#ifdef __STDC__
struct svc_req;
short *, int *);
#else
extern int authkerb_getucred();
#endif
#ifdef _KERNEL
/*
* XDR an opaque authentication struct. See auth.h.
*/
#endif
#ifdef _KERNEL
#endif
#define AUTH_NONE 0 /* no authentication */
#define AUTH_NULL 0 /* backward compatibility */
/* for use over the local transport */
#ifdef _KERNEL
extern char loopback_name[];
extern zone_key_t auth_zone_key;
extern void * auth_zone_init(zoneid_t);
extern void auth_zone_fini(zoneid_t, void *);
#endif
#ifdef __cplusplus
}
#endif
#endif /* !_RPC_AUTH_H */