jaltman-afsd-loopback-w2k-and-noipc-patches-20031121

* Change handling of CM_ERROR_NOIPC to return an Access Denied
   error instead of a Bad Network Name error.  The reason is that
   Bad Network Name results in a subsequent query by many apps
   to find a good network name which cannot be accomplished.
   Access Denied is more appropriate and results in an immediate
   error return.

 * Disable the Loopback Adapter hack for operating systems prior
   to Windows XP because the Loopback adapter on previous versions
   does not perform loopback operations on Broadcast messages
   which are necessary for the proper registration of the
   NETBIOS name for the AFS Service.

 * Many minor corrections to uninitialized variables; spelling
   errors; formatting errors; etc.
This commit is contained in:
Jeffrey Altman 2003-11-22 01:28:05 +00:00 committed by Jeffrey Altman
parent 955d376ddd
commit 1972aa4414
3 changed files with 67 additions and 45 deletions

View File

@ -167,7 +167,7 @@ BOOL InitInstance(
main_rect.right = GetDeviceCaps(hDC, HORZRES);
main_rect.top = GetDeviceCaps(hDC, LOGPIXELSY) / 4; /* 1/4 inch */
ReleaseDC(hWnd, hDC);
main_rect.bottom = rect.top + nLineHeight;
main_rect.bottom = main_rect.top + nLineHeight;
osi_InitPanic(afsd_notifier);

View File

@ -2113,6 +2113,7 @@ register struct cmd_syndesc *as; {
}
}
}
return(0);
}

View File

@ -1862,7 +1862,7 @@ void smb_MapNTError(long code, unsigned long *NTStatusp)
NTStatus = 0xC00000CCL; /* Bad network name */
}
else if (code == CM_ERROR_NOIPC) {
NTStatus = 0xC00000CCL; /* Bad network name */
NTStatus = 0xC0000022L; /* Access Denied */
}
else if (code == CM_ERROR_CLOCKSKEW) {
NTStatus = 0xC0000133L; /* Time difference at DC */
@ -1986,8 +1986,8 @@ void smb_MapCoreError(long code, smb_vc_t *vcp, unsigned short *scodep,
error = 6;
}
else if (code == CM_ERROR_NOIPC) {
class = 1;
error = 66;
class = 2;
error = 4; /* bad access */
}
else if (code == CM_ERROR_CLOCKSKEW) {
class = 1; /* invalid function */
@ -5885,7 +5885,7 @@ void smb_Listener(void *parmp)
long len;
long i, j;
smb_vc_t *vcp;
int flags;
int flags = 0;
char rname[NCBNAMSZ+1];
char cname[MAX_COMPUTERNAME_LENGTH+1];
int cnamelen = MAX_COMPUTERNAME_LENGTH+1;
@ -6059,6 +6059,7 @@ void smb_NetbiosInit()
int delname_tried=0;
int len;
int lana_found = 0;
OSVERSIONINFO Version;
/*******************************************************************/
/* ms loopback adapter scan */
@ -6076,6 +6077,11 @@ void smb_NetbiosInit()
unsigned char kWLA_MAC[6] = { 0x02, 0x00, 0x4c, 0x4f, 0x4f, 0x50 };
/*******************************************************************/
/* Get the version of Windows */
memset(&Version, 0x00, sizeof(Version));
Version.dwOSVersionInfoSize = sizeof(Version);
GetVersionEx(&Version);
/* setup the NCB system */
ncbp = GetNCB();
#ifdef DJGPP
@ -6108,7 +6114,8 @@ void smb_NetbiosInit()
ncbp->ncb_callname[2] = 100;
ncbp->ncb_lana_num = lana_list.lana[i];
code = Netbios(ncbp);
if (code == 0) code = ncbp->ncb_retcode;
if (code == 0)
code = ncbp->ncb_retcode;
if (code != 0) {
sprintf(s, "Netbios NCBRESET lana %d error code %d", lana_list.lana[i], code);
afsi_log(s);
@ -6116,7 +6123,6 @@ void smb_NetbiosInit()
} else {
sprintf(s, "Netbios NCBRESET lana %d succeeded", lana_list.lana[i]);
afsi_log(s);
/* check to see if this is the "Microsoft Loopback Adapter" */
memset( ncbp, 0, sizeof (*ncbp) );
ncbp->ncb_command = NCBASTAT;
ncbp->ncb_lana_num = lana_list.lana[i];
@ -6131,6 +6137,16 @@ void smb_NetbiosInit()
wla_found = ( Adapter.status.adapter_address[j] == kWLA_MAC[j] );
if ( wla_found ) {
/*
* check to see if this is the Microsoft Loopback Adapter"
* if we are running on Windows XP or higher
*/
if ( Version.dwPlatformId == VER_PLATFORM_WIN32_NT &&
( Version.dwMajorVersion > 5 ||
Version.dwMajorVersion == 5 &&
Version.dwMinorVersion >= 1 )
)
{
sprintf(s, "Windows Loopback Adapter detected lana %d", lana_list.lana[i]);
afsi_log(s);
@ -6138,6 +6154,11 @@ void smb_NetbiosInit()
lana_list.length = 1;
lana_list.lana[0] = lana_list.lana[i];
break;
} else {
sprintf(s, "Windows Loopback Adapter disabled lana %d", lana_list.lana[i]);
afsi_log(s);
lana_list.lana[i] = 255; /* invalid lana */
}
}
}
}