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 /* 23*0Sstevel@tonic-gate * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 24*0Sstevel@tonic-gate * Use is subject to license terms. 25*0Sstevel@tonic-gate */ 26*0Sstevel@tonic-gate 27*0Sstevel@tonic-gate #ifndef _PAM_IMPL_H 28*0Sstevel@tonic-gate #define _PAM_IMPL_H 29*0Sstevel@tonic-gate 30*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 31*0Sstevel@tonic-gate 32*0Sstevel@tonic-gate #ifdef __cplusplus 33*0Sstevel@tonic-gate extern "C" { 34*0Sstevel@tonic-gate #endif 35*0Sstevel@tonic-gate 36*0Sstevel@tonic-gate #include <limits.h> 37*0Sstevel@tonic-gate #include <shadow.h> 38*0Sstevel@tonic-gate #include <sys/types.h> 39*0Sstevel@tonic-gate 40*0Sstevel@tonic-gate #define PAMTXD "SUNW_OST_SYSOSPAM" 41*0Sstevel@tonic-gate 42*0Sstevel@tonic-gate #define PAM_CONFIG "/etc/pam.conf" 43*0Sstevel@tonic-gate #define PAM_ISA "/$ISA/" 44*0Sstevel@tonic-gate #define PAM_LIB_DIR "/usr/lib/security/" 45*0Sstevel@tonic-gate #ifdef _LP64 46*0Sstevel@tonic-gate #define PAM_ISA_DIR "/64/" 47*0Sstevel@tonic-gate #else /* !_LP64 */ 48*0Sstevel@tonic-gate #define PAM_ISA_DIR "/" 49*0Sstevel@tonic-gate #endif /* _LP64 */ 50*0Sstevel@tonic-gate 51*0Sstevel@tonic-gate /* Service Module Types */ 52*0Sstevel@tonic-gate 53*0Sstevel@tonic-gate /* 54*0Sstevel@tonic-gate * If new service types are added, they should be named in 55*0Sstevel@tonic-gate * pam_framework.c::pam_snames[] as well. 56*0Sstevel@tonic-gate */ 57*0Sstevel@tonic-gate 58*0Sstevel@tonic-gate #define PAM_ACCOUNT_NAME "account" 59*0Sstevel@tonic-gate #define PAM_AUTH_NAME "auth" 60*0Sstevel@tonic-gate #define PAM_PASSWORD_NAME "password" 61*0Sstevel@tonic-gate #define PAM_SESSION_NAME "session" 62*0Sstevel@tonic-gate 63*0Sstevel@tonic-gate #define PAM_ACCOUNT_MODULE 0 64*0Sstevel@tonic-gate #define PAM_AUTH_MODULE 1 65*0Sstevel@tonic-gate #define PAM_PASSWORD_MODULE 2 66*0Sstevel@tonic-gate #define PAM_SESSION_MODULE 3 67*0Sstevel@tonic-gate 68*0Sstevel@tonic-gate #define PAM_NUM_MODULE_TYPES 4 69*0Sstevel@tonic-gate 70*0Sstevel@tonic-gate /* Control Flags */ 71*0Sstevel@tonic-gate 72*0Sstevel@tonic-gate #define PAM_BINDING_NAME "binding" 73*0Sstevel@tonic-gate #define PAM_INCLUDE_NAME "include" 74*0Sstevel@tonic-gate #define PAM_OPTIONAL_NAME "optional" 75*0Sstevel@tonic-gate #define PAM_REQUIRED_NAME "required" 76*0Sstevel@tonic-gate #define PAM_REQUISITE_NAME "requisite" 77*0Sstevel@tonic-gate #define PAM_SUFFICIENT_NAME "sufficient" 78*0Sstevel@tonic-gate 79*0Sstevel@tonic-gate #define PAM_BINDING 0x01 80*0Sstevel@tonic-gate #define PAM_INCLUDE 0x02 81*0Sstevel@tonic-gate #define PAM_OPTIONAL 0x04 82*0Sstevel@tonic-gate #define PAM_REQUIRED 0x08 83*0Sstevel@tonic-gate #define PAM_REQUISITE 0x10 84*0Sstevel@tonic-gate #define PAM_SUFFICIENT 0x20 85*0Sstevel@tonic-gate 86*0Sstevel@tonic-gate #define PAM_REQRD_BIND (PAM_REQUIRED | PAM_BINDING) 87*0Sstevel@tonic-gate #define PAM_SUFFI_BIND (PAM_SUFFICIENT | PAM_BINDING) 88*0Sstevel@tonic-gate 89*0Sstevel@tonic-gate /* Function Indicators */ 90*0Sstevel@tonic-gate 91*0Sstevel@tonic-gate #define PAM_AUTHENTICATE 1 92*0Sstevel@tonic-gate #define PAM_SETCRED 2 93*0Sstevel@tonic-gate #define PAM_ACCT_MGMT 3 94*0Sstevel@tonic-gate #define PAM_OPEN_SESSION 4 95*0Sstevel@tonic-gate #define PAM_CLOSE_SESSION 5 96*0Sstevel@tonic-gate #define PAM_CHAUTHTOK 6 97*0Sstevel@tonic-gate 98*0Sstevel@tonic-gate /* PAM tracing */ 99*0Sstevel@tonic-gate 100*0Sstevel@tonic-gate #define PAM_DEBUG "/etc/pam_debug" 101*0Sstevel@tonic-gate #define LOG_PRIORITY "log_priority=" 102*0Sstevel@tonic-gate #define LOG_FACILITY "log_facility=" 103*0Sstevel@tonic-gate #define DEBUG_FLAGS "debug_flags=" 104*0Sstevel@tonic-gate #define PAM_DEBUG_NONE 0x0000 105*0Sstevel@tonic-gate #define PAM_DEBUG_DEFAULT 0x0001 106*0Sstevel@tonic-gate #define PAM_DEBUG_ITEM 0x0002 107*0Sstevel@tonic-gate #define PAM_DEBUG_MODULE 0x0004 108*0Sstevel@tonic-gate #define PAM_DEBUG_CONF 0x0008 109*0Sstevel@tonic-gate #define PAM_DEBUG_DATA 0x0010 110*0Sstevel@tonic-gate #define PAM_DEBUG_CONV 0x0020 111*0Sstevel@tonic-gate #define PAM_DEBUG_AUTHTOK 0x8000 112*0Sstevel@tonic-gate 113*0Sstevel@tonic-gate #define PAM_MAX_ITEMS 64 /* Max number of items */ 114*0Sstevel@tonic-gate #define PAM_MAX_INCLUDE 32 /* Max include flag recursions */ 115*0Sstevel@tonic-gate 116*0Sstevel@tonic-gate /* authentication module functions */ 117*0Sstevel@tonic-gate #define PAM_SM_AUTHENTICATE "pam_sm_authenticate" 118*0Sstevel@tonic-gate #define PAM_SM_SETCRED "pam_sm_setcred" 119*0Sstevel@tonic-gate 120*0Sstevel@tonic-gate /* session module functions */ 121*0Sstevel@tonic-gate #define PAM_SM_OPEN_SESSION "pam_sm_open_session" 122*0Sstevel@tonic-gate #define PAM_SM_CLOSE_SESSION "pam_sm_close_session" 123*0Sstevel@tonic-gate 124*0Sstevel@tonic-gate /* password module functions */ 125*0Sstevel@tonic-gate #define PAM_SM_CHAUTHTOK "pam_sm_chauthtok" 126*0Sstevel@tonic-gate 127*0Sstevel@tonic-gate /* account module functions */ 128*0Sstevel@tonic-gate #define PAM_SM_ACCT_MGMT "pam_sm_acct_mgmt" 129*0Sstevel@tonic-gate 130*0Sstevel@tonic-gate /* 131*0Sstevel@tonic-gate * Definitions shared by passwd.c and the UNIX module 132*0Sstevel@tonic-gate */ 133*0Sstevel@tonic-gate 134*0Sstevel@tonic-gate #define PAM_REP_DEFAULT 0x0 135*0Sstevel@tonic-gate #define PAM_REP_FILES 0x01 136*0Sstevel@tonic-gate #define PAM_REP_NIS 0x02 137*0Sstevel@tonic-gate #define PAM_REP_NISPLUS 0x04 138*0Sstevel@tonic-gate #define PAM_REP_LDAP 0x10 139*0Sstevel@tonic-gate #define PAM_OPWCMD 0x08 /* for nispasswd, yppasswd */ 140*0Sstevel@tonic-gate 141*0Sstevel@tonic-gate /* max # of authentication token attributes */ 142*0Sstevel@tonic-gate #define PAM_MAX_NUM_ATTR 10 143*0Sstevel@tonic-gate 144*0Sstevel@tonic-gate /* max size (in chars) of an authentication token attribute */ 145*0Sstevel@tonic-gate #define PAM_MAX_ATTR_SIZE 80 146*0Sstevel@tonic-gate 147*0Sstevel@tonic-gate /* utility function prototypes */ 148*0Sstevel@tonic-gate 149*0Sstevel@tonic-gate /* source values when calling __pam_get_authtok() */ 150*0Sstevel@tonic-gate #define PAM_PROMPT 1 /* prompt user for new password */ 151*0Sstevel@tonic-gate #define PAM_HANDLE 2 /* get password from pam handle (item) */ 152*0Sstevel@tonic-gate 153*0Sstevel@tonic-gate #if PASS_MAX >= PAM_MAX_RESP_SIZE 154*0Sstevel@tonic-gate #error PASS_MAX > PAM_MAX_RESP_SIZE 155*0Sstevel@tonic-gate #endif /* PASS_MAX >= PAM_MAX_RESP_SIZE */ 156*0Sstevel@tonic-gate 157*0Sstevel@tonic-gate extern int 158*0Sstevel@tonic-gate __pam_get_authtok(pam_handle_t *pamh, int source, int type, char *prompt, 159*0Sstevel@tonic-gate char **authtok); 160*0Sstevel@tonic-gate 161*0Sstevel@tonic-gate extern int 162*0Sstevel@tonic-gate __pam_display_msg(pam_handle_t *pamh, int msg_style, int num_msg, 163*0Sstevel@tonic-gate char messages[PAM_MAX_NUM_MSG][PAM_MAX_MSG_SIZE], void *conv_apdp); 164*0Sstevel@tonic-gate 165*0Sstevel@tonic-gate extern void 166*0Sstevel@tonic-gate __pam_log(int priority, const char *format, ...); 167*0Sstevel@tonic-gate 168*0Sstevel@tonic-gate /* file handle for pam.conf */ 169*0Sstevel@tonic-gate struct pam_fh { 170*0Sstevel@tonic-gate int fconfig; /* file descriptor returned by open() */ 171*0Sstevel@tonic-gate char line[256]; 172*0Sstevel@tonic-gate size_t bufsize; /* size of the buffer which holds */ 173*0Sstevel@tonic-gate /* the content of pam.conf */ 174*0Sstevel@tonic-gate char *bufferp; /* used to process data */ 175*0Sstevel@tonic-gate char *data; /* contents of pam.conf */ 176*0Sstevel@tonic-gate }; 177*0Sstevel@tonic-gate 178*0Sstevel@tonic-gate /* items that can be set/retrieved thru pam_[sg]et_item() */ 179*0Sstevel@tonic-gate struct pam_item { 180*0Sstevel@tonic-gate void *pi_addr; /* pointer to item */ 181*0Sstevel@tonic-gate int pi_size; /* size of item */ 182*0Sstevel@tonic-gate }; 183*0Sstevel@tonic-gate 184*0Sstevel@tonic-gate /* module specific data stored in the pam handle */ 185*0Sstevel@tonic-gate struct pam_module_data { 186*0Sstevel@tonic-gate char *module_data_name; /* unique module data name */ 187*0Sstevel@tonic-gate void *data; /* the module specific data */ 188*0Sstevel@tonic-gate void (*cleanup)(pam_handle_t *pamh, void *data, int pam_status); 189*0Sstevel@tonic-gate struct pam_module_data *next; /* pointer to next module data */ 190*0Sstevel@tonic-gate }; 191*0Sstevel@tonic-gate 192*0Sstevel@tonic-gate /* each entry from pam.conf is stored here (in the pam handle) */ 193*0Sstevel@tonic-gate typedef struct pamtab { 194*0Sstevel@tonic-gate char *pam_service; /* PAM service, e.g. login, rlogin */ 195*0Sstevel@tonic-gate int pam_type; /* AUTH, ACCOUNT, PASSWORD, SESSION */ 196*0Sstevel@tonic-gate int pam_flag; /* required, optional, sufficient */ 197*0Sstevel@tonic-gate char *module_path; /* module library */ 198*0Sstevel@tonic-gate int module_argc; /* module specific options */ 199*0Sstevel@tonic-gate char **module_argv; 200*0Sstevel@tonic-gate void *function_ptr; /* pointer to struct holding function ptrs */ 201*0Sstevel@tonic-gate struct pamtab *next; 202*0Sstevel@tonic-gate } pamtab_t; 203*0Sstevel@tonic-gate 204*0Sstevel@tonic-gate /* list of open fd's (modules that were dlopen'd) */ 205*0Sstevel@tonic-gate typedef struct fd_list { 206*0Sstevel@tonic-gate void *mh; /* module handle */ 207*0Sstevel@tonic-gate struct fd_list *next; 208*0Sstevel@tonic-gate } fd_list; 209*0Sstevel@tonic-gate 210*0Sstevel@tonic-gate /* list of PAM environment varialbes */ 211*0Sstevel@tonic-gate typedef struct env_list { 212*0Sstevel@tonic-gate char *name; 213*0Sstevel@tonic-gate char *value; 214*0Sstevel@tonic-gate struct env_list *next; 215*0Sstevel@tonic-gate } env_list; 216*0Sstevel@tonic-gate 217*0Sstevel@tonic-gate /* pam_inmodule values for pam item checking */ 218*0Sstevel@tonic-gate #define RW_OK 0 /* Read Write items OK */ 219*0Sstevel@tonic-gate #define RO_OK 1 /* Read Only items OK */ 220*0Sstevel@tonic-gate #define WO_OK 2 /* Write Only items/data OK */ 221*0Sstevel@tonic-gate 222*0Sstevel@tonic-gate /* the pam handle */ 223*0Sstevel@tonic-gate struct pam_handle { 224*0Sstevel@tonic-gate struct pam_item ps_item[PAM_MAX_ITEMS]; /* array of PAM items */ 225*0Sstevel@tonic-gate int include_depth; 226*0Sstevel@tonic-gate int pam_inmodule; /* Protect restricted pam_get_item calls */ 227*0Sstevel@tonic-gate char *pam_conf_name[PAM_MAX_INCLUDE+1]; 228*0Sstevel@tonic-gate pamtab_t *pam_conf_info[PAM_MAX_INCLUDE+1][PAM_NUM_MODULE_TYPES]; 229*0Sstevel@tonic-gate pamtab_t *pam_conf_modulep[PAM_MAX_INCLUDE+1]; 230*0Sstevel@tonic-gate struct pam_module_data *ssd; /* module specific data */ 231*0Sstevel@tonic-gate fd_list *fd; /* module fd's */ 232*0Sstevel@tonic-gate env_list *pam_env; /* environment variables */ 233*0Sstevel@tonic-gate 234*0Sstevel@tonic-gate /* 235*0Sstevel@tonic-gate * XXX -- Contracted Consolidation Private 236*0Sstevel@tonic-gate * to be eliminated when dtlogin contract is terminated 237*0Sstevel@tonic-gate * Version number requested by PAM's client 238*0Sstevel@tonic-gate */ 239*0Sstevel@tonic-gate char *pam_client_message_version_number; 240*0Sstevel@tonic-gate }; 241*0Sstevel@tonic-gate 242*0Sstevel@tonic-gate /* 243*0Sstevel@tonic-gate * the function_ptr field in pamtab_t 244*0Sstevel@tonic-gate * will point to one of these modules 245*0Sstevel@tonic-gate */ 246*0Sstevel@tonic-gate struct auth_module { 247*0Sstevel@tonic-gate int (*pam_sm_authenticate)(pam_handle_t *pamh, int flags, int argc, 248*0Sstevel@tonic-gate const char **argv); 249*0Sstevel@tonic-gate int (*pam_sm_setcred)(pam_handle_t *pamh, int flags, int argc, 250*0Sstevel@tonic-gate const char **argv); 251*0Sstevel@tonic-gate }; 252*0Sstevel@tonic-gate 253*0Sstevel@tonic-gate struct password_module { 254*0Sstevel@tonic-gate int (*pam_sm_chauthtok)(pam_handle_t *pamh, int flags, int argc, 255*0Sstevel@tonic-gate const char **argv); 256*0Sstevel@tonic-gate }; 257*0Sstevel@tonic-gate 258*0Sstevel@tonic-gate struct session_module { 259*0Sstevel@tonic-gate int (*pam_sm_open_session)(pam_handle_t *pamh, int flags, int argc, 260*0Sstevel@tonic-gate const char **argv); 261*0Sstevel@tonic-gate int (*pam_sm_close_session)(pam_handle_t *pamh, int flags, int argc, 262*0Sstevel@tonic-gate const char **argv); 263*0Sstevel@tonic-gate }; 264*0Sstevel@tonic-gate 265*0Sstevel@tonic-gate struct account_module { 266*0Sstevel@tonic-gate int (*pam_sm_acct_mgmt)(pam_handle_t *pamh, int flags, int argc, 267*0Sstevel@tonic-gate const char **argv); 268*0Sstevel@tonic-gate }; 269*0Sstevel@tonic-gate 270*0Sstevel@tonic-gate #ifdef __cplusplus 271*0Sstevel@tonic-gate } 272*0Sstevel@tonic-gate #endif 273*0Sstevel@tonic-gate 274*0Sstevel@tonic-gate #endif /* _PAM_IMPL_H */ 275