1 #ifndef __LEASH_INT_H__ 2 #define __LEASH_INT_H__ 3 4 #include <stdio.h> 5 #include <stdlib.h> 6 7 #include "leashdll.h" 8 #include <leashwin.h> 9 10 #include "tlhelp32.h" 11 12 #define MIT_PWD_DLL_CLASS "MITPasswordWndDLL" 13 14 BOOL 15 Register_MITPasswordEditControl( 16 HINSTANCE hInst 17 ); 18 19 BOOL 20 Unregister_MITPasswordEditControl( 21 HINSTANCE hInst 22 ); 23 24 // Some defines swiped from leash.h 25 // These are necessary but they must be kept sync'ed with leash.h 26 #define HELPFILE "leash32.hlp" 27 extern char KRB_HelpFile[_MAX_PATH]; 28 29 // Function Prototypes. 30 int DoNiftyErrorReport(long errnum, LPSTR what); 31 LONG Leash_timesync(int); 32 33 // Crap... 34 #include <krb5.h> 35 36 long 37 Leash_int_kinit_ex( 38 krb5_context ctx, 39 HWND hParent, 40 char * principal, 41 char * password, 42 int lifetime, 43 int forwardable, 44 int proxiable, 45 int renew_life, 46 int addressless, 47 unsigned long publicIP, 48 int displayErrors 49 ); 50 51 long 52 Leash_int_checkpwd( 53 char * principal, 54 char * password, 55 int displayErrors 56 ); 57 58 long 59 Leash_int_changepwd( 60 char * principal, 61 char * password, 62 char * newpassword, 63 char** result_string, 64 int displayErrors 65 ); 66 67 int 68 Leash_krb5_kdestroy( 69 void 70 ); 71 72 int 73 Leash_krb5_kinit( 74 krb5_context, 75 HWND hParent, 76 char * principal_name, 77 char * password, 78 krb5_deltat lifetime, 79 DWORD forwardable, 80 DWORD proxiable, 81 krb5_deltat renew_life, 82 DWORD addressless, 83 DWORD publicIP 84 ); 85 86 int 87 LeashKRB5_renew(void); 88 89 int 90 config_boolean_to_int( 91 const char *s 92 ); 93 94 BOOL GetSecurityLogonSessionData(PSECURITY_LOGON_SESSION_DATA * ppSessionData); 95 BOOL IsKerberosLogon(VOID); 96 97 int Leash_krb5_error(krb5_error_code rc, LPCSTR FailedFunctionName, 98 int FreeContextFlag, krb5_context *ctx, 99 krb5_ccache *cache); 100 int Leash_krb5_initialize(krb5_context *); 101 krb5_error_code 102 Leash_krb5_cc_default(krb5_context *ctx, krb5_ccache *cache); 103 104 LPSTR err_describe(LPSTR buf, long code); 105 106 // toolhelp functions 107 TYPEDEF_FUNC( 108 HANDLE, 109 WINAPI, 110 CreateToolhelp32Snapshot, 111 (DWORD, DWORD) 112 ); 113 TYPEDEF_FUNC( 114 BOOL, 115 WINAPI, 116 Module32First, 117 (HANDLE, LPMODULEENTRY32) 118 ); 119 TYPEDEF_FUNC( 120 BOOL, 121 WINAPI, 122 Module32Next, 123 (HANDLE, LPMODULEENTRY32) 124 ); 125 126 // psapi functions 127 TYPEDEF_FUNC( 128 DWORD, 129 WINAPI, 130 GetModuleFileNameExA, 131 (HANDLE, HMODULE, LPSTR, DWORD) 132 ); 133 TYPEDEF_FUNC( 134 BOOL, 135 WINAPI, 136 EnumProcessModules, 137 (HANDLE, HMODULE*, DWORD, LPDWORD) 138 ); 139 140 #define pGetModuleFileNameEx pGetModuleFileNameExA 141 #define TOOLHELPDLL "kernel32.dll" 142 #define PSAPIDLL "psapi.dll" 143 144 // psapi functions 145 extern DECL_FUNC_PTR(GetModuleFileNameExA); 146 extern DECL_FUNC_PTR(EnumProcessModules); 147 148 // toolhelp functions 149 extern DECL_FUNC_PTR(CreateToolhelp32Snapshot); 150 extern DECL_FUNC_PTR(Module32First); 151 extern DECL_FUNC_PTR(Module32Next); 152 153 /* In order to avoid including the private CCAPI headers */ 154 typedef int cc_int32; 155 156 #define CC_API_VER_1 1 157 #define CC_API_VER_2 2 158 159 #define CCACHE_API cc_int32 160 161 /* 162 ** The Official Error Codes 163 */ 164 #define CC_NOERROR 0 165 #define CC_BADNAME 1 166 #define CC_NOTFOUND 2 167 #define CC_END 3 168 #define CC_IO 4 169 #define CC_WRITE 5 170 #define CC_NOMEM 6 171 #define CC_FORMAT 7 172 #define CC_LOCKED 8 173 #define CC_BAD_API_VERSION 9 174 #define CC_NO_EXIST 10 175 #define CC_NOT_SUPP 11 176 #define CC_BAD_PARM 12 177 #define CC_ERR_CACHE_ATTACH 13 178 #define CC_ERR_CACHE_RELEASE 14 179 #define CC_ERR_CACHE_FULL 15 180 #define CC_ERR_CRED_VERSION 16 181 182 enum { 183 CC_CRED_VUNKNOWN = 0, // For validation 184 /* CC_CRED_V4 = 1, */ 185 CC_CRED_V5 = 2, 186 CC_CRED_VMAX = 3 // For validation 187 }; 188 189 typedef struct opaque_dll_control_block_type* apiCB; 190 typedef struct _infoNC { 191 char* name; 192 char* principal; 193 cc_int32 vers; 194 } infoNC; 195 196 TYPEDEF_FUNC( 197 CCACHE_API, 198 __cdecl, 199 cc_initialize, 200 ( 201 apiCB** cc_ctx, // < DLL's primary control structure. 202 // returned here, passed everywhere else 203 cc_int32 api_version, // > ver supported by caller (use CC_API_VER_1) 204 cc_int32* api_supported, // < if ~NULL, max ver supported by DLL 205 const char** vendor // < if ~NULL, vendor name in read only C string 206 ) 207 ); 208 209 TYPEDEF_FUNC( 210 CCACHE_API, 211 __cdecl, 212 cc_shutdown, 213 ( 214 apiCB** cc_ctx // <> DLL's primary control structure. NULL after 215 ) 216 ); 217 218 TYPEDEF_FUNC( 219 CCACHE_API, 220 __cdecl, 221 cc_get_NC_info, 222 ( 223 apiCB* cc_ctx, // > DLL's primary control structure 224 struct _infoNC*** ppNCi // < (NULL before call) null terminated, 225 // list of a structs (free via cc_free_infoNC()) 226 ) 227 ); 228 229 TYPEDEF_FUNC( 230 CCACHE_API, 231 __cdecl, 232 cc_free_NC_info, 233 ( 234 apiCB* cc_ctx, 235 struct _infoNC*** ppNCi // < free list of structs returned by 236 // cc_get_cache_names(). set to NULL on return 237 ) 238 ); 239 #define CCAPI_DLL "krbcc32.dll" 240 241 /* The following definitions are summarized from KRB5, Leash32, and 242 * Leashw32 modules. They are current as of KfW 2.6.2. There is no 243 * guarantee that changes to other modules will be updated in this list. 244 */ 245 246 /* Must match the values used in Leash32.exe */ 247 #define LEASH_SETTINGS_REGISTRY_KEY_NAME "Software\\MIT\\Leash32\\Settings" 248 #define LEASH_SETTINGS_REGISTRY_VALUE_UPPERCASEREALM "UpperCaseRealm" 249 250 /* These values are defined and used within Leashw32.dll */ 251 #define LEASH_REGISTRY_KEY_NAME "Software\\MIT\\Leash" 252 #define LEASH_REGISTRY_VALUE_LIFETIME "lifetime" 253 #define LEASH_REGISTRY_VALUE_RENEW_TILL "renew_till" 254 #define LEASH_REGISTRY_VALUE_RENEWABLE "renewable" 255 #define LEASH_REGISTRY_VALUE_FORWARDABLE "forwardable" 256 #define LEASH_REGISTRY_VALUE_NOADDRESSES "noaddresses" 257 #define LEASH_REGISTRY_VALUE_PROXIABLE "proxiable" 258 #define LEASH_REGISTRY_VALUE_PUBLICIP "publicip" 259 #define LEASH_REGISTRY_VALUE_KINIT_OPT "hide_kinit_options" 260 #define LEASH_REGISTRY_VALUE_LIFE_MIN "life_min" 261 #define LEASH_REGISTRY_VALUE_LIFE_MAX "life_max" 262 #define LEASH_REGISTRY_VALUE_RENEW_MIN "renew_min" 263 #define LEASH_REGISTRY_VALUE_RENEW_MAX "renew_max" 264 #define LEASH_REGISTRY_VALUE_PRESERVE_KINIT "preserve_kinit_options" 265 266 /* must match values used within krb5_32.dll */ 267 #define KRB5_REGISTRY_KEY_NAME "Software\\MIT\\Kerberos5" 268 #define KRB5_REGISTRY_VALUE_CCNAME "ccname" 269 #define KRB5_REGISTRY_VALUE_CONFIGFILE "config" 270 271 #endif /* __LEASH_INT_H__ */ 272