17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*f48205beScasper * Common Development and Distribution License (the "License"). 6*f48205beScasper * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 22*f48205beScasper * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ 267c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 277c478bd9Sstevel@tonic-gate /* 287c478bd9Sstevel@tonic-gate * Portions of this source code were derived from Berkeley 297c478bd9Sstevel@tonic-gate * 4.3 BSD under license from the Regents of the University of 307c478bd9Sstevel@tonic-gate * California. 317c478bd9Sstevel@tonic-gate */ 327c478bd9Sstevel@tonic-gate 337c478bd9Sstevel@tonic-gate /* 347c478bd9Sstevel@tonic-gate * auth.h, Authentication interface. 357c478bd9Sstevel@tonic-gate * 367c478bd9Sstevel@tonic-gate * The data structures are completely opaque to the client. The client 377c478bd9Sstevel@tonic-gate * is required to pass a AUTH * to routines that create rpc 387c478bd9Sstevel@tonic-gate * "sessions". 397c478bd9Sstevel@tonic-gate */ 407c478bd9Sstevel@tonic-gate 417c478bd9Sstevel@tonic-gate #ifndef _RPC_AUTH_H 427c478bd9Sstevel@tonic-gate #define _RPC_AUTH_H 437c478bd9Sstevel@tonic-gate 447c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 457c478bd9Sstevel@tonic-gate 467c478bd9Sstevel@tonic-gate #include <rpc/xdr.h> 477c478bd9Sstevel@tonic-gate #include <rpc/clnt_stat.h> 487c478bd9Sstevel@tonic-gate #include <sys/cred.h> 497c478bd9Sstevel@tonic-gate #include <sys/tiuser.h> 507c478bd9Sstevel@tonic-gate #ifdef _KERNEL 517c478bd9Sstevel@tonic-gate #include <sys/zone.h> 527c478bd9Sstevel@tonic-gate #endif 537c478bd9Sstevel@tonic-gate 547c478bd9Sstevel@tonic-gate #ifdef __cplusplus 557c478bd9Sstevel@tonic-gate extern "C" { 567c478bd9Sstevel@tonic-gate #endif 577c478bd9Sstevel@tonic-gate 587c478bd9Sstevel@tonic-gate #define MAX_AUTH_BYTES 400 597c478bd9Sstevel@tonic-gate #define MAXNETNAMELEN 255 /* maximum length of network user's name */ 607c478bd9Sstevel@tonic-gate 617c478bd9Sstevel@tonic-gate /* 627c478bd9Sstevel@tonic-gate * Client side authentication/security data 637c478bd9Sstevel@tonic-gate */ 647c478bd9Sstevel@tonic-gate typedef struct sec_data { 657c478bd9Sstevel@tonic-gate uint_t secmod; /* security mode number e.g. in nfssec.conf */ 667c478bd9Sstevel@tonic-gate uint_t rpcflavor; /* rpc flavors:AUTH_UNIX,AUTH_DES,RPCSEC_GSS */ 677c478bd9Sstevel@tonic-gate int flags; /* AUTH_F_xxx flags */ 687c478bd9Sstevel@tonic-gate uid_t uid; /* uid of caller for all sec flavors (NFSv4) */ 697c478bd9Sstevel@tonic-gate caddr_t data; /* opaque data per flavor */ 707c478bd9Sstevel@tonic-gate } sec_data_t; 717c478bd9Sstevel@tonic-gate 727c478bd9Sstevel@tonic-gate #ifdef _SYSCALL32_IMPL 737c478bd9Sstevel@tonic-gate struct sec_data32 { 747c478bd9Sstevel@tonic-gate uint32_t secmod; /* security mode number e.g. in nfssec.conf */ 757c478bd9Sstevel@tonic-gate uint32_t rpcflavor; /* AUTH_UNIX,AUTH_DES,RPCSEC_GSS */ 767c478bd9Sstevel@tonic-gate int32_t flags; /* AUTH_F_xxx flags */ 777c478bd9Sstevel@tonic-gate uid_t uid; /* uid of caller for all sec flavors (NFSv4) */ 787c478bd9Sstevel@tonic-gate caddr32_t data; /* opaque data per flavor */ 797c478bd9Sstevel@tonic-gate }; 807c478bd9Sstevel@tonic-gate #endif /* _SYSCALL32_IMPL */ 817c478bd9Sstevel@tonic-gate 827c478bd9Sstevel@tonic-gate /* 837c478bd9Sstevel@tonic-gate * AUTH_DES flavor specific data from sec_data opaque data field. 847c478bd9Sstevel@tonic-gate * AUTH_KERB has the same structure. 857c478bd9Sstevel@tonic-gate */ 867c478bd9Sstevel@tonic-gate typedef struct des_clnt_data { 877c478bd9Sstevel@tonic-gate struct netbuf syncaddr; /* time sync addr */ 887c478bd9Sstevel@tonic-gate struct knetconfig *knconf; /* knetconfig info that associated */ 897c478bd9Sstevel@tonic-gate /* with the syncaddr. */ 907c478bd9Sstevel@tonic-gate char *netname; /* server's netname */ 917c478bd9Sstevel@tonic-gate int netnamelen; /* server's netname len */ 927c478bd9Sstevel@tonic-gate } dh_k4_clntdata_t; 937c478bd9Sstevel@tonic-gate 947c478bd9Sstevel@tonic-gate #ifdef _SYSCALL32_IMPL 957c478bd9Sstevel@tonic-gate struct des_clnt_data32 { 967c478bd9Sstevel@tonic-gate struct netbuf32 syncaddr; /* time sync addr */ 977c478bd9Sstevel@tonic-gate caddr32_t knconf; /* knetconfig info that associated */ 987c478bd9Sstevel@tonic-gate /* with the syncaddr. */ 997c478bd9Sstevel@tonic-gate caddr32_t netname; /* server's netname */ 1007c478bd9Sstevel@tonic-gate int32_t netnamelen; /* server's netname len */ 1017c478bd9Sstevel@tonic-gate }; 1027c478bd9Sstevel@tonic-gate #endif /* _SYSCALL32_IMPL */ 1037c478bd9Sstevel@tonic-gate 1047c478bd9Sstevel@tonic-gate /* 1057c478bd9Sstevel@tonic-gate * flavor specific data to hold the data for AUTH_DES/AUTH_KERB(v4) 1067c478bd9Sstevel@tonic-gate * in sec_data->data opaque field. 1077c478bd9Sstevel@tonic-gate */ 1087c478bd9Sstevel@tonic-gate typedef struct krb4_svc_data { 1097c478bd9Sstevel@tonic-gate int window; /* window option value */ 1107c478bd9Sstevel@tonic-gate } krb4_svcdata_t; 1117c478bd9Sstevel@tonic-gate 1127c478bd9Sstevel@tonic-gate typedef struct krb4_svc_data des_svcdata_t; 1137c478bd9Sstevel@tonic-gate 1147c478bd9Sstevel@tonic-gate /* 1157c478bd9Sstevel@tonic-gate * authentication/security specific flags 1167c478bd9Sstevel@tonic-gate */ 1177c478bd9Sstevel@tonic-gate #define AUTH_F_RPCTIMESYNC 0x001 /* use RPC to do time sync */ 1187c478bd9Sstevel@tonic-gate #define AUTH_F_TRYNONE 0x002 /* allow fall back to AUTH_NONE */ 1197c478bd9Sstevel@tonic-gate 1207c478bd9Sstevel@tonic-gate 1217c478bd9Sstevel@tonic-gate /* 1227c478bd9Sstevel@tonic-gate * Status returned from authentication check 1237c478bd9Sstevel@tonic-gate */ 1247c478bd9Sstevel@tonic-gate enum auth_stat { 1257c478bd9Sstevel@tonic-gate AUTH_OK = 0, 1267c478bd9Sstevel@tonic-gate /* 1277c478bd9Sstevel@tonic-gate * failed at remote end 1287c478bd9Sstevel@tonic-gate */ 1297c478bd9Sstevel@tonic-gate AUTH_BADCRED = 1, /* bogus credentials (seal broken) */ 1307c478bd9Sstevel@tonic-gate AUTH_REJECTEDCRED = 2, /* client should begin new session */ 1317c478bd9Sstevel@tonic-gate AUTH_BADVERF = 3, /* bogus verifier (seal broken) */ 1327c478bd9Sstevel@tonic-gate AUTH_REJECTEDVERF = 4, /* verifier expired or was replayed */ 1337c478bd9Sstevel@tonic-gate AUTH_TOOWEAK = 5, /* rejected due to security reasons */ 1347c478bd9Sstevel@tonic-gate /* 1357c478bd9Sstevel@tonic-gate * failed locally 1367c478bd9Sstevel@tonic-gate */ 1377c478bd9Sstevel@tonic-gate AUTH_INVALIDRESP = 6, /* bogus response verifier */ 1387c478bd9Sstevel@tonic-gate AUTH_FAILED = 7, /* some unknown reason */ 1397c478bd9Sstevel@tonic-gate /* 1407c478bd9Sstevel@tonic-gate * kerberos errors 1417c478bd9Sstevel@tonic-gate */ 1427c478bd9Sstevel@tonic-gate AUTH_KERB_GENERIC = 8, /* kerberos generic error */ 1437c478bd9Sstevel@tonic-gate AUTH_TIMEEXPIRE = 9, /* time of credential expired */ 1447c478bd9Sstevel@tonic-gate AUTH_TKT_FILE = 10, /* something wrong with ticket file */ 1457c478bd9Sstevel@tonic-gate AUTH_DECODE = 11, /* can't decode authenticator */ 1467c478bd9Sstevel@tonic-gate AUTH_NET_ADDR = 12, /* wrong net address in ticket */ 1477c478bd9Sstevel@tonic-gate /* 1487c478bd9Sstevel@tonic-gate * GSS related errors 1497c478bd9Sstevel@tonic-gate */ 1507c478bd9Sstevel@tonic-gate RPCSEC_GSS_NOCRED = 13, /* no credentials for user */ 1517c478bd9Sstevel@tonic-gate RPCSEC_GSS_FAILED = 14 /* GSS failure, credentials deleted */ 1527c478bd9Sstevel@tonic-gate }; 1537c478bd9Sstevel@tonic-gate typedef enum auth_stat AUTH_STAT; 1547c478bd9Sstevel@tonic-gate 1557c478bd9Sstevel@tonic-gate union des_block { 1567c478bd9Sstevel@tonic-gate struct { 1577c478bd9Sstevel@tonic-gate uint32_t high; 1587c478bd9Sstevel@tonic-gate uint32_t low; 1597c478bd9Sstevel@tonic-gate } key; 1607c478bd9Sstevel@tonic-gate char c[8]; 1617c478bd9Sstevel@tonic-gate }; 1627c478bd9Sstevel@tonic-gate typedef union des_block des_block; 1637c478bd9Sstevel@tonic-gate 1647c478bd9Sstevel@tonic-gate #ifdef __STDC__ 1657c478bd9Sstevel@tonic-gate extern bool_t xdr_des_block(XDR *, des_block *); 1667c478bd9Sstevel@tonic-gate #else 1677c478bd9Sstevel@tonic-gate extern bool_t xdr_des_block(); 1687c478bd9Sstevel@tonic-gate #endif 1697c478bd9Sstevel@tonic-gate 1707c478bd9Sstevel@tonic-gate 1717c478bd9Sstevel@tonic-gate /* 1727c478bd9Sstevel@tonic-gate * Authentication info. Opaque to client. 1737c478bd9Sstevel@tonic-gate */ 1747c478bd9Sstevel@tonic-gate struct opaque_auth { 1757c478bd9Sstevel@tonic-gate enum_t oa_flavor; /* flavor of auth */ 1767c478bd9Sstevel@tonic-gate caddr_t oa_base; /* address of more auth stuff */ 1777c478bd9Sstevel@tonic-gate uint_t oa_length; /* not to exceed MAX_AUTH_BYTES */ 1787c478bd9Sstevel@tonic-gate }; 1797c478bd9Sstevel@tonic-gate 1807c478bd9Sstevel@tonic-gate 1817c478bd9Sstevel@tonic-gate /* 1827c478bd9Sstevel@tonic-gate * Auth handle, interface to client side authenticators. 1837c478bd9Sstevel@tonic-gate */ 1847c478bd9Sstevel@tonic-gate typedef struct __auth { 1857c478bd9Sstevel@tonic-gate struct opaque_auth ah_cred; 1867c478bd9Sstevel@tonic-gate struct opaque_auth ah_verf; 1877c478bd9Sstevel@tonic-gate union des_block ah_key; 1887c478bd9Sstevel@tonic-gate struct auth_ops { 1897c478bd9Sstevel@tonic-gate #ifdef __STDC__ 1907c478bd9Sstevel@tonic-gate void (*ah_nextverf)(struct __auth *); 1917c478bd9Sstevel@tonic-gate #ifdef _KERNEL 1927c478bd9Sstevel@tonic-gate int (*ah_marshal)(struct __auth *, XDR *, struct cred *); 1937c478bd9Sstevel@tonic-gate #else 1947c478bd9Sstevel@tonic-gate int (*ah_marshal)(struct __auth *, XDR *); 1957c478bd9Sstevel@tonic-gate #endif 1967c478bd9Sstevel@tonic-gate /* nextverf & serialize */ 1977c478bd9Sstevel@tonic-gate int (*ah_validate)(struct __auth *, 1987c478bd9Sstevel@tonic-gate struct opaque_auth *); 1997c478bd9Sstevel@tonic-gate /* validate varifier */ 2007c478bd9Sstevel@tonic-gate #ifdef _KERNEL 2017c478bd9Sstevel@tonic-gate int (*ah_refresh)(struct __auth *, struct rpc_msg *, 2027c478bd9Sstevel@tonic-gate cred_t *); 2037c478bd9Sstevel@tonic-gate #else 2047c478bd9Sstevel@tonic-gate int (*ah_refresh)(struct __auth *, void *); 2057c478bd9Sstevel@tonic-gate /* refresh credentials */ 2067c478bd9Sstevel@tonic-gate #endif 2077c478bd9Sstevel@tonic-gate void (*ah_destroy)(struct __auth *); 2087c478bd9Sstevel@tonic-gate /* destroy this structure */ 2097c478bd9Sstevel@tonic-gate 2107c478bd9Sstevel@tonic-gate #ifdef _KERNEL 2117c478bd9Sstevel@tonic-gate int (*ah_wrap)(struct __auth *, caddr_t, uint_t, 2127c478bd9Sstevel@tonic-gate XDR *, xdrproc_t, caddr_t); 2137c478bd9Sstevel@tonic-gate int (*ah_unwrap)(struct __auth *, XDR *, xdrproc_t, 2147c478bd9Sstevel@tonic-gate caddr_t); 2157c478bd9Sstevel@tonic-gate #endif 2167c478bd9Sstevel@tonic-gate #else 2177c478bd9Sstevel@tonic-gate void (*ah_nextverf)(); 2187c478bd9Sstevel@tonic-gate int (*ah_marshal)(); /* nextverf & serialize */ 2197c478bd9Sstevel@tonic-gate int (*ah_validate)(); /* validate verifier */ 2207c478bd9Sstevel@tonic-gate int (*ah_refresh)(); /* refresh credentials */ 2217c478bd9Sstevel@tonic-gate void (*ah_destroy)(); /* destroy this structure */ 2227c478bd9Sstevel@tonic-gate #ifdef _KERNEL 2237c478bd9Sstevel@tonic-gate int (*ah_wrap)(); /* encode XDR data */ 2247c478bd9Sstevel@tonic-gate int (*ah_unwrap)(); /* decode XDR data */ 2257c478bd9Sstevel@tonic-gate #endif 2267c478bd9Sstevel@tonic-gate 2277c478bd9Sstevel@tonic-gate #endif 2287c478bd9Sstevel@tonic-gate } *ah_ops; 2297c478bd9Sstevel@tonic-gate caddr_t ah_private; 2307c478bd9Sstevel@tonic-gate } AUTH; 2317c478bd9Sstevel@tonic-gate 2327c478bd9Sstevel@tonic-gate 2337c478bd9Sstevel@tonic-gate /* 2347c478bd9Sstevel@tonic-gate * Authentication ops. 2357c478bd9Sstevel@tonic-gate * The ops and the auth handle provide the interface to the authenticators. 2367c478bd9Sstevel@tonic-gate * 2377c478bd9Sstevel@tonic-gate * AUTH *auth; 2387c478bd9Sstevel@tonic-gate * XDR *xdrs; 2397c478bd9Sstevel@tonic-gate * struct opaque_auth verf; 2407c478bd9Sstevel@tonic-gate */ 2417c478bd9Sstevel@tonic-gate #define AUTH_NEXTVERF(auth) \ 2427c478bd9Sstevel@tonic-gate ((*((auth)->ah_ops->ah_nextverf))(auth)) 2437c478bd9Sstevel@tonic-gate #define auth_nextverf(auth) \ 2447c478bd9Sstevel@tonic-gate ((*((auth)->ah_ops->ah_nextverf))(auth)) 2457c478bd9Sstevel@tonic-gate 2467c478bd9Sstevel@tonic-gate 2477c478bd9Sstevel@tonic-gate #ifdef _KERNEL 2487c478bd9Sstevel@tonic-gate #define AUTH_MARSHALL(auth, xdrs, cred) \ 2497c478bd9Sstevel@tonic-gate ((*((auth)->ah_ops->ah_marshal))(auth, xdrs, cred)) 2507c478bd9Sstevel@tonic-gate #define auth_marshall(auth, xdrs, cred) \ 2517c478bd9Sstevel@tonic-gate ((*((auth)->ah_ops->ah_marshal))(auth, xdrs, cred)) 2527c478bd9Sstevel@tonic-gate #else 2537c478bd9Sstevel@tonic-gate #define AUTH_MARSHALL(auth, xdrs) \ 2547c478bd9Sstevel@tonic-gate ((*((auth)->ah_ops->ah_marshal))(auth, xdrs)) 2557c478bd9Sstevel@tonic-gate #define auth_marshall(auth, xdrs) \ 2567c478bd9Sstevel@tonic-gate ((*((auth)->ah_ops->ah_marshal))(auth, xdrs)) 2577c478bd9Sstevel@tonic-gate #endif 2587c478bd9Sstevel@tonic-gate 2597c478bd9Sstevel@tonic-gate 2607c478bd9Sstevel@tonic-gate #define AUTH_VALIDATE(auth, verfp) \ 2617c478bd9Sstevel@tonic-gate ((*((auth)->ah_ops->ah_validate))((auth), verfp)) 2627c478bd9Sstevel@tonic-gate #define auth_validate(auth, verfp) \ 2637c478bd9Sstevel@tonic-gate ((*((auth)->ah_ops->ah_validate))((auth), verfp)) 2647c478bd9Sstevel@tonic-gate 2657c478bd9Sstevel@tonic-gate #ifdef _KERNEL 2667c478bd9Sstevel@tonic-gate #define AUTH_REFRESH(auth, msg, cr) \ 2677c478bd9Sstevel@tonic-gate ((*((auth)->ah_ops->ah_refresh))(auth, msg, cr)) 2687c478bd9Sstevel@tonic-gate #define auth_refresh(auth, msg, cr) \ 2697c478bd9Sstevel@tonic-gate ((*((auth)->ah_ops->ah_refresh))(auth, msg, cr)) 2707c478bd9Sstevel@tonic-gate #else 2717c478bd9Sstevel@tonic-gate #define AUTH_REFRESH(auth, msg) \ 2727c478bd9Sstevel@tonic-gate ((*((auth)->ah_ops->ah_refresh))(auth, msg)) 2737c478bd9Sstevel@tonic-gate #define auth_refresh(auth, msg) \ 2747c478bd9Sstevel@tonic-gate ((*((auth)->ah_ops->ah_refresh))(auth, msg)) 2757c478bd9Sstevel@tonic-gate #endif 2767c478bd9Sstevel@tonic-gate 2777c478bd9Sstevel@tonic-gate #define AUTH_DESTROY(auth) \ 2787c478bd9Sstevel@tonic-gate ((*((auth)->ah_ops->ah_destroy))(auth)) 2797c478bd9Sstevel@tonic-gate #define auth_destroy(auth) \ 2807c478bd9Sstevel@tonic-gate ((*((auth)->ah_ops->ah_destroy))(auth)) 2817c478bd9Sstevel@tonic-gate 2827c478bd9Sstevel@tonic-gate /* 2837c478bd9Sstevel@tonic-gate * Auth flavors can now apply a transformation in addition to simple XDR 2847c478bd9Sstevel@tonic-gate * on the body of a call/response in ways that depend on the flavor being 2857c478bd9Sstevel@tonic-gate * used. These interfaces provide a generic interface between the 2867c478bd9Sstevel@tonic-gate * internal RPC frame and the auth flavor specific code to allow the 2877c478bd9Sstevel@tonic-gate * auth flavor to encode (WRAP) or decode (UNWRAP) the body. 2887c478bd9Sstevel@tonic-gate */ 2897c478bd9Sstevel@tonic-gate #ifdef _KERNEL 2907c478bd9Sstevel@tonic-gate #define AUTH_WRAP(auth, buf, buflen, xdrs, xfunc, xwhere) \ 2917c478bd9Sstevel@tonic-gate ((*((auth)->ah_ops->ah_wrap))(auth, buf, buflen, \ 2927c478bd9Sstevel@tonic-gate xdrs, xfunc, xwhere)) 2937c478bd9Sstevel@tonic-gate #define auth_wrap(auth, buf, buflen, xdrs, xfunc, xwhere) \ 2947c478bd9Sstevel@tonic-gate ((*((auth)->ah_ops->ah_wrap))(auth, buf, buflen, \ 2957c478bd9Sstevel@tonic-gate xdrs, xfunc, xwhere)) 2967c478bd9Sstevel@tonic-gate 2977c478bd9Sstevel@tonic-gate #define AUTH_UNWRAP(auth, xdrs, xfunc, xwhere) \ 2987c478bd9Sstevel@tonic-gate ((*((auth)->ah_ops->ah_unwrap))(auth, xdrs, xfunc, xwhere)) 2997c478bd9Sstevel@tonic-gate #define auth_unwrap(auth, xdrs) \ 3007c478bd9Sstevel@tonic-gate ((*((auth)->ah_ops->ah_unwrap))(auth, xdrs, xfunc, xwhere)) 3017c478bd9Sstevel@tonic-gate #endif 3027c478bd9Sstevel@tonic-gate 3037c478bd9Sstevel@tonic-gate extern struct opaque_auth _null_auth; 3047c478bd9Sstevel@tonic-gate 3057c478bd9Sstevel@tonic-gate /* 3067c478bd9Sstevel@tonic-gate * These are the various implementations of client side authenticators. 3077c478bd9Sstevel@tonic-gate */ 3087c478bd9Sstevel@tonic-gate 3097c478bd9Sstevel@tonic-gate /* 3107c478bd9Sstevel@tonic-gate * System style authentication 3117c478bd9Sstevel@tonic-gate * AUTH *authsys_create(machname, uid, gid, len, aup_gids) 3127c478bd9Sstevel@tonic-gate * const char *machname; 3137c478bd9Sstevel@tonic-gate * const uid_t uid; 3147c478bd9Sstevel@tonic-gate * const gid_t gid; 3157c478bd9Sstevel@tonic-gate * const int len; 3167c478bd9Sstevel@tonic-gate * const gid_t *aup_gids; 3177c478bd9Sstevel@tonic-gate */ 3187c478bd9Sstevel@tonic-gate #ifdef _KERNEL 3197c478bd9Sstevel@tonic-gate extern AUTH *authkern_create(void); /* takes no parameters */ 3207c478bd9Sstevel@tonic-gate extern int authkern_init(void *, void *, int); 3217c478bd9Sstevel@tonic-gate extern struct kmem_cache *authkern_cache; 3227c478bd9Sstevel@tonic-gate extern AUTH *authloopback_create(void); /* takes no parameters */ 3237c478bd9Sstevel@tonic-gate extern int authloopback_init(void *, void *, int); 3247c478bd9Sstevel@tonic-gate extern struct kmem_cache *authloopback_cache; 3257c478bd9Sstevel@tonic-gate #else /* _KERNEL */ 3267c478bd9Sstevel@tonic-gate #ifdef __STDC__ 3277c478bd9Sstevel@tonic-gate extern AUTH *authsys_create(const char *, const uid_t, const gid_t, const int, 3287c478bd9Sstevel@tonic-gate const gid_t *); 3297c478bd9Sstevel@tonic-gate extern AUTH *authsys_create_default(void); /* takes no parameters */ 3307c478bd9Sstevel@tonic-gate extern AUTH *authnone_create(void); /* takes no parameters */ 3317c478bd9Sstevel@tonic-gate #else /* __STDC__ */ 3327c478bd9Sstevel@tonic-gate extern AUTH *authsys_create(); 3337c478bd9Sstevel@tonic-gate extern AUTH *authsys_create_default(); /* takes no parameters */ 3347c478bd9Sstevel@tonic-gate extern AUTH *authnone_create(); /* takes no parameters */ 3357c478bd9Sstevel@tonic-gate #endif /* __STDC__ */ 3367c478bd9Sstevel@tonic-gate /* Will get obsolete in near future */ 3377c478bd9Sstevel@tonic-gate #define authunix_create authsys_create 3387c478bd9Sstevel@tonic-gate #define authunix_create_default authsys_create_default 3397c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 3407c478bd9Sstevel@tonic-gate 3417c478bd9Sstevel@tonic-gate /* 3427c478bd9Sstevel@tonic-gate * DES style authentication 3437c478bd9Sstevel@tonic-gate * AUTH *authdes_seccreate(servername, window, timehost, ckey) 3447c478bd9Sstevel@tonic-gate * const char *servername; - network name of server 3457c478bd9Sstevel@tonic-gate * const uint_t window; - time to live 3467c478bd9Sstevel@tonic-gate * const char *timehost; - optional hostname to sync with 3477c478bd9Sstevel@tonic-gate * const des_block *ckey; - optional conversation key to use 3487c478bd9Sstevel@tonic-gate */ 3497c478bd9Sstevel@tonic-gate /* Will get obsolete in near future */ 3507c478bd9Sstevel@tonic-gate #ifdef _KERNEL 3517c478bd9Sstevel@tonic-gate extern int authdes_create(char *, uint_t, struct netbuf *, struct knetconfig *, 3527c478bd9Sstevel@tonic-gate des_block *, int, AUTH **retauth); 3537c478bd9Sstevel@tonic-gate #else /* _KERNEL */ 3547c478bd9Sstevel@tonic-gate #ifdef __STDC__ 3557c478bd9Sstevel@tonic-gate extern AUTH *authdes_seccreate(const char *, const uint_t, const char *, 3567c478bd9Sstevel@tonic-gate const des_block *); 3577c478bd9Sstevel@tonic-gate #else 3587c478bd9Sstevel@tonic-gate extern AUTH *authdes_seccreate(); 3597c478bd9Sstevel@tonic-gate #endif /* __STDC__ */ 3607c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 3617c478bd9Sstevel@tonic-gate 3627c478bd9Sstevel@tonic-gate /* 3637c478bd9Sstevel@tonic-gate * Netname manipulating functions 3647c478bd9Sstevel@tonic-gate */ 3657c478bd9Sstevel@tonic-gate 3667c478bd9Sstevel@tonic-gate #ifdef _KERNEL 367*f48205beScasper extern enum clnt_stat netname2user(char *, uid_t *, gid_t *, int *, gid_t *); 3687c478bd9Sstevel@tonic-gate #endif 3697c478bd9Sstevel@tonic-gate #ifdef __STDC__ 3707c478bd9Sstevel@tonic-gate extern int getnetname(char *); 3717c478bd9Sstevel@tonic-gate extern int host2netname(char *, const char *, const char *); 3727c478bd9Sstevel@tonic-gate extern int user2netname(char *, const uid_t, const char *); 3737c478bd9Sstevel@tonic-gate #ifndef _KERNEL 3747c478bd9Sstevel@tonic-gate extern int netname2user(const char *, uid_t *, gid_t *, int *, gid_t *); 3757c478bd9Sstevel@tonic-gate #endif 3767c478bd9Sstevel@tonic-gate extern int netname2host(const char *, char *, const int); 3777c478bd9Sstevel@tonic-gate #else 3787c478bd9Sstevel@tonic-gate extern int getnetname(); 3797c478bd9Sstevel@tonic-gate extern int host2netname(); 3807c478bd9Sstevel@tonic-gate extern int user2netname(); 3817c478bd9Sstevel@tonic-gate extern int netname2host(); 3827c478bd9Sstevel@tonic-gate #endif 3837c478bd9Sstevel@tonic-gate 3847c478bd9Sstevel@tonic-gate /* 3857c478bd9Sstevel@tonic-gate * These routines interface to the keyserv daemon 3867c478bd9Sstevel@tonic-gate */ 3877c478bd9Sstevel@tonic-gate 3887c478bd9Sstevel@tonic-gate #ifdef _KERNEL 3897c478bd9Sstevel@tonic-gate extern enum clnt_stat key_decryptsession(); 3907c478bd9Sstevel@tonic-gate extern enum clnt_stat key_encryptsession(); 3917c478bd9Sstevel@tonic-gate extern enum clnt_stat key_gendes(); 3927c478bd9Sstevel@tonic-gate extern enum clnt_stat key_getnetname(); 3937c478bd9Sstevel@tonic-gate #endif 3947c478bd9Sstevel@tonic-gate 3957c478bd9Sstevel@tonic-gate #ifndef _KERNEL 3967c478bd9Sstevel@tonic-gate #ifdef __STDC__ 3977c478bd9Sstevel@tonic-gate extern int key_decryptsession(const char *, des_block *); 3987c478bd9Sstevel@tonic-gate extern int key_encryptsession(const char *, des_block *); 3997c478bd9Sstevel@tonic-gate extern int key_gendes(des_block *); 4007c478bd9Sstevel@tonic-gate extern int key_setsecret(const char *); 4017c478bd9Sstevel@tonic-gate extern int key_secretkey_is_set(void); 4027c478bd9Sstevel@tonic-gate /* 4037c478bd9Sstevel@tonic-gate * The following routines are private. 4047c478bd9Sstevel@tonic-gate */ 4057c478bd9Sstevel@tonic-gate extern int key_setnet_ruid(); 4067c478bd9Sstevel@tonic-gate extern int key_setnet_g_ruid(); 4077c478bd9Sstevel@tonic-gate extern int key_removesecret_g_ruid(); 4087c478bd9Sstevel@tonic-gate extern int key_secretkey_is_set_g_ruid(); 4097c478bd9Sstevel@tonic-gate extern AUTH *authsys_create_ruid(); 4107c478bd9Sstevel@tonic-gate #else 4117c478bd9Sstevel@tonic-gate extern int key_decryptsession(); 4127c478bd9Sstevel@tonic-gate extern int key_encryptsession(); 4137c478bd9Sstevel@tonic-gate extern int key_gendes(); 4147c478bd9Sstevel@tonic-gate extern int key_setsecret(); 4157c478bd9Sstevel@tonic-gate extern int key_secretkey_is_set(); 4167c478bd9Sstevel@tonic-gate #endif 4177c478bd9Sstevel@tonic-gate #endif 4187c478bd9Sstevel@tonic-gate 4197c478bd9Sstevel@tonic-gate 4207c478bd9Sstevel@tonic-gate /* 4217c478bd9Sstevel@tonic-gate * Kerberos style authentication 4227c478bd9Sstevel@tonic-gate * AUTH *authkerb_seccreate(service, srv_inst, realm, window, timehost, status) 4237c478bd9Sstevel@tonic-gate * const char *service; - service name 4247c478bd9Sstevel@tonic-gate * const char *srv_inst; - server instance 4257c478bd9Sstevel@tonic-gate * const char *realm; - server realm 4267c478bd9Sstevel@tonic-gate * const uint_t window; - time to live 4277c478bd9Sstevel@tonic-gate * const char *timehost; - optional hostname to sync with 4287c478bd9Sstevel@tonic-gate * int *status; - kerberos status returned 4297c478bd9Sstevel@tonic-gate */ 4307c478bd9Sstevel@tonic-gate #ifdef _KERNEL 4317c478bd9Sstevel@tonic-gate extern int authkerb_create(char *, char *, char *, uint_t, 4327c478bd9Sstevel@tonic-gate struct netbuf *, int *, struct knetconfig *, int, AUTH **); 4337c478bd9Sstevel@tonic-gate #else 4347c478bd9Sstevel@tonic-gate #ifdef __STDC__ 4357c478bd9Sstevel@tonic-gate extern AUTH *authkerb_seccreate(const char *, const char *, const char *, 4367c478bd9Sstevel@tonic-gate const uint_t, const char *, int *); 4377c478bd9Sstevel@tonic-gate #else 4387c478bd9Sstevel@tonic-gate extern AUTH *authkerb_seccreate(); 4397c478bd9Sstevel@tonic-gate #endif 4407c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 4417c478bd9Sstevel@tonic-gate 4427c478bd9Sstevel@tonic-gate /* 4437c478bd9Sstevel@tonic-gate * Map a kerberos credential into a unix cred. 4447c478bd9Sstevel@tonic-gate * 4457c478bd9Sstevel@tonic-gate * authkerb_getucred(rqst, uid, gid, grouplen, groups) 4467c478bd9Sstevel@tonic-gate * const struct svc_req *rqst; - request pointer 4477c478bd9Sstevel@tonic-gate * uid_t *uid; 4487c478bd9Sstevel@tonic-gate * gid_t *gid; 4497c478bd9Sstevel@tonic-gate * short *grouplen; 4507c478bd9Sstevel@tonic-gate * int *groups; 4517c478bd9Sstevel@tonic-gate * 4527c478bd9Sstevel@tonic-gate */ 4537c478bd9Sstevel@tonic-gate #ifdef __STDC__ 4547c478bd9Sstevel@tonic-gate struct svc_req; 4557c478bd9Sstevel@tonic-gate extern int authkerb_getucred(struct svc_req *, uid_t *, gid_t *, 4567c478bd9Sstevel@tonic-gate short *, int *); 4577c478bd9Sstevel@tonic-gate #else 4587c478bd9Sstevel@tonic-gate extern int authkerb_getucred(); 4597c478bd9Sstevel@tonic-gate #endif 4607c478bd9Sstevel@tonic-gate 4617c478bd9Sstevel@tonic-gate #ifdef _KERNEL 4627c478bd9Sstevel@tonic-gate /* 4637c478bd9Sstevel@tonic-gate * XDR an opaque authentication struct. See auth.h. 4647c478bd9Sstevel@tonic-gate */ 4657c478bd9Sstevel@tonic-gate extern bool_t xdr_opaque_auth(XDR *, struct opaque_auth *); 4667c478bd9Sstevel@tonic-gate #endif 4677c478bd9Sstevel@tonic-gate 4687c478bd9Sstevel@tonic-gate #ifdef _KERNEL 4697c478bd9Sstevel@tonic-gate extern int authany_wrap(AUTH *, caddr_t, uint_t, XDR *, xdrproc_t, caddr_t); 4707c478bd9Sstevel@tonic-gate extern int authany_unwrap(AUTH *, XDR *, xdrproc_t, caddr_t); 4717c478bd9Sstevel@tonic-gate #endif 4727c478bd9Sstevel@tonic-gate 4737c478bd9Sstevel@tonic-gate #define AUTH_NONE 0 /* no authentication */ 4747c478bd9Sstevel@tonic-gate #define AUTH_NULL 0 /* backward compatibility */ 4757c478bd9Sstevel@tonic-gate #define AUTH_SYS 1 /* unix style (uid, gids) */ 4767c478bd9Sstevel@tonic-gate #define AUTH_UNIX AUTH_SYS 4777c478bd9Sstevel@tonic-gate #define AUTH_SHORT 2 /* short hand unix style */ 4787c478bd9Sstevel@tonic-gate #define AUTH_DH 3 /* for Diffie-Hellman mechanism */ 4797c478bd9Sstevel@tonic-gate #define AUTH_DES AUTH_DH /* for backward compatibility */ 4807c478bd9Sstevel@tonic-gate #define AUTH_KERB 4 /* kerberos style */ 4817c478bd9Sstevel@tonic-gate #define RPCSEC_GSS 6 /* GSS-API style */ 4827c478bd9Sstevel@tonic-gate 4837c478bd9Sstevel@tonic-gate #define AUTH_LOOPBACK 21982 /* unix style w/ expanded groups */ 4847c478bd9Sstevel@tonic-gate /* for use over the local transport */ 4857c478bd9Sstevel@tonic-gate 4867c478bd9Sstevel@tonic-gate #ifdef _KERNEL 4877c478bd9Sstevel@tonic-gate extern char loopback_name[]; 4887c478bd9Sstevel@tonic-gate 4897c478bd9Sstevel@tonic-gate extern zone_key_t auth_zone_key; 4907c478bd9Sstevel@tonic-gate extern void * auth_zone_init(zoneid_t); 4917c478bd9Sstevel@tonic-gate extern void auth_zone_fini(zoneid_t, void *); 4927c478bd9Sstevel@tonic-gate #endif 4937c478bd9Sstevel@tonic-gate 4947c478bd9Sstevel@tonic-gate #ifdef __cplusplus 4957c478bd9Sstevel@tonic-gate } 4967c478bd9Sstevel@tonic-gate #endif 4977c478bd9Sstevel@tonic-gate 4987c478bd9Sstevel@tonic-gate #endif /* !_RPC_AUTH_H */ 499