1*0Sstevel@tonic-gate /* 2*0Sstevel@tonic-gate * CDDL HEADER START 3*0Sstevel@tonic-gate * 4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*0Sstevel@tonic-gate * with the License. 8*0Sstevel@tonic-gate * 9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*0Sstevel@tonic-gate * See the License for the specific language governing permissions 12*0Sstevel@tonic-gate * and limitations under the License. 13*0Sstevel@tonic-gate * 14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*0Sstevel@tonic-gate * 20*0Sstevel@tonic-gate * CDDL HEADER END 21*0Sstevel@tonic-gate */ 22*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 23*0Sstevel@tonic-gate 24*0Sstevel@tonic-gate /* 25*0Sstevel@tonic-gate * auth.h, Authentication interface. 26*0Sstevel@tonic-gate * 27*0Sstevel@tonic-gate * Copyright (C) 1984, Sun Microsystems, Inc. 28*0Sstevel@tonic-gate * 29*0Sstevel@tonic-gate * The data structures are completely opaque to the client. The client 30*0Sstevel@tonic-gate * is required to pass a AUTH * to routines that create rpc 31*0Sstevel@tonic-gate * "sessions". 32*0Sstevel@tonic-gate */ 33*0Sstevel@tonic-gate 34*0Sstevel@tonic-gate 35*0Sstevel@tonic-gate #ifndef _rpc_auth_h 36*0Sstevel@tonic-gate #define _rpc_auth_h 37*0Sstevel@tonic-gate 38*0Sstevel@tonic-gate #define MAX_AUTH_BYTES 400 39*0Sstevel@tonic-gate #define MAXNETNAMELEN 255 /* maximum length of network user's name */ 40*0Sstevel@tonic-gate 41*0Sstevel@tonic-gate /* 42*0Sstevel@tonic-gate * Status returned from authentication check 43*0Sstevel@tonic-gate */ 44*0Sstevel@tonic-gate enum auth_stat { 45*0Sstevel@tonic-gate AUTH_OK=0, 46*0Sstevel@tonic-gate /* 47*0Sstevel@tonic-gate * failed at remote end 48*0Sstevel@tonic-gate */ 49*0Sstevel@tonic-gate AUTH_BADCRED=1, /* bogus credentials (seal broken) */ 50*0Sstevel@tonic-gate AUTH_REJECTEDCRED=2, /* client should begin new session */ 51*0Sstevel@tonic-gate AUTH_BADVERF=3, /* bogus verifier (seal broken) */ 52*0Sstevel@tonic-gate AUTH_REJECTEDVERF=4, /* verifier expired or was replayed */ 53*0Sstevel@tonic-gate AUTH_TOOWEAK=5, /* rejected due to security reasons */ 54*0Sstevel@tonic-gate /* 55*0Sstevel@tonic-gate * failed locally 56*0Sstevel@tonic-gate */ 57*0Sstevel@tonic-gate AUTH_INVALIDRESP=6, /* bogus response verifier */ 58*0Sstevel@tonic-gate AUTH_FAILED=7 /* some unknown reason */ 59*0Sstevel@tonic-gate }; 60*0Sstevel@tonic-gate 61*0Sstevel@tonic-gate #if (mc68000 || sparc || vax || i386) 62*0Sstevel@tonic-gate typedef u_long u_int32; /* 32-bit unsigned integers */ 63*0Sstevel@tonic-gate #endif 64*0Sstevel@tonic-gate 65*0Sstevel@tonic-gate union des_block { 66*0Sstevel@tonic-gate struct { 67*0Sstevel@tonic-gate u_int32 high; 68*0Sstevel@tonic-gate u_int32 low; 69*0Sstevel@tonic-gate } key; 70*0Sstevel@tonic-gate char c[8]; 71*0Sstevel@tonic-gate }; 72*0Sstevel@tonic-gate typedef union des_block des_block; 73*0Sstevel@tonic-gate extern bool_t xdr_des_block(); 74*0Sstevel@tonic-gate 75*0Sstevel@tonic-gate /* 76*0Sstevel@tonic-gate * Authentication info. Opaque to client. 77*0Sstevel@tonic-gate */ 78*0Sstevel@tonic-gate struct opaque_auth { 79*0Sstevel@tonic-gate enum_t oa_flavor; /* flavor of auth */ 80*0Sstevel@tonic-gate caddr_t oa_base; /* address of more auth stuff */ 81*0Sstevel@tonic-gate u_int oa_length; /* not to exceed MAX_AUTH_BYTES */ 82*0Sstevel@tonic-gate }; 83*0Sstevel@tonic-gate 84*0Sstevel@tonic-gate 85*0Sstevel@tonic-gate /* 86*0Sstevel@tonic-gate * Auth handle, interface to client side authenticators. 87*0Sstevel@tonic-gate */ 88*0Sstevel@tonic-gate typedef struct { 89*0Sstevel@tonic-gate struct opaque_auth ah_cred; 90*0Sstevel@tonic-gate struct opaque_auth ah_verf; 91*0Sstevel@tonic-gate union des_block ah_key; 92*0Sstevel@tonic-gate struct auth_ops { 93*0Sstevel@tonic-gate void (*ah_nextverf)(); 94*0Sstevel@tonic-gate int (*ah_marshal)(); /* nextverf & serialize */ 95*0Sstevel@tonic-gate int (*ah_validate)(); /* validate varifier */ 96*0Sstevel@tonic-gate int (*ah_refresh)(); /* refresh credentials */ 97*0Sstevel@tonic-gate void (*ah_destroy)(); /* destroy this structure */ 98*0Sstevel@tonic-gate } *ah_ops; 99*0Sstevel@tonic-gate caddr_t ah_private; 100*0Sstevel@tonic-gate } AUTH; 101*0Sstevel@tonic-gate 102*0Sstevel@tonic-gate 103*0Sstevel@tonic-gate /* 104*0Sstevel@tonic-gate * Authentication ops. 105*0Sstevel@tonic-gate * The ops and the auth handle provide the interface to the authenticators. 106*0Sstevel@tonic-gate * 107*0Sstevel@tonic-gate * AUTH *auth; 108*0Sstevel@tonic-gate * XDR *xdrs; 109*0Sstevel@tonic-gate * struct opaque_auth verf; 110*0Sstevel@tonic-gate */ 111*0Sstevel@tonic-gate #define AUTH_NEXTVERF(auth) \ 112*0Sstevel@tonic-gate ((*((auth)->ah_ops->ah_nextverf))(auth)) 113*0Sstevel@tonic-gate #define auth_nextverf(auth) \ 114*0Sstevel@tonic-gate ((*((auth)->ah_ops->ah_nextverf))(auth)) 115*0Sstevel@tonic-gate 116*0Sstevel@tonic-gate #define AUTH_MARSHALL(auth, xdrs) \ 117*0Sstevel@tonic-gate ((*((auth)->ah_ops->ah_marshal))(auth, xdrs)) 118*0Sstevel@tonic-gate #define auth_marshall(auth, xdrs) \ 119*0Sstevel@tonic-gate ((*((auth)->ah_ops->ah_marshal))(auth, xdrs)) 120*0Sstevel@tonic-gate 121*0Sstevel@tonic-gate #define AUTH_VALIDATE(auth, verfp) \ 122*0Sstevel@tonic-gate ((*((auth)->ah_ops->ah_validate))((auth), verfp)) 123*0Sstevel@tonic-gate #define auth_validate(auth, verfp) \ 124*0Sstevel@tonic-gate ((*((auth)->ah_ops->ah_validate))((auth), verfp)) 125*0Sstevel@tonic-gate 126*0Sstevel@tonic-gate #define AUTH_REFRESH(auth) \ 127*0Sstevel@tonic-gate ((*((auth)->ah_ops->ah_refresh))(auth)) 128*0Sstevel@tonic-gate #define auth_refresh(auth) \ 129*0Sstevel@tonic-gate ((*((auth)->ah_ops->ah_refresh))(auth)) 130*0Sstevel@tonic-gate 131*0Sstevel@tonic-gate #define AUTH_DESTROY(auth) \ 132*0Sstevel@tonic-gate ((*((auth)->ah_ops->ah_destroy))(auth)) 133*0Sstevel@tonic-gate #define auth_destroy(auth) \ 134*0Sstevel@tonic-gate ((*((auth)->ah_ops->ah_destroy))(auth)) 135*0Sstevel@tonic-gate 136*0Sstevel@tonic-gate 137*0Sstevel@tonic-gate extern struct opaque_auth _null_auth; 138*0Sstevel@tonic-gate 139*0Sstevel@tonic-gate 140*0Sstevel@tonic-gate /* 141*0Sstevel@tonic-gate * These are the various implementations of client side authenticators. 142*0Sstevel@tonic-gate */ 143*0Sstevel@tonic-gate 144*0Sstevel@tonic-gate /* 145*0Sstevel@tonic-gate * Unix style authentication 146*0Sstevel@tonic-gate * AUTH *authunix_create(machname, uid, gid, len, aup_gids) 147*0Sstevel@tonic-gate * char *machname; 148*0Sstevel@tonic-gate * int uid; 149*0Sstevel@tonic-gate * int gid; 150*0Sstevel@tonic-gate * int len; 151*0Sstevel@tonic-gate * int *aup_gids; 152*0Sstevel@tonic-gate */ 153*0Sstevel@tonic-gate #ifdef KERNEL 154*0Sstevel@tonic-gate extern AUTH *authkern_create(); /* takes no parameters */ 155*0Sstevel@tonic-gate #else 156*0Sstevel@tonic-gate extern AUTH *authsys_create(const char *, const uid_t, const gid_t, 157*0Sstevel@tonic-gate const int, const gid_t *); 158*0Sstevel@tonic-gate extern AUTH *authsys_create_default(void); /* takes no parameters */ 159*0Sstevel@tonic-gate extern AUTH *authnone_create(); /* takes no parameters */ 160*0Sstevel@tonic-gate #endif 161*0Sstevel@tonic-gate extern AUTH *authdes_create(); 162*0Sstevel@tonic-gate 163*0Sstevel@tonic-gate #define AUTH_NONE 0 /* no authentication */ 164*0Sstevel@tonic-gate #define AUTH_NULL 0 /* backward compatibility */ 165*0Sstevel@tonic-gate #define AUTH_UNIX 1 /* unix style (uid, gids) */ 166*0Sstevel@tonic-gate #define AUTH_SHORT 2 /* short hand unix style */ 167*0Sstevel@tonic-gate #define AUTH_DES 3 /* des style (encrypted timestamps) */ 168*0Sstevel@tonic-gate 169*0Sstevel@tonic-gate #endif /* !_rpc_auth_h */ 170