*/\r
\r
#include "kfwlogon.h"\r
-#include <winbase.h>\r
+#include <windows.h>\r
#include <Aclapi.h>\r
#include <userenv.h>\r
#include <Sddl.h>\r
static DWORD TraceOption = 0;\r
static HANDLE hDLL;\r
\r
+BOOL IsDebugLogging(void)\r
+{\r
+ DWORD LSPtype, 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
+ LSPsize=sizeof(dwDebug);\r
+ if (RegQueryValueEx(NPKey, "Debug", NULL, &LSPtype, (LPBYTE)&dwDebug, &LSPsize) != ERROR_SUCCESS \r
+ || LSPtype != REG_DWORD)\r
+ dwDebug = FALSE;\r
+\r
+ RegCloseKey (NPKey);\r
+ }\r
+\r
+ return(dwDebug ? TRUE : FALSE);\r
+}\r
+\r
void DebugEvent0(char *a) \r
{\r
-#ifdef DEBUG\r
HANDLE h; char *ptbuf[1];\r
\r
- h = RegisterEventSource(NULL, KFW_LOGON_EVENT_NAME);\r
- ptbuf[0] = a;\r
- ReportEvent(h, EVENTLOG_INFORMATION_TYPE, 0, 0, NULL, 1, 0, (const char **)ptbuf, NULL);\r
- DeregisterEventSource(h);\r
-#endif\r
+ if (IsDebugLogging()) {\r
+ h = RegisterEventSource(NULL, KFW_LOGON_EVENT_NAME);\r
+ ptbuf[0] = a;\r
+ ReportEvent(h, EVENTLOG_INFORMATION_TYPE, 0, 0, NULL, 1, 0, (const char **)ptbuf, NULL);\r
+ DeregisterEventSource(h);\r
+ }\r
}\r
\r
#define MAXBUF_ 512\r
void DebugEvent(char *b,...) \r
{\r
-#ifdef DEBUG\r
HANDLE h; char *ptbuf[1],buf[MAXBUF_+1];\r
va_list marker;\r
\r
- h = RegisterEventSource(NULL, KFW_LOGON_EVENT_NAME);\r
- va_start(marker,b);\r
- StringCbVPrintf(buf, MAXBUF_+1,b,marker);\r
- buf[MAXBUF_] = '\0';\r
- ptbuf[0] = buf;\r
- ReportEvent(h, EVENTLOG_INFORMATION_TYPE, 0, 0, NULL, 1, 0, (const char **)ptbuf, NULL);\r
- DeregisterEventSource(h);\r
- va_end(marker);\r
-#endif\r
+ if (IsDebugLogging()) {\r
+ h = RegisterEventSource(NULL, KFW_LOGON_EVENT_NAME);\r
+ va_start(marker,b);\r
+ StringCbVPrintf(buf, MAXBUF_+1,b,marker);\r
+ buf[MAXBUF_] = '\0';\r
+ ptbuf[0] = buf;\r
+ ReportEvent(h, EVENTLOG_INFORMATION_TYPE, 0, 0, NULL, 1, 0, (const char **)ptbuf, NULL);\r
+ DeregisterEventSource(h);\r
+ va_end(marker);\r
+ }\r
}\r
\r
void\r
DWORD dwLen = 0;\r
\r
if (!hUserToken || !newfilename || size <= 0)\r
- return;\r
+ return 1;\r
\r
*newfilename = '\0';\r
\r
}\r
\r
void\r
-KFW_copy_cache_to_system_file(char * user, char * filename)\r
+KFW_copy_cache_to_system_file(const char * user, const char * filename)\r
{\r
DWORD count;\r
char cachename[MAX_PATH + 8] = "FILE:";\r