From: Jeffrey Altman Date: Wed, 18 Apr 2007 01:47:08 +0000 (+0000) Subject: kfwlogon corrections for XP X-Git-Tag: krb5-1.7-alpha1~1133 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=53df682ae3371198e44f38534264ca20966ff856;p=krb5.git kfwlogon corrections for XP 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: new component: windows tags: pullup git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@19488 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);