summaryrefslogtreecommitdiffstats
path: root/src/windows/kfwlogon
diff options
context:
space:
mode:
authorJeffrey Altman <jaltman@secure-endpoints.com>2007-04-18 01:47:08 +0000
committerJeffrey Altman <jaltman@secure-endpoints.com>2007-04-18 01:47:08 +0000
commit53df682ae3371198e44f38534264ca20966ff856 (patch)
treee76d1b4d47b0c463cbaac0c1133937a7f32f711d /src/windows/kfwlogon
parented0fe6c23007890333ef45886fd97b8775896d86 (diff)
downloadkrb5-53df682ae3371198e44f38534264ca20966ff856.tar.gz
krb5-53df682ae3371198e44f38534264ca20966ff856.tar.xz
krb5-53df682ae3371198e44f38534264ca20966ff856.zip
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
Diffstat (limited to 'src/windows/kfwlogon')
-rw-r--r--src/windows/kfwlogon/kfwlogon.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/windows/kfwlogon/kfwlogon.c b/src/windows/kfwlogon/kfwlogon.c
index f76da3cab3..8422f58b11 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);