From: Tom Yu Date: Wed, 18 Apr 2007 21:57:42 +0000 (+0000) Subject: pull up r19488 from trunk X-Git-Tag: krb5-1.6.1-final~20 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=c1640b0d6e7f04807121d283faaf47e2b2b561af;p=krb5.git pull up r19488 from trunk r19488@cathode-dark-space: jaltman | 2007-04-17 21:47:08 -0400 ticket: new subject: kfwlogon corrections for XP component: windows tags: pullup This patch addresses a problem discovered on some XP systems. After rundll32.exe starts, the CreateProcess can fail to start kfwcpcc.exe if the current directory is not %WinDir%\System32. CreateProcess() should be called with the lpApplicationName parameter set to NULL in order to permit the use of the PATH. Also, in ConfigureLogonScript ensure that the trailing NUL of the constructed command line is processed when producing the wide character version of the string. ticket: 5534 version_fixed: 1.6.1 git-svn-id: svn://anonsvn.mit.edu/krb5/branches/krb5-1-6@19491 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/windows/kfwlogon/kfwlogon.c b/src/windows/kfwlogon/kfwlogon.c index f76da3cab..8422f58b1 100644 --- a/src/windows/kfwlogon/kfwlogon.c +++ b/src/windows/kfwlogon/kfwlogon.c @@ -136,6 +136,8 @@ is_windows_vista(void) /* Construct a Logon Script that will cause the LogonEventHandler to be executed * under in the logon session */ + +#define RUNDLL32_CMDLINE "rundll32.exe kfwlogon.dll,LogonEventHandler " VOID ConfigureLogonScript(LPWSTR *lpLogonScript, char * filename) { DWORD dwLogonScriptLen; @@ -149,23 +151,20 @@ ConfigureLogonScript(LPWSTR *lpLogonScript, char * filename) { if (!filename) return; - dwLogonScriptLen = strlen("rundll32.exe kfwlogon.dll,LogonEventHandler ") + strlen(filename) + 1; + dwLogonScriptLen = strlen(RUNDLL32_CMDLINE) + strlen(filename) + 2; lpTemp = (LPSTR) malloc(dwLogonScriptLen); if (!lpTemp) return; - _snprintf(lpTemp, dwLogonScriptLen, - "rundll32.exe kfwlogon.dll,LogonEventHandler %s", - filename); + _snprintf(lpTemp, dwLogonScriptLen, "%s%s", RUNDLL32_CMDLINE, filename); SetLastError(0); - dwLogonScriptLen = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, lpTemp, strlen(lpTemp), NULL, 0); + dwLogonScriptLen = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, lpTemp, -1, NULL, 0); DebugEvent("ConfigureLogonScript %s requires %d bytes gle=0x%x", lpTemp, dwLogonScriptLen, GetLastError()); lpScript = LocalAlloc(LMEM_ZEROINIT, dwLogonScriptLen * 2); if (lpScript) { - if (MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, lpTemp, strlen(lpTemp), - lpScript, 2 * dwLogonScriptLen)) + if (MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, lpTemp, -1, lpScript, 2 * dwLogonScriptLen)) *lpLogonScript = lpScript; else { DebugEvent("ConfigureLogonScript - MultiByteToWideChar failed gle = 0x%x", GetLastError()); @@ -605,7 +604,8 @@ LogonEventHandlerA(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow) _snprintf(commandline, sizeof(commandline), "kfwcpcc.exe \"%s\"", lpszCmdLine); GetStartupInfo(&startupinfo); - if (CreateProcess( "kfwcpcc.exe", + SetLastError(0); + if (CreateProcess( NULL, commandline, NULL, NULL, @@ -623,7 +623,9 @@ LogonEventHandlerA(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow) CloseHandle(procinfo.hThread); CloseHandle(procinfo.hProcess); } else { - DebugEvent0("KFW_Logon_Event - CreateProcessFailed"); + DebugEvent("KFW_Logon_Event - CreateProcessFailed \"%s\" GLE 0x%x", + commandline, GetLastError()); + DebugEvent("KFW_Logon_Event PATH %s", getenv("PATH")); } DeleteFile(lpszCmdLine);