From: Tom Yu Date: Fri, 30 Mar 2007 03:08:51 +0000 (+0000) Subject: pull up r19240 from trunk X-Git-Tag: kfw-3.2.0-beta1~42 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=479b83a65f5e4e05816245f49950841441fbc865;p=krb5.git pull up r19240 from trunk r19240@cathode-dark-space: jaltman | 2007-03-21 00:48:09 -0400 ticket: 5469 When using the Vista SDK version of NTSecAPI.h it is necessary to ensure the _WIN32_WINNT have a value of 0x0501 or greater. Otherwise, required LSA type declarations are undeclared. Provide a registry value that can be set to turn on Application Event log messages for debugging. HKLM\System\CurrentControlSet\Services\MIT Kerberos\Network Provider DWORD "Debug" Ensure that KFW_obtain_user_temp_directory() returns a value on error. Correct the declaration of KFW_copy_cache_to_system_file() to match the prototype. ticket: 5469 git-svn-id: svn://anonsvn.mit.edu/krb5/branches/krb5-1-6@19335 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/windows/kfwlogon/kfwcommon.c b/src/windows/kfwlogon/kfwcommon.c index a3b02eeab..b578d943b 100644 --- a/src/windows/kfwlogon/kfwcommon.c +++ b/src/windows/kfwlogon/kfwcommon.c @@ -24,7 +24,7 @@ SOFTWARE. */ #include "kfwlogon.h" -#include +#include #include #include #include @@ -291,34 +291,54 @@ static HINSTANCE hCCAPI = 0; static DWORD TraceOption = 0; static HANDLE hDLL; +BOOL IsDebugLogging(void) +{ + DWORD LSPtype, LSPsize; + HKEY NPKey; + DWORD dwDebug = FALSE; + + if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, + "System\\CurrentControlSet\\Services\\MIT Kerberos\\Network Provider", + 0, KEY_QUERY_VALUE, &NPKey) == ERROR_SUCCESS) { + LSPsize=sizeof(dwDebug); + if (RegQueryValueEx(NPKey, "Debug", NULL, &LSPtype, (LPBYTE)&dwDebug, &LSPsize) != ERROR_SUCCESS + || LSPtype != REG_DWORD) + dwDebug = FALSE; + + RegCloseKey (NPKey); + } + + return(dwDebug ? TRUE : FALSE); +} + void DebugEvent0(char *a) { -#ifdef DEBUG HANDLE h; char *ptbuf[1]; - h = RegisterEventSource(NULL, KFW_LOGON_EVENT_NAME); - ptbuf[0] = a; - ReportEvent(h, EVENTLOG_INFORMATION_TYPE, 0, 0, NULL, 1, 0, (const char **)ptbuf, NULL); - DeregisterEventSource(h); -#endif + if (IsDebugLogging()) { + h = RegisterEventSource(NULL, KFW_LOGON_EVENT_NAME); + ptbuf[0] = a; + ReportEvent(h, EVENTLOG_INFORMATION_TYPE, 0, 0, NULL, 1, 0, (const char **)ptbuf, NULL); + DeregisterEventSource(h); + } } #define MAXBUF_ 512 void DebugEvent(char *b,...) { -#ifdef DEBUG HANDLE h; char *ptbuf[1],buf[MAXBUF_+1]; va_list marker; - h = RegisterEventSource(NULL, KFW_LOGON_EVENT_NAME); - va_start(marker,b); - StringCbVPrintf(buf, MAXBUF_+1,b,marker); - buf[MAXBUF_] = '\0'; - ptbuf[0] = buf; - ReportEvent(h, EVENTLOG_INFORMATION_TYPE, 0, 0, NULL, 1, 0, (const char **)ptbuf, NULL); - DeregisterEventSource(h); - va_end(marker); -#endif + if (IsDebugLogging()) { + h = RegisterEventSource(NULL, KFW_LOGON_EVENT_NAME); + va_start(marker,b); + StringCbVPrintf(buf, MAXBUF_+1,b,marker); + buf[MAXBUF_] = '\0'; + ptbuf[0] = buf; + ReportEvent(h, EVENTLOG_INFORMATION_TYPE, 0, 0, NULL, 1, 0, (const char **)ptbuf, NULL); + DeregisterEventSource(h); + va_end(marker); + } } void @@ -978,7 +998,7 @@ int KFW_obtain_user_temp_directory(HANDLE hUserToken, char *newfilename, int siz DWORD dwLen = 0; if (!hUserToken || !newfilename || size <= 0) - return; + return 1; *newfilename = '\0'; @@ -993,7 +1013,7 @@ int KFW_obtain_user_temp_directory(HANDLE hUserToken, char *newfilename, int siz } void -KFW_copy_cache_to_system_file(char * user, char * filename) +KFW_copy_cache_to_system_file(const char * user, const char * filename) { DWORD count; char cachename[MAX_PATH + 8] = "FILE:"; diff --git a/src/windows/kfwlogon/kfwlogon.h b/src/windows/kfwlogon/kfwlogon.h index a542b81c3..d9bf13d06 100644 --- a/src/windows/kfwlogon/kfwlogon.h +++ b/src/windows/kfwlogon/kfwlogon.h @@ -27,8 +27,16 @@ SOFTWARE. /* We only support VC 1200 and above anyway */ #pragma once +/* _WIN32_WINNT must be 0x0501 or greater to pull in definition of + * all required LSA data types when the Vista SDK NtSecAPI.h is used. + */ #ifndef _WIN32_WINNT -#define _WIN32_WINNT 0x0500 +#define _WIN32_WINNT 0x0501 +#else +#if _WIN32_WINNT < 0x0501 +#undef _WIN32_WINNT +#define _WIN32_WINNT 0x0501 +#endif #endif #include