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