Imported Upstream version 1.15.1
[platform/upstream/krb5.git] / src / windows / leashdll / leash-int.h
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 lsh_com_err_proc (LPSTR whoami, long code, LPSTR fmt, va_list args);
31 int DoNiftyErrorReport(long errnum, LPSTR what);
32 LONG Leash_timesync(int);
33 BOOL Leash_ms2mit(BOOL);
34
35 #ifndef NO_AFS
36 int      not_an_API_LeashAFSGetToken(TICKETINFO * ticketinfo, TicketList** ticketList, char * kprinc);
37 long FAR not_an_API_LeashFreeTicketList(TicketList** ticketList) ;
38 #endif
39
40 // Crap...
41 #include <krb5.h>
42
43 long
44 Leash_int_kinit_ex(
45     krb5_context ctx,
46     HWND hParent,
47     char * principal,
48     char * password,
49     int lifetime,
50     int forwardable,
51     int proxiable,
52     int renew_life,
53     int addressless,
54     unsigned long publicIP,
55     int displayErrors
56     );
57
58 long
59 Leash_int_checkpwd(
60     char * principal,
61     char * password,
62     int    displayErrors
63     );
64
65 long
66 Leash_int_changepwd(
67     char * principal,
68     char * password,
69     char * newpassword,
70     char** result_string,
71     int    displayErrors
72     );
73
74 int
75 Leash_krb5_kdestroy(
76     void
77     );
78
79 int
80 Leash_krb5_kinit(
81     krb5_context,
82     HWND hParent,
83     char * principal_name,
84     char * password,
85     krb5_deltat lifetime,
86     DWORD       forwardable,
87     DWORD       proxiable,
88     krb5_deltat renew_life,
89     DWORD       addressless,
90     DWORD       publicIP
91     );
92
93 long
94 Leash_convert524(
95     krb5_context ctx
96     );
97
98 int
99 Leash_afs_unlog(
100     void
101     );
102
103 int
104 Leash_afs_klog(
105     char *,
106     char *,
107     char *,
108     int
109     );
110
111 int
112 LeashKRB5_renew(void);
113
114 LONG
115 write_registry_setting(
116     char* setting,
117     DWORD type,
118     void* buffer,
119     size_t size
120     );
121
122 LONG
123 read_registry_setting_user(
124     char* setting,
125     void* buffer,
126     size_t size
127     );
128
129 LONG
130 read_registry_setting(
131     char* setting,
132     void* buffer,
133     size_t size
134     );
135
136 BOOL
137 get_STRING_from_registry(
138     HKEY hBaseKey,
139     char * key,
140     char * value,
141     char * outbuf,
142     DWORD  outlen
143     );
144
145 BOOL
146 get_DWORD_from_registry(
147     HKEY hBaseKey,
148     char * key,
149     char * value,
150     DWORD * result
151     );
152
153 int
154 config_boolean_to_int(
155     const char *s
156     );
157
158 BOOL GetSecurityLogonSessionData(PSECURITY_LOGON_SESSION_DATA * ppSessionData);
159 BOOL IsKerberosLogon(VOID);
160
161 #ifndef NO_KRB5
162 int Leash_krb5_error(krb5_error_code rc, LPCSTR FailedFunctionName,
163                      int FreeContextFlag, krb5_context *ctx,
164                      krb5_ccache *cache);
165 int Leash_krb5_initialize(krb5_context *);
166 krb5_error_code
167 Leash_krb5_cc_default(krb5_context *ctx, krb5_ccache *cache);
168 #endif /* NO_KRB5 */
169
170 LPSTR err_describe(LPSTR buf, long code);
171
172 // toolhelp functions
173 TYPEDEF_FUNC(
174     HANDLE,
175     WINAPI,
176     CreateToolhelp32Snapshot,
177     (DWORD, DWORD)
178     );
179 TYPEDEF_FUNC(
180     BOOL,
181     WINAPI,
182     Module32First,
183     (HANDLE, LPMODULEENTRY32)
184     );
185 TYPEDEF_FUNC(
186     BOOL,
187     WINAPI,
188     Module32Next,
189     (HANDLE, LPMODULEENTRY32)
190     );
191
192 // psapi functions
193 TYPEDEF_FUNC(
194     DWORD,
195     WINAPI,
196     GetModuleFileNameExA,
197     (HANDLE, HMODULE, LPSTR, DWORD)
198     );
199 TYPEDEF_FUNC(
200     BOOL,
201     WINAPI,
202     EnumProcessModules,
203     (HANDLE, HMODULE*, DWORD, LPDWORD)
204     );
205
206 #define pGetModuleFileNameEx pGetModuleFileNameExA
207 #define TOOLHELPDLL "kernel32.dll"
208 #define PSAPIDLL "psapi.dll"
209
210 // psapi functions
211 extern DECL_FUNC_PTR(GetModuleFileNameExA);
212 extern DECL_FUNC_PTR(EnumProcessModules);
213
214 // toolhelp functions
215 extern DECL_FUNC_PTR(CreateToolhelp32Snapshot);
216 extern DECL_FUNC_PTR(Module32First);
217 extern DECL_FUNC_PTR(Module32Next);
218
219 /* In order to avoid including the private CCAPI headers */
220 typedef int cc_int32;
221
222 #define CC_API_VER_1 1
223 #define CC_API_VER_2 2
224
225 #define CCACHE_API cc_int32
226
227 /*
228 ** The Official Error Codes
229 */
230 #define CC_NOERROR           0
231 #define CC_BADNAME           1
232 #define CC_NOTFOUND          2
233 #define CC_END               3
234 #define CC_IO                4
235 #define CC_WRITE             5
236 #define CC_NOMEM             6
237 #define CC_FORMAT            7
238 #define CC_LOCKED            8
239 #define CC_BAD_API_VERSION   9
240 #define CC_NO_EXIST          10
241 #define CC_NOT_SUPP          11
242 #define CC_BAD_PARM          12
243 #define CC_ERR_CACHE_ATTACH  13
244 #define CC_ERR_CACHE_RELEASE 14
245 #define CC_ERR_CACHE_FULL    15
246 #define CC_ERR_CRED_VERSION  16
247
248 enum {
249     CC_CRED_VUNKNOWN = 0,       // For validation
250     CC_CRED_V4 = 1,
251     CC_CRED_V5 = 2,
252     CC_CRED_VMAX = 3            // For validation
253 };
254
255 typedef struct opaque_dll_control_block_type* apiCB;
256 typedef struct _infoNC {
257     char*     name;
258     char*     principal;
259     cc_int32  vers;
260 } infoNC;
261
262 TYPEDEF_FUNC(
263 CCACHE_API,
264 __cdecl,
265 cc_initialize,
266     (
267     apiCB** cc_ctx,           // <  DLL's primary control structure.
268                               //    returned here, passed everywhere else
269     cc_int32 api_version,     // >  ver supported by caller (use CC_API_VER_1)
270     cc_int32*  api_supported, // <  if ~NULL, max ver supported by DLL
271     const char** vendor       // <  if ~NULL, vendor name in read only C string
272     )
273 );
274
275 TYPEDEF_FUNC(
276 CCACHE_API,
277 __cdecl,
278 cc_shutdown,
279     (
280     apiCB** cc_ctx            // <> DLL's primary control structure. NULL after
281     )
282 );
283
284 TYPEDEF_FUNC(
285 CCACHE_API,
286 __cdecl,
287 cc_get_NC_info,
288     (
289     apiCB* cc_ctx,          // >  DLL's primary control structure
290     struct _infoNC*** ppNCi // <  (NULL before call) null terminated,
291                             //    list of a structs (free via cc_free_infoNC())
292     )
293 );
294
295 TYPEDEF_FUNC(
296 CCACHE_API,
297 __cdecl,
298 cc_free_NC_info,
299     (
300     apiCB* cc_ctx,
301     struct _infoNC*** ppNCi // <  free list of structs returned by
302                             //    cc_get_cache_names().  set to NULL on return
303     )
304 );
305 #define CCAPI_DLL   "krbcc32.dll"
306
307 /* The following definitions are summarized from KRB4, KRB5, Leash32, and
308  * Leashw32 modules.  They are current as of KfW 2.6.2.  There is no
309  * guarrantee that changes to other modules will be updated in this list.
310  */
311
312 /* Must match the values used in Leash32.exe */
313 #define LEASH_SETTINGS_REGISTRY_KEY_NAME "Software\\MIT\\Leash32\\Settings"
314 #define LEASH_SETTINGS_REGISTRY_VALUE_AFS_STATUS       "AfsStatus"
315 #define LEASH_SETTINGS_REGISTRY_VALUE_DEBUG_WINDOW     "DebugWindow"
316 #define LEASH_SETTINGS_REGISTRY_VALUE_LARGE_ICONS      "LargeIcons"
317 #define LEASH_SETTINGS_REGISTRY_VALUE_DESTROY_TKTS     "DestroyTickets"
318 #define LEASH_SETTINGS_REGISTRY_VALUE_LOW_TKT_ALARM    "LowTicketAlarm"
319 #define LEASH_SETTINGS_REGISTRY_VALUE_AUTO_RENEW_TKTS  "AutoRenewTickets"
320 #define LEASH_SETTINGS_REGISTRY_VALUE_UPPERCASEREALM   "UpperCaseRealm"
321 #define LEASH_SETTINGS_REGISTRY_VALUE_TIMEHOST         "TIMEHOST"
322 #define LEASH_SETTINGS_REGISTRY_VALUE_CREATE_MISSING_CFG "CreateMissingConfig"
323 #define LEASH_SETTINGS_REGISTRY_VALUE_MSLSA_IMPORT     "MsLsaImport"
324
325 /* These values are defined and used within Leashw32.dll */
326 #define LEASH_REGISTRY_KEY_NAME "Software\\MIT\\Leash"
327 #define LEASH_REGISTRY_VALUE_LIFETIME "lifetime"
328 #define LEASH_REGISTRY_VALUE_RENEW_TILL "renew_till"
329 #define LEASH_REGISTRY_VALUE_RENEWABLE "renewable"
330 #define LEASH_REGISTRY_VALUE_FORWARDABLE "forwardable"
331 #define LEASH_REGISTRY_VALUE_NOADDRESSES "noaddresses"
332 #define LEASH_REGISTRY_VALUE_PROXIABLE "proxiable"
333 #define LEASH_REGISTRY_VALUE_PUBLICIP "publicip"
334 #define LEASH_REGISTRY_VALUE_USEKRB4 "usekrb4"
335 #define LEASH_REGISTRY_VALUE_KINIT_OPT "hide_kinit_options"
336 #define LEASH_REGISTRY_VALUE_LIFE_MIN "life_min"
337 #define LEASH_REGISTRY_VALUE_LIFE_MAX "life_max"
338 #define LEASH_REGISTRY_VALUE_RENEW_MIN "renew_min"
339 #define LEASH_REGISTRY_VALUE_RENEW_MAX "renew_max"
340 #define LEASH_REGISTRY_VALUE_LOCK_LOCATION "lock_file_locations"
341 #define LEASH_REGISTRY_VALUE_PRESERVE_KINIT "preserve_kinit_options"
342
343 /* must match values used within krbv4w32.dll */
344 #define KRB4_REGISTRY_KEY_NAME "Software\\MIT\\Kerberos4"
345 #define KRB4_REGISTRY_VALUE_CONFIGFILE  "config"
346 #define KRB4_REGISTRY_VALUE_KRB_CONF    "krb.conf"
347 #define KRB4_REGISTRY_VALUE_KRB_REALMS  "krb.realms"
348 #define KRB4_REGISTRY_VALUE_TICKETFILE  "ticketfile"
349
350 /* must match values used within krb5_32.dll */
351 #define KRB5_REGISTRY_KEY_NAME "Software\\MIT\\Kerberos5"
352 #define KRB5_REGISTRY_VALUE_CCNAME      "ccname"
353 #define KRB5_REGISTRY_VALUE_CONFIGFILE  "config"
354
355 /* must match values used within wshelper.dll */
356 #define WSHELP_REGISTRY_KEY_NAME  "Software\\MIT\\WsHelper"
357 #define WSHELP_REGISTRY_VALUE_DEBUG   "DebugOn"
358
359 #endif /* __LEASH_INT_H__ */