LSPsize=sizeof(dwDebug);\r
if (RegQueryValueEx(NPKey, "Debug", NULL, NULL, (LPBYTE)&dwDebug, &LSPsize) != ERROR_SUCCESS) \r
{\r
- static int once = 0;\r
-\r
dwDebug = FALSE;\r
-\r
- if (!once) {\r
- HANDLE h; char *ptbuf[1];\r
- h = RegisterEventSource(NULL, KFW_LOGON_EVENT_NAME);\r
- ptbuf[0] = "Unable to read debug value";\r
- ReportEvent(h, EVENTLOG_INFORMATION_TYPE, 0, 0, NULL, 1, 0, (const char **)ptbuf, NULL);\r
- DeregisterEventSource(h);\r
- once++;\r
- }\r
}\r
RegCloseKey (NPKey);\r
- } else {\r
- static int once = 0;\r
- if (!once) {\r
- HANDLE h; char *ptbuf[1];\r
- h = RegisterEventSource(NULL, KFW_LOGON_EVENT_NAME);\r
- ptbuf[0] = "Unable to open network provider key";\r
- ReportEvent(h, EVENTLOG_INFORMATION_TYPE, 0, 0, NULL, 1, 0, (const char **)ptbuf, NULL);\r
- DeregisterEventSource(h);\r
- once++;\r
- }\r
}\r
\r
return(dwDebug ? TRUE : FALSE);\r
\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
+ if (h) {\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
\r
\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
+ if (h) {\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
\r
if ( strlen(filename) + sizeof("FILE:") > sizeof(cachename) )\r
return 1;\r
\r
- strcat(cachename, filename);\r
-\r
code = pkrb5_init_context(&ctx);\r
- if (code) ctx = 0;\r
+ if (code) return 1;\r
+\r
+ strcat(cachename, filename);\r
\r
code = pkrb5_cc_resolve(ctx, cachename, &cc);\r
if (code) {\r
if ( strlen(filename) + sizeof("FILE:") > sizeof(cachename) )\r
return 1;\r
\r
- strcat(cachename, filename);\r
-\r
code = pkrb5_init_context(&ctx);\r
- if (code) ctx = 0;\r
+ if (code) return 1;\r
+\r
+ strcat(cachename, filename);\r
\r
code = pkrb5_cc_resolve(ctx, cachename, &cc);\r
if (code) {\r
return 0;\r
\r
code = pkrb5_init_context(&ctx);\r
- if (code) ctx = 0;\r
+ if (code) return 1;\r
\r
code = pkrb5_parse_name(ctx, user, &princ);\r
if (code) goto loop_cleanup;\r
return TRUE;\r
}\r
\r
-\r
-\r
DWORD APIENTRY NPGetCaps(DWORD index)\r
{\r
switch (index) {\r
case WNNC_NET_TYPE:\r
- /* Don't have our own type; use somebody else's. */\r
+ /* We aren't a file system; We don't have our own type; use somebody else's. */\r
return WNNC_NET_SUN_PC_NFS;\r
-\r
case WNNC_START:\r
/* Say we are already started, even though we might wait after we receive NPLogonNotify */\r
return 1;\r
}\r
} \r
\r
+\r
static BOOL\r
WINAPI\r
UnicodeStringToANSI(UNICODE_STRING uInputString, LPSTR lpszOutputString, int nOutStringLen)\r
return fIsWinVista;\r
}\r
\r
+\r
/* Construct a Logon Script that will cause the LogonEventHandler to be executed\r
* under in the logon session \r
*/\r
free(lpTemp);\r
}\r
\r
+\r
DWORD APIENTRY NPLogonNotify(\r
PLUID lpLogonId,\r
LPCWSTR lpAuthentInfoType,\r
char *reason;\r
char *ctemp;\r
\r
- BOOLEAN interactive;\r
+ BOOLEAN interactive = TRUE;\r
HWND hwndOwner = (HWND)StationHandle;\r
BOOLEAN lowercased_name = TRUE;\r
\r
- /* Are we interactive? */\r
- interactive = (wcscmp(lpStationName, L"WinSta0") == 0);\r
-\r
- if ( !interactive || !KFW_is_available() )\r
- return 0;\r
+ /* Can we load KFW binaries? */\r
+ if ( !KFW_is_available() )\r
+ return 0;\r
\r
- DebugEvent("NPLogonNotify - LoginId(%d,%d)", lpLogonId->HighPart, lpLogonId->LowPart);\r
+ /* Are we interactive? */\r
+ if (lpStationName)\r
+ interactive = (wcsicmp(lpStationName, L"WinSta0") == 0);\r
+\r
+ if ( !interactive ) {\r
+ char station[64]="station";\r
+ DWORD rv;\r
+\r
+ SetLastError(0);\r
+ rv = WideCharToMultiByte(CP_UTF8, 0, lpStationName, -1, \r
+ station, sizeof(station), NULL, NULL);\r
+ DebugEvent("Skipping NPLogonNotify- LoginId(%d,%d) - Interactive(%d:%s) - gle %d", \r
+ lpLogonId->HighPart, lpLogonId->LowPart, interactive, rv != 0 ? station : "failure", GetLastError());\r
+ return 0;\r
+ } else\r
+ DebugEvent("NPLogonNotify - LoginId(%d,%d)", lpLogonId->HighPart, lpLogonId->LowPart);\r
\r
/* Initialize Logon Script to none */\r
*lpLogonScript=NULL;\r
/* MSV1_0_INTERACTIVE_LOGON and KERB_INTERACTIVE_LOGON are equivalent for\r
* our purposes */\r
\r
- if ( wcscmp(lpAuthentInfoType,L"MSV1_0:Interactive") && \r
- wcscmp(lpAuthentInfoType,L"Kerberos:Interactive") )\r
+ if ( wcsicmp(lpAuthentInfoType,L"MSV1_0:Interactive") && \r
+ wcsicmp(lpAuthentInfoType,L"Kerberos:Interactive") )\r
{\r
char msg[64];\r
- WideCharToMultiByte(CP_ACP, 0, lpAuthentInfoType, 0, \r
+ WideCharToMultiByte(CP_ACP, 0, lpAuthentInfoType, -1, \r
msg, sizeof(msg), NULL, NULL);\r
msg[sizeof(msg)-1]='\0';\r
DebugEvent("NPLogonNotify - Unsupported Authentication Info Type: %s", msg);\r
\r
IL = (MSV1_0_INTERACTIVE_LOGON *) lpAuthentInfo;\r
\r
- DebugEvent("Interactive %s", interactive ? "yes" : "no");\r
-\r
/* Convert from Unicode to ANSI */\r
\r
/*TODO: Use SecureZeroMemory to erase passwords */\r
DebugEvent0("LogonEventHandler - Start");\r
\r
/* Validate lpszCmdLine as a file */\r
- hf = CreateFile(lpszCmdLine, FILE_ALL_ACCESS, 0, NULL, OPEN_EXISTING, \r
+ hf = CreateFile(lpszCmdLine, GENERIC_READ | DELETE, 0, NULL, OPEN_EXISTING, \r
FILE_ATTRIBUTE_NORMAL, NULL);\r
if (hf == INVALID_HANDLE_VALUE) {\r
- DebugEvent0("LogonEventHandler - file cannot be opened");\r
+ DebugEvent("LogonEventHandler - \"%s\" cannot be opened", lpszCmdLine);\r
return;\r
}\r
CloseHandle(hf);\r