\r
BOOL IsDebugLogging(void)\r
{\r
- DWORD LSPtype, LSPsize;\r
+ DWORD LSPsize;\r
HKEY NPKey;\r
DWORD dwDebug = FALSE;\r
\r
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, \r
- "System\\CurrentControlSet\\Services\\MIT Kerberos\\Network Provider", \r
- 0, KEY_QUERY_VALUE, &NPKey) == ERROR_SUCCESS) {\r
+ "System\\CurrentControlSet\\Services\\MIT Kerberos\\NetworkProvider", \r
+ 0, KEY_QUERY_VALUE, &NPKey) == ERROR_SUCCESS) \r
+ {\r
LSPsize=sizeof(dwDebug);\r
- if (RegQueryValueEx(NPKey, "Debug", NULL, &LSPtype, (LPBYTE)&dwDebug, &LSPsize) != ERROR_SUCCESS \r
- || LSPtype != REG_DWORD)\r
+ if (RegQueryValueEx(NPKey, "Debug", NULL, NULL, (LPBYTE)&dwDebug, &LSPsize) != ERROR_SUCCESS) \r
+ {\r
+ static int once = 0;\r
+\r
dwDebug = FALSE;\r
\r
+ if (!once) {\r
+ HANDLE h; char *ptbuf[1];\r
+ h = RegisterEventSource(NULL, KFW_LOGON_EVENT_NAME);\r
+ ptbuf[0] = "Unable to read debug value";\r
+ ReportEvent(h, EVENTLOG_INFORMATION_TYPE, 0, 0, NULL, 1, 0, (const char **)ptbuf, NULL);\r
+ DeregisterEventSource(h);\r
+ once++;\r
+ }\r
+ }\r
RegCloseKey (NPKey);\r
+ } else {\r
+ static int once = 0;\r
+ if (!once) {\r
+ HANDLE h; char *ptbuf[1];\r
+ h = RegisterEventSource(NULL, KFW_LOGON_EVENT_NAME);\r
+ ptbuf[0] = "Unable to open network provider key";\r
+ ReportEvent(h, EVENTLOG_INFORMATION_TYPE, 0, 0, NULL, 1, 0, (const char **)ptbuf, NULL);\r
+ DeregisterEventSource(h);\r
+ once++;\r
+ }\r
}\r
\r
return(dwDebug ? TRUE : FALSE);\r
char * pname = 0;\r
krb5_error_code code;\r
\r
- if (!pkrb5_init_context || !username || !password)\r
+ if (!pkrb5_init_context || !username || !password || !password[0])\r
return 0;\r
\r
DebugEvent0(username);\r
if ( code ) goto cleanup;\r
\r
DebugEvent0("got ccache");\r
+\r
if ( lifetime == 0 )\r
lifetime = pLeash_get_default_lifetime();\r
\r
- if ( password[0] ) {\r
- code = KFW_kinit( ctx, cc, HWND_DESKTOP, \r
- pname, \r
- password,\r
- lifetime,\r
- pLeash_get_default_forwardable(),\r
- pLeash_get_default_proxiable(),\r
- pLeash_get_default_renewable() ? pLeash_get_default_renew_till() : 0,\r
- pLeash_get_default_noaddresses(),\r
- pLeash_get_default_publicip());\r
- DebugEvent0("kinit returned");\r
- if ( code ) goto cleanup;\r
- }\r
+ DebugEvent0("got lifetime");\r
+\r
+ code = KFW_kinit( ctx, cc, HWND_DESKTOP, \r
+ pname, \r
+ password,\r
+ lifetime,\r
+ pLeash_get_default_forwardable(),\r
+ pLeash_get_default_proxiable(),\r
+ pLeash_get_default_renewable() ? pLeash_get_default_renew_till() : 0,\r
+ pLeash_get_default_noaddresses(),\r
+ pLeash_get_default_publicip());\r
+ DebugEvent0("kinit returned");\r
+ if ( code ) goto cleanup;\r
\r
cleanup:\r
if ( pname )\r
}\r
\r
\r
+int\r
+KFW_copy_file_cache_to_api_cache(char * filename)\r
+{\r
+ char cachename[MAX_PATH + 8] = "FILE:";\r
+ krb5_context ctx = 0;\r
+ krb5_error_code code;\r
+ krb5_principal princ = 0;\r
+ krb5_ccache cc = 0;\r
+ krb5_ccache ncc = 0;\r
+ char *name = NULL;\r
+ int retval = 1;\r
+\r
+ if (!pkrb5_init_context || !filename)\r
+ return 1;\r
+\r
+ if ( strlen(filename) + sizeof("FILE:") > sizeof(cachename) )\r
+ return 1;\r
+\r
+ strcat(cachename, filename);\r
+\r
+ code = pkrb5_init_context(&ctx);\r
+ if (code) ctx = 0;\r
+\r
+ code = pkrb5_cc_resolve(ctx, cachename, &cc);\r
+ if (code) {\r
+ DebugEvent0("kfwcpcc krb5_cc_resolve failed");\r
+ goto cleanup;\r
+ }\r
+ \r
+ code = pkrb5_cc_get_principal(ctx, cc, &princ);\r
+ if (code) {\r
+ DebugEvent0("kfwcpcc krb5_cc_get_principal failed");\r
+ goto cleanup;\r
+ }\r
+\r
+ code = pkrb5_unparse_name(ctx, princ, &name);\r
+ if (code) {\r
+ DebugEvent0("kfwcpcc krb5_unparse_name failed");\r
+ goto cleanup;\r
+ }\r
+\r
+ sprintf(cachename, "API:%s", name);\r
+\r
+ code = pkrb5_cc_resolve(ctx, cachename, &ncc);\r
+ if (code) {\r
+ DebugEvent0("kfwcpcc krb5_cc_default failed");\r
+ goto cleanup;\r
+ }\r
+ if (!code) {\r
+ code = pkrb5_cc_initialize(ctx, ncc, princ);\r
+\r
+ if (!code)\r
+ code = pkrb5_cc_copy_creds(ctx,cc,ncc);\r
+ if (code) {\r
+ DebugEvent0("kfwcpcc krb5_cc_copy_creds failed");\r
+ goto cleanup;\r
+ }\r
+ }\r
+ if ( ncc ) {\r
+ pkrb5_cc_close(ctx, ncc);\r
+ ncc = 0;\r
+ }\r
+\r
+ retval=0; /* success */\r
+\r
+ cleanup:\r
+ if (name)\r
+ pkrb5_free_unparsed_name(ctx, name);\r
+\r
+ if ( cc ) {\r
+ pkrb5_cc_close(ctx, cc);\r
+ cc = 0;\r
+ }\r
+\r
+ DeleteFile(filename);\r
+\r
+ if ( princ ) {\r
+ pkrb5_free_principal(ctx, princ);\r
+ princ = 0;\r
+ }\r
+\r
+ if (ctx)\r
+ pkrb5_free_context(ctx);\r
+\r
+ return 0;\r
+}\r
+\r
+\r
int \r
KFW_destroy_tickets_for_principal(char * user)\r
{\r