afslogon-20040318

Fix memory deallocation errors (never call free() on memory allocated
by GlobalAlloc() or LocalAlloc())

Modify event logging to be consistent between High and Low Security

Only generate a random user name when using High Security.  Use the normal
user name when running with Low security.
This commit is contained in:
Jeffrey Altman 2004-03-19 03:52:07 +00:00 committed by Jeffrey Altman
parent e8fc0557d3
commit 48913f747f

View File

@ -148,7 +148,7 @@ WCHAR *GetLogonScript(CHAR *pname)
&LSPtype, (LPBYTE)buf, &LSPsize); &LSPtype, (LPBYTE)buf, &LSPsize);
MultiByteToWideChar(CP_ACP,0,pname,strlen(pname)+1,randomName,(strlen(pname)+1)*sizeof(WCHAR)); MultiByteToWideChar(CP_ACP,0,pname,strlen(pname)+1,randomName,(strlen(pname)+1)*sizeof(WCHAR));
swprintf(script,buf,randomName); swprintf(script,buf,randomName);
free(buf); LocalFree(buf);
#ifdef DEBUG_VERBOSE #ifdef DEBUG_VERBOSE
{ {
@ -374,7 +374,8 @@ DWORD APIENTRY NPLogonNotify(
RegCloseKey (NPKey); RegCloseKey (NPKey);
if ((code!=0) || (LSPtype!=REG_DWORD)) if ((code!=0) || (LSPtype!=REG_DWORD))
LogonOption=LOGON_OPTION_INTEGRATED; /*default to integrated logon only*/ LogonOption=LOGON_OPTION_INTEGRATED; /*default to integrated logon only*/
DebugEvent("AFS AfsLogon - NPLogonNotify","LogonOption[%x], Service AutoStart[%d]",LogonOption,AFSWillAutoStart()); DebugEvent("AFS AfsLogon - NPLogonNotify","LogonOption[%x], Service AutoStart[%d]",
LogonOption,AFSWillAutoStart());
/* Check for zero length password if integrated logon*/ /* Check for zero length password if integrated logon*/
if ( ISLOGONINTEGRATED(LogonOption) && (password[0] == 0) ) { if ( ISLOGONINTEGRATED(LogonOption) && (password[0] == 0) ) {
code = GT_PW_NULL; code = GT_PW_NULL;
@ -398,30 +399,40 @@ DWORD APIENTRY NPLogonNotify(
afsWillAutoStart = AFSWillAutoStart(); afsWillAutoStart = AFSWillAutoStart();
*lpLogonScript = GetLogonScript(GenRandomName(RandomName)); /*only do if high security option is on*/ /*only do if high security option is on*/
if (ISHIGHSECURITY(LogonOption))
*lpLogonScript = GetLogonScript(GenRandomName(RandomName));
else
*lpLogonScript = GetLogonScript(uname);
/* loop until AFS is started. */ /* loop until AFS is started. */
while (TRUE) { while (TRUE) {
code=0; code=0;
/* is service started yet?*/ /* is service started yet?*/
if (ISLOGONINTEGRATED(LogonOption) && !ISHIGHSECURITY(LogonOption)) /* if Integrated Logon only */
DebugEvent("AFS AfsLogon - ka_UserAuthenticateGeneral2","Code[%x] uname[%s] Cell[%s]",
code,uname,cell);
/* if Integrated Logon only */
if (ISLOGONINTEGRATED(LogonOption) && !ISHIGHSECURITY(LogonOption))
{ {
DebugEvent("AFS AfsLogon - ka_UserAuthenticateGeneral2","Code[%x],uame[%s] Cell[%s]",code,uname,cell); code = ka_UserAuthenticateGeneral2(KA_USERAUTH_VERSION+KA_USERAUTH_AUTHENT_LOGON,
code = ka_UserAuthenticateGeneral2(
KA_USERAUTH_VERSION+KA_USERAUTH_AUTHENT_LOGON,
uname, "", cell, password,uname, 0, &pw_exp, 0, uname, "", cell, password,uname, 0, &pw_exp, 0,
&reason); &reason);
DebugEvent("AFS AfsLogon - (INTEGERTED only)ka_UserAuthenticateGeneral2","Code[%x]",code); DebugEvent("AFS AfsLogon - (INTEGRATED only)ka_UserAuthenticateGeneral2","Code[%x]",
} else if (ISLOGONINTEGRATED(LogonOption) && ISHIGHSECURITY(LogonOption)) /* if Integrated Logon and High Security pass random generated name*/ code);
}
/* if Integrated Logon and High Security pass random generated name*/
else if (ISLOGONINTEGRATED(LogonOption) && ISHIGHSECURITY(LogonOption))
{ {
code = ka_UserAuthenticateGeneral2( code = ka_UserAuthenticateGeneral2(KA_USERAUTH_VERSION+KA_USERAUTH_AUTHENT_LOGON,
KA_USERAUTH_VERSION+KA_USERAUTH_AUTHENT_LOGON,
uname, "", cell, password,RandomName, 0, &pw_exp, 0, uname, "", cell, password,RandomName, 0, &pw_exp, 0,
&reason); &reason);
DebugEvent("AFS AfsLogon - (Both)ka_UserAuthenticateGeneral2","Code[%x],RandomName[%s]",code,RandomName); DebugEvent("AFS AfsLogon - (Both)ka_UserAuthenticateGeneral2","Code[%x] RandomName[%s]",
} else { /*JUST check to see if its running*/ code, RandomName);
} else {
/*JUST check to see if its running*/
if (IsServiceRunning()) if (IsServiceRunning())
break; break;
code = KTC_NOCM; code = KTC_NOCM;