Index: openafs/src/WINNT/afs_setup_utils/afs_setup_utils.cpp
diff -c openafs/src/WINNT/afs_setup_utils/afs_setup_utils.cpp:1.8 openafs/src/WINNT/afs_setup_utils/afs_setup_utils.cpp:1.9
*** openafs/src/WINNT/afs_setup_utils/afs_setup_utils.cpp:1.8	Mon Aug 25 14:23:49 2003
--- openafs/src/WINNT/afs_setup_utils/afs_setup_utils.cpp	Tue Jul 13 23:28:36 2004
***************
*** 234,244 ****
      TARGETDIR"\\Common\\*.gid\0"
      TARGETDIR"\\Common\\*.fts\0"
      WINDIR"\\..\\AFSCache\0"
!     WINDIR"\\afsd.log\0"
!     WINDIR"\\afsd.ini\0"
!     WINDIR"\\afsdsbmt.ini\0"
!     WINDIR"\\afsdcell.ini\0"
!     WINDIR"\\afsd_init.log\0",
      
      clientRegValues,
      clientWinNTRegValues,
--- 234,244 ----
      TARGETDIR"\\Common\\*.gid\0"
      TARGETDIR"\\Common\\*.fts\0"
      WINDIR"\\..\\AFSCache\0"
!     WINDIR"\\TEMP\\afsd.log\0"
!     TARGETDIR"\\Client\\afsd.ini\0"
!     TARGETDIR"\\Client\\afsdsbmt.ini\0"
!     TARGETDIR"\\Client\\afsdcell.ini\0"
!     WINDIR"\\TEMP\\afsd_init.log\0",
      
      clientRegValues,
      clientWinNTRegValues,
Index: openafs/src/WINNT/afs_setup_utils/forceremove.c
diff -c openafs/src/WINNT/afs_setup_utils/forceremove.c:1.2 openafs/src/WINNT/afs_setup_utils/forceremove.c:1.3
*** openafs/src/WINNT/afs_setup_utils/forceremove.c:1.2	Sat Nov  4 05:01:10 2000
--- openafs/src/WINNT/afs_setup_utils/forceremove.c	Tue Jul 13 23:28:36 2004
***************
*** 119,131 ****
  	}
      }
  
!     sprintf(filePath, "%s\\%s", winPath, "afsd.log");
      status = FileForceRemove(filePath);
      if (status != ERROR_SUCCESS && status != ERROR_FILE_NOT_FOUND) {
  	rc = status;
      }
  
!     sprintf(filePath, "%s\\%s", winPath, "afsd_init.log");
      status = FileForceRemove(filePath);
      if (status != ERROR_SUCCESS && status != ERROR_FILE_NOT_FOUND) {
  	rc = status;
--- 119,131 ----
  	}
      }
  
!     sprintf(filePath, "%s\\%s", winPath, "temp\\afsd.log");
      status = FileForceRemove(filePath);
      if (status != ERROR_SUCCESS && status != ERROR_FILE_NOT_FOUND) {
  	rc = status;
      }
  
!     sprintf(filePath, "%s\\%s", winPath, "temp\\afsd_init.log");
      status = FileForceRemove(filePath);
      if (status != ERROR_SUCCESS && status != ERROR_FILE_NOT_FOUND) {
  	rc = status;
***************
*** 144,162 ****
      }
  
      if (!keepConfig) {
! 	sprintf(filePath, "%s\\%s", winPath, "afsdcell.ini");
  	status = FileForceRemove(filePath);
  	if (status != ERROR_SUCCESS && status != ERROR_FILE_NOT_FOUND) {
  	    rc = status;
  	}
  
! 	sprintf(filePath, "%s\\%s", winPath, "afsdsbmt.ini");
  	status = FileForceRemove(filePath);
  	if (status != ERROR_SUCCESS && status != ERROR_FILE_NOT_FOUND) {
  	    rc = status;
  	}
  
! 	sprintf(filePath, "%s\\%s", winPath, "afsd.ini");
  	status = FileForceRemove(filePath);
  	if (status != ERROR_SUCCESS && status != ERROR_FILE_NOT_FOUND) {
  	    rc = status;
--- 144,162 ----
      }
  
      if (!keepConfig) {
! 	sprintf(filePath, "%s\\%s", installPath, "Client\\afsdcell.ini");
  	status = FileForceRemove(filePath);
  	if (status != ERROR_SUCCESS && status != ERROR_FILE_NOT_FOUND) {
  	    rc = status;
  	}
  
! 	sprintf(filePath, "%s\\%s", installPath, "Client\\afsdsbmt.ini");
  	status = FileForceRemove(filePath);
  	if (status != ERROR_SUCCESS && status != ERROR_FILE_NOT_FOUND) {
  	    rc = status;
  	}
  
! 	sprintf(filePath, "%s\\%s", installPath, "Client\\afsd.ini");
  	status = FileForceRemove(filePath);
  	if (status != ERROR_SUCCESS && status != ERROR_FILE_NOT_FOUND) {
  	    rc = status;
Index: openafs/src/WINNT/afsd/NTMakefile
diff -c openafs/src/WINNT/afsd/NTMakefile:1.21 openafs/src/WINNT/afsd/NTMakefile:1.26
*** openafs/src/WINNT/afsd/NTMakefile:1.21	Sat Jun 19 11:18:58 2004
--- openafs/src/WINNT/afsd/NTMakefile	Thu Jul 22 18:15:47 2004
***************
*** 64,70 ****
  	$(INCFILEDIR)\cm_freelance.h \
      $(INCFILEDIR)\afsd_eventlog.h \
      $(INCFILEDIR)\afsd_eventmessages.h \
!     $(INCFILEDIR)\afskfw.h
  
  IDLFILES =\
  	afsrpc.h $(OUT)\afsrpc_c.obj
--- 64,71 ----
  	$(INCFILEDIR)\cm_freelance.h \
      $(INCFILEDIR)\afsd_eventlog.h \
      $(INCFILEDIR)\afsd_eventmessages.h \
!     $(INCFILEDIR)\afskfw.h \
!     $(INCFILEDIR)\afsicf.h
  
  IDLFILES =\
  	afsrpc.h $(OUT)\afsrpc_c.obj
***************
*** 116,122 ****
  !ENDIF
      $(OUT)\cm_freelance.obj \
      $(OUT)\afsd_eventlog.obj \
!     $(OUT)\afsd_flushvol.obj
  
  $(AFSDOBJS):
  
--- 117,124 ----
  !ENDIF
      $(OUT)\cm_freelance.obj \
      $(OUT)\afsd_eventlog.obj \
!     $(OUT)\afsd_flushvol.obj \
!     $(OUT)\afsicf.obj
  
  $(AFSDOBJS):
  
***************
*** 208,213 ****
--- 210,216 ----
  
  LOGON_DLLOBJS =\
  	$(OUT)\afslogon.obj \
+     $(OUT)\logon_ad.obj \
  	$(OUT)\afslogon.res
  
  LOGON_DLLLIBS =\
***************
*** 217,224 ****
      $(DESTDIR)\lib\afsdes.lib \
      $(AFSKFWLIB)
  
  $(LOGON_DLLFILE): $(LOGON_DLLOBJS) $(LOGON_DLLLIBS)
! 	$(DLLGUILINK) $(LOGONLINKFLAGS) -def:afslogon.def dnsapi.lib secur32.lib
  	$(DLLPREP)
  	$(COPY) $*.lib $(DESTDIR)\lib
  	$(DEL) $*.lib $*.exp
--- 220,238 ----
      $(DESTDIR)\lib\afsdes.lib \
      $(AFSKFWLIB)
  
+ LOGON_DLLSDKLIBS =\
+ 	dnsapi.lib \
+ 	advapi32.lib \
+ 	secur32.lib \
+ 	strsafe.lib \
+ 	oleaut32.lib \
+ 	ole32.lib \
+ 	adsiid.lib \
+ 	activeds.lib \
+     userenv.lib
+ 
  $(LOGON_DLLFILE): $(LOGON_DLLOBJS) $(LOGON_DLLLIBS)
! 	$(DLLGUILINK) $(LOGONLINKFLAGS) -def:afslogon.def $(LOGON_DLLSDKLIBS)
  	$(DLLPREP)
  	$(COPY) $*.lib $(DESTDIR)\lib
  	$(DEL) $*.lib $*.exp
***************
*** 245,253 ****
  ############################################################################
  # Install target; primary makefile target
  
! install_objs: $(OUT)\cm_dns.obj $(OUT)\cm_config.obj $(LANAHELPERLIB)
       $(COPY) $(OUT)\cm_dns.obj $(DESTDIR)\lib
       $(COPY) $(OUT)\cm_config.obj $(DESTDIR)\lib
  
  install_headers: $(IDLFILES) $(INCFILES)
  
--- 259,268 ----
  ############################################################################
  # Install target; primary makefile target
  
! install_objs: $(OUT)\cm_dns.obj $(OUT)\cm_config.obj $(LANAHELPERLIB) $(OUT)\afsicf.obj
       $(COPY) $(OUT)\cm_dns.obj $(DESTDIR)\lib
       $(COPY) $(OUT)\cm_config.obj $(DESTDIR)\lib
+      $(COPY) $(OUT)\afsicf.obj $(DESTDIR)\lib
  
  install_headers: $(IDLFILES) $(INCFILES)
  
***************
*** 322,333 ****
  AFSD_SDKLIBS =\
  	largeint.lib \
  	netapi32.lib \
-     mpr.lib \
      dnsapi.lib \
  	rpcrt4.lib \
  	user32.lib \
      Dbghelp.lib \
!     strsafe.lib
  
  AFSD_EXELIBS =\
  	$(DESTDIR)\lib\libosi.lib \
--- 337,351 ----
  AFSD_SDKLIBS =\
  	largeint.lib \
  	netapi32.lib \
      dnsapi.lib \
  	rpcrt4.lib \
  	user32.lib \
      Dbghelp.lib \
!     strsafe.lib \
!     mpr.lib \
!     secur32.lib \
!     ole32.lib \
!     oleaut32.lib
  
  AFSD_EXELIBS =\
  	$(DESTDIR)\lib\libosi.lib \
Index: openafs/src/WINNT/afsd/afsd.h
diff -c openafs/src/WINNT/afsd/afsd.h:1.4 openafs/src/WINNT/afsd/afsd.h:1.5
*** openafs/src/WINNT/afsd/afsd.h:1.4	Fri Oct  5 17:40:47 2001
--- openafs/src/WINNT/afsd/afsd.h	Tue Jul 20 10:36:41 2004
***************
*** 61,66 ****
--- 61,67 ----
  #include "cm_dnlc.h"
  #include "cm_buf.h"
  #include "cm_freelance.h"
+ #include "smb_ioctl.h"
  #ifdef DJGPP
  #include "afs/afsmsg95.h"
  #endif
Index: openafs/src/WINNT/afsd/afsd_init.c
diff -c openafs/src/WINNT/afsd/afsd_init.c:1.31 openafs/src/WINNT/afsd/afsd_init.c:1.37
*** openafs/src/WINNT/afsd/afsd_init.c:1.31	Sat Jun 19 11:18:59 2004
--- openafs/src/WINNT/afsd/afsd_init.c	Sun Jul 25 16:53:12 2004
***************
*** 29,34 ****
--- 29,35 ----
  #include "smb.h"
  #include "cm_rpc.h"
  #include "lanahelper.h"
+ #include "afsicf.h"
  
  extern int RXAFSCB_ExecuteRequest(struct rx_call *z_call);
  extern int RXSTATS_ExecuteRequest(struct rx_call *z_call);
***************
*** 83,88 ****
--- 84,91 ----
  int   cm_sysNameCount = 0;
  char *cm_sysNameList[MAXNUMSYSNAMES];
  
+ DWORD TraceOption = 0;
+ 
  /*
   * AFSD Initialization Log
   *
***************
*** 112,117 ****
--- 115,124 ----
  	char t[100], u[100], *p, *path;
  	int zilch;
  	int code;
+     DWORD dwLow, dwHigh;
+ 	HKEY parmKey;
+ 	DWORD dummyLen;
+     DWORD maxLogSize = 100 * 1024;
  
  	afsi_file = INVALID_HANDLE_VALUE;
      if (getenv("TEMP"))
***************
*** 127,132 ****
--- 134,158 ----
  	GetTimeFormat(LOCALE_SYSTEM_DEFAULT, 0, NULL, NULL, t, sizeof(t));
  	afsi_file = CreateFile(wd, GENERIC_WRITE, FILE_SHARE_READ, NULL,
                             OPEN_ALWAYS, FILE_FLAG_WRITE_THROUGH, NULL);
+ 
+     code = RegOpenKeyEx(HKEY_LOCAL_MACHINE, AFSConfigKeyName,
+                          0, KEY_QUERY_VALUE, &parmKey);
+ 	if (code == ERROR_SUCCESS) {
+         dummyLen = sizeof(maxLogSize);
+         code = RegQueryValueEx(parmKey, "MaxLogSize", NULL, NULL,
+                                 (BYTE *) &maxLogSize, &dummyLen);
+         RegCloseKey (parmKey);
+ 	}
+ 
+     if (maxLogSize) {
+         dwLow = GetFileSize( afsi_file, &dwHigh );
+         if ( dwHigh > 0 || dwLow >= maxLogSize ) {
+             CloseHandle(afsi_file);
+             afsi_file = CreateFile( wd, GENERIC_WRITE, FILE_SHARE_READ, NULL,
+                                     CREATE_ALWAYS, FILE_FLAG_WRITE_THROUGH, NULL);
+         }
+     }
+ 
      SetFilePointer(afsi_file, 0, NULL, FILE_END);
  	GetTimeFormat(LOCALE_SYSTEM_DEFAULT, 0, NULL, NULL, u, sizeof(u));
  	StringCbCatA(t, sizeof(t), ": Create log file\n");
***************
*** 193,198 ****
--- 219,359 ----
  	CloseHandle(handle);
  }
  
+ static void
+ configureBackConnectionHostNames(void)
+ {
+     /* On Windows XP SP2, Windows 2003 SP1, and all future Windows operating systems
+      * there is a restriction on the use of SMB authentication on loopback connections.
+      * There are two work arounds available:
+      * 
+      *   (1) We can disable the check for matching host names.  This does not
+      *   require a reboot:
+      *   [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa]
+      *     "DisableLoopbackCheck"=dword:00000001
+      *
+      *   (2) We can add the AFS SMB/CIFS service name to an approved list.  This
+      *   does require a reboot:
+      *   [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa\MSV1_0]
+      *     "BackConnectionHostNames"=multi-sz
+      *
+      * The algorithm will be:
+      *   (1) Check to see if cm_NetbiosName exists in the BackConnectionHostNames list
+      *   (2a) If not, add it to the list.  (This will not take effect until the next reboot.)
+      *   (2b1)    and check to see if DisableLoopbackCheck is set.
+      *   (2b2)    If not set, set the DisableLoopbackCheck value to 0x1 
+      *   (2b3)                and create HKLM\SOFTWARE\OpenAFS\Client  UnsetDisableLoopbackCheck
+      *   (2c) else If cm_NetbiosName exists in the BackConnectionHostNames list,
+      *             check for the UnsetDisableLoopbackCheck value.  
+      *             If set, set the DisableLoopbackCheck flag to 0x0 
+      *             and delete the UnsetDisableLoopbackCheck value
+      */
+     HKEY hkLsa;
+     HKEY hkMSV10;
+     HKEY hkClient;
+     DWORD dwType;
+     DWORD dwSize;
+     DWORD dwValue;
+     PBYTE pHostNames = NULL, pName;
+     BOOL  bNameFound = FALSE;   
+ 
+     if ( RegOpenKeyEx( HKEY_LOCAL_MACHINE, 
+                        "SYSTEM\\CurrentControlSet\\Control\\Lsa\\MSV1_0",
+                        0,
+                        KEY_READ|KEY_WRITE,
+                        &hkMSV10) == ERROR_SUCCESS )
+     {
+         if (RegQueryValueEx( hkMSV10, "BackConnectionHostNames", 0, &dwType, NULL, &dwSize) == ERROR_SUCCESS) {
+             pHostNames = malloc(dwSize + strlen(cm_NetbiosName) + 1);
+             RegQueryValueEx( hkMSV10, "BackConnectionHostNames", 0, &dwType, pHostNames, &dwSize);
+ 
+             for (pName = pHostNames; *pName ; pName += strlen(pName) + 1)
+             {
+                 if ( !stricmp(pName, cm_NetbiosName) ) {
+                     bNameFound = TRUE;
+                     break;
+                 }   
+             }
+         }
+              
+         if ( !bNameFound ) {
+             if ( !pHostNames ) {
+                 pName = pHostNames = malloc(strlen(cm_NetbiosName) + 2);
+                 dwSize = 1;
+             }
+             strcpy(pName, cm_NetbiosName);
+             pName += strlen(cm_NetbiosName) + 1;
+             *pName = '\0';  /* add a second nul terminator */
+ 
+             dwType = REG_MULTI_SZ;
+             dwSize += strlen(cm_NetbiosName) + 1;
+             RegSetValueEx( hkMSV10, "BackConnectionHostNames", 0, dwType, pHostNames, dwSize);
+ 
+             if ( RegOpenKeyEx( HKEY_LOCAL_MACHINE, 
+                                "SYSTEM\\CurrentControlSet\\Control\\Lsa",
+                                0,
+                                KEY_READ|KEY_WRITE,
+                                &hkLsa) == ERROR_SUCCESS )
+             {
+                 dwSize = sizeof(DWORD);
+                 if ( RegQueryValueEx( hkLsa, "DisableLoopbackCheck", 0, &dwType, &dwValue, &dwSize) != ERROR_SUCCESS ||
+                      dwValue == 0 ) {
+                     dwType = REG_DWORD;
+                     dwSize = sizeof(DWORD);
+                     dwValue = 1;
+                     RegSetValueEx( hkLsa, "DisableLoopbackCheck", 0, dwType, &dwValue, dwSize);
+ 
+                     if (RegCreateKeyEx( HKEY_LOCAL_MACHINE, 
+                                         "SOFTWARE\\OpenAFS\\Client",
+                                         0,
+                                         NULL,
+                                         REG_OPTION_NON_VOLATILE,
+                                         KEY_READ|KEY_WRITE,
+                                         NULL,
+                                         &hkClient,
+                                         NULL) == ERROR_SUCCESS) {
+ 
+                         dwType = REG_DWORD;
+                         dwSize = sizeof(DWORD);
+                         dwValue = 1;
+                         RegSetValueEx( hkClient, "RemoveDisableLoopbackCheck", 0, dwType, &dwValue, dwSize);
+                         RegCloseKey(hkClient);
+                     }
+                     RegCloseKey(hkLsa);
+                 }
+             }
+         } else {
+             if (RegCreateKeyEx( HKEY_LOCAL_MACHINE, 
+                                 "SOFTWARE\\OpenAFS\\Client",
+                                 0,
+                                 NULL,
+                                 REG_OPTION_NON_VOLATILE,
+                                 KEY_READ|KEY_WRITE,
+                                 NULL,
+                                 &hkClient,
+                                 NULL) == ERROR_SUCCESS) {
+ 
+                 dwSize = sizeof(DWORD);
+                 if ( RegQueryValueEx( hkClient, "RemoveDisableLoopbackCheck", 0, &dwType, &dwValue, &dwSize) == ERROR_SUCCESS &&
+                      dwValue == 1 ) {
+                     if ( RegOpenKeyEx( HKEY_LOCAL_MACHINE, 
+                                        "SYSTEM\\CurrentControlSet\\Control\\Lsa",
+                                        0,
+                                        KEY_READ|KEY_WRITE,
+                                        &hkLsa) == ERROR_SUCCESS )
+                     {
+                         RegDeleteValue(hkLsa, "DisableLoopbackCheck");
+                         RegCloseKey(hkLsa);
+                     }
+                 }
+                 RegDeleteValue(hkClient, "RemoveDisableLoopbackCheck");
+                 RegCloseKey(hkClient);
+             }
+         }
+         RegCloseKey(hkMSV10);
+     }
+ }
+ 
+ 
  /*
   * AFSD Initialization
   */
***************
*** 205,210 ****
--- 366,372 ----
  	long logChunkSize;
  	long stats;
  	long traceBufSize;
+     long maxcpus;
  	long ltt, ltto;
      long rx_mtu, rx_nojumbo;
  	char rootCellName[256];
***************
*** 258,263 ****
--- 420,466 ----
  		osi_panic(buf, __FILE__, __LINE__);
  	}
  
+     dummyLen = sizeof(maxcpus);
+ 	code = RegQueryValueEx(parmKey, "MaxCPUs", NULL, NULL,
+ 				(BYTE *) &maxcpus, &dummyLen);
+ 	if (code == ERROR_SUCCESS) {
+         HANDLE hProcess;
+         DWORD_PTR processAffinityMask, systemAffinityMask;
+ 
+         hProcess = OpenProcess(PROCESS_QUERY_INFORMATION|PROCESS_SET_INFORMATION,
+                                FALSE, GetCurrentProcessId());
+         if ( hProcess != NULL &&
+              GetProcessAffinityMask(hProcess, &processAffinityMask, &systemAffinityMask) )
+         {
+             int i, n, bits;
+             DWORD_PTR mask, newAffinityMask;
+ 
+ #if defined(_WIN64)
+             bits = 64;
+ #else
+             bits = 32;
+ #endif
+             for ( i=0, n=0, mask=1, newAffinityMask=0; i<bits && n<maxcpus; i++ ) {
+                 if ( processAffinityMask & mask ) {
+                     newAffinityMask |= mask;
+                     n++;
+                 }
+                 mask *= 2;
+             }
+ 
+             SetProcessAffinityMask(hProcess, newAffinityMask);
+             CloseHandle(hProcess);
+             afsi_log("CPU Restrictions set to %d cpu(s); %d cpu(s) available", maxcpus, n);
+         } else {
+             afsi_log("CPU Restrictions set to %d cpu(s); unable to access process information", maxcpus);
+         }
+     }
+ 
+ 	dummyLen = sizeof(TraceOption);
+ 	code = RegQueryValueEx(parmKey, "TraceOption", NULL, NULL,
+ 				(BYTE *) &TraceOption, &dummyLen);
+     afsi_log("Event Log Tracing = %lX", TraceOption);
+ 
  	dummyLen = sizeof(traceBufSize);
  	code = RegQueryValueEx(parmKey, "TraceBufferSize", NULL, NULL,
  				(BYTE *) &traceBufSize, &dummyLen);
***************
*** 343,348 ****
--- 546,552 ----
  		afsi_log("Logoff token transfer on by default");
  	}
      smb_LogoffTokenTransfer = ltt;
+     afsi_log("Logoff token transfer is currently ignored");
  
  	if (ltt) {
  		dummyLen = sizeof(ltto);
***************
*** 359,364 ****
--- 563,569 ----
          ltto = 0;
      }
      smb_LogoffTransferTimeout = ltto;
+     afsi_log("Default logoff token is currently ignored");
  
  	dummyLen = sizeof(cm_rootVolumeName);
  	code = RegQueryValueEx(parmKey, "RootVolume", NULL, NULL,
***************
*** 371,377 ****
  	}
  
  	cm_mountRootLen = sizeof(cm_mountRoot);
! 	code = RegQueryValueEx(parmKey, "Mountroot", NULL, NULL,
  				cm_mountRoot, &cm_mountRootLen);
  	if (code == ERROR_SUCCESS) {
  		afsi_log("Mount root %s", cm_mountRoot);
--- 576,582 ----
  	}
  
  	cm_mountRootLen = sizeof(cm_mountRoot);
! 	code = RegQueryValueEx(parmKey, "MountRoot", NULL, NULL,
  				cm_mountRoot, &cm_mountRootLen);
  	if (code == ERROR_SUCCESS) {
  		afsi_log("Mount root %s", cm_mountRoot);
***************
*** 513,518 ****
--- 718,733 ----
      }
      afsi_log("Maximum number of VCs per server is %d", smb_maxVCPerServer);
  
+ 	dummyLen = sizeof(smb_authType);
+ 	code = RegQueryValueEx(parmKey, "SMBAuthType", NULL, NULL,
+ 		(BYTE *) &smb_authType, &dummyLen);
+ 
+ 	if (code != ERROR_SUCCESS || 
+         (smb_authType != SMB_AUTH_EXTENDED && smb_authType != SMB_AUTH_NTLM && smb_authType != SMB_AUTH_NONE)) {
+ 		smb_authType = SMB_AUTH_EXTENDED; /* default is to use extended authentication */
+ 	}
+ 	afsi_log("SMB authentication type is %s", ((smb_authType == SMB_AUTH_NONE)?"NONE":((smb_authType == SMB_AUTH_EXTENDED)?"EXTENDED":"NTLM")));
+ 
      dummyLen = sizeof(rx_nojumbo);
      code = RegQueryValueEx(parmKey, "RxNoJumbo", NULL, NULL,
                             (BYTE *) &rx_nojumbo, &dummyLen);
***************
*** 607,631 ****
      }
  
      /* Open Microsoft Firewall to allow in port 7001 */
!     {
!         HKEY hk;
!         DWORD dwDisp;
!         TCHAR* value = TEXT("7001:UDP:*:Enabled:AFS Cache Manager Callback");
!         if (RegCreateKeyEx (HKEY_LOCAL_MACHINE, 
!                             "SYSTEM\\CurrentControlSet\\Services\\SharedAccess\\Parameters\\FirewallPolicy\\DomainProfile\\GloballyOpenP", 
!                             0, TEXT("container"), 0, KEY_SET_VALUE, NULL, &hk, &dwDisp) == ERROR_SUCCESS)
!         {
!             RegSetValueEx (hk, TEXT("7001:UDP"), 0, REG_SZ, (PBYTE)value, sizeof(TCHAR) * (1+lstrlen(value)));
!             RegCloseKey (hk);
!         }
!         if (RegCreateKeyEx (HKEY_LOCAL_MACHINE, 
!                             "SYSTEM\\CurrentControlSet\\Services\\SharedAccess\\Parameters\\FirewallPolicy\\StandardProfile\\GloballyOpenP", 
!                             0, TEXT("container"), 0, KEY_SET_VALUE, NULL, &hk, &dwDisp) == ERROR_SUCCESS)
!         {
!             RegSetValueEx (hk, TEXT("7001:UDP"), 0, REG_SZ, (PBYTE)value, sizeof(TCHAR) * (1+lstrlen(value)));
!             RegCloseKey (hk);
!         }
!     }
  
  	/* initialize RX, and tell it to listen to port 7001, which is used for
       * callback RPC messages.
--- 822,831 ----
      }
  
      /* Open Microsoft Firewall to allow in port 7001 */
!     icf_CheckAndAddAFSPorts(AFS_PORTSET_CLIENT);
! 
!     /* Ensure the AFS Netbios Name is registered to allow loopback access */
!     configureBackConnectionHostNames();
  
  	/* initialize RX, and tell it to listen to port 7001, which is used for
       * callback RPC messages.
Index: openafs/src/WINNT/afsd/afsd_service.c
diff -c openafs/src/WINNT/afsd/afsd_service.c:1.27 openafs/src/WINNT/afsd/afsd_service.c:1.28
*** openafs/src/WINNT/afsd/afsd_service.c:1.27	Sat May 29 19:47:59 2004
--- openafs/src/WINNT/afsd/afsd_service.c	Sat Jul 24 11:25:35 2004
***************
*** 346,359 ****
   
  		    sprintf(szAfsPath,"\\\\%s\\%s",cm_NetbiosName,szSubMount);
  		    
! 		    nr.dwScope = RESOURCE_GLOBALNET;
  		    nr.dwType=RESOURCETYPE_DISK;
  		    nr.lpLocalName=szDriveToMapTo;
  		    nr.lpRemoteName=szAfsPath;
! 		    nr.dwDisplayType = RESOURCEDISPLAYTYPE_SHARE;
! 		    nr.dwUsage = RESOURCEUSAGE_CONNECTABLE;
  
! 		    dwResult = WNetAddConnection2(&nr,NULL,NULL,FALSE);
              afsi_log("GlobalAutoMap of %s to %s %s (%d)", szDriveToMapTo, szSubMount, 
                       (dwResult == NO_ERROR) ? "succeeded" : "failed", dwResult);
              if (dwResult == NO_ERROR) {
--- 346,359 ----
   
  		    sprintf(szAfsPath,"\\\\%s\\%s",cm_NetbiosName,szSubMount);
  		    
! 		    nr.dwScope = RESOURCE_GLOBALNET;              /* ignored parameter */
  		    nr.dwType=RESOURCETYPE_DISK;
  		    nr.lpLocalName=szDriveToMapTo;
  		    nr.lpRemoteName=szAfsPath;
! 		    nr.dwDisplayType = RESOURCEDISPLAYTYPE_SHARE; /* ignored parameter */
! 		    nr.dwUsage = RESOURCEUSAGE_CONNECTABLE;       /* ignored parameter */
  
! 		    dwResult = WNetAddConnection2(&nr,NULL,NULL,0);
              afsi_log("GlobalAutoMap of %s to %s %s (%d)", szDriveToMapTo, szSubMount, 
                       (dwResult == NO_ERROR) ? "succeeded" : "failed", dwResult);
              if (dwResult == NO_ERROR) {
***************
*** 361,366 ****
--- 361,369 ----
              }
              /* wait for smb server to come up */
              Sleep((DWORD)1000 /* miliseconds */);		
+ 
+             /* Disconnect any previous mappings */
+             dwResult = WNetCancelConnection2(szDriveToMapTo, 0, TRUE);
          }
      }        
  
***************
*** 400,405 ****
--- 403,409 ----
  
          sprintf(szAfsPath,"\\\\%s\\%s",cm_NetbiosName,szSubMount);
  		    
+         dwResult = WNetCancelConnection2(szDriveToMapTo, 0, TRUE);
          dwResult = WNetCancelConnection(szAfsPath, TRUE);
          
          afsi_log("Disconnect from GlobalAutoMap of %s to %s %s", szDriveToMapTo, szSubMount, dwResult ? "succeeded" : "failed");
Index: openafs/src/WINNT/afsd/afsicf.cpp
diff -c /dev/null openafs/src/WINNT/afsd/afsicf.cpp:1.1
*** /dev/null	Tue Jul 27 19:19:43 2004
--- openafs/src/WINNT/afsd/afsicf.cpp	Wed Jul 14 02:00:18 2004
***************
*** 0 ****
--- 1,326 ----
+ /*
+ 
+ Copyright 2004 by the Massachusetts Institute of Technology
+ 
+ All rights reserved.
+ 
+ Permission to use, copy, modify, and distribute this software and its
+ documentation for any purpose and without fee is hereby granted,
+ provided that the above copyright notice appear in all copies and that
+ both that copyright notice and this permission notice appear in
+ supporting documentation, and that the name of the Massachusetts
+ Institute of Technology (M.I.T.) not be used in advertising or publicity
+ pertaining to distribution of the software without specific, written
+ prior permission.
+ 
+ M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ M.I.T. BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ SOFTWARE.
+ 
+ */
+ 
+ #define _WIN32_DCOM
+ #include <windows.h>
+ #include <netfw.h>
+ #include <objbase.h>
+ #include <oleauto.h>
+ #include "afsicf.h"
+ 
+ //#define TESTMAIN
+ 
+ #ifdef TESTMAIN
+ #include<stdio.h>
+ #pragma comment(lib,"ole32.lib")
+ #pragma comment(lib,"oleaut32.lib")
+ #define DEBUGOUT(x) printf x
+ #else
+ #define DEBUGOUT(x)
+ #endif
+ 
+ /* an IPv4, enabled port with global scope */
+ struct global_afs_port_type {
+     LPWSTR	name;
+ 	LONG	port;
+ 	NET_FW_IP_PROTOCOL protocol;
+ };
+ 
+ typedef struct global_afs_port_type global_afs_port_t;
+ 
+ global_afs_port_t afs_clientPorts[] = {
+ 	{ L"AFS CacheManager Callback (UDP)", 7001, NET_FW_IP_PROTOCOL_UDP },
+ 	{ L"AFS CacheManager Callback (TCP)", 7001, NET_FW_IP_PROTOCOL_TCP }
+ };
+ 
+ global_afs_port_t afs_serverPorts[] = {
+ 	{ L"AFS File Server (UDP)", 7000, NET_FW_IP_PROTOCOL_UDP },
+ 	{ L"AFS File Server (TCP)", 7000, NET_FW_IP_PROTOCOL_TCP },
+ 	{ L"AFS User & Group Database (UDP)", 7002, NET_FW_IP_PROTOCOL_UDP },
+ 	{ L"AFS User & Group Database (TCP)", 7002, NET_FW_IP_PROTOCOL_TCP },
+ 	{ L"AFS Volume Location Database (UDP)", 7003, NET_FW_IP_PROTOCOL_UDP },
+ 	{ L"AFS Volume Location Database (TCP)", 7003, NET_FW_IP_PROTOCOL_TCP },
+ 	{ L"AFS/Kerberos Authentication (UDP)", 7004, NET_FW_IP_PROTOCOL_UDP },
+ 	{ L"AFS/Kerberos Authentication (TCP)", 7004, NET_FW_IP_PROTOCOL_TCP },
+ 	{ L"AFS Volume Mangement (UDP)", 7005, NET_FW_IP_PROTOCOL_UDP },
+ 	{ L"AFS Volume Mangement (TCP)", 7005, NET_FW_IP_PROTOCOL_TCP },
+ 	{ L"AFS Error Interpretation (UDP)", 7006, NET_FW_IP_PROTOCOL_UDP },
+ 	{ L"AFS Error Interpretation (TCP)", 7006, NET_FW_IP_PROTOCOL_TCP },
+ 	{ L"AFS Basic Overseer (UDP)", 7007, NET_FW_IP_PROTOCOL_UDP },
+ 	{ L"AFS Basic Overseer (TCP)", 7007, NET_FW_IP_PROTOCOL_TCP },
+ 	{ L"AFS Server-to-server Updater (UDP)", 7008, NET_FW_IP_PROTOCOL_UDP },
+ 	{ L"AFS Server-to-server Updater (TCP)", 7008, NET_FW_IP_PROTOCOL_TCP },
+ 	{ L"AFS Remote Cache Manager (UDP)", 7009, NET_FW_IP_PROTOCOL_UDP },
+ 	{ L"AFS Remote Cache Manager (TCP)", 7009, NET_FW_IP_PROTOCOL_TCP }
+ };
+ 
+ HRESULT icf_OpenFirewallProfile(INetFwProfile ** fwProfile) {
+     HRESULT hr = S_OK;
+     INetFwMgr* fwMgr = NULL;
+     INetFwPolicy* fwPolicy = NULL;
+ 
+     *fwProfile = NULL;
+ 
+     // Create an instance of the firewall settings manager.
+     hr = CoCreateInstance(
+             __uuidof(NetFwMgr),
+             NULL,
+             CLSCTX_INPROC_SERVER,
+             __uuidof(INetFwMgr),
+             reinterpret_cast<void**>(static_cast<INetFwMgr**>(&fwMgr))
+             );
+     if (FAILED(hr))
+     {
+ 		DEBUGOUT(("Can't create fwMgr\n"));
+         goto error;
+     }
+ 
+     // Retrieve the local firewall policy.
+     hr = fwMgr->get_LocalPolicy(&fwPolicy);
+     if (FAILED(hr))
+     {
+ 		DEBUGOUT(("Cant get local policy\n"));
+         goto error;
+     }
+ 
+     // Retrieve the firewall profile currently in effect.
+     hr = fwPolicy->get_CurrentProfile(fwProfile);
+     if (FAILED(hr))
+     {
+ 		DEBUGOUT(("Can't get current profile\n"));
+         goto error;
+     }
+ 
+ error:
+ 
+     // Release the local firewall policy.
+     if (fwPolicy != NULL)
+     {
+         fwPolicy->Release();
+     }
+ 
+     // Release the firewall settings manager.
+     if (fwMgr != NULL)
+     {
+         fwMgr->Release();
+     }
+ 
+     return hr;
+ }
+ 
+ HRESULT icf_CheckAndAddPorts(INetFwProfile * fwProfile, global_afs_port_t * ports, int nPorts) {
+ 	INetFwOpenPorts * fwPorts = NULL;
+ 	INetFwOpenPort * fwPort = NULL;
+ 	HRESULT hr;
+ 	HRESULT rhr = S_OK; /* return value */
+ 
+ 	hr = fwProfile->get_GloballyOpenPorts(&fwPorts);
+ 	if (FAILED(hr)) {
+ 		// Abort!
+ 		DEBUGOUT(("Can't get globallyOpenPorts\n"));
+ 		rhr = hr;
+ 		goto cleanup;
+ 	}
+ 
+ 	// go through the supplied ports
+ 	for (int i=0; i<nPorts; i++) {
+ 		VARIANT_BOOL vbEnabled;
+ 		BSTR bstName = NULL;
+ 		BOOL bCreate = FALSE;
+ 		fwPort = NULL;
+ 
+ 		hr = fwPorts->Item(ports[i].port, ports[i].protocol, &fwPort);
+ 		if (SUCCEEDED(hr)) {
+ 			DEBUGOUT(("Found port for %S\n",ports[i].name));
+             hr = fwPort->get_Enabled(&vbEnabled);
+ 			if (SUCCEEDED(hr)) {
+ 				if ( vbEnabled == VARIANT_FALSE ) {
+ 					hr = fwPort->put_Enabled(VARIANT_TRUE);
+ 					if (FAILED(hr)) {
+ 						// failed. Mark as failure. Don't try to create the port either.
+ 						rhr = hr;
+ 					}
+ 				} // else we are fine
+ 			} else {
+                 // Something is wrong with the port.
+ 				// We try to create a new one thus overriding this faulty one.
+ 				bCreate = TRUE;
+ 			}
+ 			fwPort->Release();
+ 			fwPort = NULL;
+ 		} else if (hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND)) {
+ 			DEBUGOUT(("Port not found for %S\n", ports[i].name));
+ 			bCreate = TRUE;
+ 		}
+ 
+ 		if (bCreate) {
+ 			DEBUGOUT(("Trying to create port %S\n",ports[i].name));
+ 			hr = CoCreateInstance(
+ 				__uuidof(NetFwOpenPort),
+ 				NULL,
+ 				CLSCTX_INPROC_SERVER,
+ 				__uuidof(INetFwOpenPort),
+ 				reinterpret_cast<void**>
+ 					(static_cast<INetFwOpenPort**>(&fwPort))
+ 				);
+ 
+ 			if (FAILED(hr)) {
+ 				DEBUGOUT(("Can't create port\n"));
+                 rhr = hr;
+ 			} else {
+ 				DEBUGOUT(("Created port\n"));
+ 				hr = fwPort->put_IpVersion( NET_FW_IP_VERSION_ANY );
+ 				if (FAILED(hr)) {
+ 					DEBUGOUT(("Can't set IpVersion\n"));
+ 					rhr = hr;
+ 					goto abandon_port;
+ 				}
+ 
+ 				hr = fwPort->put_Port( ports[i].port );
+ 				if (FAILED(hr)) {
+ 					DEBUGOUT(("Can't set Port\n"));
+ 					rhr = hr;
+ 					goto abandon_port;
+ 				}
+ 
+ 				hr = fwPort->put_Protocol( ports[i].protocol );
+ 				if (FAILED(hr)) {
+ 					DEBUGOUT(("Can't set Protocol\n"));
+ 					rhr = hr;
+ 					goto abandon_port;
+ 				}
+ 
+ 				hr = fwPort->put_Scope( NET_FW_SCOPE_ALL );
+ 				if (FAILED(hr)) {
+ 					DEBUGOUT(("Can't set Scope\n"));
+ 					rhr = hr;
+ 					goto abandon_port;
+ 				}
+ 
+ 				bstName = SysAllocString( ports[i].name );
+ 
+ 				if (SysStringLen(bstName) == 0) {
+ 					rhr = E_OUTOFMEMORY;
+ 				} else {
+ 					hr = fwPort->put_Name( bstName );
+ 					if (FAILED(hr)) {
+ 						DEBUGOUT(("Can't set Name\n"));
+ 						rhr = hr;
+ 						SysFreeString( bstName );
+ 						goto abandon_port;
+ 					}
+ 				}
+ 
+ 				SysFreeString( bstName );
+ 
+ 				hr = fwPorts->Add( fwPort );
+ 				if (FAILED(hr)) {
+ 					DEBUGOUT(("Can't add port\n"));
+ 					rhr = hr;
+ 				} else
+ 					DEBUGOUT(("Added port\n"));
+ 
+ abandon_port:
+ 				fwPort->Release();
+ 			}
+ 		}
+ 	} // loop through ports
+ 
+ 	fwPorts->Release();
+ 
+ cleanup:
+ 
+ 	if (fwPorts != NULL)
+ 		fwPorts->Release();
+ 
+ 	return rhr;
+ }
+ 
+ long icf_CheckAndAddAFSPorts(int portset) {
+ 	HRESULT hr;
+ 	BOOL coInitialized = FALSE;
+ 	INetFwProfile * fwProfile = NULL;
+ 	global_afs_port_t * ports;
+ 	int nports;
+ 	long code = 0;
+ 
+ 	if (portset == AFS_PORTSET_CLIENT) {
+ 		ports = afs_clientPorts;
+ 		nports = sizeof(afs_clientPorts) / sizeof(*afs_clientPorts);
+ 	} else if (portset == AFS_PORTSET_SERVER) {
+ 		ports = afs_serverPorts;
+ 		nports = sizeof(afs_serverPorts) / sizeof(*afs_serverPorts);
+ 	} else
+ 		return 1; /* Invalid port set */
+ 
+ 	hr = CoInitializeEx(
+         NULL,
+         COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE
+         );
+ 
+ 	if (SUCCEEDED(hr) || RPC_E_CHANGED_MODE == hr)
+     {
+        coInitialized = TRUE;
+     }
+ 	// not necessarily catastrophic if the call failed.  We'll try to
+ 	// continue as if it succeeded.
+ 
+     hr = icf_OpenFirewallProfile(&fwProfile);
+ 	if (FAILED(hr)) {
+ 		// Ok. That didn't work.  This could be because the machine we
+ 		// are running on doesn't have Windows Firewall.  We'll return
+ 		// a failure to the caller, which shouldn't be taken to mean
+ 		// it's catastrophic.
+ 		DEBUGOUT(("Can't open Firewall profile\n"));
+ 		code = 1;
+ 		goto cleanup;
+ 	}
+ 
+ 	// Now that we have a firewall profile, we can start checking
+ 	// and adding the ports that we want.
+ 	hr = icf_CheckAndAddPorts(fwProfile, ports, nports);
+ 	if (FAILED(hr))
+ 		code = 1;
+ 
+ cleanup:
+ 	if (coInitialized) {
+ 		CoUninitialize();
+ 	}
+ 
+ 	return code;
+ }
+ 
+ 
+ #ifdef TESTMAIN
+ int main(int argc, char **argv) {
+ 	printf("Starting...\n");
+     if (icf_CheckAndAddAFSPorts(AFS_PORTSET_CLIENT))
+ 		printf("Failed\n");
+ 	else
+ 		printf("Succeeded\n");
+ 	printf("Done\n");
+ 	return 0;
+ }
+ #endif
\ No newline at end of file
Index: openafs/src/WINNT/afsd/afsicf.h
diff -c /dev/null openafs/src/WINNT/afsd/afsicf.h:1.1
*** /dev/null	Tue Jul 27 19:19:43 2004
--- openafs/src/WINNT/afsd/afsicf.h	Wed Jul 14 02:00:18 2004
***************
*** 0 ****
--- 1,40 ----
+ /*
+ 
+ Copyright 2004 by the Massachusetts Institute of Technology
+ 
+ All rights reserved.
+ 
+ Permission to use, copy, modify, and distribute this software and its
+ documentation for any purpose and without fee is hereby granted,
+ provided that the above copyright notice appear in all copies and that
+ both that copyright notice and this permission notice appear in
+ supporting documentation, and that the name of the Massachusetts
+ Institute of Technology (M.I.T.) not be used in advertising or publicity
+ pertaining to distribution of the software without specific, written
+ prior permission.
+ 
+ M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ M.I.T. BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ SOFTWARE.
+ 
+ */
+ 
+ #pragma once
+ 
+ #ifdef __cplusplus
+ extern "C" {
+ #endif
+ 
+ long icf_CheckAndAddAFSPorts(int portset);
+ 
+ #ifdef __cplusplus
+ }
+ #endif
+ 
+ #define AFS_PORTSET_CLIENT 1
+ #define AFS_PORTSET_SERVER 2
+ 
Index: openafs/src/WINNT/afsd/afskfw-int.h
diff -c openafs/src/WINNT/afsd/afskfw-int.h:1.2 openafs/src/WINNT/afsd/afskfw-int.h:1.3
*** openafs/src/WINNT/afsd/afskfw-int.h:1.2	Sun May 30 11:54:13 2004
--- openafs/src/WINNT/afsd/afskfw-int.h	Thu Jul 22 18:41:27 2004
***************
*** 247,251 ****
  int  KFW_AFS_klog(krb5_context, krb5_ccache, char*, char*, char*, int, char*);
  void KFW_import_ccache_data(void);
  BOOL MSLSA_IsKerberosLogon();
! char *afs_realm_of_cell(struct afsconf_cell *);
  #endif /* AFSKFW_INT_H */
--- 247,251 ----
  int  KFW_AFS_klog(krb5_context, krb5_ccache, char*, char*, char*, int, char*);
  void KFW_import_ccache_data(void);
  BOOL MSLSA_IsKerberosLogon();
! char *afs_realm_of_cell(krb5_context, struct afsconf_cell *);
  #endif /* AFSKFW_INT_H */
Index: openafs/src/WINNT/afsd/afskfw.c
diff -c openafs/src/WINNT/afsd/afskfw.c:1.6 openafs/src/WINNT/afsd/afskfw.c:1.8
*** openafs/src/WINNT/afsd/afskfw.c:1.6	Fri Jun 18 13:36:33 2004
--- openafs/src/WINNT/afsd/afskfw.c	Sun Jul 11 17:23:07 2004
***************
*** 1197,1219 ****
      if ( lifetime == 0 )
          lifetime = pLeash_get_default_lifetime();
  
!     code = KFW_kinit(ctx, cc, HWND_DESKTOP, 
!                       pname, 
!                       password,
!                       lifetime,
!                       pLeash_get_default_forwardable(),
!                       pLeash_get_default_proxiable(),
!                       pLeash_get_default_renewable() ? pLeash_get_default_renew_till() : 0,
!                       pLeash_get_default_noaddresses(),
!                       pLeash_get_default_publicip());
!     if ( IsDebuggerPresent() ) {
!         char message[256];
!         sprintf(message,"KFW_kinit() returns: %d\n",code);
!         OutputDebugString(message);
      }
-     if ( code ) goto cleanup;
-                    
-     KFW_AFS_update_princ_ccache_data(ctx, cc, FALSE);
  
      code = KFW_AFS_klog(ctx, cc, "afs", cell, realm, lifetime,smbname);
      if ( IsDebuggerPresent() ) {
--- 1197,1221 ----
      if ( lifetime == 0 )
          lifetime = pLeash_get_default_lifetime();
  
!     if ( password && password[0] ) {
!         code = KFW_kinit( ctx, cc, HWND_DESKTOP, 
!                           pname, 
!                           password,
!                           lifetime,
!                           pLeash_get_default_forwardable(),
!                           pLeash_get_default_proxiable(),
!                           pLeash_get_default_renewable() ? pLeash_get_default_renew_till() : 0,
!                           pLeash_get_default_noaddresses(),
!                           pLeash_get_default_publicip());
!         if ( IsDebuggerPresent() ) {
!             char message[256];
!             sprintf(message,"KFW_kinit() returns: %d\n",code);
!             OutputDebugString(message);
!         }
!         if ( code ) goto cleanup;
! 
!         KFW_AFS_update_princ_ccache_data(ctx, cc, FALSE);
      }
  
      code = KFW_AFS_klog(ctx, cc, "afs", cell, realm, lifetime,smbname);
      if ( IsDebuggerPresent() ) {
***************
*** 2716,2728 ****
          }
  
          if ( smbname ) {
!             strncpy(aclient.smbname, smbname, MAXRANDOMNAMELEN);
!             aclient.smbname[MAXRANDOMNAMELEN-1] = '\0';
          } else {
              aclient.smbname[0] = '\0';
          }
  
!         rc = ktc_SetToken(&aserver, &atoken, &aclient, 0);
          if (!rc)
              goto cleanup;   /* We have successfully inserted the token */
  
--- 2718,2730 ----
          }
  
          if ( smbname ) {
!             strncpy(aclient.smbname, smbname, sizeof(aclient.smbname));
!             aclient.smbname[sizeof(aclient.smbname)-1] = '\0';
          } else {
              aclient.smbname[0] = '\0';
          }
  
!         rc = ktc_SetToken(&aserver, &atoken, &aclient, (aclient.smbname[0]?AFS_SETTOK_LOGON:0));
          if (!rc)
              goto cleanup;   /* We have successfully inserted the token */
  
***************
*** 2834,2846 ****
      strcpy(aclient.cell, CellName);
  
      if ( smbname ) {
!         strncpy(aclient.smbname, smbname, MAXRANDOMNAMELEN);
!         aclient.smbname[MAXRANDOMNAMELEN-1] = '\0';
      } else {
          aclient.smbname[0] = '\0';
      }
  
!     if (rc = ktc_SetToken(&aserver, &atoken, &aclient, 0))
      {
          KFW_AFS_error(rc, "ktc_SetToken()");
          code = rc;
--- 2836,2848 ----
      strcpy(aclient.cell, CellName);
  
      if ( smbname ) {
!         strncpy(aclient.smbname, smbname, sizeof(aclient.smbname));
!         aclient.smbname[sizeof(aclient.smbname)-1] = '\0';
      } else {
          aclient.smbname[0] = '\0';
      }
  
!     if (rc = ktc_SetToken(&aserver, &atoken, &aclient, (aclient.smbname[0]?AFS_SETTOK_LOGON:0)))
      {
          KFW_AFS_error(rc, "ktc_SetToken()");
          code = rc;
Index: openafs/src/WINNT/afsd/afslogon.c
diff -c openafs/src/WINNT/afsd/afslogon.c:1.14 openafs/src/WINNT/afsd/afslogon.c:1.23
*** openafs/src/WINNT/afsd/afslogon.c:1.14	Thu May  6 16:46:31 2004
--- openafs/src/WINNT/afsd/afslogon.c	Mon Jul 26 19:14:42 2004
***************
*** 7,95 ****
   * directory or online at http://www.openafs.org/dl/license10.html
   */
  
! #include <afs/param.h>
! #include <afs/stds.h>
  
- #include <windows.h>
- #include <npapi.h>
  #include <winsock2.h>
! #include "afsd.h"
  #include <afs/pioctl_nt.h>
  #include <afs/kautils.h>
  #include "cm_config.h"
  #include "krb.h"
  
! #include <io.h>
! #include <sys/stat.h>
! #include <sys/types.h>
! #include <fcntl.h>
! 
! DWORD LogonOption,TraceOption;
  
  HANDLE hDLL;
  
  WSADATA WSAjunk;
! 
! #define REG_CLIENT_PARMS_KEY            "SYSTEM\\CurrentControlSet\\Services\\TransarcAFSDaemon\\Parameters"
! #define REG_CLIENT_PROVIDER_KEY			"SYSTEM\\CurrentControlSet\\Services\\TransarcAFSDaemon\\NetworkProvider"
! #define REG_CLIENT_RETRY_INTERVAL_PARM  "LoginRetryInterval"
! #define REG_CLIENT_FAIL_SILENTLY_PARM   "FailLoginsSilently"
! #define DEFAULT_RETRY_INTERVAL          30                        /* seconds*/
! #define DEFAULT_FAIL_SILENTLY           FALSE
! #define DEFAULT_SLEEP_INTERVAL          5                         /* seconds*/
! 
! #define ISLOGONINTEGRATED(v) ( ((v) & LOGON_OPTION_INTEGRATED)==LOGON_OPTION_INTEGRATED)
! #define ISHIGHSECURITY(v) ( ((v) & LOGON_OPTION_HIGHSECURITY)==LOGON_OPTION_HIGHSECURITY)
! 
! #define TRACE_OPTION_EVENT 1
! #define ISLOGONTRACE(v) ( ((v) & TRACE_OPTION_EVENT)==TRACE_OPTION_EVENT)
! 
! /* Structure def copied from DDK (NTDEF.H) */
! typedef struct UNICODE_STRING {
! 	USHORT Length;		/* number of bytes of Buffer actually used */
! 	USHORT MaximumLength;	/* sizeof buffer in bytes */
! 	WCHAR *Buffer;		/* 16 bit characters */
! } UNICODE_STRING;
! 
! /* Structure def copied from NP API documentation */
! typedef struct _MSV1_0_INTERACTIVE_LOGON {
! 	DWORD		MessageType;	/* Actually this is an enum; ignored */
! 	UNICODE_STRING	LogonDomainName;
! 	UNICODE_STRING	UserName;
! 	UNICODE_STRING	Password;
! } MSV1_0_INTERACTIVE_LOGON;
! 
! /*
!  * GetLogonScript
!  *
!  * We get a logon script pathname from the HKEY_LOCAL_MACHINE registry.
!  * I don't know what good this does; I just copied it from DFS.
!  *
!  * Returns NULL on failure.
!  */
! 
  
  void DebugEvent0(char *a) 
  {
  	HANDLE h; char *ptbuf[1];
  	if (!ISLOGONTRACE(TraceOption))
  		return;
! 	h = RegisterEventSource(NULL, AFS_DAEMON_EVENT_NAME);
  	ptbuf[0] = a;
  	ReportEvent(h, EVENTLOG_INFORMATION_TYPE, 0, 0, NULL, 1, 0, (const char **)ptbuf, NULL);
  	DeregisterEventSource(h);
  }
  
! #define MAXBUF_ 131
! void DebugEvent(char *a,char *b,...) 
  {
  	HANDLE h; char *ptbuf[1],buf[MAXBUF_+1];
  	va_list marker;
  	if (!ISLOGONTRACE(TraceOption))
  		return;
! 	h = RegisterEventSource(NULL, AFS_DAEMON_EVENT_NAME);
  	va_start(marker,b);
! 	_vsnprintf(buf,MAXBUF_,b,marker);
      buf[MAXBUF_] = '\0';
  	ptbuf[0] = buf;
  	ReportEvent(h, EVENTLOG_INFORMATION_TYPE, 0, 0, NULL, 1, 0, (const char **)ptbuf, NULL);\
--- 7,61 ----
   * directory or online at http://www.openafs.org/dl/license10.html
   */
  
! #include "afslogon.h"
! 
! #include <io.h>
! #include <sys/stat.h>
! #include <sys/types.h>
! #include <fcntl.h>
  
  #include <winsock2.h>
! 
! #include <afs/param.h>
! #include <afs/stds.h>
  #include <afs/pioctl_nt.h>
  #include <afs/kautils.h>
+ 
+ #include "afsd.h"
  #include "cm_config.h"
  #include "krb.h"
+ #include "afskfw.h"
  
! DWORD TraceOption = 0;
  
  HANDLE hDLL;
  
  WSADATA WSAjunk;
! #define AFS_LOGON_EVENT_NAME TEXT("AFS Logon")
  
  void DebugEvent0(char *a) 
  {
  	HANDLE h; char *ptbuf[1];
  	if (!ISLOGONTRACE(TraceOption))
  		return;
! 	h = RegisterEventSource(NULL, AFS_LOGON_EVENT_NAME);
  	ptbuf[0] = a;
  	ReportEvent(h, EVENTLOG_INFORMATION_TYPE, 0, 0, NULL, 1, 0, (const char **)ptbuf, NULL);
  	DeregisterEventSource(h);
  }
  
! #define MAXBUF_ 512
! void DebugEvent(char *b,...) 
  {
  	HANDLE h; char *ptbuf[1],buf[MAXBUF_+1];
  	va_list marker;
+ 
  	if (!ISLOGONTRACE(TraceOption))
  		return;
! 
! 	h = RegisterEventSource(NULL, AFS_LOGON_EVENT_NAME);
  	va_start(marker,b);
! 	StringCbVPrintf(buf, MAXBUF_+1,b,marker);
      buf[MAXBUF_] = '\0';
  	ptbuf[0] = buf;
  	ReportEvent(h, EVENTLOG_INFORMATION_TYPE, 0, 0, NULL, 1, 0, (const char **)ptbuf, NULL);\
***************
*** 107,172 ****
  	return pbuf;
  }
  
- WCHAR *GetLogonScript(CHAR *pname)
- {
- 	WCHAR *script,*buf;
- 	DWORD code;
- 	DWORD LSPtype, LSPsize;
- 	HKEY NPKey;
- 	WCHAR randomName[MAXRANDOMNAMELEN];
- 
- 	/*
- 	 * Get Network Provider key.
- 	 * Assume this works or we wouldn't be here.
- 	 */
- 	(void) RegOpenKeyEx(HKEY_LOCAL_MACHINE, REG_CLIENT_PROVIDER_KEY,
- 			    0, KEY_QUERY_VALUE, &NPKey);
- 
- 	/*
- 	 * Get Logon Script pathname length
- 	 */
- 
- 	code = RegQueryValueExW(NPKey, L"LogonScript", NULL,
- 				&LSPtype, NULL, &LSPsize);
- 
- 	if (code) {
- 		RegCloseKey (NPKey);
- 		return NULL;
- 	}
- 
- 	if (LSPtype != REG_SZ) {	/* Maybe handle REG_EXPAND_SZ? */
- 		RegCloseKey (NPKey);
- 		return NULL;
- 	}
- 
- 	buf=(WCHAR *)LocalAlloc(LMEM_FIXED,LSPsize);
- 	script=(WCHAR *)LocalAlloc(LMEM_FIXED,LSPsize+(MAXRANDOMNAMELEN)*sizeof(WCHAR));
- 	/*
- 	 * Explicitly call UNICODE version
- 	 * Assume it will succeed since it did before
- 	 */
- 	(void) RegQueryValueExW(NPKey, L"LogonScript", NULL,
- 				&LSPtype, (LPBYTE)buf, &LSPsize);
- 	MultiByteToWideChar(CP_ACP,0,pname,strlen(pname)+1,randomName,(strlen(pname)+1)*sizeof(WCHAR));
- 	swprintf(script,buf,randomName);
- 	LocalFree(buf);
- 
- #ifdef DEBUG_VERBOSE
-     {
-         HANDLE h; char *ptbuf[1],buf[132],tbuf[255];
- 		WideCharToMultiByte(CP_ACP,0,script,LSPsize,tbuf,255,NULL,NULL);
-         h = RegisterEventSource(NULL, AFS_DAEMON_EVENT_NAME);
-         sprintf(buf, "Script[%s,%d] Return Code[%x]",tbuf,LSPsize,code);
-         ptbuf[0] = buf;
-         ReportEvent(h, EVENTLOG_INFORMATION_TYPE, 0, 0, NULL, 1, 0, ptbuf, NULL);
-         DeregisterEventSource(h);
-     }
- #endif
- 
- 	RegCloseKey (NPKey);
- 	return script;
- }
- 
  BOOLEAN AFSWillAutoStart(void)
  {
  	SC_HANDLE scm;
--- 73,78 ----
***************
*** 178,184 ****
  	LONG status;
  
  	/* Open services manager */
! 	scm = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
  	if (!scm) return FALSE;
  
  	/* Open AFSD service */
--- 84,90 ----
  	LONG status;
  
  	/* Open services manager */
! 	scm = OpenSCManager(NULL, NULL, GENERIC_READ);
  	if (!scm) return FALSE;
  
  	/* Open AFSD service */
***************
*** 220,230 ****
  DWORD MapAuthError(DWORD code)
  {
  	switch (code) {
! 	case KTC_NOCM:
  	case KTC_NOCMRPC:
! 		return WN_NO_NETWORK;
! /*	case INTK_BADPW: return WN_BAD_PASSWORD;*/
! /*	case KERB_ERR_PRINCIPAL_UNKNOWN: return WN_BAD_USER;*/
  	default: return WN_SUCCESS;
  	}
  }
--- 126,140 ----
  DWORD MapAuthError(DWORD code)
  {
  	switch (code) {
! 		/* Unfortunately, returning WN_NO_NETWORK results in the MPR abandoning
! 		 * logon scripts for all credential managers, although they will still
! 		 * receive logon notifications.  Since we don't want this, we return
! 		 * WN_SUCCESS.  This is highly undesirable, but we also don't want to
! 		 * break other network providers.
! 		 */
! /*	case KTC_NOCM:
  	case KTC_NOCMRPC:
! 		return WN_NO_NETWORK; */
  	default: return WN_SUCCESS;
  	}
  }
***************
*** 257,294 ****
  		case WNNC_NET_TYPE:
  			/* Don't have our own type; use somebody else's. */
  			return WNNC_NET_SUN_PC_NFS;
  		default:
  			return 0;
  	}
  }
  
- static void GetLoginBehavior(int *pRetryInterval, BOOLEAN *pFailSilently)
- {
-     long result;
-     HKEY hKey;
-     DWORD dummyLen;
-                 
- 	result = RegOpenKeyEx(HKEY_LOCAL_MACHINE, REG_CLIENT_PARMS_KEY, 0, KEY_QUERY_VALUE, &hKey);
-     if (result != ERROR_SUCCESS) {
-         *pRetryInterval = DEFAULT_RETRY_INTERVAL;
-         *pFailSilently = DEFAULT_FAIL_SILENTLY;
-         return;
-     }
-         
-     result = RegQueryValueEx(hKey, REG_CLIENT_RETRY_INTERVAL_PARM, 0, 0, (BYTE *)pRetryInterval, &dummyLen);
-     if (result != ERROR_SUCCESS)
-         *pRetryInterval = DEFAULT_RETRY_INTERVAL;
-        	        
-     result = RegQueryValueEx(hKey, REG_CLIENT_FAIL_SILENTLY_PARM, 0, 0, (BYTE *)pFailSilently, &dummyLen);
-     if (result != ERROR_SUCCESS)
-         *pFailSilently = DEFAULT_FAIL_SILENTLY;
- 
-     /* Make sure this is really a bool value in the strict sense*/
-     *pFailSilently = !!*pFailSilently;
- 
-     RegCloseKey(hKey);
- }   
- 
  BOOL IsServiceRunning (void)
  {
      SERVICE_STATUS Status;
--- 167,182 ----
  		case WNNC_NET_TYPE:
  			/* Don't have our own type; use somebody else's. */
  			return WNNC_NET_SUN_PC_NFS;
+ 
+ 		case WNNC_START:
+ 			/* Say we are already started, even though we might wait after we receive NPLogonNotify */
+ 			return 1;
+ 
  		default:
  			return 0;
  	}
  }
  
  BOOL IsServiceRunning (void)
  {
      SERVICE_STATUS Status;
***************
*** 311,316 ****
--- 199,517 ----
      return (Status.dwCurrentState == SERVICE_RUNNING);
  }   
  
+ /* LOOKUPKEYCHAIN: macro to look up the value in the list of keys in order until it's found
+    v:variable to receive value (reference type)
+    t:type
+    d:default, in case the value isn't on any of the keys
+    n:name of value */
+ #define LOOKUPKEYCHAIN(v,t,d,n) \
+ 	do { \
+ 		rv = ~ERROR_SUCCESS; \
+ 		dwType = t; \
+ 		if(hkDom) { \
+ 			dwSize = sizeof(v); \
+ 			rv = RegQueryValueEx(hkDom, n, 0, &dwType, (LPBYTE) &(v), &dwSize); \
+ 			if(rv == ERROR_SUCCESS) DebugEvent(#v " found in hkDom with type [%d]", dwType); \
+ 		} \
+ 		if(hkDoms && (rv != ERROR_SUCCESS || dwType != t)) { \
+ 			dwSize = sizeof(v); \
+ 			rv = RegQueryValueEx(hkDoms, n, 0, &dwType, (LPBYTE) &(v), &dwSize); \
+ 			if(rv == ERROR_SUCCESS) DebugEvent(#v " found in hkDoms with type [%d]", dwType); \
+ 		} \
+ 		if(hkNp && (rv != ERROR_SUCCESS || dwType != t)) { \
+ 			dwSize = sizeof(v); \
+ 			rv = RegQueryValueEx(hkNp, n, 0, &dwType, (LPBYTE) &(v), &dwSize); \
+ 			if(rv == ERROR_SUCCESS) DebugEvent(#v " found in hkNp with type [%d]", dwType); \
+ 		} \
+ 		if(rv != ERROR_SUCCESS || dwType != t) { \
+ 			v = d; \
+ 			DebugEvent(#v " being set to default"); \
+ 		} \
+ 	} while(0)
+ 
+ /* Get domain specific configuration info.  We are returning void because if anything goes wrong
+    we just return defaults.
+  */
+ void GetDomainLogonOptions( PLUID lpLogonId, char * username, char * domain, LogonOptions_t *opt ) {
+ 	HKEY hkParm = NULL; /* Service parameter */
+ 	HKEY hkNp = NULL;   /* network provider key */
+ 	HKEY hkDoms = NULL; /* domains key */
+ 	HKEY hkDom = NULL;  /* DOMAINS/domain key */
+ 	HKEY hkTemp = NULL;
+ 	LONG rv;
+ 	DWORD dwSize;
+ 	DWORD dwType;
+ 	DWORD dwDummy;
+ 	char computerName[MAX_COMPUTERNAME_LENGTH + 1];
+ 	char *effDomain;
+ 
+ 	DebugEvent("In GetDomainLogonOptions for user [%s] in domain [%s]", username, domain);
+ 	/* If the domain is the same as the Netbios computer name, we use the LOCALHOST domain name*/
+ 	opt->flags = LOGON_FLAG_REMOTE;
+ 	if(domain) {
+ 		dwSize = MAX_COMPUTERNAME_LENGTH;
+ 		if(GetComputerName(computerName, &dwSize)) {
+ 			if(!stricmp(computerName, domain)) {
+ 				effDomain = "LOCALHOST";
+ 				opt->flags = LOGON_FLAG_LOCAL;
+ 			}
+ 			else
+ 				effDomain = domain;
+ 		}
+ 	} else
+ 		effDomain = NULL;
+ 
+ 	rv = RegOpenKeyEx( HKEY_LOCAL_MACHINE, REG_CLIENT_PARMS_KEY, 0, KEY_READ, &hkParm );
+ 	if(rv != ERROR_SUCCESS) {
+ 		hkParm = NULL;
+ 		DebugEvent("GetDomainLogonOption: Can't open parms key [%d]", rv);
+ 	}
+ 
+ 	rv = RegOpenKeyEx( HKEY_LOCAL_MACHINE, REG_CLIENT_PROVIDER_KEY, 0, KEY_READ, &hkNp );
+ 	if(rv != ERROR_SUCCESS) {
+ 		hkNp = NULL;
+ 		DebugEvent("GetDomainLogonOptions: Can't open NP key [%d]", rv);
+ 	}
+ 
+ 	if(hkNp) {
+ 		rv = RegOpenKeyEx( hkNp, REG_CLIENT_DOMAINS_SUBKEY, 0, KEY_READ, &hkDoms );
+ 		if( rv != ERROR_SUCCESS ) {
+ 			hkDoms = NULL;
+ 			DebugEvent("GetDomainLogonOptions: Can't open Domains key [%d]", rv);
+ 		}
+ 	}
+ 
+ 	if(hkDoms && effDomain) {
+ 		rv = RegOpenKeyEx( hkDoms, effDomain, 0, KEY_READ, &hkDom );
+ 		if( rv != ERROR_SUCCESS ) {
+ 			hkDom = NULL;
+ 			DebugEvent("GetDomainLogonOptions: Can't open domain key for [%s] [%d]", effDomain, rv);
+ 			/* If none of the domains match, we shouldn't use the domain key either */
+ 			RegCloseKey(hkDoms);
+ 			hkDoms = NULL;
+ 		}
+ 	} else
+ 		DebugEvent("Not opening domain key for [%s]", effDomain);
+ 
+ 	/* Each individual can either be specified on the domain key, the domains key or in the
+ 	   net provider key.  They fail over in that order.  If none is found, we just use the 
+ 	   defaults. */
+ 
+ 	/* LogonOption */
+ 	LOOKUPKEYCHAIN(opt->LogonOption, REG_DWORD, DEFAULT_LOGON_OPTION, REG_CLIENT_LOGON_OPTION_PARM);
+ 
+ 	/* FailLoginsSilently */
+ 	dwSize = sizeof(dwDummy);
+ 	rv = RegQueryValueEx(hkParm, REG_CLIENT_FAIL_SILENTLY_PARM, 0, &dwType, (LPBYTE) &dwDummy, &dwSize);
+ 	if(rv != ERROR_SUCCESS)
+ 		LOOKUPKEYCHAIN(dwDummy, REG_DWORD, DEFAULT_FAIL_SILENTLY, REG_CLIENT_FAIL_SILENTLY_PARM);
+     opt->failSilently = !!dwDummy;
+ 
+ 	/* Retry interval */
+ 	LOOKUPKEYCHAIN(opt->retryInterval, REG_DWORD, DEFAULT_RETRY_INTERVAL, REG_CLIENT_RETRY_INTERVAL_PARM);
+ 
+ 	/* Sleep interval */
+ 	LOOKUPKEYCHAIN(opt->sleepInterval, REG_DWORD, DEFAULT_SLEEP_INTERVAL, REG_CLIENT_SLEEP_INTERVAL_PARM);
+ 
+ 	opt->logonScript = NULL;
+ 	opt->smbName = NULL;
+ 
+ 	if(!ISLOGONINTEGRATED(opt->LogonOption)) {
+ 		goto cleanup; /* no need to lookup the logon script */
+ 	}
+ 
+ 	/* come up with SMB username */
+ 	if(ISHIGHSECURITY(opt->LogonOption)) {
+         opt->smbName = malloc( MAXRANDOMNAMELEN );
+ 		GenRandomName(opt->smbName);
+ 	} else {
+ 		/* username and domain for logon session is not necessarily the same as
+ 		   username and domain passed into network provider. */
+ 		PSECURITY_LOGON_SESSION_DATA plsd;
+ 		char lsaUsername[MAX_USERNAME_LENGTH];
+ 		char lsaDomain[MAX_DOMAIN_LENGTH];
+ 		size_t len, tlen;
+ 
+         LsaGetLogonSessionData(lpLogonId, &plsd);
+         
+ 		UnicodeStringToANSI(plsd->UserName, lsaUsername, MAX_USERNAME_LENGTH);
+ 		UnicodeStringToANSI(plsd->LogonDomain, lsaDomain, MAX_DOMAIN_LENGTH);
+ 
+ 		DebugEvent("PLSD username[%s] domain[%s]",lsaUsername,lsaDomain);
+ 
+ 		if(SUCCEEDED(StringCbLength(lsaUsername, MAX_USERNAME_LENGTH, &tlen)))
+ 			len = tlen;
+ 		else
+ 			goto bad_strings;
+ 
+ 		if(SUCCEEDED(StringCbLength(lsaDomain, MAX_DOMAIN_LENGTH, &tlen)))
+ 			len += tlen;
+ 		else
+ 			goto bad_strings;
+ 
+ 		len += 2;
+ 
+ 		opt->smbName = malloc(len);
+ 
+ 		StringCbCopy(opt->smbName, len, lsaDomain);
+ 		StringCbCat(opt->smbName, len, "\\");
+ 		StringCbCat(opt->smbName, len, lsaUsername);
+ 
+ 		strlwr(opt->smbName);
+ 
+ bad_strings:
+ 		LsaFreeReturnBuffer(plsd);
+ 	}
+ 
+ 	DebugEvent("Looking up logon script");
+ 	/* Logon script */
+ 	/* First find out where the key is */
+ 	hkTemp = NULL;
+ 	rv = ~ERROR_SUCCESS;
+ 	dwType = 0;
+ 	if(hkDom)
+ 	    rv = RegQueryValueExW(hkDom, REG_CLIENT_LOGON_SCRIPT_PARMW, 0, &dwType, NULL, &dwSize);
+ 	if(rv == ERROR_SUCCESS && (dwType == REG_SZ || dwType == REG_EXPAND_SZ)) {
+ 		hkTemp = hkDom;
+ 		DebugEvent("Located logon script in hkDom");
+ 	}
+ 	else if(hkDoms)
+ 	    rv = RegQueryValueExW(hkDoms, REG_CLIENT_LOGON_SCRIPT_PARMW, 0, &dwType, NULL, &dwSize);
+ 	if(rv == ERROR_SUCCESS && !hkTemp && (dwType == REG_SZ || dwType == REG_EXPAND_SZ)) {
+ 		hkTemp = hkDoms;
+ 		DebugEvent("Located logon script in hkDoms");
+ 	}
+ 	/* Note that the LogonScript in the NP key is only used if we are doing high security. */
+ 	else if(hkNp && ISHIGHSECURITY(opt->LogonOption))
+ 	    rv = RegQueryValueExW(hkNp, REG_CLIENT_LOGON_SCRIPT_PARMW, 0, &dwType, NULL, &dwSize);
+ 	if(rv == ERROR_SUCCESS && !hkTemp && (dwType == REG_SZ || dwType == REG_EXPAND_SZ)) {
+ 		hkTemp = hkNp;
+ 		DebugEvent("Located logon script in hkNp");
+ 	}
+ 
+ 	if(hkTemp) {
+ 		WCHAR *regscript	= NULL;
+ 		WCHAR *regexscript	= NULL;
+ 		WCHAR *regexuscript	= NULL;
+ 		WCHAR *wuname		= NULL;
+ 		HRESULT hr;
+ 
+ 		size_t len;
+ 		
+ 		StringCbLength(opt->smbName, MAX_USERNAME_LENGTH, &len);
+ 		len ++;
+ 
+ 		wuname = malloc(len * sizeof(WCHAR));
+ 		MultiByteToWideChar(CP_ACP,0,opt->smbName,-1,wuname,len*sizeof(WCHAR));
+ 
+ 		DebugEvent("Username is set for [%S]", wuname);
+ 
+ 		/* dwSize still has the size of the required buffer in bytes. */
+         regscript = malloc(dwSize);
+ 		rv = RegQueryValueExW(hkTemp, REG_CLIENT_LOGON_SCRIPT_PARMW, 0, &dwType, (LPBYTE) regscript, &dwSize);
+ 		if(rv != ERROR_SUCCESS) {/* what the ..? */
+ 			DebugEvent("Can't look up logon script [%d]",rv);
+ 			goto doneLogonScript;
+ 		}
+ 		
+ 		DebugEvent("Found logon script [%S]", regscript);
+ 
+ 		if(dwType == REG_EXPAND_SZ) {
+ 			DWORD dwReq;
+ 
+ 	   		dwSize += MAX_PATH * sizeof(WCHAR);  /* make room for environment expansion. */
+ 			regexscript = malloc(dwSize);
+ 			dwReq = ExpandEnvironmentStringsW(regscript, regexscript, dwSize / sizeof(WCHAR));
+ 			free(regscript);
+ 			regscript = regexscript;
+ 			regexscript = NULL;
+ 			if(dwReq > (dwSize / sizeof(WCHAR))) {
+ 				DebugEvent("Overflow while expanding environment strings.");
+ 				goto doneLogonScript;
+ 			}
+ 		}
+ 
+ 		DebugEvent("After expanding env strings [%S]", regscript);
+ 
+ 		if(wcsstr(regscript, L"%s")) {
+ 	        dwSize += len * sizeof(WCHAR); /* make room for username expansion */
+ 			regexuscript = (WCHAR *) LocalAlloc(LMEM_FIXED, dwSize);
+ 			hr = StringCbPrintfW(regexuscript, dwSize, regscript, wuname);
+ 		} else {
+ 			regexuscript = (WCHAR *) LocalAlloc(LMEM_FIXED, dwSize);
+ 			hr = StringCbCopyW(regexuscript, dwSize, regscript);
+ 		}
+ 
+ 		DebugEvent("After expanding username [%S]", regexuscript);
+ 
+ 		if(hr == S_OK)
+ 			opt->logonScript = regexuscript;
+ 		else
+ 			LocalFree(regexuscript);
+ 
+ doneLogonScript:
+ 		if(wuname) free(wuname);
+ 		if(regscript) free(regscript);
+ 		if(regexscript) free(regexscript);
+ 	}
+ 
+ cleanup:
+ 	if(hkNp) RegCloseKey(hkNp);
+ 	if(hkDom) RegCloseKey(hkDom);
+ 	if(hkDoms) RegCloseKey(hkDoms);
+ 	if(hkParm) RegCloseKey(hkParm);
+ }
+ 
+ #undef LOOKUPKEYCHAIN
+ 
+ /* Try to find out which cell the given path is in.  We must retain
+    the contents of *cell in case of failure. *cell is assumed to be
+    at least cellLen chars */
+ DWORD GetFileCellName(char * path, char * cell, size_t cellLen) {
+ 	struct ViceIoctl blob;
+ 	char tcell[MAX_PATH];
+ 	DWORD code;
+ 
+ 	blob.in_size = 0;
+ 	blob.out_size = MAX_PATH;
+ 	blob.out = tcell;
+ 
+ 	code = pioctl(path, VIOC_FILE_CELL_NAME, &blob, 1);
+ 
+ 	if(!code) {
+ 		strncpy(cell, tcell, cellLen);
+ 		cell[cellLen - 1] = '\0';
+ 	}
+ 	return code;
+ }
+ 
+ 
+ static BOOL
+ WINAPI
+ UnicodeStringToANSI(UNICODE_STRING uInputString, LPSTR lpszOutputString, int nOutStringLen)
+ {
+     CPINFO CodePageInfo;
+ 
+     GetCPInfo(CP_ACP, &CodePageInfo);
+ 
+     if (CodePageInfo.MaxCharSize > 1)
+         // Only supporting non-Unicode strings
+         return FALSE;
+     
+     if (uInputString.Buffer && ((LPBYTE) uInputString.Buffer)[1] == '\0')
+     {
+         // Looks like unicode, better translate it
+         // UNICODE_STRING specifies the length of the buffer string in Bytes not WCHARS
+         WideCharToMultiByte(CP_ACP, 0, (LPCWSTR) uInputString.Buffer, uInputString.Length/2,
+                             lpszOutputString, nOutStringLen-1, NULL, NULL);
+         lpszOutputString[min(uInputString.Length/2,nOutStringLen-1)] = '\0';
+         return TRUE;
+     }
+ 	else
+ 		lpszOutputString[0] = '\0';
+     return FALSE;
+ }  // UnicodeStringToANSI
+ 
  DWORD APIENTRY NPLogonNotify(
  	PLUID lpLogonId,
  	LPCWSTR lpAuthentInfoType,
***************
*** 321,357 ****
  	LPVOID StationHandle,
  	LPWSTR *lpLogonScript)
  {
! 	char uname[256]="";
! 	char *ctemp;
! 	char password[256]="";
  	char cell[256]="<non-integrated logon>";
  	MSV1_0_INTERACTIVE_LOGON *IL;
  	DWORD code;
  	int pw_exp;
  	char *reason;
  	BOOLEAN interactive;
  	BOOLEAN flag;
  	DWORD LSPtype, LSPsize;
  	HKEY NPKey;
  	HWND hwndOwner = (HWND)StationHandle;
!     BOOLEAN failSilently;
!     int retryInterval;
!     int sleepInterval = DEFAULT_SLEEP_INTERVAL;        /* seconds        */
!     BOOLEAN afsWillAutoStart;
! 	CHAR RandomName[MAXRANDOMNAMELEN];
      BOOLEAN uppercased_name = TRUE;
  
      /* Initialize Logon Script to none */
  	*lpLogonScript=NULL;
!         
  	IL = (MSV1_0_INTERACTIVE_LOGON *) lpAuthentInfo;
  
  	/* Are we interactive? */
  	interactive = (wcscmp(lpStationName, L"WinSta0") == 0);
  
  	/* Convert from Unicode to ANSI */
! 	wcstombs(uname, IL->UserName.Buffer, 256);
! 	wcstombs(password, IL->Password.Buffer, 256);
  
  	/* Make sure AD-DOMANS sent from login that is sent to us is striped */
      ctemp = strchr(uname, '@');
--- 522,573 ----
  	LPVOID StationHandle,
  	LPWSTR *lpLogonScript)
  {
! 	char uname[MAX_USERNAME_LENGTH]="";
! 	char password[MAX_PASSWORD_LENGTH]="";
! 	char logonDomain[MAX_DOMAIN_LENGTH]="";
  	char cell[256]="<non-integrated logon>";
+ 	char homePath[MAX_PATH]="";
+ 
  	MSV1_0_INTERACTIVE_LOGON *IL;
+ 
  	DWORD code;
+ 
  	int pw_exp;
  	char *reason;
+ 	char *ctemp;
+ 
  	BOOLEAN interactive;
  	BOOLEAN flag;
  	DWORD LSPtype, LSPsize;
  	HKEY NPKey;
+ 
  	HWND hwndOwner = (HWND)StationHandle;
! 
! 	BOOLEAN afsWillAutoStart;
! 
      BOOLEAN uppercased_name = TRUE;
  
+ 	LogonOptions_t opt; /* domain specific logon options */
+ 	int retryInterval;
+ 	int sleepInterval;
+ 
      /* Initialize Logon Script to none */
  	*lpLogonScript=NULL;
!     
! 	/* TODO: We should check the value of lpAuthentInfoType before assuming that it is
! 	         MSV1_0_INTERACTIVE_LOGON though for our purposes KERB_INTERACTIVE_LOGON is
! 			 co-incidentally equivalent. */
  	IL = (MSV1_0_INTERACTIVE_LOGON *) lpAuthentInfo;
  
  	/* Are we interactive? */
  	interactive = (wcscmp(lpStationName, L"WinSta0") == 0);
  
  	/* Convert from Unicode to ANSI */
! 
! 	/*TODO: Use SecureZeroMemory to erase passwords */
! 	UnicodeStringToANSI(IL->UserName, uname, MAX_USERNAME_LENGTH);
! 	UnicodeStringToANSI(IL->Password, password, MAX_PASSWORD_LENGTH);
! 	UnicodeStringToANSI(IL->LogonDomainName, logonDomain, MAX_DOMAIN_LENGTH);
  
  	/* Make sure AD-DOMANS sent from login that is sent to us is striped */
      ctemp = strchr(uname, '@');
***************
*** 368,440 ****
  	(void) RegOpenKeyEx(HKEY_LOCAL_MACHINE, REG_CLIENT_PARMS_KEY,
                          0, KEY_QUERY_VALUE, &NPKey);
  	LSPsize=sizeof(TraceOption);
! 	RegQueryValueEx(NPKey, "TraceOption", NULL,
                       &LSPtype, (LPBYTE)&TraceOption, &LSPsize);
!     RegCloseKey (NPKey);
! 	
  	/*
! 	 * Get Logon OPTIONS
  	 */
  
! 	(void) RegOpenKeyEx(HKEY_LOCAL_MACHINE, REG_CLIENT_PROVIDER_KEY,
!                          0, KEY_QUERY_VALUE, &NPKey);
! 
! 	LSPsize=sizeof(LogonOption);
! 	code = RegQueryValueEx(NPKey, "LogonOptions", NULL,
!                             &LSPtype, (LPBYTE)&LogonOption, &LSPsize);
  
! 	RegCloseKey (NPKey);
! 	if ((code!=0) || (LSPtype!=REG_DWORD))
! 		LogonOption=LOGON_OPTION_INTEGRATED;	/*default to integrated logon only*/
  
  	afsWillAutoStart = AFSWillAutoStart();
!         
! 	DebugEvent("AFS AfsLogon - NPLogonNotify","LogonOption[%x], Service AutoStart[%d]",
!                 LogonOption,afsWillAutoStart);
      
-     /* Get local machine specified login behavior (or defaults) */
-     GetLoginBehavior(&retryInterval, &failSilently);
-         
      /* Check for zero length password if integrated logon*/
! 	if ( ISLOGONINTEGRATED(LogonOption) )  {
          if ( password[0] == 0 ) {
              code = GT_PW_NULL;
              reason = "zero length password is illegal";
              code=0;
          }
  
!         /* Get cell name if doing integrated logon */
  		code = cm_GetRootCellName(cell);
  		if (code < 0) { 
  			code = KTC_NOCELL;
  			reason = "unknown cell";
  			code=0;
! 		}
  
!         /*only do if high security option is on*/
!         if (ISHIGHSECURITY(LogonOption))
!             *lpLogonScript = GetLogonScript(GenRandomName(RandomName));	
      }
  
      /* loop until AFS is started. */
      while (TRUE) {
!         code=0;
! 		
!         /* is service started yet?*/
!         DebugEvent("AFS AfsLogon - ka_UserAuthenticateGeneral2","Code[%x] uname[%s] Cell[%s]",
!                    code,uname,cell);
  
!         /* if Integrated Logon only */
!         if (ISLOGONINTEGRATED(LogonOption) && !ISHIGHSECURITY(LogonOption))
  		{			
!             if ( KFW_is_available() )
!                 code = KFW_AFS_get_cred(uname, cell, password, 0, uname, &reason);
!             else
                  code = ka_UserAuthenticateGeneral2(KA_USERAUTH_VERSION+KA_USERAUTH_AUTHENT_LOGON,
!                                                 uname, "", cell, password, uname, 0, &pw_exp, 0,
                                                  &reason);
! 			DebugEvent("AFS AfsLogon - (INTEGRATED only)ka_UserAuthenticateGeneral2","Code[%x]",
!                         code);
              if ( code && code != KTC_NOCM && code != KTC_NOCMRPC && uppercased_name ) {
                  for ( ctemp = uname; *ctemp ; ctemp++) {
                      *ctemp = tolower(*ctemp);
--- 584,672 ----
  	(void) RegOpenKeyEx(HKEY_LOCAL_MACHINE, REG_CLIENT_PARMS_KEY,
                          0, KEY_QUERY_VALUE, &NPKey);
  	LSPsize=sizeof(TraceOption);
! 	RegQueryValueEx(NPKey, REG_CLIENT_TRACE_OPTION_PARM, NULL,
                       &LSPtype, (LPBYTE)&TraceOption, &LSPsize);
! 
! 	RegCloseKey (NPKey);
! 
  	/*
! 	 * Get Logon options
  	 */
  
! 	GetDomainLogonOptions( lpLogonId, uname, logonDomain, &opt );
! 	retryInterval = opt.retryInterval;
! 	sleepInterval = opt.sleepInterval;
! 	*lpLogonScript = opt.logonScript;
  
! 	DebugEvent("Got logon script: %S",opt.logonScript);
  
  	afsWillAutoStart = AFSWillAutoStart();
! 
! 	DebugEvent("LogonOption[%x], Service AutoStart[%d]",
!                 opt.LogonOption,afsWillAutoStart);
      
      /* Check for zero length password if integrated logon*/
! 	if ( ISLOGONINTEGRATED(opt.LogonOption) )  {
          if ( password[0] == 0 ) {
+             DebugEvent("Password is the empty string");
              code = GT_PW_NULL;
              reason = "zero length password is illegal";
              code=0;
          }
  
!         /* Get cell name if doing integrated logon.  
! 		   We might overwrite this if we are logging into an AD realm and we find out that
! 		   the user's home dir is in some other cell. */
!         DebugEvent("About to call cm_GetRootCellName(%s)",cell);
  		code = cm_GetRootCellName(cell);
  		if (code < 0) { 
+             DebugEvent("Unable to obtain Root Cell");
  			code = KTC_NOCELL;
  			reason = "unknown cell";
  			code=0;
! 		} else {
!             DebugEvent("Cell is %s",cell);
!         }
  
! 		/* We get the user's home directory path, if applicable, though we can't lookup the
! 		   cell right away because the client service may not have started yet. This call
! 		   also sets the AD_REALM flag in opt.flags if applicable. */
! 		if(ISREMOTE(opt.flags)) {
!             DebugEvent("Is Remote");
! 			GetAdHomePath(homePath,MAX_PATH,lpLogonId,&opt);
!         }
      }
  
      /* loop until AFS is started. */
      while (TRUE) {
!         DebugEvent("while(TRUE) LogonOption[%x], Service AutoStart[%d]",
!                     opt.LogonOption,afsWillAutoStart);
  
!         if(ISADREALM(opt.flags)) {
! 			code = GetFileCellName(homePath,cell,256);
! 			if(!code) {
! 				DebugEvent("profile path [%s] is in cell [%s]",homePath,cell);
! 			}
! 			/* Don't bail out if GetFileCellName failed.
! 			 * The home dir may not be in AFS after all. 
! 			 */
! 		} else
! 	        code=0;
! 		
!         /* if Integrated Logon  */
!         if (ISLOGONINTEGRATED(opt.LogonOption))
  		{			
! 			if ( KFW_is_available() ) {
!                 code = KFW_AFS_get_cred(uname, cell, password, 0, opt.smbName, &reason);
! 				DebugEvent("KFW_AFS_get_cred  uname=[%s] smbname=[%s] cell=[%s] code=[%d]",uname,opt.smbName,cell,code);
! 			}
! 			else {
                  code = ka_UserAuthenticateGeneral2(KA_USERAUTH_VERSION+KA_USERAUTH_AUTHENT_LOGON,
!                                                 uname, "", cell, password, opt.smbName, 0, &pw_exp, 0,
                                                  &reason);
! 				DebugEvent("AFS AfsLogon - (INTEGRATED only)ka_UserAuthenticateGeneral2","Code[%x]",
! 							code);
! 			}
              if ( code && code != KTC_NOCM && code != KTC_NOCMRPC && uppercased_name ) {
                  for ( ctemp = uname; *ctemp ; ctemp++) {
                      *ctemp = tolower(*ctemp);
***************
*** 442,468 ****
                  uppercased_name = FALSE;
                  continue;
              }
! 		} 
!         /* if Integrated Logon and High Security pass random generated name*/
!         else if (ISLOGONINTEGRATED(LogonOption) && ISHIGHSECURITY(LogonOption))
! 		{
!             if ( KFW_is_available() )
!                 code = KFW_AFS_get_cred(uname, cell, password, 0, RandomName, &reason);
!             else
!                 code = ka_UserAuthenticateGeneral2(KA_USERAUTH_VERSION+KA_USERAUTH_AUTHENT_LOGON,
!                                                 uname, "", cell, password,RandomName, 0, &pw_exp, 0,
!                                                 &reason);
! 			DebugEvent("AFS AfsLogon - (Both)ka_UserAuthenticateGeneral2","Code[%x] RandomName[%s]",
!                        code, RandomName);
! 
!             if ( code && code != KTC_NOCM && code != KTC_NOCMRPC && uppercased_name ) {
!                 for ( ctemp = uname; *ctemp ; ctemp++) {
!                     *ctemp = tolower(*ctemp);
!                 }
!                 uppercased_name = FALSE;
!                 continue;
!             }
! 		} else {  
              /*JUST check to see if its running*/
  		    if (IsServiceRunning())
                  break;
--- 674,681 ----
                  uppercased_name = FALSE;
                  continue;
              }
! 		}
! 		else {  
              /*JUST check to see if its running*/
  		    if (IsServiceRunning())
                  break;
***************
*** 471,476 ****
--- 684,693 ----
                  break;
  		}
  
+ 		/* is service started yet?*/
+         DebugEvent("AFS AfsLogon - ka_UserAuthenticateGeneral2","Code[%x] uname[%s] Cell[%s]",
+                    code,uname,cell);
+ 
  		/* If we've failed because the client isn't running yet and the
           * client is set to autostart (and therefore it makes sense for
           * us to wait for it to start) then sleep a while and try again. 
***************
*** 484,490 ****
           * user know we failed and give them a chance to try again. */
          if (retryInterval <= 0) {
              reason = "AFS not running";
!             if (!interactive || failSilently)
                  break;
  			flag = MessageBox(hwndOwner,
                                 "AFS is still starting.  Retry?",
--- 701,707 ----
           * user know we failed and give them a chance to try again. */
          if (retryInterval <= 0) {
              reason = "AFS not running";
!             if (!interactive || opt.failSilently)
                  break;
  			flag = MessageBox(hwndOwner,
                                 "AFS is still starting.  Retry?",
***************
*** 505,534 ****
          retryInterval -= sleepInterval;
      }
  
      /* remove any kerberos 5 tickets currently held by the SYSTEM account */
      if ( KFW_is_available() )
          KFW_AFS_destroy_tickets_for_cell(cell);
  
  	if (code) {
          char msg[128];
!         sprintf(msg, "Integrated login failed: %s", reason);
  
! 		if (interactive && !failSilently)
  			MessageBox(hwndOwner, msg, "AFS Logon", MB_OK);
! 		else {
!             HANDLE h;
!             char *ptbuf[1];
! 
!             h = RegisterEventSource(NULL, AFS_DAEMON_EVENT_NAME);
!             ptbuf[0] = msg;
!             ReportEvent(h, EVENTLOG_WARNING_TYPE, 0, 1008, NULL,
!                          1, 0, ptbuf, NULL);
!             DeregisterEventSource(h);
!         }
! 	    code = MapAuthError(code);
  		SetLastError(code);
  
! 		if (ISLOGONINTEGRATED(LogonOption) && (code!=0))
  		{
  			if (*lpLogonScript)
  				LocalFree(*lpLogonScript);
--- 722,752 ----
          retryInterval -= sleepInterval;
      }
  
+     DebugEvent("while loop exited");
      /* remove any kerberos 5 tickets currently held by the SYSTEM account */
      if ( KFW_is_available() )
          KFW_AFS_destroy_tickets_for_cell(cell);
  
  	if (code) {
          char msg[128];
!         HANDLE h;
!         char *ptbuf[1];
  
! 		StringCbPrintf(msg, sizeof(msg), "Integrated login failed: %s", reason);
! 
! 		if (ISLOGONINTEGRATED(opt.LogonOption) && interactive && !opt.failSilently)
  			MessageBox(hwndOwner, msg, "AFS Logon", MB_OK);
! 
!         h = RegisterEventSource(NULL, AFS_LOGON_EVENT_NAME);
!         ptbuf[0] = msg;
!         ReportEvent(h, EVENTLOG_WARNING_TYPE, 0, 1008, NULL,
!                      1, 0, ptbuf, NULL);
!         DeregisterEventSource(h);
! 	    
!         code = MapAuthError(code);
  		SetLastError(code);
  
! 		if (ISLOGONINTEGRATED(opt.LogonOption) && (code!=0))
  		{
  			if (*lpLogonScript)
  				LocalFree(*lpLogonScript);
***************
*** 539,544 ****
--- 757,764 ----
  		}
  	}
  
+ 	if(opt.smbName) free(opt.smbName);
+ 
  	DebugEvent("AFS AfsLogon - Exit","Return Code[%x]",code);
  	return code;
  }
***************
*** 556,558 ****
--- 776,878 ----
  	return 0;
  }
  
+ #include <userenv.h>
+ #include <Winwlx.h>
+ #include <afs/vice.h>
+ #include <afs/fs_utils.h>
+ 
+ BOOL IsPathInAfs(const CHAR *strPath)
+ {
+     char space[2048];
+     struct ViceIoctl blob;
+     int code;
+ 
+     blob.in_size = 0;
+     blob.out_size = 2048;
+     blob.out = space;
+ 
+     code = pioctl((LPTSTR)((LPCTSTR)strPath), VIOC_FILE_CELL_NAME, &blob, 1);
+     if (code)
+         return FALSE;
+     return TRUE;
+ }
+ 
+ #ifdef COMMENT
+ typedef struct _WLX_NOTIFICATION_INFO {  
+     ULONG Size;  
+     ULONG Flags;  
+     PWSTR UserName;  
+     PWSTR Domain;  
+     PWSTR WindowStation;  
+     HANDLE hToken;  
+     HDESK hDesktop;  
+     PFNMSGECALLBACK pStatusCallback;
+ } WLX_NOTIFICATION_INFO, *PWLX_NOTIFICATION_INFO;
+ #endif
+ 
+ VOID AFS_Startup_Event( PWLX_NOTIFICATION_INFO pInfo )
+ {
+ 	DWORD LSPtype, LSPsize;
+ 	HKEY NPKey;
+ 
+     (void) RegOpenKeyEx(HKEY_LOCAL_MACHINE, REG_CLIENT_PARMS_KEY,
+                         0, KEY_QUERY_VALUE, &NPKey);
+ 	LSPsize=sizeof(TraceOption);
+ 	RegQueryValueEx(NPKey, REG_CLIENT_TRACE_OPTION_PARM, NULL,
+                      &LSPtype, (LPBYTE)&TraceOption, &LSPsize);
+ 
+ 	RegCloseKey (NPKey);
+     DebugEvent0("AFS_Startup_Event");
+ }
+ 
+ VOID AFS_Logoff_Event( PWLX_NOTIFICATION_INFO pInfo )
+ {
+     DWORD code;
+     TCHAR profileDir[256] = TEXT("");
+     DWORD  len = 256;
+     PTOKEN_USER  tokenUser = NULL;
+     DWORD  retLen;
+     HANDLE hToken;
+ 
+     DebugEvent0("AFS_Logoff_Event - Starting");
+ 
+     if (!GetTokenInformation(pInfo->hToken, TokenUser, NULL, 0, &retLen))
+     {
+         if ( GetLastError() == ERROR_INSUFFICIENT_BUFFER ) {
+             tokenUser = (PTOKEN_USER) LocalAlloc(LPTR, retLen);
+ 
+             if (!GetTokenInformation(pInfo->hToken, TokenUser, tokenUser, retLen, &retLen))
+             {
+                 DebugEvent("GetTokenInformation failed: GLE = %lX", GetLastError());
+             }
+         }
+     }
+ 
+     /* We can't use pInfo->Domain for the domain since in the cross realm case 
+      * this is source domain and not the destination domain.
+      */
+     if (QueryAdHomePathFromSid( profileDir, sizeof(profileDir), tokenUser->User.Sid, pInfo->Domain)) {
+         WCHAR Domain[64]=L"";
+         GetLocalShortDomain(Domain);
+         if (QueryAdHomePathFromSid( profileDir, sizeof(profileDir), tokenUser->User.Sid, Domain))
+             GetUserProfileDirectory(pInfo->hToken, profileDir, &len);
+     }
+     
+     if (strlen(profileDir)) {
+         DebugEvent("Profile Directory: %s", profileDir);
+         if (!IsPathInAfs(profileDir)) {
+             if (code = ktc_ForgetAllTokens())
+                 DebugEvent("AFS_Logoff_Event - ForgetAllTokens failed [%lX]",code);
+             else
+                 DebugEvent0("AFS_Logoff_Event - ForgetAllTokens succeeded");
+         } else {
+             DebugEvent0("AFS_Logoff_Event - Tokens left in place; profile in AFS");
+         }
+     } else {
+         DebugEvent0("AFS_Logoff_Event - Unable to load profile");
+     }
+ 
+     if ( tokenUser )
+         LocalFree(tokenUser);
+ }   
+ 
Index: openafs/src/WINNT/afsd/afslogon.def
diff -c openafs/src/WINNT/afsd/afslogon.def:1.1 openafs/src/WINNT/afsd/afslogon.def:1.3
*** openafs/src/WINNT/afsd/afslogon.def:1.1	Fri Nov  3 21:14:12 2000
--- openafs/src/WINNT/afsd/afslogon.def	Thu Jul 22 05:23:52 2004
***************
*** 8,11 ****
--- 8,14 ----
      NPGetCaps
      NPLogonNotify
      NPPasswordChangeNotify
+     AFS_Startup_Event
+     AFS_Logoff_Event
+ 
  
Index: openafs/src/WINNT/afsd/afslogon.h
diff -c /dev/null openafs/src/WINNT/afsd/afslogon.h:1.4
*** /dev/null	Tue Jul 27 19:19:44 2004
--- openafs/src/WINNT/afsd/afslogon.h	Thu Jul 22 18:15:47 2004
***************
*** 0 ****
--- 1,127 ----
+ /*
+ 
+ Copyright 2004 by the Massachusetts Institute of Technology
+ 
+ All rights reserved.
+ 
+ Permission to use, copy, modify, and distribute this software and its
+ documentation for any purpose and without fee is hereby granted,
+ provided that the above copyright notice appear in all copies and that
+ both that copyright notice and this permission notice appear in
+ supporting documentation, and that the name of the Massachusetts
+ Institute of Technology (M.I.T.) not be used in advertising or publicity
+ pertaining to distribution of the software without specific, written
+ prior permission.
+ 
+ M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ M.I.T. BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ SOFTWARE.
+ 
+ */
+ 
+ /* We only support VC 1200 and above anyway */
+ #pragma once
+ 
+ #include <windows.h>
+ #include <npapi.h>
+ #include <ntsecapi.h>
+ #include <strsafe.h>
+ 
+ 
+ #define REG_CLIENT_PARMS_KEY            "SYSTEM\\CurrentControlSet\\Services\\TransarcAFSDaemon\\Parameters"
+ #define REG_CLIENT_PROVIDER_KEY			"SYSTEM\\CurrentControlSet\\Services\\TransarcAFSDaemon\\NetworkProvider"
+ #define REG_CLIENT_DOMAINS_SUBKEY		"Domain"
+ #define REG_CLIENT_RETRY_INTERVAL_PARM  "LoginRetryInterval"
+ #define REG_CLIENT_SLEEP_INTERVAL_PARM	"LoginSleepInterval"
+ #define REG_CLIENT_FAIL_SILENTLY_PARM   "FailLoginsSilently"
+ #define REG_CLIENT_TRACE_OPTION_PARM	"TraceOption"
+ #define REG_CLIENT_LOGON_OPTION_PARM	"LogonOptions"
+ #define REG_CLIENT_LOGON_SCRIPT_PARMW	L"LogonScript"
+ #define DEFAULT_RETRY_INTERVAL          30                        /* seconds*/
+ #define DEFAULT_FAIL_SILENTLY           FALSE
+ #define DEFAULT_SLEEP_INTERVAL          5                         /* seconds*/
+ #define DEFAULT_LOGON_OPTION			1
+ 
+ #define TRACE_OPTION_EVENT 1
+ 
+ #define ISLOGONTRACE(v) ( ((v) & TRACE_OPTION_EVENT)==TRACE_OPTION_EVENT)
+ 
+ #define ISLOGONINTEGRATED(v) ( ((v) & LOGON_OPTION_INTEGRATED)==LOGON_OPTION_INTEGRATED)
+ #define ISHIGHSECURITY(v) ( ((v) & LOGON_OPTION_HIGHSECURITY)==LOGON_OPTION_HIGHSECURITY)
+ 
+ #define ISREMOTE(v) ( ((v) & LOGON_FLAG_REMOTE)==LOGON_FLAG_REMOTE)
+ #define ISADREALM(v) ( ((v) & LOGON_FLAG_AD_REALM)==LOGON_FLAG_AD_REALM)
+ extern DWORD TraceOption;
+ 
+ #define LOGON_FLAG_LOCAL	0
+ #define LOGON_FLAG_REMOTE	1
+ #define LOGON_FLAG_AD_REALM 2
+ 
+ typedef struct LogonOptions_type {
+ 	DWORD	LogonOption;
+ 	BOOLEAN	failSilently;
+ 	int		retryInterval;
+ 	int		sleepInterval;
+ 	char *	smbName;
+ 	LPWSTR	logonScript;
+ 	DWORD	flags; /* LOGON_FLAG_* */
+ } LogonOptions_t;
+ 
+ /* */
+ #define MAX_USERNAME_LENGTH 256
+ #define MAX_PASSWORD_LENGTH 256
+ #define MAX_DOMAIN_LENGTH 256
+ 
+ BOOLEAN APIENTRY DllEntryPoint(HANDLE dll, DWORD reason, PVOID reserved);
+ 
+ DWORD APIENTRY NPGetCaps(DWORD index);
+ 
+ DWORD APIENTRY NPLogonNotify(
+ 	PLUID lpLogonId,
+ 	LPCWSTR lpAuthentInfoType,
+ 	LPVOID lpAuthentInfo,
+ 	LPCWSTR lpPreviousAuthentInfoType,
+ 	LPVOID lpPreviousAuthentInfo,
+ 	LPWSTR lpStationName,
+ 	LPVOID StationHandle,
+ 	LPWSTR *lpLogonScript);
+ 
+ DWORD APIENTRY NPPasswordChangeNotify(
+ 	LPCWSTR lpAuthentInfoType,
+ 	LPVOID lpAuthentInfo,
+ 	LPCWSTR lpPreviousAuthentInfoType,
+ 	LPVOID lpPreviousAuthentInfo,
+ 	LPWSTR lpStationName,
+ 	LPVOID StationHandle,
+ 	DWORD dwChangeInfo);
+ 
+ #ifdef __cplusplus
+ extern "C" {
+ #endif
+ 
+ void DebugEvent0(char *a);
+ void DebugEvent(char *b,...);
+ 
+ CHAR *GenRandomName(CHAR *pbuf);
+ 
+ BOOLEAN AFSWillAutoStart(void);
+ 
+ DWORD MapAuthError(DWORD code);
+ 
+ BOOL IsServiceRunning (void);
+ 
+ static BOOL WINAPI UnicodeStringToANSI(UNICODE_STRING uInputString, LPSTR lpszOutputString, int nOutStringLen);
+ 
+ void GetDomainLogonOptions( PLUID lpLogonId, char * username, char * domain, LogonOptions_t *opt );
+ DWORD GetFileCellName(char * path, char * cell, size_t cellLen);
+ DWORD GetAdHomePath(char * homePath, size_t homePathLen, PLUID lpLogonId, LogonOptions_t * opt);
+ DWORD QueryAdHomePathFromSid(char * homePath, size_t homePathLen, PSID psid, PWSTR domain);
+ BOOL GetLocalShortDomain(PWSTR Domain);
+ 
+ #ifdef __cplusplus
+ }
+ #endif
Index: openafs/src/WINNT/afsd/afsshare.c
diff -c openafs/src/WINNT/afsd/afsshare.c:1.2 openafs/src/WINNT/afsd/afsshare.c:1.5
*** openafs/src/WINNT/afsd/afsshare.c:1.2	Sat Nov  4 05:01:36 2000
--- openafs/src/WINNT/afsd/afsshare.c	Tue Jul 20 10:36:41 2004
***************
*** 13,30 ****
  #include <windows.h>
  #include <stdio.h>
  
  main(int argc, char **argv) {
      BOOL res;
      if (argc < 2 || argc > 3) {
! 	fprintf(stderr, "Incorrect arguments\n");
! 	exit(1);
      }
-     res = WritePrivateProfileString("AFS Submounts",
- 				    argv[1],
- 				    (argc == 3) ? argv[2] : NULL,
- 				    "afsdsbmt.ini");
-     if (res == FALSE)
- 	fprintf(stderr, "Failed, error code %d\n", GetLastError());
  
      return 0;
  }
--- 13,81 ----
  #include <windows.h>
  #include <stdio.h>
  
+ int
  main(int argc, char **argv) {
      BOOL res;
+     HKEY hkSubmounts;
+     HKEY hkParameters;
+     char mountRoot[64]="/afs";
+     char * mountstring;
+ 
      if (argc < 2 || argc > 3) {
!         fprintf(stderr, "afsshare.exe <submount> [<afs mount path>]\n");
!         exit(1);
      }
  
+     if (RegCreateKeyEx( HKEY_LOCAL_MACHINE,
+                         "SOFTWARE\\OpenAFS\\Client\\Submounts",
+                         0,
+                         NULL,
+                         REG_OPTION_NON_VOLATILE,
+                         KEY_READ|KEY_WRITE,
+                         NULL,
+                         &hkSubmounts,
+                         NULL) == ERROR_SUCCESS) 
+     {
+         if ( argc == 2 ) {
+             if (RegDeleteValue(hkSubmounts, argv[1])) {
+                 fprintf(stderr,"Submount Deletion failure for [%s]: %lX",
+                          argv[1], GetLastError());
+                 RegCloseKey(hkSubmounts);
+                 return 1;
+             }
+         } else {
+             if (RegCreateKeyEx( HKEY_LOCAL_MACHINE,
+                                 "SYSTEM\\CurrentControlSet\\Services\\TransarcAFSDaemon\\Parameters",
+                                 0,
+                                 NULL,
+                                 REG_OPTION_NON_VOLATILE,
+                                 KEY_READ,
+                                 NULL,
+                                 &hkParameters,
+                                 NULL) == ERROR_SUCCESS) 
+             {
+                 DWORD dwSize = sizeof(mountRoot);
+                 RegQueryValueEx (hkParameters, "MountRoot", NULL, NULL, (PBYTE)mountRoot, &dwSize);
+                 RegCloseKey(hkParameters);
+             }
+ 
+ 
+             if ( !strncmp(mountRoot, argv[2], strlen(mountRoot)) )
+                 mountstring = argv[2] + strlen(mountRoot);
+             else
+                 mountstring = argv[2];
+ 
+             if (RegSetValueEx(hkSubmounts, argv[1], 0, REG_SZ, mountstring, strlen(mountstring)+1)) {
+                 fprintf(stderr,"Submount Set failure for [%s]: %lX",
+                          argv[1], GetLastError());
+                 RegCloseKey(hkSubmounts);
+                 return 2;
+             }
+         }
+         RegCloseKey(hkSubmounts);
+     } else {
+         fprintf(stderr,"Submount access denied: %lX", GetLastError());
+         return 3;
+     }
      return 0;
  }
Index: openafs/src/WINNT/afsd/cm.h
diff -c openafs/src/WINNT/afsd/cm.h:1.7 openafs/src/WINNT/afsd/cm.h:1.9
*** openafs/src/WINNT/afsd/cm.h:1.7	Thu May  6 11:17:29 2004
--- openafs/src/WINNT/afsd/cm.h	Mon Jul 26 19:22:20 2004
***************
*** 219,225 ****
  #define CM_ERROR_EXISTS			(CM_ERROR_BASE+11)
  #define CM_ERROR_CROSSDEVLINK		(CM_ERROR_BASE+12)
  #define CM_ERROR_BADOP			(CM_ERROR_BASE+13)
! /* CM_ERROR_BADPASSWORD used to be here */
  #define CM_ERROR_NOTDIR			(CM_ERROR_BASE+15)
  #define CM_ERROR_ISDIR			(CM_ERROR_BASE+16)
  #define CM_ERROR_READONLY		(CM_ERROR_BASE+17)
--- 219,225 ----
  #define CM_ERROR_EXISTS			(CM_ERROR_BASE+11)
  #define CM_ERROR_CROSSDEVLINK		(CM_ERROR_BASE+12)
  #define CM_ERROR_BADOP			(CM_ERROR_BASE+13)
! #define CM_ERROR_BADPASSWORD    (CM_ERROR_BASE+14)
  #define CM_ERROR_NOTDIR			(CM_ERROR_BASE+15)
  #define CM_ERROR_ISDIR			(CM_ERROR_BASE+16)
  #define CM_ERROR_READONLY		(CM_ERROR_BASE+17)
***************
*** 246,249 ****
--- 246,252 ----
  #define CM_ERROR_RENAME_IDENTICAL	(CM_ERROR_BASE+39)
  #define CM_ERROR_ALLOFFLINE             (CM_ERROR_BASE+40)
  #define CM_ERROR_AMBIGUOUS_FILENAME (CM_ERROR_BASE+41)
+ #define CM_ERROR_BADLOGONTYPE	(CM_ERROR_BASE+42)
+ #define CM_ERROR_GSSCONTINUE    (CM_ERROR_BASE+43)
+ #define CM_ERROR_TIDIPC         (CM_ERROR_BASE+44)
  #endif /*  __CM_H_ENV__ */
Index: openafs/src/WINNT/afsd/cm_callback.c
diff -c openafs/src/WINNT/afsd/cm_callback.c:1.14 openafs/src/WINNT/afsd/cm_callback.c:1.15
*** openafs/src/WINNT/afsd/cm_callback.c:1.14	Mon Jun  7 02:22:57 2004
--- openafs/src/WINNT/afsd/cm_callback.c	Mon Jul 26 15:08:42 2004
***************
*** 600,606 ****
      // good shape and we simply return true, provided no change is detected.
    int fdc, fgc;
  
!     if (cm_freelanceEnabled && scp->fid.cell==0x1 && scp->fid.volume==AFS_FAKE_ROOT_VOL_ID) {	// if it's something on /afs
  	if (!(scp->fid.vnode==0x1 && scp->fid.unique==0x1))  	// if it's not root.afs
  	    return 1;
  	else {
--- 600,608 ----
      // good shape and we simply return true, provided no change is detected.
    int fdc, fgc;
  
!     if (cm_freelanceEnabled && 
!         scp->fid.cell==AFS_FAKE_ROOT_CELL_ID &&
!         scp->fid.volume==AFS_FAKE_ROOT_VOL_ID) {	// if it's something on /afs
  	if (!(scp->fid.vnode==0x1 && scp->fid.unique==0x1))  	// if it's not root.afs
  	    return 1;
  	else {
***************
*** 757,763 ****
  	// specially. We need to fetch the status by calling
  	// cm_MergeStatus and mark that cm_fakeDirCallback is 2
  	if (cm_freelanceEnabled &&
!         scp->fid.cell==0x1 &&
  		scp->fid.volume==AFS_FAKE_ROOT_VOL_ID &&
  		scp->fid.unique==0x1 &&
  		scp->fid.vnode==0x1) {
--- 759,765 ----
  	// specially. We need to fetch the status by calling
  	// cm_MergeStatus and mark that cm_fakeDirCallback is 2
  	if (cm_freelanceEnabled &&
!         scp->fid.cell==AFS_FAKE_ROOT_CELL_ID &&
  		scp->fid.volume==AFS_FAKE_ROOT_VOL_ID &&
  		scp->fid.unique==0x1 &&
  		scp->fid.vnode==0x1) {
Index: openafs/src/WINNT/afsd/cm_cell.c
diff -c openafs/src/WINNT/afsd/cm_cell.c:1.10 openafs/src/WINNT/afsd/cm_cell.c:1.12
*** openafs/src/WINNT/afsd/cm_cell.c:1.10	Sat Jun  5 02:02:39 2004
--- openafs/src/WINNT/afsd/cm_cell.c	Mon Jul 19 18:40:12 2004
***************
*** 68,73 ****
--- 68,76 ----
  	int ttl;
  	char fullname[200]="";
  
+ 	if (!strcmp(namep,SMB_IOCTL_FILENAME_NOSLASH))
+ 		return NULL;
+ 
  	lock_ObtainWrite(&cm_cellLock);
  	for (cp = cm_allCellsp; cp; cp=cp->nextp) {
  		if (strcmp(namep, cp->namep) == 0) {
***************
*** 85,92 ****
  	  ) {
          int dns_expired = 0;
  		if (!cp) {
!             cp = malloc(sizeof(*cp));
!             memset(cp, 0, sizeof(*cp));
          } 
          else {
              dns_expired = 1;
--- 88,95 ----
  	  ) {
          int dns_expired = 0;
  		if (!cp) {
!             cp = malloc(sizeof(cm_cell_t));
!             memset(cp, 0, sizeof(cm_cell_t));
          } 
          else {
              dns_expired = 1;
***************
*** 109,114 ****
--- 112,118 ----
                      if (dns_expired) {
                          cp->flags |= CM_CELLFLAG_VLSERVER_INVALID;
                          cp = NULL;  /* set cp to NULL to indicate error */
+                         goto done;
                      } 
                  }
                  else {   /* got cell from DNS */
***************
*** 126,132 ****
  		}
  
  		/* randomise among those vlservers having the same rank*/ 
! 		cm_RandomizeServer(&cp->vlServersp);
  
  #ifdef AFS_AFSDB_ENV
          if (dns_expired) {
--- 130,136 ----
  		}
  
  		/* randomise among those vlservers having the same rank*/ 
!         cm_RandomizeServer(&cp->vlServersp);
  
  #ifdef AFS_AFSDB_ENV
          if (dns_expired) {
Index: openafs/src/WINNT/afsd/cm_config.c
diff -c openafs/src/WINNT/afsd/cm_config.c:1.16 openafs/src/WINNT/afsd/cm_config.c:1.20
*** openafs/src/WINNT/afsd/cm_config.c:1.16	Sat May 29 19:47:59 2004
--- openafs/src/WINNT/afsd/cm_config.c	Thu Jul 22 05:23:52 2004
***************
*** 23,28 ****
--- 23,29 ----
  #include <string.h>
  
  #include "cm_config.h"
+ #include <WINNT\afssw.h>
  #ifdef AFS_AFSDB_ENV
  #include "cm_dns.h"
  #include <afs/afsint.h>
***************
*** 30,38 ****
--- 31,42 ----
  
  char AFSConfigKeyName[] =
  	"SYSTEM\\CurrentControlSet\\Services\\TransarcAFSDaemon\\Parameters";
+ char AFSLocalMachineKeyName[] = "SOFTWARE\\OpenAFS\\Client";
  
  /* TODO: these should be pulled in from dirpath.h */
+ #if !defined(DJGPP) && !defined(AFS_WIN95_ENV)
  #define AFS_THISCELL "ThisCell"
+ #endif
  #define AFS_CELLSERVDB_UNIX "CellServDB"
  #define AFS_CELLSERVDB_NT "afsdcell.ini"
  #ifndef AFSDIR_CLIENT_ETC_DIRPATH
***************
*** 45,63 ****
  extern int errno;
  #endif /* DJGPP */
  #else
! #define AFS_CELLSERVDB AFS_CELLSERVDB_NT
  #endif /* DJGPP || WIN95 */
  
! #ifdef DEBUG
! DWORD TraceOption=1;
  
! #define TRACE_OPTION_EVENT 1
! #define ISLOGONTRACE(v) ( ((v) & TRACE_OPTION_EVENT)==TRACE_OPTION_EVENT)
  
  void DebugEvent0_local(char *a) 
  {
  	HANDLE h; char *ptbuf[1];
! 	if (!ISLOGONTRACE(TraceOption))
  		return;
  	h = RegisterEventSource(NULL, a);
  	ptbuf[0] = a;
--- 49,68 ----
  extern int errno;
  #endif /* DJGPP */
  #else
! #define AFS_CELLSERVDB AFS_CELLSERVDB_UNIX
  #endif /* DJGPP || WIN95 */
  
! static DWORD TraceOption = 0;
! 
! /* This really needs to be initialized at DLL Init */
! #define TRACE_OPTION_EVENT 4
  
! #define ISCONFIGTRACE(v) ( ((v) & TRACE_OPTION_EVENT)==TRACE_OPTION_EVENT)
  
  void DebugEvent0_local(char *a) 
  {
  	HANDLE h; char *ptbuf[1];
! 	if (!ISCONFIGTRACE(TraceOption))
  		return;
  	h = RegisterEventSource(NULL, a);
  	ptbuf[0] = a;
***************
*** 71,77 ****
  {
  	HANDLE h; char *ptbuf[1],buf[MAXBUF_+1];
  	va_list marker;
! 	if (!ISLOGONTRACE(TraceOption))
  		return;
  	h = RegisterEventSource(NULL, a);
  	va_start(marker,b);
--- 76,82 ----
  {
  	HANDLE h; char *ptbuf[1],buf[MAXBUF_+1];
  	va_list marker;
! 	if (!ISCONFIGTRACE(TraceOption))
  		return;
  	h = RegisterEventSource(NULL, a);
  	va_start(marker,b);
***************
*** 81,87 ****
  	DeregisterEventSource(h);
  	va_end(marker);
  }
! #endif /* DEBUG */
  
  static long cm_ParsePair(char *lineBufferp, char *leftp, char *rightp)
  {
--- 86,130 ----
  	DeregisterEventSource(h);
  	va_end(marker);
  }
! 
! #define REG_CLIENT_PARMS_KEY            TEXT("SYSTEM\\CurrentControlSet\\Services\\TransarcAFSDaemon\\Parameters")
! #define REG_CLIENT_TRACE_OPTION_PARM	TEXT("TraceOption")
! 
! #ifdef COMMENT
! BOOL WINAPI DllMain (HANDLE hModule, DWORD fdwReason, LPVOID lpReserved)
! {
!     switch (fdwReason)
!     {
!     case DLL_PROCESS_ATTACH: {
!         DWORD LSPtype, LSPsize;
!         HKEY NPKey;
! 
!         (void) RegOpenKeyEx(HKEY_LOCAL_MACHINE, REG_CLIENT_PARMS_KEY,
!                              0, KEY_QUERY_VALUE, &NPKey);
!         LSPsize=sizeof(TraceOption);
!         RegQueryValueEx(NPKey, REG_CLIENT_TRACE_OPTION_PARM, NULL,
!                         &LSPtype, (LPBYTE)&TraceOption, &LSPsize);
! 
!         RegCloseKey (NPKey);
!         break;
!     }
! 
!     case DLL_THREAD_ATTACH:
!         break;
! 
!     case DLL_THREAD_DETACH:
!         break;
! 
!     case DLL_PROCESS_DETACH:
!         break;
! 
!     default:
!         return FALSE;
!     }
! 
!     return TRUE;   // successful DLL_PROCESS_ATTACH
! }
! #endif /* COMMENT */
  
  static long cm_ParsePair(char *lineBufferp, char *leftp, char *rightp)
  {
***************
*** 149,186 ****
  	cm_configProc_t *procp, void *rockp)
  {
  	char wdir[257];
!     int tlen;
!     FILE *tfilep, *bestp, *tempp;
      char *tp;
      char lineBuffer[257];
      struct hostent *thp;
      char *valuep;
      struct sockaddr_in vlSockAddr;
      int inRightCell;
!     int foundCell;
      long code;
  	int tracking = 1, partial = 0;
  #if defined(DJGPP) || defined(AFS_WIN95_ENV)
      char *afsconf_path;
  #endif
  
! 	foundCell = 0;
! 
! #if !defined(DJGPP)
! 	code = GetWindowsDirectory(wdir, sizeof(wdir));
!     if (code == 0 || code > sizeof(wdir))
!         return -1;
! 
! 	/* add trailing backslash, if required */
!     tlen = strlen(wdir);
!     if (wdir[tlen-1] != '\\') strcat(wdir, "\\");
! #else
!     strcpy(wdir, cm_confDir);
!     strcat(wdir,"/");
! #endif /* !DJGPP */
!         
!     strcat(wdir, AFS_CELLSERVDB);
! 
      tfilep = fopen(wdir, "r");
  
  #if defined(DJGPP) || defined(AFS_WIN95_ENV)
--- 192,212 ----
  	cm_configProc_t *procp, void *rockp)
  {
  	char wdir[257];
!     FILE *tfilep = NULL, *bestp, *tempp;
      char *tp;
      char lineBuffer[257];
      struct hostent *thp;
      char *valuep;
      struct sockaddr_in vlSockAddr;
      int inRightCell;
!     int foundCell = 0;
      long code;
  	int tracking = 1, partial = 0;
  #if defined(DJGPP) || defined(AFS_WIN95_ENV)
      char *afsconf_path;
  #endif
  
!     cm_GetCellServDB(wdir);
      tfilep = fopen(wdir, "r");
  
  #if defined(DJGPP) || defined(AFS_WIN95_ENV)
***************
*** 195,201 ****
          else
              strcpy(wdir, afsconf_path);
          strcat(wdir, "/");
!         strcat(wdir, AFS_CELLSERVDB_UNIX);
          /*fprintf(stderr, "opening cellservdb file %s\n", wdir);*/
          tfilep = fopen(wdir, "r");
          if (!tfilep) return -2;
--- 221,227 ----
          else
              strcpy(wdir, afsconf_path);
          strcat(wdir, "/");
!         strcat(wdir, AFS_CELLSERVDB);
          /*fprintf(stderr, "opening cellservdb file %s\n", wdir);*/
          tfilep = fopen(wdir, "r");
          if (!tfilep) return -2;
***************
*** 397,402 ****
--- 423,466 ----
  }
  
  #if !defined(DJGPP) && !defined(AFS_WIN95_ENV)
+ /* look up the CellServDBDir's name in the Registry 
+  * or use the Client Dirpath value to produce a CellServDB 
+  * filename
+  */
+ long cm_GetCellServDB(char *cellNamep)
+ {
+ #if !defined(DJGPP)
+ 	DWORD code, dummyLen;
+ 	HKEY parmKey;
+     int tlen;
+ 
+ 	code = RegOpenKeyEx(HKEY_LOCAL_MACHINE, AFSLocalMachineKeyName,
+ 				0, KEY_QUERY_VALUE, &parmKey);
+ 	if (code != ERROR_SUCCESS)
+         goto dirpath;
+ 
+ 	dummyLen = 256;
+ 	code = RegQueryValueEx(parmKey, "CellServDBDir", NULL, NULL,
+ 				cellNamep, &dummyLen);
+ 	RegCloseKey (parmKey);
+ 
+   dirpath:
+ 	if (code != ERROR_SUCCESS || cellNamep[0] == 0)
+         strcpy(cellNamep, AFSDIR_CLIENT_ETC_DIRPATH);
+ 
+     /* add trailing backslash, if required */
+     tlen = strlen(cellNamep);
+     if (cellNamep[tlen-1] != '\\') 
+         strcat(cellNamep, "\\");
+ #else
+     strcpy(cellNamep, cm_confDir);
+     strcat(cellNamep,"/");
+ #endif /* !DJGPP */
+         
+     strcat(cellNamep, AFS_CELLSERVDB);
+ 	return 0;
+ }
+ 
  /* look up the root cell's name in the Registry */
  long cm_GetRootCellName(char *cellNamep)
  {
***************
*** 458,471 ****
  cm_configFile_t *cm_CommonOpen(char *namep, char *rwp)
  {
  	char wdir[256];
-     long code;
      long tlen;
      FILE *tfilep;
  
  #if !defined(DJGPP) && !defined(AFS_WIN95_ENV)
! 	code = GetWindowsDirectory(wdir, sizeof(wdir));
!         if (code == 0 || code > sizeof(wdir)) 
!             return 0;
          
  	/* add trailing backslash, if required */
          tlen = strlen(wdir);
--- 522,532 ----
  cm_configFile_t *cm_CommonOpen(char *namep, char *rwp)
  {
  	char wdir[256];
      long tlen;
      FILE *tfilep;
  
  #if !defined(DJGPP) && !defined(AFS_WIN95_ENV)
!     strcpy(wdir, AFSDIR_CLIENT_ETC_DIRPATH);
          
  	/* add trailing backslash, if required */
          tlen = strlen(wdir);
***************
*** 635,709 ****
  	closeCode = fclose((FILE *)filep);
  
  #if !defined(DJGPP) && !defined(AFS_WIN95_ENV)
! 	code = GetWindowsDirectory(wdir, sizeof(wdir));
!         if (code == 0 || code > sizeof(wdir)) 
! 	    return closeCode;
          
  	/* add trailing backslash, if required */
!         tlen = strlen(wdir);
!         if (wdir[tlen-1] != '\\') strcat(wdir, "\\");
  #else
  #ifdef DJGPP
!         strcpy(wdir,cm_confDir);
  #else
!         afsconf_path = getenv("AFSCONF");
!         if (!afsconf_path)
!           strcpy(wdir, AFSDIR_CLIENT_ETC_DIRPATH);
!         else
!           strcpy(wdir, afsconf_path);
  #endif /* !DJGPP */
!         strcat(wdir,"/");
  #endif /* DJGPP || WIN95 */
  
!         strcpy(sdir, wdir);
  
  	if (closeCode != 0) {
  		/* something went wrong, preserve original database */
!                 strcat(wdir, "afsdcel2.ini");
!                 unlink(wdir);
!                 return closeCode;
!         }
  
!         strcat(wdir, AFS_CELLSERVDB);
!         strcat(sdir, "afsdcel2.ini");	/* new file */
!         
!         unlink(wdir);			/* delete old file */
!         
!         code = rename(sdir, wdir);	/* do the rename */
!         
!         if (code) 
! 	  code = errno;
!         
!         return code;
! }
  
  void cm_GetConfigDir(char *dir)
  {
  	char wdir[256];
-     int code;
      int tlen;
  #ifdef AFS_WIN95_ENV
      char *afsconf_path;
  #endif
  
  #if !defined(DJGPP) && !defined(AFS_WIN95_ENV)
! 	code = GetWindowsDirectory(wdir, sizeof(wdir));
!       if (code == 0 || code > sizeof(wdir)) wdir[0] = 0;
          
  	/* add trailing backslash, if required */
!         tlen = strlen(wdir);
!         if (wdir[tlen-1] != '\\') strcat(wdir, "\\");
  #else
  #ifdef DJGPP
!         strcpy(wdir,cm_confDir);
  #else
!         afsconf_path = getenv("AFSCONF");
!         if (!afsconf_path)
!           strcpy(wdir, AFSDIR_CLIENT_ETC_DIRPATH);
!         else
!           strcpy(wdir, afsconf_path);
  #endif /* !DJGPP */
!         strcat(wdir,"\\");
  #endif /* DJGPP || WIN95 */
!         strcpy(dir, wdir);
  }
--- 696,766 ----
  	closeCode = fclose((FILE *)filep);
  
  #if !defined(DJGPP) && !defined(AFS_WIN95_ENV)
!     strcpy(wdir, AFSDIR_CLIENT_ETC_DIRPATH);
          
  	/* add trailing backslash, if required */
!     tlen = strlen(wdir);
!     if (wdir[tlen-1] != '\\') strcat(wdir, "\\");
  #else
  #ifdef DJGPP
!     strcpy(wdir,cm_confDir);
  #else
!     afsconf_path = getenv("AFSCONF");
!     if (!afsconf_path)
!         strcpy(wdir, AFSDIR_CLIENT_ETC_DIRPATH);
!     else
!         strcpy(wdir, afsconf_path);
  #endif /* !DJGPP */
!     strcat(wdir,"/");
  #endif /* DJGPP || WIN95 */
  
!     strcpy(sdir, wdir);
  
  	if (closeCode != 0) {
  		/* something went wrong, preserve original database */
!         strcat(wdir, "afsdcel2.ini");
!         unlink(wdir);
!         return closeCode;
!     }
  
!     strcat(wdir, AFS_CELLSERVDB);
!     strcat(sdir, "afsdcel2.ini");	/* new file */
! 
!     unlink(wdir);			/* delete old file */
! 
!     code = rename(sdir, wdir);	/* do the rename */
! 
!     if (code) 
!         code = errno;
! 
!     return code;
! }   
  
  void cm_GetConfigDir(char *dir)
  {
  	char wdir[256];
      int tlen;
  #ifdef AFS_WIN95_ENV
      char *afsconf_path;
  #endif
  
  #if !defined(DJGPP) && !defined(AFS_WIN95_ENV)
!     strcpy(wdir, AFSDIR_CLIENT_ETC_DIRPATH);
          
  	/* add trailing backslash, if required */
!     tlen = strlen(wdir);
!     if (wdir[tlen-1] != '\\') strcat(wdir, "\\");
  #else
  #ifdef DJGPP
!     strcpy(wdir,cm_confDir);
  #else
!     afsconf_path = getenv("AFSCONF");
!     if (!afsconf_path)
!         strcpy(wdir, AFSDIR_CLIENT_ETC_DIRPATH);
!     else
!         strcpy(wdir, afsconf_path);
  #endif /* !DJGPP */
!     strcat(wdir,"\\");
  #endif /* DJGPP || WIN95 */
!     strcpy(dir, wdir);
  }
Index: openafs/src/WINNT/afsd/cm_config.h
diff -c openafs/src/WINNT/afsd/cm_config.h:1.4 openafs/src/WINNT/afsd/cm_config.h:1.5
*** openafs/src/WINNT/afsd/cm_config.h:1.4	Fri Oct  5 17:40:47 2001
--- openafs/src/WINNT/afsd/cm_config.h	Wed Jul 21 10:06:11 2004
***************
*** 53,58 ****
--- 53,60 ----
  
  extern long cm_CloseCellFile(cm_configFile_t *filep);
  
+ extern long cm_GetCellServDB(char *cellNamep);
+ 
  #endif /* __CM_CONFIG_INTERFACES_ONLY__ */
  
  #endif /* __CONFIG_H_ENV_ */
Index: openafs/src/WINNT/afsd/cm_conn.c
diff -c openafs/src/WINNT/afsd/cm_conn.c:1.16 openafs/src/WINNT/afsd/cm_conn.c:1.20
*** openafs/src/WINNT/afsd/cm_conn.c:1.16	Sat Jun  5 14:57:58 2004
--- openafs/src/WINNT/afsd/cm_conn.c	Sun Jul 25 22:48:47 2004
***************
*** 201,217 ****
  	    osi_Log0(afsd_logp, "cm_Analyze passed CM_ERROR_ALLOFFLINE.");
  	    thrd_Sleep(5000);
  	    /* cm_ForceUpdateVolume marks all servers as non_busy */
! 	    cm_ForceUpdateVolume(fidp, userp, reqp);
! 	    retry = 1;
  	}
  
  	/* if all servers are busy, mark them non-busy and start over */
  	if (errorCode == CM_ERROR_ALLBUSY) {
  		cm_GetServerList(fidp, userp, reqp, &serversp);
  		for (tsrp = serversp; tsrp; tsrp=tsrp->next) {
  			if (tsrp->status == busy)
  				tsrp->status = not_busy;
  		}
  		thrd_Sleep(5000);
  		retry = 1;
  	}
--- 201,236 ----
  	    osi_Log0(afsd_logp, "cm_Analyze passed CM_ERROR_ALLOFFLINE.");
  	    thrd_Sleep(5000);
  	    /* cm_ForceUpdateVolume marks all servers as non_busy */
! 		/* No it doesn't and it won't do anything if all of the 
! 		 * the servers are marked as DOWN.  So clear the DOWN
! 		 * flag and reset the busy state as well.
! 		 */
! 		cm_GetServerList(fidp, userp, reqp, &serversp);
!         if (serversp) {
!             lock_ObtainWrite(&cm_serverLock);
!             for (tsrp = serversp; tsrp; tsrp=tsrp->next) {
!                 tsrp->server->flags &= ~CM_SERVERFLAG_DOWN;
!                 if (tsrp->status == busy)
!                     tsrp->status = not_busy;
!             }
!             lock_ReleaseWrite(&cm_serverLock);
! 
!             retry = 1;
!         }
! 
!         if (fidp != NULL)   /* Not a VLDB call */
!             cm_ForceUpdateVolume(fidp, userp, reqp);
  	}
  
  	/* if all servers are busy, mark them non-busy and start over */
  	if (errorCode == CM_ERROR_ALLBUSY) {
  		cm_GetServerList(fidp, userp, reqp, &serversp);
+ 		lock_ObtainWrite(&cm_serverLock);
  		for (tsrp = serversp; tsrp; tsrp=tsrp->next) {
  			if (tsrp->status == busy)
  				tsrp->status = not_busy;
  		}
+         lock_ReleaseWrite(&cm_serverLock);
  		thrd_Sleep(5000);
  		retry = 1;
  	}
***************
*** 219,224 ****
--- 238,244 ----
  	/* special codes:  VBUSY and VRESTARTING */
  	if (errorCode == VBUSY || errorCode == VRESTARTING) {
  		cm_GetServerList(fidp, userp, reqp, &serversp);
+ 		lock_ObtainWrite(&cm_serverLock);
  		for (tsrp = serversp; tsrp; tsrp=tsrp->next) {
  			if (tsrp->server == serverp
  			    && tsrp->status == not_busy) {
***************
*** 226,231 ****
--- 246,252 ----
  				break;
  			}
  		}
+         lock_ReleaseWrite(&cm_serverLock);
  		retry = 1;
  	}
  
***************
*** 328,334 ****
  	cm_serverRef_t *tsrp;
          cm_server_t *tsp;
          long firstError = 0;
! 	int someBusy = 0, someOffline = 0, allDown = 1;
  	long timeUsed, timeLeft, hardTimeLeft;
  #ifdef DJGPP
          struct timeval now;
--- 349,355 ----
  	cm_serverRef_t *tsrp;
          cm_server_t *tsp;
          long firstError = 0;
! 	int someBusy = 0, someOffline = 0, allBusy = 1, allDown = 1;
  	long timeUsed, timeLeft, hardTimeLeft;
  #ifdef DJGPP
          struct timeval now;
***************
*** 360,365 ****
--- 381,387 ----
              else if (tsrp->status == offline)
                  someOffline = 1;
              else {
+ 				allBusy = 0;
                  code = cm_ConnByServer(tsp, usersp, connpp);
                  if (code == 0) {
                      cm_PutServer(tsp);
***************
*** 389,404 ****
  
  	lock_ReleaseWrite(&cm_serverLock);
  	if (firstError == 0) {
! 		if (someBusy) 
! 			firstError = CM_ERROR_ALLBUSY;
! 		else if (someOffline) 
  			firstError = CM_ERROR_ALLOFFLINE;
! 		else if (!allDown && serversp) 
  			firstError = CM_ERROR_TIMEDOUT;
- 		/* Only return CM_ERROR_NOSUCHVOLUME if there are no
- 		   servers for this volume */
- 		else 
- 			firstError = CM_ERROR_NOSUCHVOLUME;
  	}
  	osi_Log1(afsd_logp, "cm_ConnByMServers returning %x", firstError);
      return firstError;
--- 411,424 ----
  
  	lock_ReleaseWrite(&cm_serverLock);
  	if (firstError == 0) {
!         if (serversp == NULL)
! 			firstError = CM_ERROR_NOSUCHVOLUME;
!         else if (allDown) 
  			firstError = CM_ERROR_ALLOFFLINE;
! 		else if (allBusy) 
! 			firstError = CM_ERROR_ALLBUSY;
! 		else
  			firstError = CM_ERROR_TIMEDOUT;
  	}
  	osi_Log1(afsd_logp, "cm_ConnByMServers returning %x", firstError);
      return firstError;
Index: openafs/src/WINNT/afsd/cm_dcache.c
diff -c openafs/src/WINNT/afsd/cm_dcache.c:1.8 openafs/src/WINNT/afsd/cm_dcache.c:1.9
*** openafs/src/WINNT/afsd/cm_dcache.c:1.8	Mon Jun  7 02:22:58 2004
--- openafs/src/WINNT/afsd/cm_dcache.c	Sun Jul 25 16:53:12 2004
***************
*** 153,167 ****
                  /* write out wbytes of data from bufferp */
                  temp = rx_Write(callp, bufferp, wbytes);
                  if (temp != wbytes) {
                      code = -1;
  					break;
! 				}
                  nbytes -= wbytes;
              }	/* while more bytes to write */
  		}		/* if RPC started successfully */
! 
! 		if (code == 0)
  			code = EndRXAFS_StoreData(callp, &outStatus, &volSync);
          code = rx_EndCall(callp, code);
          osi_Log0(afsd_logp, "CALL StoreData DONE");
                  
--- 153,175 ----
                  /* write out wbytes of data from bufferp */
                  temp = rx_Write(callp, bufferp, wbytes);
                  if (temp != wbytes) {
+                     osi_Log2(afsd_logp, "rx_Write failed %d != %d",temp,wbytes);
                      code = -1;
  					break;
! 				} else {
!                     osi_Log1(afsd_logp, "rx_Write succeeded %d",temp);
!                 }
                  nbytes -= wbytes;
              }	/* while more bytes to write */
  		}		/* if RPC started successfully */
!         else {
!             osi_Log1(afsd_logp, "StartRXAFS_StoreData failed (%lX)",code);
!         }
! 		if (code == 0) {
  			code = EndRXAFS_StoreData(callp, &outStatus, &volSync);
+             if (code)
+                 osi_Log1(afsd_logp, "EndRXAFS_StoreData failed (%lX)",code);
+         }
          code = rx_EndCall(callp, code);
          osi_Log0(afsd_logp, "CALL StoreData DONE");
                  
Index: openafs/src/WINNT/afsd/cm_freelance.c
diff -c openafs/src/WINNT/afsd/cm_freelance.c:1.9 openafs/src/WINNT/afsd/cm_freelance.c:1.14
*** openafs/src/WINNT/afsd/cm_freelance.c:1.9	Mon Jun  7 02:22:58 2004
--- openafs/src/WINNT/afsd/cm_freelance.c	Tue Jul 27 17:34:46 2004
***************
*** 3,8 ****
--- 3,9 ----
  
  #ifndef DJGPP
  #include <windows.h>
+ #include <winreg.h>
  #include <winsock2.h>
  #else
  #include <netdb.h>
***************
*** 33,51 ****
  void cm_InitFakeRootDir();
  
  void cm_InitFreelance() {
-   
- #ifdef COMMENT
-     while ( !IsDebuggerPresent() ) {
-         Sleep(1000);
-     }
- #endif
- 
  	lock_InitializeMutex(&cm_Freelance_Lock, "Freelance Lock");
    
  	// yj: first we make a call to cm_initLocalMountPoints
  	// to read all the local mount points from an ini file
  	cm_InitLocalMountPoints();
! 	
  	// then we make a call to InitFakeRootDir to create
  	// a fake root directory based on the local mount points
  	cm_InitFakeRootDir();
--- 34,45 ----
  void cm_InitFakeRootDir();
  
  void cm_InitFreelance() {
  	lock_InitializeMutex(&cm_Freelance_Lock, "Freelance Lock");
    
  	// yj: first we make a call to cm_initLocalMountPoints
  	// to read all the local mount points from an ini file
  	cm_InitLocalMountPoints();
! 
  	// then we make a call to InitFakeRootDir to create
  	// a fake root directory based on the local mount points
  	cm_InitFakeRootDir();
***************
*** 231,237 ****
  
  int cm_FakeRootFid(cm_fid_t *fidp)
  {
!       fidp->cell = 0x1;            /* root cell */
        fidp->volume = AFS_FAKE_ROOT_VOL_ID;   /* root.afs ? */
        fidp->vnode = 0x1;
        fidp->unique = 0x1;
--- 225,231 ----
  
  int cm_FakeRootFid(cm_fid_t *fidp)
  {
!       fidp->cell = AFS_FAKE_ROOT_CELL_ID;            /* root cell */
        fidp->volume = AFS_FAKE_ROOT_VOL_ID;   /* root.afs ? */
        fidp->vnode = 0x1;
        fidp->unique = 0x1;
***************
*** 270,276 ****
  
  	osi_Log0(afsd_logp,"Invalidating local mount point scp...  ");
  
! 	aFid.cell = 0x1;
  	aFid.volume=AFS_FAKE_ROOT_VOL_ID;
  	aFid.unique=0x1;
  	aFid.vnode=0x2;
--- 264,270 ----
  
  	osi_Log0(afsd_logp,"Invalidating local mount point scp...  ");
  
! 	aFid.cell = AFS_FAKE_ROOT_CELL_ID;
  	aFid.volume=AFS_FAKE_ROOT_VOL_ID;
  	aFid.unique=0x1;
  	aFid.vnode=0x2;
***************
*** 344,356 ****
  // process for the freelance client.
  /* to be called while holding freelance lock unless during init. */
  long cm_InitLocalMountPoints() {
- 	
  	FILE *fp;
! 	char line[200];
  	int i;
  	char* t;
  	cm_localMountPoint_t* aLocalMountPoint;
  	char hdir[120];
  
  	cm_GetConfigDir(hdir);
  	strcat(hdir, AFS_FREELANCE_INI);
--- 338,441 ----
  // process for the freelance client.
  /* to be called while holding freelance lock unless during init. */
  long cm_InitLocalMountPoints() {
  	FILE *fp;
! 	char line[512];
  	int i;
  	char* t;
  	cm_localMountPoint_t* aLocalMountPoint;
  	char hdir[120];
+     long code;
+     char rootCellName[256];
+ #if !defined(DJGPP)
+     HKEY hkFreelance = 0;
+     DWORD dwType, dwSize;
+     DWORD dwMountPoints;
+     DWORD dwIndex;
+ #endif
+ 
+ #if !defined(DJGPP)
+     if (RegOpenKeyEx( HKEY_LOCAL_MACHINE, 
+                         "SOFTWARE\\OpenAFS\\Client\\Freelance",
+ 						0,
+                         KEY_READ|KEY_WRITE|KEY_QUERY_VALUE,
+                         &hkFreelance) == ERROR_SUCCESS) {
+ 
+         RegQueryInfoKey( hkFreelance,
+                          NULL,  /* lpClass */
+                          NULL,  /* lpcClass */
+                          NULL,  /* lpReserved */
+                          NULL,  /* lpcSubKeys */
+                          NULL,  /* lpcMaxSubKeyLen */
+                          NULL,  /* lpcMaxClassLen */
+                          &dwMountPoints, /* lpcValues */
+                          NULL,  /* lpcMaxValueNameLen */
+                          NULL,  /* lpcMaxValueLen */
+                          NULL,  /* lpcbSecurityDescriptor */
+                          NULL   /* lpftLastWriteTime */
+                          );
+ 
+         if ( dwMountPoints == 0 ) {
+             sprintf(line,"%s#%s:root.cell.\n",rootCellName,rootCellName);
+             dwType = REG_SZ;
+             dwSize = strlen(line) + 1;
+             RegSetValueEx( hkFreelance, "0", 0, dwType, line, dwSize);
+             sprintf(line,".%s%%%s:root.cell.\n",rootCellName,rootCellName);
+             dwSize = strlen(line) + 1;
+             RegSetValueEx( hkFreelance, "1", 0, dwType, line, dwSize);
+             dwMountPoints = 2;
+         }
+ 
+         // get the number of entries there are from the first line
+         // that we read
+         cm_noLocalMountPoints = dwMountPoints;
+ 
+         // create space to store the local mount points
+         cm_localMountPoints = malloc(sizeof(cm_localMountPoint_t) * cm_noLocalMountPoints);
+         aLocalMountPoint = cm_localMountPoints;
+ 
+         // now we read n lines and parse them into local mount points
+         // where n is the number of local mount points there are, as
+         // determined above.
+         // Each line in the ini file represents 1 local mount point and 
+         // is in the format xxx#yyy:zzz, where xxx is the directory
+         // entry name, yyy is the cell name and zzz is the volume name.
+         // #yyy:zzz together make up the mount point.
+         for ( dwIndex = 0 ; dwIndex < dwMountPoints; dwIndex++ ) {
+             TCHAR szValueName[16];
+             DWORD dwValueSize = 16;
+             dwSize = sizeof(line);
+             RegEnumValue( hkFreelance, dwIndex, szValueName, &dwValueSize, NULL,
+                           &dwType, line, &dwSize);
+ 
+             // line is not empty, so let's parse it
+             t = strchr(line, '#');
+             if (!t)
+                 t = strchr(line, '%');
+             // make sure that there is a '#' or '%' separator in the line
+             if (!t) {
+                 afsi_log("error occurred while parsing entry in %s: no # or %% separator in line %d", AFS_FREELANCE_INI, i);
+                 fprintf(stderr, "error occurred while parsing entry in afs_freelance.ini: no # or %% separator in line %d", i);
+                 return -1;
+             }
+             aLocalMountPoint->namep=malloc(t-line+1);
+             memcpy(aLocalMountPoint->namep, line, t-line);
+             *(aLocalMountPoint->namep + (t-line)) = 0;
+ 		
+             aLocalMountPoint->mountPointStringp=malloc(strlen(line) - (t-line) + 1);
+             memcpy(aLocalMountPoint->mountPointStringp, t, strlen(line)-(t-line)-2);
+             *(aLocalMountPoint->mountPointStringp + (strlen(line)-(t-line)-2)) = 0;
+     
+             osi_Log2(afsd_logp,"found mount point: name %s, string %s",
+                       osi_LogSaveString(afsd_logp,aLocalMountPoint->namep),
+                       osi_LogSaveString(afsd_logp,aLocalMountPoint->mountPointStringp));
+ 
+             aLocalMountPoint++;
+         }
+ 
+         RegCloseKey(hkFreelance);
+         return 0;
+     }
+ #endif
  
  	cm_GetConfigDir(hdir);
  	strcat(hdir, AFS_FREELANCE_INI);
***************
*** 359,376 ****
  
  	// if we fail to open the file, create an empty one
  	if (!fp) {
! 	  fp = fopen(hdir, "w");
! 	  fputs("0\n", fp);
! 	  fclose(fp);
! 	  return 0;  /* success */
  	}
  
  	// we successfully opened the file
  	osi_Log0(afsd_logp,"opened afs_freelance.ini");
  	
  	// now we read the first line to see how many entries
  	// there are
! 	fgets(line, 200, fp);
  
  	// if the line is empty at any point when we're reading
  	// we're screwed. report error and return.
--- 444,484 ----
  
  	// if we fail to open the file, create an empty one
  	if (!fp) {
!         fp = fopen(hdir, "w");
!       	code = cm_GetRootCellName(rootCellName);
!         if (code == 0) {
!             fputs("1\n", fp);
!             fprintf(fp,"%s#%s:root.cell.\n",rootCellName,rootCellName);
!             fprintf(fp,".%s%%%s:root.cell.\n",rootCellName,rootCellName);
!             fclose(fp);
!             fopen(hdir, "r");
!         } else {
!             fputs("0\n", fp);
!             fclose(fp);
!             return 0;  /* success */
!         }
  	}
  
  	// we successfully opened the file
  	osi_Log0(afsd_logp,"opened afs_freelance.ini");
  	
+ 
+ #if !defined(DJGPP)
+     RegCreateKeyEx( HKEY_LOCAL_MACHINE, 
+                     "SOFTWARE\\OpenAFS\\Client\\Freelance",
+                     0,
+                     NULL,
+                     REG_OPTION_NON_VOLATILE,
+                     KEY_READ|KEY_WRITE,
+                     NULL,
+                     &hkFreelance,
+                     NULL);
+     dwIndex = 0;
+ #endif
+ 
  	// now we read the first line to see how many entries
  	// there are
! 	fgets(line, sizeof(line), fp);
  
  	// if the line is empty at any point when we're reading
  	// we're screwed. report error and return.
***************
*** 396,434 ****
  	// entry name, yyy is the cell name and zzz is the volume name.
  	// #yyy:zzz together make up the mount point.
  	for (i=0; i<cm_noLocalMountPoints; i++) {
! 		fgets(line, 200, fp);
  		// check that the line is not empty
  		if (line[0]==0) {
  			afsi_log("error occurred while parsing entry in %s: empty line in line %d", AFS_FREELANCE_INI, i);
  			fprintf(stderr, "error occurred while parsing entry in afs_freelance.ini: empty line in line %d", i);
  			return -1;
  		}
  		// line is not empty, so let's parse it
  		t = strchr(line, '#');
! 		// make sure that there is a '#' separator in the line
  		if (!t) {
! 			afsi_log("error occurred while parsing entry in %s: no # separator in line %d", AFS_FREELANCE_INI, i);
! 			fprintf(stderr, "error occurred while parsing entry in afs_freelance.ini: no # separator in line %d", i);
  			return -1;
  		}
  		aLocalMountPoint->namep=malloc(t-line+1);
  		memcpy(aLocalMountPoint->namep, line, t-line);
  		*(aLocalMountPoint->namep + (t-line)) = 0;
! 		aLocalMountPoint->mountPointStringp=malloc(strlen(line) - (t-line) + 1);
  		memcpy(aLocalMountPoint->mountPointStringp, t, strlen(line)-(t-line)-2);
  		*(aLocalMountPoint->mountPointStringp + (strlen(line)-(t-line)-2)) = 0;
      
          osi_Log2(afsd_logp,"found mount point: name %s, string %s",
! 			aLocalMountPoint->namep,
! 			aLocalMountPoint->mountPointStringp);
  
          aLocalMountPoint++;
  	}
  	fclose(fp);
  	return 0;
  }
  
- 
  int cm_getNoLocalMountPoints() {
  	return cm_noLocalMountPoints;
  }
--- 504,562 ----
  	// entry name, yyy is the cell name and zzz is the volume name.
  	// #yyy:zzz together make up the mount point.
  	for (i=0; i<cm_noLocalMountPoints; i++) {
! 		fgets(line, sizeof(line), fp);
  		// check that the line is not empty
  		if (line[0]==0) {
  			afsi_log("error occurred while parsing entry in %s: empty line in line %d", AFS_FREELANCE_INI, i);
  			fprintf(stderr, "error occurred while parsing entry in afs_freelance.ini: empty line in line %d", i);
  			return -1;
  		}
+ 
+ #if !defined(DJGPP)
+         if ( hkFreelance ) {
+             char szIndex[16];
+             /* we are migrating to the registry */
+             sprintf(szIndex,"%d",dwIndex++);
+             dwType = REG_SZ;
+             dwSize = strlen(line) + 1;
+             RegSetValueEx( hkFreelance, szIndex, 0, dwType, line, dwSize);
+         }
+ #endif 
+ 
  		// line is not empty, so let's parse it
  		t = strchr(line, '#');
!         if (!t)
!             t = strchr(line, '%');
! 		// make sure that there is a '#' or '%' separator in the line
  		if (!t) {
! 			afsi_log("error occurred while parsing entry in %s: no # or %% separator in line %d", AFS_FREELANCE_INI, i);
! 			fprintf(stderr, "error occurred while parsing entry in afs_freelance.ini: no # or %% separator in line %d", i);
  			return -1;
  		}
  		aLocalMountPoint->namep=malloc(t-line+1);
  		memcpy(aLocalMountPoint->namep, line, t-line);
  		*(aLocalMountPoint->namep + (t-line)) = 0;
! 		
!         aLocalMountPoint->mountPointStringp=malloc(strlen(line) - (t-line) + 1);
  		memcpy(aLocalMountPoint->mountPointStringp, t, strlen(line)-(t-line)-2);
  		*(aLocalMountPoint->mountPointStringp + (strlen(line)-(t-line)-2)) = 0;
      
          osi_Log2(afsd_logp,"found mount point: name %s, string %s",
!                   aLocalMountPoint->namep,
!                   aLocalMountPoint->mountPointStringp);
  
          aLocalMountPoint++;
  	}
  	fclose(fp);
+ #if !defined(DJGPP)
+     if ( hkFreelance ) {
+         RegCloseKey(hkFreelance);
+         DeleteFile(hdir);
+     }
+ #endif
  	return 0;
  }
  
  int cm_getNoLocalMountPoints() {
  	return cm_noLocalMountPoints;
  }
***************
*** 437,550 ****
  	return 0;
  }
  
! long cm_FreelanceAddMount(char *filename, char *cellname, char *volume, cm_fid_t *fidp)
  {
      FILE *fp;
      char hfile[120];
!     char line[200];
      char fullname[200];
      int n;
      int alias = 0;
  
      /* before adding, verify the cell name; if it is not a valid cell,
         don't add the mount point.
         allow partial matches as a means of poor man's alias. */
      /* major performance issue? */
!     osi_Log3(afsd_logp,"Freelance Add Mount request: filename=%s cellname=%s volume=%s",
!               filename, cellname, volume);
      if (cellname[0] == '.') {
!         if (!cm_GetCell_Gen(&cellname[1], &fullname[1], CM_FLAG_CREATE))
              return -1;
-         fullname[0]='.';
      } else {
          if (!cm_GetCell_Gen(cellname, fullname, CM_FLAG_CREATE))
              return -1;
      }
      
!     osi_Log1(afsd_logp,"Freelance Adding Mount for Cell: %s", cellname);
  
      lock_ObtainMutex(&cm_Freelance_Lock);
  
!      cm_GetConfigDir(hfile);
!      strcat(hfile, AFS_FREELANCE_INI);
!      fp = fopen(hfile, "r+");
!      if (!fp)
!        return CM_ERROR_INVAL;
!      fgets(line, 200, fp);
!      n = atoi(line);
!      n++;
!      fseek(fp, 0, SEEK_SET);
!      fprintf(fp, "%d", n);
!      fseek(fp, 0, SEEK_END);
!      fprintf(fp, "%s#%s:%s\n", filename, fullname, volume);
!      fclose(fp);
!      lock_ReleaseMutex(&cm_Freelance_Lock);
! 
!      /* cm_reInitLocalMountPoints(); */
!      if (fidp) {
!        fidp->unique = 1;
!        fidp->vnode = cm_noLocalMountPoints + 1;   /* vnode value of last mt pt */
!      }
!      cm_noteLocalMountPointChange();
!     
!      return 0;
  }
  
  long cm_FreelanceRemoveMount(char *toremove)
  {
!      int i, n;
!      char* cp;
!      char line[200];
!      char shortname[200];
!      char hfile[120], hfile2[120];
!      FILE *fp1, *fp2;
!      int found=0;
  
      lock_ObtainMutex(&cm_Freelance_Lock);
  
-      cm_GetConfigDir(hfile);
-      strcat(hfile, AFS_FREELANCE_INI);
-      strcpy(hfile2, hfile);
-      strcat(hfile2, "2");
-      fp1=fopen(hfile, "r+");
-      if (!fp1)
-        return CM_ERROR_INVAL;
-      fp2=fopen(hfile2, "w+");
-      if (!fp2) {
-        fclose(fp1);
-        return CM_ERROR_INVAL;
-      }
- 
-      fgets(line, 200, fp1);
-      n=atoi(line);
-      fprintf(fp2, "%d\n", n-1);
- 
-      for (i=0; i<n; i++) {
-           fgets(line, 200, fp1);
-           cp=strchr(line, '#');
-           memcpy(shortname, line, cp-line);
-           shortname[cp-line]=0;
- 
-           if (strcmp(shortname, toremove)==0) {
- 
-           } else {
- 	    found = 1;
- 	    fputs(line, fp2);
-           }
-      }
- 
-      fclose(fp1);
-      fclose(fp2);
-      if (!found)
-        return CM_ERROR_NOSUCHFILE;
  
!      unlink(hfile);
!      rename(hfile2, hfile);
! 
!      lock_ReleaseMutex(&cm_Freelance_Lock);
  
!      cm_noteLocalMountPointChange();
!      return 0;
  }
  
  #endif /* AFS_FREELANCE_CLIENT */
--- 565,785 ----
  	return 0;
  }
  
! long cm_FreelanceAddMount(char *filename, char *cellname, char *volume, int rw, cm_fid_t *fidp)
  {
      FILE *fp;
      char hfile[120];
!     char line[512];
      char fullname[200];
      int n;
      int alias = 0;
+ #if !defined(DJGPP)
+     HKEY hkFreelance = 0;
+     DWORD dwType, dwSize;
+     DWORD dwMountPoints;
+     DWORD dwIndex;
+ #endif
  
      /* before adding, verify the cell name; if it is not a valid cell,
         don't add the mount point.
         allow partial matches as a means of poor man's alias. */
      /* major performance issue? */
!     osi_Log3(afsd_logp,"Freelance Add Mount request: filename=%s cellname=%s volume=%s %s",
!               osi_LogSaveString(afsd_logp,filename), 
!               osi_LogSaveString(afsd_logp,cellname), 
!               osi_LogSaveString(afsd_logp,volume), rw ? "rw" : "ro");
      if (cellname[0] == '.') {
!         if (!cm_GetCell_Gen(&cellname[1], fullname, CM_FLAG_CREATE))
              return -1;
      } else {
          if (!cm_GetCell_Gen(cellname, fullname, CM_FLAG_CREATE))
              return -1;
      }
      
!     osi_Log1(afsd_logp,"Freelance Adding Mount for Cell: %s", 
!               osi_LogSaveString(afsd_logp,cellname));
  
      lock_ObtainMutex(&cm_Freelance_Lock);
  
! #if !defined(DJGPP)
!     if (RegOpenKeyEx( HKEY_LOCAL_MACHINE, 
!                       "SOFTWARE\\OpenAFS\\Client\\Freelance",
!                       0,
!                       KEY_READ|KEY_WRITE|KEY_QUERY_VALUE,
!                       &hkFreelance) == ERROR_SUCCESS) {
! 
!         RegQueryInfoKey( hkFreelance,
!                          NULL,  /* lpClass */
!                          NULL,  /* lpcClass */
!                          NULL,  /* lpReserved */
!                          NULL,  /* lpcSubKeys */
!                          NULL,  /* lpcMaxSubKeyLen */
!                          NULL,  /* lpcMaxClassLen */
!                          &dwMountPoints, /* lpcValues */
!                          NULL,  /* lpcMaxValueNameLen */
!                          NULL,  /* lpcMaxValueLen */
!                          NULL,  /* lpcbSecurityDescriptor */
!                          NULL   /* lpftLastWriteTime */
!                          );
! 
!         if (rw)
!             sprintf(line, "%s%%%s:%s\n", filename, fullname, volume);
!         else
!             sprintf(line, "%s#%s:%s\n", filename, fullname, volume);
! 
!         /* If we are adding a new value, there must be an unused name
!          * within the range 0 to dwMountPoints 
!          */
!         for ( dwIndex = 0; dwIndex <= dwMountPoints; dwIndex++ ) {
!             char szIndex[16];
!             sprintf(szIndex, "%d", dwIndex);
!             if (RegQueryValueEx( hkFreelance, szIndex, 0, &dwType, NULL, &dwSize) != ERROR_SUCCESS) {
!                 /* found an unused value */
!                 dwType = REG_SZ;
!                 dwSize = strlen(line) + 1;
!                 RegSetValueEx( hkFreelance, szIndex, 0, dwType, line, dwSize);
!                 break;
!             }
!         }
!         RegCloseKey(hkFreelance);
!     } else 
! #endif
!     {
!         cm_GetConfigDir(hfile);
!         strcat(hfile, AFS_FREELANCE_INI);
!         fp = fopen(hfile, "r+");
!         if (!fp)
!             return CM_ERROR_INVAL;
!         fgets(line, sizeof(line), fp);
!         n = atoi(line);
!         n++;
!         fseek(fp, 0, SEEK_SET);
!         fprintf(fp, "%d", n);
!         fseek(fp, 0, SEEK_END);
!         if (rw)
!             fprintf(fp, "%s%%%s:%s\n", filename, fullname, volume);
!         else
!             fprintf(fp, "%s#%s:%s\n", filename, fullname, volume);
!         fclose(fp);
!     }
!     lock_ReleaseMutex(&cm_Freelance_Lock);
! 
!     /* cm_reInitLocalMountPoints(); */
!     if (fidp) {
!         fidp->unique = 1;
!         fidp->vnode = cm_noLocalMountPoints + 1;   /* vnode value of last mt pt */
!     }
!     cm_noteLocalMountPointChange();
!     return 0;
  }
  
  long cm_FreelanceRemoveMount(char *toremove)
  {
!     int i, n;
!     char* cp;
!     char line[512];
!     char shortname[200];
!     char hfile[120], hfile2[120];
!     FILE *fp1, *fp2;
!     int found=0;
! #if !defined(DJGPP)
!     HKEY hkFreelance = 0;
!     DWORD dwType, dwSize;
!     DWORD dwMountPoints;
!     DWORD dwIndex;
! #endif
  
      lock_ObtainMutex(&cm_Freelance_Lock);
  
  
! #if !defined(DJGPP)
!     if (RegOpenKeyEx( HKEY_LOCAL_MACHINE, 
!                       "SOFTWARE\\OpenAFS\\Client\\Freelance",
!                       0,
!                       KEY_READ|KEY_WRITE|KEY_QUERY_VALUE,
!                       &hkFreelance) == ERROR_SUCCESS) {
! 
!         RegQueryInfoKey( hkFreelance,
!                          NULL,  /* lpClass */
!                          NULL,  /* lpcClass */
!                          NULL,  /* lpReserved */
!                          NULL,  /* lpcSubKeys */
!                          NULL,  /* lpcMaxSubKeyLen */
!                          NULL,  /* lpcMaxClassLen */
!                          &dwMountPoints, /* lpcValues */
!                          NULL,  /* lpcMaxValueNameLen */
!                          NULL,  /* lpcMaxValueLen */
!                          NULL,  /* lpcbSecurityDescriptor */
!                          NULL   /* lpftLastWriteTime */
!                          );
! 
!         for ( dwIndex = 0; dwIndex < dwMountPoints; dwIndex++ ) {
!             TCHAR szValueName[16];
!             DWORD dwValueSize = 16;
!             dwSize = sizeof(line);
!             RegEnumValue( hkFreelance, dwIndex, szValueName, &dwValueSize, NULL,
!                           &dwType, line, &dwSize);
! 
!             cp=strchr(line, '#');
!             if (!cp)
!                 cp=strchr(line, '%');
!             memcpy(shortname, line, cp-line);
!             shortname[cp-line]=0;
! 
!             if (!strcmp(shortname, toremove)) {
!                 RegDeleteValue( hkFreelance, szValueName );
!                 break;
!             }
!         }
!         RegCloseKey(hkFreelance);
!     } else 
! #endif
!     {
!         cm_GetConfigDir(hfile);
!         strcat(hfile, AFS_FREELANCE_INI);
!         strcpy(hfile2, hfile);
!         strcat(hfile2, "2");
!         fp1=fopen(hfile, "r+");
!         if (!fp1)
!             return CM_ERROR_INVAL;
!         fp2=fopen(hfile2, "w+");
!         if (!fp2) {
!             fclose(fp1);
!             return CM_ERROR_INVAL;
!         }
! 
!         fgets(line, sizeof(line), fp1);
!         n=atoi(line);
!         fprintf(fp2, "%d\n", n-1);
! 
!         for (i=0; i<n; i++) {
!             fgets(line, sizeof(line), fp1);
!             cp=strchr(line, '#');
!             if (!cp)
!                 cp=strchr(line, '%');
!             memcpy(shortname, line, cp-line);
!             shortname[cp-line]=0;
! 
!             if (strcmp(shortname, toremove)==0) {
! 
!             } else {
!                 found = 1;
!                 fputs(line, fp2);
!             }
!         }
! 
!         fclose(fp1);
!         fclose(fp2);
!         if (!found)
!             return CM_ERROR_NOSUCHFILE;
  
!         unlink(hfile);
!         rename(hfile2, hfile);
!     }
!     
!     lock_ReleaseMutex(&cm_Freelance_Lock);
!     cm_noteLocalMountPointChange();
!     return 0;
  }
  
  #endif /* AFS_FREELANCE_CLIENT */
Index: openafs/src/WINNT/afsd/cm_freelance.h
diff -c openafs/src/WINNT/afsd/cm_freelance.h:1.2 openafs/src/WINNT/afsd/cm_freelance.h:1.4
*** openafs/src/WINNT/afsd/cm_freelance.h:1.2	Mon Jun  7 02:22:58 2004
--- openafs/src/WINNT/afsd/cm_freelance.h	Mon Jul 26 15:08:42 2004
***************
*** 15,22 ****
  extern cm_localMountPoint_t* cm_getLocalMountPoint(int vnode);
  extern void cm_InitFreelance();
  extern long cm_FreelanceRemoveMount(char *toremove);
! extern long cm_FreelanceAddMount(char *filename, char *cellname, char *volume, cm_fid_t *fidp);
  
  #define AFS_FREELANCE_INI "afs_freelance.ini"
! #define AFS_FAKE_ROOT_VOL_ID  0x00000001
  #endif // _CM_FREELANCE_H
--- 15,23 ----
  extern cm_localMountPoint_t* cm_getLocalMountPoint(int vnode);
  extern void cm_InitFreelance();
  extern long cm_FreelanceRemoveMount(char *toremove);
! extern long cm_FreelanceAddMount(char *filename, char *cellname, char *volume, int rw, cm_fid_t *fidp);
  
  #define AFS_FREELANCE_INI "afs_freelance.ini"
! #define AFS_FAKE_ROOT_CELL_ID 0xFFFFFFFF
! #define AFS_FAKE_ROOT_VOL_ID  0xFFFFFFFF
  #endif // _CM_FREELANCE_H
Index: openafs/src/WINNT/afsd/cm_ioctl.c
diff -c openafs/src/WINNT/afsd/cm_ioctl.c:1.27 openafs/src/WINNT/afsd/cm_ioctl.c:1.30
*** openafs/src/WINNT/afsd/cm_ioctl.c:1.27	Sat Jun 19 12:00:13 2004
--- openafs/src/WINNT/afsd/cm_ioctl.c	Thu Jul 15 23:38:31 2004
***************
*** 1435,1441 ****
  	  /* we are adding the mount point to the root dir., so call
  	     the freelance code to do the add. */
  	  osi_Log0(afsd_logp,"IoctlCreateMountPoint within Freelance root dir");
! 	  code = cm_FreelanceAddMount(leaf, fullCell, volume, NULL);
  	  return code;
  	}
  #endif
--- 1435,1442 ----
  	  /* we are adding the mount point to the root dir., so call
  	     the freelance code to do the add. */
  	  osi_Log0(afsd_logp,"IoctlCreateMountPoint within Freelance root dir");
! 	  code = cm_FreelanceAddMount(leaf, fullCell, volume, 
!                                   *ioctlp->inDatap == '%', NULL);
  	  return code;
  	}
  #endif
***************
*** 1690,1696 ****
          if (flags & PIOCTL_LOGON) {
  		  /* SMB user name with which to associate tokens */
  		  smbname = tp;
! 		  fprintf(stderr, "SMB name = %s\n", smbname);
  		  tp += strlen(tp) + 1;
          }
  
--- 1691,1698 ----
          if (flags & PIOCTL_LOGON) {
  		  /* SMB user name with which to associate tokens */
  		  smbname = tp;
!           osi_Log1(smb_logp,"cm_IoctlSetToken for user [%s]",osi_LogSaveString(smb_logp,smbname));		  
!           fprintf(stderr, "SMB name = %s\n", smbname);
  		  tp += strlen(tp) + 1;
          }
  
***************
*** 1981,1990 ****
  	char afspath[MAX_PATH];
  	char *submountreqp;
  	int iteration;
- 	int submountDataSize;
- 	char *submountData;
- 	char *submountName;
  	int nextAutoSubmount;
  
  	cm_SkipIoctlPath(ioctlp);
  
--- 1983,1994 ----
  	char afspath[MAX_PATH];
  	char *submountreqp;
  	int iteration;
  	int nextAutoSubmount;
+     HKEY hkSubmounts;
+     DWORD dwType, dwSize;
+     DWORD status;
+     DWORD dwIndex;
+     DWORD dwSubmounts;
  
  	cm_SkipIoctlPath(ioctlp);
  
***************
*** 2003,2035 ****
  	 * that submount name is in use... if so, the submount's path
  	 * has to match our path.
  	 */
! 	if (submountreqp && *submountreqp) {
  		char submountPathNormalized[MAX_PATH];
  		char submountPath[MAX_PATH];
  		int submountPathLen;
  
! 		submountPathLen = GetPrivateProfileString("AFS Submounts",
! 					submountreqp, "", submountPath,
! 					sizeof(submountPath), "afsdsbmt.ini");
  
! 		if ((submountPathLen == 0) ||
! 		    (submountPathLen == sizeof(submountPath) - 1)) {
  
  			/* The suggested submount name isn't in use now--
  			 * so we can safely map the requested submount name
  			 * to the supplied path. Remember not to write the
  			 * leading "/afs" when writing out the submount.
  			 */
! 			WritePrivateProfileString("AFS Submounts",
! 					submountreqp, 
! 					(strlen(&afspath[strlen(cm_mountRoot)])) ?
! 						  &afspath[strlen(cm_mountRoot)]:"/",
! 					"afsdsbmt.ini");
  
  			strcpy(ioctlp->outDatap, submountreqp);
  			ioctlp->outDatap += strlen(ioctlp->outDatap) +1;
  			lock_ReleaseMutex(&cm_Afsdsbmt_Lock);
!         		return 0;
  		}
  
  		/* The suggested submount name is already in use--if the
--- 2007,2051 ----
  	 * that submount name is in use... if so, the submount's path
  	 * has to match our path.
  	 */
! 
!     RegCreateKeyEx( HKEY_LOCAL_MACHINE, 
!                     "SOFTWARE\\OpenAFS\\Client\\Submounts",
!                     0, 
!                     "AFS", 
!                     REG_OPTION_NON_VOLATILE,
!                     KEY_READ|KEY_WRITE|KEY_QUERY_VALUE,
!                     NULL, 
!                     &hkSubmounts,
!                     NULL );
! 
!     if (submountreqp && *submountreqp) {
  		char submountPathNormalized[MAX_PATH];
  		char submountPath[MAX_PATH];
  		int submountPathLen;
  
!         dwSize = sizeof(submountPath);
!         status = RegQueryValueEx( hkSubmounts, submountreqp, 0,
!                          &dwType, submountPath, &dwSize);
  
! 		if (status != ERROR_SUCCESS) {
  
  			/* The suggested submount name isn't in use now--
  			 * so we can safely map the requested submount name
  			 * to the supplied path. Remember not to write the
  			 * leading "/afs" when writing out the submount.
  			 */
!             RegSetValueEx( hkSubmounts, submountreqp, 0,
!                            REG_SZ, 
!                            (strlen(&afspath[strlen(cm_mountRoot)])) ?
!                            &afspath[strlen(cm_mountRoot)]:"/",
!                            (strlen(&afspath[strlen(cm_mountRoot)])) ?
!                            strlen(&afspath[strlen(cm_mountRoot)])+1:2);
  
+             RegCloseKey( hkSubmounts );
  			strcpy(ioctlp->outDatap, submountreqp);
  			ioctlp->outDatap += strlen(ioctlp->outDatap) +1;
  			lock_ReleaseMutex(&cm_Afsdsbmt_Lock);
!             return 0;
  		}
  
  		/* The suggested submount name is already in use--if the
***************
*** 2040,2074 ****
  		if (!strcmp (submountPathNormalized, afspath)) {
  			strcpy(ioctlp->outDatap, submountreqp);
  			ioctlp->outDatap += strlen(ioctlp->outDatap) +1;
  			lock_ReleaseMutex(&cm_Afsdsbmt_Lock);
!         		return 0;
  		}
  	}
  
! 	/* At this point, the user either didn't request a particular
! 	 * submount name, or that submount name couldn't be used.
! 	 * Look through afsdsbmt.ini to see if there are any submounts
! 	 * already associated with the specified path. The first
! 	 * step in doing that search is to load the AFS Submounts
! 	 * section of afsdsbmt.ini into memory.
! 	 */
! 
! 	submountDataSize = 1024;
! 	submountData = malloc (submountDataSize);
! 
! 	for (iteration = 0; iteration < 5; ++iteration) {
! 
! 		int sectionSize;
! 		sectionSize = GetPrivateProfileString("AFS Submounts",
! 					NULL, "", submountData,
! 					submountDataSize, "afsdsbmt.ini");
! 		if (sectionSize < submountDataSize-2)
! 			break;
  
- 		free (submountData);
- 		submountDataSize *= 2;
- 		submountData = malloc (submountDataSize);
- 	}
  
  	/* Having obtained a list of all available submounts, start
  	 * searching that list for a path which matches the requested
--- 2056,2081 ----
  		if (!strcmp (submountPathNormalized, afspath)) {
  			strcpy(ioctlp->outDatap, submountreqp);
  			ioctlp->outDatap += strlen(ioctlp->outDatap) +1;
+             RegCloseKey( hkSubmounts );
  			lock_ReleaseMutex(&cm_Afsdsbmt_Lock);
!             return 0;
  		}
  	}
  
!     RegQueryInfoKey( hkSubmounts,
!                  NULL,  /* lpClass */
!                  NULL,  /* lpcClass */
!                  NULL,  /* lpReserved */
!                  NULL,  /* lpcSubKeys */
!                  NULL,  /* lpcMaxSubKeyLen */
!                  NULL,  /* lpcMaxClassLen */
!                  &dwSubmounts, /* lpcValues */
!                  NULL,  /* lpcMaxValueNameLen */
!                  NULL,  /* lpcMaxValueLen */
!                  NULL,  /* lpcbSecurityDescriptor */
!                  NULL   /* lpftLastWriteTime */
!                  );
  
  
  	/* Having obtained a list of all available submounts, start
  	 * searching that list for a path which matches the requested
***************
*** 2078,2090 ****
  
  	nextAutoSubmount = 1;
  
! 	for (submountName = submountData;
!         	submountName && *submountName;
!         	submountName += 1+strlen(submountName)) {
! 
  		char submountPathNormalized[MAX_PATH];
  		char submountPath[MAX_PATH] = "";
! 		int submountPathLen;
  
  		/* If this is an Auto### submount, remember its ### value */
  
--- 2085,2099 ----
  
  	nextAutoSubmount = 1;
  
!     for ( dwIndex = 0; dwIndex < dwSubmounts; dwIndex ++ ) {
  		char submountPathNormalized[MAX_PATH];
  		char submountPath[MAX_PATH] = "";
! 		DWORD submountPathLen = sizeof(submountPath);
!         char submountName[256];
!         DWORD submountNameLen = sizeof(submountName);
! 
!         RegEnumValue( hkSubmounts, dwIndex, submountName, &submountNameLen, NULL,
!               &dwType, submountPath, &submountPathLen);
  
  		/* If this is an Auto### submount, remember its ### value */
  
***************
*** 2096,2109 ****
  						thisAutoSubmount+1);
  		}
  
- 		/* We have the name of a submount in the AFS Submounts
- 		 * section; read that entry to find out what path it
- 		 * maps to.
- 		 */
- 		submountPathLen = GetPrivateProfileString("AFS Submounts",
- 					submountName, "", submountPath,
- 					sizeof(submountPath), "afsdsbmt.ini");
- 
  		if ((submountPathLen == 0) ||
  		    (submountPathLen == sizeof(submountPath) - 1)) {
  			continue;
--- 2105,2110 ----
***************
*** 2115,2132 ****
  		 */
  		cm_NormalizeAfsPath (submountPathNormalized, submountPath);
  		if (!strcmp (submountPathNormalized, afspath)) {
- 
  			strcpy(ioctlp->outDatap, submountName);
  			ioctlp->outDatap += strlen(ioctlp->outDatap) +1;
! 			free (submountData);
  			lock_ReleaseMutex(&cm_Afsdsbmt_Lock);
!         		return 0;
  
  		}
  	}
  
- 	free (submountData);
- 
  	/* We've been through the entire list of existing submounts, and
  	 * didn't find any which matched the specified path. So, we'll
  	 * just have to add one. Remember not to write the leading "/afs"
--- 2116,2130 ----
  		 */
  		cm_NormalizeAfsPath (submountPathNormalized, submountPath);
  		if (!strcmp (submountPathNormalized, afspath)) {
  			strcpy(ioctlp->outDatap, submountName);
  			ioctlp->outDatap += strlen(ioctlp->outDatap) +1;
!             RegCloseKey(hkSubmounts);
  			lock_ReleaseMutex(&cm_Afsdsbmt_Lock);
!             return 0;
  
  		}
  	}
  
  	/* We've been through the entire list of existing submounts, and
  	 * didn't find any which matched the specified path. So, we'll
  	 * just have to add one. Remember not to write the leading "/afs"
***************
*** 2135,2146 ****
  
  	sprintf(ioctlp->outDatap, "auto%ld", nextAutoSubmount);
  
! 	WritePrivateProfileString("AFS Submounts", ioctlp->outDatap,
! 				  (strlen(&afspath[lstrlen(cm_mountRoot)])) ? 
! 				  &afspath[lstrlen(cm_mountRoot)]:"/",
! 				  "afsdsbmt.ini");
  
  	ioctlp->outDatap += strlen(ioctlp->outDatap) +1;
  	lock_ReleaseMutex(&cm_Afsdsbmt_Lock);
  	return 0;
  }
--- 2133,2149 ----
  
  	sprintf(ioctlp->outDatap, "auto%ld", nextAutoSubmount);
  
!     RegSetValueEx( hkSubmounts, 
!                    ioctlp->outDatap,
!                    0,
!                    REG_SZ, 
!                    (strlen(&afspath[strlen(cm_mountRoot)])) ?
!                    &afspath[strlen(cm_mountRoot)]:"/",
!                    (strlen(&afspath[strlen(cm_mountRoot)])) ?
!                    strlen(&afspath[strlen(cm_mountRoot)])+1:2);
  
  	ioctlp->outDatap += strlen(ioctlp->outDatap) +1;
+     RegCloseKey(hkSubmounts);
  	lock_ReleaseMutex(&cm_Afsdsbmt_Lock);
  	return 0;
  }
Index: openafs/src/WINNT/afsd/cm_scache.c
diff -c openafs/src/WINNT/afsd/cm_scache.c:1.11 openafs/src/WINNT/afsd/cm_scache.c:1.13
*** openafs/src/WINNT/afsd/cm_scache.c:1.11	Mon Jun  7 02:22:58 2004
--- openafs/src/WINNT/afsd/cm_scache.c	Mon Jul 26 15:08:42 2004
***************
*** 272,281 ****
  	// because we have to fill in the status stuff 'coz we
  	// don't want trybulkstat to fill it in for us
  #ifdef AFS_FREELANCE_CLIENT
! 	special = (fidp->cell==0x1 && fidp->volume==AFS_FAKE_ROOT_VOL_ID && 
  			   !(fidp->vnode==0x1 && fidp->unique==0x1));
! 	isRoot = (fidp->cell==0x1 && fidp->volume==AFS_FAKE_ROOT_VOL_ID && 
! 			   fidp->vnode==0x1 && fidp->unique==0x1);
  	if (cm_freelanceEnabled && isRoot) {
  		osi_Log0(afsd_logp,"cm_getSCache Freelance and isRoot");
            /* freelance: if we are trying to get the root scp for the first
--- 272,283 ----
  	// because we have to fill in the status stuff 'coz we
  	// don't want trybulkstat to fill it in for us
  #ifdef AFS_FREELANCE_CLIENT
! 	special = (fidp->cell==AFS_FAKE_ROOT_CELL_ID && 
!                fidp->volume==AFS_FAKE_ROOT_VOL_ID &&
  			   !(fidp->vnode==0x1 && fidp->unique==0x1));
! 	isRoot = (fidp->cell==AFS_FAKE_ROOT_CELL_ID && 
!               fidp->volume==AFS_FAKE_ROOT_VOL_ID &&
! 			  fidp->vnode==0x1 && fidp->unique==0x1);
  	if (cm_freelanceEnabled && isRoot) {
  		osi_Log0(afsd_logp,"cm_getSCache Freelance and isRoot");
            /* freelance: if we are trying to get the root scp for the first
***************
*** 295,301 ****
  		scp->volp = cm_rootSCachep->volp;
  		if (scp->dotdotFidp == (cm_fid_t *) NULL)
  			scp->dotdotFidp = (cm_fid_t *) malloc (sizeof(cm_fid_t));
! 		scp->dotdotFidp->cell=0x1;
  		scp->dotdotFidp->volume=AFS_FAKE_ROOT_VOL_ID;
  		scp->dotdotFidp->unique=1;
  		scp->dotdotFidp->vnode=1;
--- 297,303 ----
  		scp->volp = cm_rootSCachep->volp;
  		if (scp->dotdotFidp == (cm_fid_t *) NULL)
  			scp->dotdotFidp = (cm_fid_t *) malloc (sizeof(cm_fid_t));
! 		scp->dotdotFidp->cell=AFS_FAKE_ROOT_CELL_ID;
  		scp->dotdotFidp->volume=AFS_FAKE_ROOT_VOL_ID;
  		scp->dotdotFidp->unique=1;
  		scp->dotdotFidp->vnode=1;
***************
*** 592,598 ****
  #ifdef AFS_FREELANCE_CLIENT
  			&& (!cm_freelanceEnabled || !(!(scp->fid.vnode==0x1 &&
  				                         scp->fid.unique==0x1) &&
! 				                         scp->fid.cell==0x1 &&
  				                         scp->fid.volume==AFS_FAKE_ROOT_VOL_ID))
  #endif /* AFS_FREELANCE_CLIENT */
  		    ) {
--- 594,600 ----
  #ifdef AFS_FREELANCE_CLIENT
  			&& (!cm_freelanceEnabled || !(!(scp->fid.vnode==0x1 &&
  				                         scp->fid.unique==0x1) &&
! 				                         scp->fid.cell==AFS_FAKE_ROOT_CELL_ID &&
  				                         scp->fid.volume==AFS_FAKE_ROOT_VOL_ID))
  #endif /* AFS_FREELANCE_CLIENT */
  		    ) {
***************
*** 648,653 ****
--- 650,657 ----
  		osi_Log1(afsd_logp, "CM SyncOp sleeping scp %x", (long) scp);
          if ( scp->flags & CM_SCACHEFLAG_WAITING ) 
              osi_Log1(afsd_logp, "CM SyncOp CM_SCACHEFLAG_WAITING already set for 0x%x", scp);
+         else 
+             osi_Log1(afsd_logp, "CM SyncOp CM_SCACHEFLAG_WAITING set for 0x%x", scp);
  		scp->flags |= CM_SCACHEFLAG_WAITING;
  		if (bufLocked) lock_ReleaseMutex(&bufp->mx);
          osi_SleepM((long) &scp->flags, &scp->mx);
***************
*** 775,782 ****
          
          /* and wakeup anyone who is waiting */
          if (scp->flags & CM_SCACHEFLAG_WAITING) {
! 		scp->flags &= ~CM_SCACHEFLAG_WAITING;
!                 osi_Wakeup((long) &scp->flags);
          }
  }
  
--- 779,787 ----
          
          /* and wakeup anyone who is waiting */
          if (scp->flags & CM_SCACHEFLAG_WAITING) {
!             osi_Log1(afsd_logp, "CM SyncOp CM_SCACHEFLAG_WAITING reset for 0x%x", scp);
!             scp->flags &= ~CM_SCACHEFLAG_WAITING;
!             osi_Wakeup((long) &scp->flags);
          }
  }
  
Index: openafs/src/WINNT/afsd/cm_server.c
diff -c openafs/src/WINNT/afsd/cm_server.c:1.8 openafs/src/WINNT/afsd/cm_server.c:1.9
*** openafs/src/WINNT/afsd/cm_server.c:1.8	Sat Jun  5 14:57:58 2004
--- openafs/src/WINNT/afsd/cm_server.c	Wed Jul 14 02:34:09 2004
***************
*** 399,405 ****
           * for this server have a 0 refCount; otherwise, they will
           * not be garbage collected 
           */
!         cm_GCConnections(&server);  /* connsp */
  
          lock_FinalizeMutex(&server->mx);
          if ( cm_allServersp == server )
--- 399,405 ----
           * for this server have a 0 refCount; otherwise, they will
           * not be garbage collected 
           */
!         cm_GCConnections(server);  /* connsp */
  
          lock_FinalizeMutex(&server->mx);
          if ( cm_allServersp == server )
Index: openafs/src/WINNT/afsd/cm_vnodeops.c
diff -c openafs/src/WINNT/afsd/cm_vnodeops.c:1.14 openafs/src/WINNT/afsd/cm_vnodeops.c:1.18
*** openafs/src/WINNT/afsd/cm_vnodeops.c:1.14	Sat Jun 19 12:00:13 2004
--- openafs/src/WINNT/afsd/cm_vnodeops.c	Tue Jul 27 17:34:46 2004
***************
*** 1010,1018 ****
                  return CM_ERROR_NOSUCHFILE;
          }
          else {  /* nonexistent dir on freelance root, so add it */
! 			osi_Log1(afsd_logp,"cm_Lookup adding mount for non-existent directory: %s", namep);
!             code = cm_FreelanceAddMount(namep, namep, "root.cell.",
! 					&rock.fid);
              if (code < 0) {   /* add mount point failed, so give up */
                  if (flags & CM_FLAG_CHECKPATH)
                      return CM_ERROR_NOSUCHPATH;
--- 1010,1018 ----
                  return CM_ERROR_NOSUCHFILE;
          }
          else {  /* nonexistent dir on freelance root, so add it */
! 			osi_Log1(afsd_logp,"cm_Lookup adding mount for non-existent directory: %s", 
!                      osi_LogSaveString(afsd_logp,namep));
! 			code = cm_FreelanceAddMount(namep, namep, "root.cell.", namep[0] == '.', &rock.fid);
              if (code < 0) {   /* add mount point failed, so give up */
                  if (flags & CM_FLAG_CHECKPATH)
                      return CM_ERROR_NOSUCHPATH;
***************
*** 1275,1280 ****
--- 1275,1283 ----
          	tp = pathp;
  		phase = 2;
  	}
+ 	if (tp == NULL) {
+ 		tp = "";
+ 	}
  	haveComponent = 0;
          psp = NULL;
          tscp = rootSCachep;
***************
*** 1548,1556 ****
  	// yj: if this is a mountpoint under root.afs then we don't want it
  	// to be bulkstat-ed, instead, we call getSCache directly and under
  	// getSCache, it is handled specially.
! 	if 	(cm_freelanceEnabled &&
!            tfid.cell==0x1 && tfid.volume==AFS_FAKE_ROOT_VOL_ID &&
! 			   !(tfid.vnode==0x1 && tfid.unique==0x1) )
  	{
          osi_Log0(afsd_logp, "cm_TryBulkProc Freelance calls cm_SCache on root.afs mountpoint");
  		return cm_GetSCache(&tfid, &tscp, NULL, NULL);
--- 1551,1560 ----
  	// yj: if this is a mountpoint under root.afs then we don't want it
  	// to be bulkstat-ed, instead, we call getSCache directly and under
  	// getSCache, it is handled specially.
! 	if 	( cm_freelanceEnabled &&
!           tfid.cell==AFS_FAKE_ROOT_CELL_ID && 
!           tfid.volume==AFS_FAKE_ROOT_VOL_ID &&
!           !(tfid.vnode==0x1 && tfid.unique==0x1) )
  	{
          osi_Log0(afsd_logp, "cm_TryBulkProc Freelance calls cm_SCache on root.afs mountpoint");
  		return cm_GetSCache(&tfid, &tscp, NULL, NULL);
Index: openafs/src/WINNT/afsd/cm_volume.c
diff -c openafs/src/WINNT/afsd/cm_volume.c:1.5 openafs/src/WINNT/afsd/cm_volume.c:1.6
*** openafs/src/WINNT/afsd/cm_volume.c:1.5	Sat Mar 20 12:23:48 2004
--- openafs/src/WINNT/afsd/cm_volume.c	Sat Jul 24 14:59:32 2004
***************
*** 287,295 ****
--- 287,307 ----
  	cm_mountRootGen++;
  	lock_ObtainMutex(&volp->mx);
  	volp->flags |= CM_VOLUMEFLAG_RESET;
+ #ifdef COMMENT
+     /* Mark the volume to be updated but don't update it now.
+      * This function is called only from within cm_Analyze
+      * when cm_ConnByMServers has failed with all servers down
+      * The problem is that cm_UpdateVolume is going to call
+      * cm_ConnByMServers which may cause a recursive chain
+      * of calls each returning a retry on failure.
+      * Instead, set the flag so the next time the volume is
+      * accessed by Name or ID the UpdateVolume call will
+      * occur.
+      */
  	code = cm_UpdateVolume(cellp, userp, reqp, volp);
  	if (code == 0)
  		volp->flags &= ~CM_VOLUMEFLAG_RESET;
+ #endif
  	lock_ReleaseMutex(&volp->mx);
  
  	cm_PutVolume(volp);
Index: openafs/src/WINNT/afsd/fs.c
diff -c openafs/src/WINNT/afsd/fs.c:1.15 openafs/src/WINNT/afsd/fs.c:1.16
*** openafs/src/WINNT/afsd/fs.c:1.15	Sat Jun 19 12:00:13 2004
--- openafs/src/WINNT/afsd/fs.c	Tue Jul 13 23:28:42 2004
***************
*** 3241,3249 ****
  {
  	struct cmd_item *ti;
  	char *share = NULL;
! 	char sbmtpath[256];
! 	char *policy;
! 	
  	for(ti=asp->parms[0].items; ti;ti=ti->next) {
  		share = ti->data;
  		if (share)
--- 3241,3248 ----
  {
  	struct cmd_item *ti;
  	char *share = NULL;
!     HKEY hkCSCPolicy;
! 
  	for(ti=asp->parms[0].items; ti;ti=ti->next) {
  		share = ti->data;
  		if (share)
***************
*** 3251,3270 ****
  			break;
  		}
  	}
! 	
  	if (share)
  	{
! #ifdef WIN32
!         if ( !IsAdmin() ) {
              fprintf (stderr,"Permission denied: requires Administrator access.\n");
              return EACCES;
          }
- #else /* WIN32 */
-         if (geteuid()) {
-             fprintf (stderr,"Permission denied: requires root access.\n");
-             return EACCES;
-         }
- #endif /* WIN32 */
  
          policy = "manual";
  		
--- 3250,3276 ----
  			break;
  		}
  	}
! 
  	if (share)
  	{
!         char *policy;
! 
!         RegCreateKeyEx( HKEY_LOCAL_MACHINE, 
!                         "SOFTWARE\\OpenAFS\\Client\\CSCPolicy",
!                         0, 
!                         "AFS", 
!                         REG_OPTION_NON_VOLATILE,
!                         KEY_WRITE,
!                         NULL, 
!                         &hkCSCPolicy,
!                         NULL );
! 
!         if ( !IsAdmin() || hkCSCPolicy == NULL ) {
              fprintf (stderr,"Permission denied: requires Administrator access.\n");
+             if ( hkCSCPolicy )
+                 RegCloseKey(hkCSCPolicy);
              return EACCES;
          }
  
          policy = "manual";
  		
***************
*** 3277,3306 ****
  		if (asp->parms[4].items)
  			policy = "disable";
  		
! 		strcpy(sbmtpath, "afsdsbmt.ini");
! 		WritePrivateProfileString("CSC Policy", share, policy, sbmtpath);
  		
  		printf("CSC policy on share \"%s\" changed to \"%s\".\n\n", share, policy);
  		printf("Close all applications that accessed files on this share or restart AFS Client for the change to take effect.\n"); 
  	}
  	else
  	{
! 		char policies[1024];
! 		DWORD len = sizeof(policies);
  
  		/* list current csc policies */
! 		strcpy(sbmtpath, "afsdsbmt.ini");
! 				
! 		GetPrivateProfileSection("CSC Policy", policies, len, sbmtpath);
  		
  		printf("Current CSC policies:\n");
! 		policy = policies;
! 		while (policy[0])
! 		{
! 			printf("  %s\n", policy);
! 			policy += strlen(policy) + 1;
  		}
  	}
  
  	return (0);
  }
--- 3283,3340 ----
  		if (asp->parms[4].items)
  			policy = "disable";
  		
!         RegSetValueEx( hkCSCPolicy, share, 0, REG_SZ, policy, strlen(policy)+1);
  		
  		printf("CSC policy on share \"%s\" changed to \"%s\".\n\n", share, policy);
  		printf("Close all applications that accessed files on this share or restart AFS Client for the change to take effect.\n"); 
  	}
  	else
  	{
!         DWORD dwIndex, dwPolicies;
! 		char policyName[256];
! 		DWORD policyNameLen;
!         char policy[256];
!         DWORD policyLen;
!         DWORD dwType;
  
  		/* list current csc policies */
! 		
!         RegCreateKeyEx( HKEY_LOCAL_MACHINE, 
!                         "SOFTWARE\\OpenAFS\\Client\\CSCPolicy",
!                         0, 
!                         "AFS", 
!                         REG_OPTION_NON_VOLATILE,
!                         KEY_READ|KEY_QUERY_VALUE,
!                         NULL, 
!                         &hkCSCPolicy,
!                         NULL );
! 
!         RegQueryInfoKey( hkCSCPolicy,
!                          NULL,  /* lpClass */
!                          NULL,  /* lpcClass */
!                          NULL,  /* lpReserved */
!                          NULL,  /* lpcSubKeys */
!                          NULL,  /* lpcMaxSubKeyLen */
!                          NULL,  /* lpcMaxClassLen */
!                          &dwPolicies, /* lpcValues */
!                          NULL,  /* lpcMaxValueNameLen */
!                          NULL,  /* lpcMaxValueLen */
!                          NULL,  /* lpcbSecurityDescriptor */
!                          NULL   /* lpftLastWriteTime */
!                          );
  		
  		printf("Current CSC policies:\n");
!         for ( dwIndex = 0; dwIndex < dwPolicies; dwIndex ++ ) {
! 
!             policyNameLen = sizeof(policyName);
!             policyLen = sizeof(policy);
!             RegEnumValue( hkCSCPolicy, dwIndex, policyName, &policyNameLen, NULL,
!                           &dwType, policy, &policyLen);
! 
! 			printf("  %s = %s\n", policyName, policy);
  		}
  	}
  
+     RegCloseKey(hkCSCPolicy);
  	return (0);
  }
Index: openafs/src/WINNT/afsd/lanahelper.cpp
diff -c openafs/src/WINNT/afsd/lanahelper.cpp:1.7 openafs/src/WINNT/afsd/lanahelper.cpp:1.8
*** openafs/src/WINNT/afsd/lanahelper.cpp:1.7	Mon Apr 26 21:26:01 2004
--- openafs/src/WINNT/afsd/lanahelper.cpp	Wed Jul 14 02:00:18 2004
***************
*** 1,3 ****
--- 1,28 ----
+ /*
+ 
+ Copyright 2004 by the Massachusetts Institute of Technology
+ 
+ All rights reserved.
+ 
+ Permission to use, copy, modify, and distribute this software and its
+ documentation for any purpose and without fee is hereby granted,
+ provided that the above copyright notice appear in all copies and that
+ both that copyright notice and this permission notice appear in
+ supporting documentation, and that the name of the Massachusetts
+ Institute of Technology (M.I.T.) not be used in advertising or publicity
+ pertaining to distribution of the software without specific, written
+ prior permission.
+ 
+ M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ M.I.T. BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ SOFTWARE.
+ 
+ */
+ 
  #include <windows.h>
  #include <winreg.h>
  #include <nb30.h>
Index: openafs/src/WINNT/afsd/lanahelper.h
diff -c openafs/src/WINNT/afsd/lanahelper.h:1.2 openafs/src/WINNT/afsd/lanahelper.h:1.3
*** openafs/src/WINNT/afsd/lanahelper.h:1.2	Fri Mar  5 18:09:25 2004
--- openafs/src/WINNT/afsd/lanahelper.h	Wed Jul 14 02:00:18 2004
***************
*** 1,3 ****
--- 1,28 ----
+ /*
+ 
+ Copyright 2004 by the Massachusetts Institute of Technology
+ 
+ All rights reserved.
+ 
+ Permission to use, copy, modify, and distribute this software and its
+ documentation for any purpose and without fee is hereby granted,
+ provided that the above copyright notice appear in all copies and that
+ both that copyright notice and this permission notice appear in
+ supporting documentation, and that the name of the Massachusetts
+ Institute of Technology (M.I.T.) not be used in advertising or publicity
+ pertaining to distribution of the software without specific, written
+ prior permission.
+ 
+ M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ M.I.T. BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ SOFTWARE.
+ 
+ */
+ 
  #ifndef __LANAHELPER_H__
  #define __LANAHELPER_H__
  
Index: openafs/src/WINNT/afsd/libafsconf.def
diff -c openafs/src/WINNT/afsd/libafsconf.def:1.2 openafs/src/WINNT/afsd/libafsconf.def:1.3
*** openafs/src/WINNT/afsd/libafsconf.def:1.2	Fri Oct  5 17:40:47 2001
--- openafs/src/WINNT/afsd/libafsconf.def	Thu Jul 22 05:23:52 2004
***************
*** 21,23 ****
--- 21,24 ----
       getAFSServer             @14
       cm_InitDNS               @15
       cm_GetConfigDir          @16
+   
\ No newline at end of file
Index: openafs/src/WINNT/afsd/logon_ad.cpp
diff -c /dev/null openafs/src/WINNT/afsd/logon_ad.cpp:1.5
*** /dev/null	Tue Jul 27 19:19:45 2004
--- openafs/src/WINNT/afsd/logon_ad.cpp	Thu Jul 22 19:21:06 2004
***************
*** 0 ****
--- 1,384 ----
+ /*
+ 
+ Copyright 2004 by the Massachusetts Institute of Technology
+ 
+ All rights reserved.
+ 
+ Permission to use, copy, modify, and distribute this software and its
+ documentation for any purpose and without fee is hereby granted,
+ provided that the above copyright notice appear in all copies and that
+ both that copyright notice and this permission notice appear in
+ supporting documentation, and that the name of the Massachusetts
+ Institute of Technology (M.I.T.) not be used in advertising or publicity
+ pertaining to distribution of the software without specific, written
+ prior permission.
+ 
+ M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ M.I.T. BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ SOFTWARE.
+ 
+ */
+ 
+ 
+ //#pragma keyword("interface",on)
+ #define interface struct
+ #define SECURITY_WIN32
+ #include "afslogon.h"
+ 
+ /**/
+ #include <security.h>
+ #include <ntsecapi.h>
+ #include <sddl.h>
+ #include <unknwn.h>
+ #include <oaidl.h>
+ #include <Iads.h>
+ #include <adshlp.h>
+ /**/
+ 
+ #define SEC_ERR_VALUE(v) if (status==v) return #v
+ 
+ char * _get_sec_err_text(SECURITY_STATUS status) {
+ 	SEC_ERR_VALUE(SEC_E_OK);
+ 	SEC_ERR_VALUE(SEC_I_CONTINUE_NEEDED);
+ 	SEC_ERR_VALUE(SEC_I_COMPLETE_NEEDED);
+ 	SEC_ERR_VALUE(SEC_I_COMPLETE_AND_CONTINUE);
+ 	SEC_ERR_VALUE(SEC_E_INCOMPLETE_MESSAGE);
+ 	SEC_ERR_VALUE(SEC_I_INCOMPLETE_CREDENTIALS);
+ 	SEC_ERR_VALUE(SEC_E_INVALID_HANDLE);
+ 	SEC_ERR_VALUE(SEC_E_TARGET_UNKNOWN);
+ 	SEC_ERR_VALUE(SEC_E_LOGON_DENIED);
+ 	SEC_ERR_VALUE(SEC_E_INTERNAL_ERROR);
+ 	SEC_ERR_VALUE(SEC_E_NO_CREDENTIALS);
+ 	SEC_ERR_VALUE(SEC_E_NO_AUTHENTICATING_AUTHORITY);
+ 	SEC_ERR_VALUE(SEC_E_INSUFFICIENT_MEMORY);
+ 	SEC_ERR_VALUE(SEC_E_INVALID_TOKEN);
+ 	SEC_ERR_VALUE(SEC_E_UNSUPPORTED_FUNCTION);
+ 	SEC_ERR_VALUE(SEC_E_WRONG_PRINCIPAL);
+ 	return "Unknown";
+ }
+ 
+ #undef SEC_ERR_VALUE
+ 
+ DWORD LogonSSP(PLUID lpLogonId, PCtxtHandle outCtx) {
+ 	DWORD code = 1;
+     SECURITY_STATUS status;
+ 	CredHandle creds;
+ 	CtxtHandle ctxclient,ctxserver;
+ 	TimeStamp expiry;
+ 	BOOL cont = TRUE;
+ 	BOOL first = TRUE;
+ 	SecBufferDesc sdescc,sdescs;
+ 	SecBuffer stokc,stoks;
+ 	ULONG cattrs,sattrs;
+ 	int iters = 10;
+ 
+ 	outCtx->dwLower = 0;
+ 	outCtx->dwUpper = 0;
+ 
+ 	cattrs = 0;
+ 	sattrs = 0;
+ 
+ 	status = AcquireCredentialsHandle(
+ 		NULL,
+ 		"Negotiate",
+ 		SECPKG_CRED_BOTH,
+ 		lpLogonId,
+ 		NULL,
+ 		NULL,
+ 		NULL,
+ 		&creds,
+ 		&expiry);
+ 
+ 	if (status != SEC_E_OK) {
+ 		DebugEvent("AcquireCredentialsHandle failed: %lX", status);
+ 		goto ghp_0;
+ 	}
+ 
+ 	sdescc.cBuffers = 1;
+ 	sdescc.pBuffers = &stokc;
+ 	sdescc.ulVersion = SECBUFFER_VERSION;
+ 
+ 	stokc.BufferType = SECBUFFER_TOKEN;
+ 	stokc.cbBuffer = 0;
+ 	stokc.pvBuffer = NULL;
+ 
+ 	sdescs.cBuffers = 1;
+ 	sdescs.pBuffers = &stoks;
+ 	sdescs.ulVersion = SECBUFFER_VERSION;
+ 
+ 	stoks.BufferType = SECBUFFER_TOKEN;
+ 	stoks.cbBuffer = 0;
+ 	stoks.pvBuffer = NULL;
+ 
+ 	do {
+ 		status = InitializeSecurityContext(
+ 			&creds,
+ 			((first)? NULL:&ctxclient),
+             NULL,
+ 			ISC_REQ_DELEGATE | ISC_REQ_ALLOCATE_MEMORY,
+ 			0,
+ 			SECURITY_NATIVE_DREP,
+ 			((first)?NULL:&sdescs),
+ 			0,
+ 			&ctxclient,
+ 			&sdescc,
+ 			&cattrs,
+ 			&expiry
+ 			);
+ 
+ 		DebugEvent("InitializeSecurityContext returns status[%lX](%s)",status,_get_sec_err_text(status));
+ 
+ 		if (!first) FreeContextBuffer(stoks.pvBuffer);
+         
+ 		if (status == SEC_I_COMPLETE_NEEDED || status == SEC_I_COMPLETE_AND_CONTINUE) {
+ 			CompleteAuthToken(&ctxclient, &sdescc);
+ 		}
+ 
+ 		if (status != SEC_I_CONTINUE_NEEDED && status != SEC_I_COMPLETE_AND_CONTINUE) {
+ 			cont = FALSE;
+ 		}
+ 
+ 		if (!stokc.cbBuffer && !cont) {
+ 			DebugEvent("Breaking out after InitializeSecurityContext");
+ 			break;
+ 		}
+ 
+ 		status = AcceptSecurityContext(
+ 			&creds,
+ 			((first)?NULL:&ctxserver),
+ 			&sdescc,
+ 			ASC_REQ_DELEGATE | ASC_REQ_ALLOCATE_MEMORY,
+ 			SECURITY_NATIVE_DREP,
+ 			&ctxserver,
+ 			&sdescs,
+ 			&sattrs,
+ 			&expiry);
+ 
+ 		DebugEvent("AcceptSecurityContext returns status[%lX](%s)", status, _get_sec_err_text(status));
+ 
+ 		FreeContextBuffer(stokc.pvBuffer);
+ 
+ 		if (status == SEC_I_COMPLETE_NEEDED || status == SEC_I_COMPLETE_AND_CONTINUE) {
+ 			CompleteAuthToken(&ctxserver,&sdescs);
+ 		}
+ 
+ 		if (status == SEC_I_CONTINUE_NEEDED || status == SEC_I_COMPLETE_AND_CONTINUE) {
+ 			cont = TRUE;
+ 		}
+ 
+ 		if (!cont)
+ 			FreeContextBuffer(stoks.pvBuffer);
+ 
+ 		first = FALSE;
+ 		iters--; /* just in case, hard limit on loop */
+ 	} while (cont && iters);
+ 
+ 	if (sattrs & ASC_RET_DELEGATE) {
+ 		DebugEvent("Received delegate context");
+ 		*outCtx = ctxserver;
+ 		code = 0;
+ 	} else {
+ 		DebugEvent("Didn't receive delegate context");
+ 		outCtx->dwLower = 0;
+ 		outCtx->dwUpper = 0;
+ 		DeleteSecurityContext(&ctxserver);
+ 	}
+ 
+ 	DeleteSecurityContext(&ctxclient);
+     FreeCredentialsHandle(&creds);
+ ghp_0:
+ 	return code;
+ }
+ 
+ DWORD QueryAdHomePathFromSid(char * homePath, size_t homePathLen, PSID psid, PWSTR domain) {
+ 	DWORD code = 1; /* default is failure */
+ 	NTSTATUS rv = 0;
+ 	HRESULT hr = S_OK;
+ 	LPWSTR p = NULL;
+ 	WCHAR adsPath[MAX_PATH] = L"";
+ 	BOOL coInitialized = FALSE;
+     CHAR ansidomain[256], *a;
+ 
+ 	homePath[0] = '\0';
+     
+     /* I trust this is an ASCII domain name */
+     for ( p=domain, a=ansidomain; *a = (CHAR)*p; p++, a++);
+     DebugEvent("Domain: %s", ansidomain);
+ 
+     if (ConvertSidToStringSidW(psid,&p)) {
+         IADsNameTranslate *pNto;
+ 
+         DebugEvent("Got SID string [%S]", p);
+ 
+         hr = CoInitialize(NULL);
+         if (SUCCEEDED(hr))
+             coInitialized = TRUE;
+ 
+         hr = CoCreateInstance( CLSID_NameTranslate,
+                                NULL,
+                                CLSCTX_INPROC_SERVER,
+                                IID_IADsNameTranslate,
+                                (void**)&pNto);
+ 
+         if (FAILED(hr)) { DebugEvent("Can't create nametranslate object"); }
+         else {
+             hr = pNto->Init(ADS_NAME_INITTYPE_GC,L"");
+             if (FAILED(hr)) { 
+                 DebugEvent("NameTranslate Init GC failed [%ld]", hr);
+                 if ( domain ) {
+                     hr = pNto->Init(ADS_NAME_INITTYPE_DOMAIN,domain);
+                     if (FAILED(hr)) { 
+                         DebugEvent("NameTranslate Init Domain failed [%ld]", hr);
+                     }
+                 }
+             }
+ 
+             if (!FAILED(hr)) {
+                 hr = pNto->Set(ADS_NAME_TYPE_SID_OR_SID_HISTORY_NAME, p);
+                 if (FAILED(hr)) { DebugEvent("Can't set sid string"); }
+                 else {
+                     BSTR bstr;
+ 
+                     hr = pNto->Get(ADS_NAME_TYPE_1779, &bstr);
+                     wcscpy(adsPath, bstr);
+ 
+                     SysFreeString(bstr);
+                 }
+             }
+             pNto->Release();
+         }
+ 
+         LocalFree(p);
+ 
+     } else {
+         DebugEvent("Can't convert sid to string");
+     }
+ 
+ 	if (adsPath[0]) {
+ 		WCHAR fAdsPath[MAX_PATH];
+ 		IADsUser *pAdsUser;
+ 		BSTR bstHomeDir = NULL;
+ 
+ 		hr = StringCchPrintfW(fAdsPath, MAX_PATH, L"LDAP://%s", adsPath);
+ 		if (hr != S_OK) {
+ 			DebugEvent("Can't format full adspath");
+ 			goto cleanup;
+ 		}
+ 
+ 		DebugEvent("Trying adsPath=[%S]", fAdsPath);
+ 
+ 		hr = ADsGetObject( fAdsPath, IID_IADsUser, (LPVOID *) &pAdsUser);
+ 		if (hr != S_OK) {
+ 			DebugEvent("Can't open IADs object");
+ 			goto cleanup;
+ 		}
+ 
+         hr = pAdsUser->get_Profile(&bstHomeDir);
+ 		if (hr != S_OK) {
+ 			DebugEvent("Can't get profile directory");
+ 			goto cleanup_homedir_section;
+ 		}
+ 
+ 		wcstombs(homePath, bstHomeDir, homePathLen);
+ 
+ 		DebugEvent("Got homepath [%s]", homePath);
+ 
+ 		SysFreeString(bstHomeDir);
+ 
+ 		code = 0;
+ 
+ cleanup_homedir_section:
+ 		pAdsUser->Release();
+ 	}
+ 
+ cleanup:
+ 	if (coInitialized)
+ 		CoUninitialize();
+ 
+ 	return code;               
+ }
+ 
+ /* Try to determine the user's AD home path.  *homePath is assumed to be at least MAXPATH bytes. 
+    If successful, opt.flags is updated with LOGON_FLAG_AD_REALM to indicate that we are dealing with
+    an AD realm. */
+ DWORD GetAdHomePath(char * homePath, size_t homePathLen, PLUID lpLogonId, LogonOptions_t * opt) {
+ 	CtxtHandle ctx;
+ 	DWORD code = 0;
+ 	SECURITY_STATUS status;
+ 
+ 	homePath[0] = '\0';
+ 
+ 	if (LogonSSP(lpLogonId,&ctx)) {
+         DebugEvent("Failed LogonSSP");
+ 		return 1;
+     } else {
+ 		status = ImpersonateSecurityContext(&ctx);
+ 		if (status == SEC_E_OK) {
+ 		    PSECURITY_LOGON_SESSION_DATA plsd;
+             NTSTATUS rv;
+ 
+             rv = LsaGetLogonSessionData(lpLogonId, &plsd);
+             if (rv == 0) {
+                 PWSTR domain;
+ 
+                 domain = (PWSTR)malloc(sizeof(WCHAR) * (plsd->LogonDomain.Length+1));
+                 memcpy(domain, plsd->LogonDomain.Buffer, sizeof(WCHAR) * (plsd->LogonDomain.Length));
+                 domain[plsd->LogonDomain.Length] = 0;
+ 
+                 if (!QueryAdHomePathFromSid(homePath,homePathLen,plsd->Sid,domain)) {
+                     DebugEvent("Returned home path [%s]",homePath);
+                     opt->flags |= LOGON_FLAG_AD_REALM;
+                 }
+                 free(domain);
+                 LsaFreeReturnBuffer(plsd);
+             } else {
+                 DebugEvent("LsaGetLogonSessionData failed [%lX]", rv);
+             }
+             RevertSecurityContext(&ctx);
+ 		} else {
+ 			DebugEvent("Can't impersonate context [%lX]",status);
+ 			code = 1;
+ 		}
+ 
+         DeleteSecurityContext(&ctx);
+ 		return code;
+ 	}
+ }
+ 
+ BOOL GetLocalShortDomain(PWSTR Domain)
+ {
+     HRESULT hr;
+     IADsADSystemInfo *pADsys;
+     BOOL coInitialized = FALSE;
+     BOOL retval = FALSE;
+ 
+     hr = CoInitialize(NULL);
+     if (SUCCEEDED(hr))
+         coInitialized = TRUE;
+ 
+     hr = CoCreateInstance(CLSID_ADSystemInfo,
+                            NULL,
+                            CLSCTX_INPROC_SERVER,
+                            IID_IADsADSystemInfo,
+                            (void**)&pADsys);
+     if ( !FAILED(hr) ) {
+         BSTR bstr;
+ 
+         hr = pADsys->get_DomainShortName(&bstr);
+         if ( !FAILED(hr) ) {
+             wcscpy( Domain, bstr );
+             SysFreeString(bstr);
+             retval = TRUE;
+         }
+         pADsys->Release();
+     }
+ 
+ 	if (coInitialized)
+ 		CoUninitialize();
+ 
+     return retval;
+ }
Index: openafs/src/WINNT/afsd/smb.c
diff -c openafs/src/WINNT/afsd/smb.c:1.42 openafs/src/WINNT/afsd/smb.c:1.51
*** openafs/src/WINNT/afsd/smb.c:1.42	Thu Jun  3 23:10:45 2004
--- openafs/src/WINNT/afsd/smb.c	Mon Jul 26 19:22:20 2004
***************
*** 9,16 ****
  
  //#define NOSERVICE 1
  
- #define NOMOREFILESFIX 1
- 
  #include <afs/param.h>
  #include <afs/stds.h>
  
--- 9,14 ----
***************
*** 28,33 ****
--- 26,32 ----
  #include <time.h>
  
  #include <osi.h>
+ #include <ntstatus.h>
  
  #include "afsd.h"
  
***************
*** 87,92 ****
--- 86,96 ----
  int smb_maxVCPerServer;
  int smb_maxMpxRequests;
  
+ int smb_authType = SMB_AUTH_EXTENDED; /* type of SMB auth to use. One of SMB_AUTH_* */
+ HANDLE smb_lsaHandle;
+ ULONG smb_lsaSecPackage;
+ LSA_STRING smb_lsaLogonOrigin;
+ 
  #define NCBmax MAXIMUM_WAIT_OBJECTS
  EVENT_HANDLE NCBavails[NCBmax], NCBevents[NCBmax];
  EVENT_HANDLE **NCBreturns;
***************
*** 187,192 ****
--- 191,206 ----
  
  extern char AFSConfigKeyName[];
  
+ char smb_ServerDomainName[MAX_COMPUTERNAME_LENGTH + 1] = ""; /* domain name */
+ int smb_ServerDomainNameLength = 0;
+ char smb_ServerOS[] = "Windows 5.0"; /* Faux OS String */
+ int smb_ServerOSLength = sizeof(smb_ServerOS);
+ char smb_ServerLanManager[] = "Windows 2000 LAN Manager"; /* Faux LAN Manager string */
+ int smb_ServerLanManagerLength = sizeof(smb_ServerLanManager);
+ 
+ /* Faux server GUID. This is never checked. */
+ GUID smb_ServerGUID = { 0x40015cb8, 0x058a, 0x44fc, { 0xae, 0x7e, 0xbb, 0x29, 0x52, 0xee, 0x7e, 0xff }};
+ 
  /*
   * Demo expiration
   *
***************
*** 251,256 ****
--- 265,274 ----
  		return "(23)ReceiveV3GetAttributes";
  	case 0x24:
  		return "(24)ReceiveV3LockingX";
+ 	case 0x25:
+ 		return "(25)ReceiveV3Trans";
+ 	case 0x26:
+ 		return "(26)ReceiveV3Trans[aux]";
  	case 0x29:
  		return "(29)SendCoreBadOp";
  	case 0x2b:
***************
*** 262,268 ****
  	case 0x32:
  		return "(32)ReceiveV3Tran2A";
  	case 0x33:
! 		return "(33)ReceiveV3Tran2A";
  	case 0x34:
  		return "(34)ReceiveV3FindClose";
  	case 0x35:
--- 280,286 ----
  	case 0x32:
  		return "(32)ReceiveV3Tran2A";
  	case 0x33:
! 		return "(33)ReceiveV3Tran2A[aux]";
  	case 0x34:
  		return "(34)ReceiveV3FindClose";
  	case 0x35:
***************
*** 337,342 ****
--- 355,377 ----
  	}
  }
  
+ char * myCrt_RapDispatch(int i)
+ {
+ 	switch(i)
+ 	{
+ 	default:
+ 		return "unknown RAP OP";
+ 	case 0:
+ 		return "RAP(0)NetShareEnum";
+ 	case 1:
+ 		return "RAP(1)NetShareGetInfo";
+ 	case 13:
+ 		return "RAP(13)NetServerGetInfo";
+ 	case 63:
+ 		return "RAP(63)NetWkStaGetInfo";
+ 	}
+ }
+ 
  /* scache must be locked */
  unsigned int smb_Attributes(cm_scache_t *scp)
  {
***************
*** 738,743 ****
--- 773,805 ----
  		lock_InitializeMutex(&vcp->mx, "vc_t mutex");
  		vcp->lsn = lsn;
  		vcp->lana = lana;
+         vcp->secCtx = NULL;
+ 
+ 		if (smb_authType == SMB_AUTH_NTLM || smb_authType == SMB_AUTH_EXTENDED) {
+             /* We must obtain a challenge for extended auth 
+              * in case the client negotiates smb v3 
+              */
+             NTSTATUS nts,ntsEx;
+ 			MSV1_0_LM20_CHALLENGE_REQUEST lsaReq;
+ 			PMSV1_0_LM20_CHALLENGE_RESPONSE lsaResp;
+ 			ULONG lsaRespSize;
+ 
+ 			lsaReq.MessageType = MsV1_0Lm20ChallengeRequest;
+ 
+ 			nts = LsaCallAuthenticationPackage( smb_lsaHandle,
+                                                 smb_lsaSecPackage,
+                                                 &lsaReq,
+                                                 sizeof(lsaReq),
+                                                 &lsaResp,
+                                                 &lsaRespSize,
+                                                 &ntsEx);
+ 			osi_assert(nts == STATUS_SUCCESS); /* this had better work! */
+ 
+ 			memcpy(vcp->encKey, lsaResp->ChallengeToClient, MSV1_0_CHALLENGE_LENGTH);
+             LsaFreeReturnBuffer(lsaResp);
+ 		}
+ 		else
+ 			memset(vcp->encKey, 0, MSV1_0_CHALLENGE_LENGTH);
  	}
  	lock_ReleaseWrite(&smb_rctLock);
  	return vcp;
***************
*** 963,979 ****
   * Return a pointer to a pathname extracted from a TID structure.  The
   * TID structure is not held; assume it won't go away.
   */
! char *smb_GetTIDPath(smb_vc_t *vcp, unsigned short tid)
  {
  	smb_tid_t *tidp;
! 	char *tpath;
  
  	tidp = smb_FindTID(vcp, tid, 0);
!     if (!tidp) 
!         return NULL;
! 	tpath = tidp->pathname;
  	smb_ReleaseTID(tidp);
! 	return tpath;
  }
  
  /* check to see if we have a chained fid, that is, a fid that comes from an
--- 1025,1047 ----
   * Return a pointer to a pathname extracted from a TID structure.  The
   * TID structure is not held; assume it won't go away.
   */
! long smb_LookupTIDPath(smb_vc_t *vcp, unsigned short tid, char ** treepath)
  {
  	smb_tid_t *tidp;
!     long code = 0;
  
  	tidp = smb_FindTID(vcp, tid, 0);
!     if (!tidp) {
!         *treepath = NULL;
!     } else {
!         if(tidp->flags & SMB_TIDFLAG_IPC) {
!             code = CM_ERROR_TIDIPC;
!             /* tidp->pathname would be NULL, but that's fine */
!         }
!         *treepath = tidp->pathname;
  	smb_ReleaseTID(tidp);
!     }
!     return code;
  }
  
  /* check to see if we have a chained fid, that is, a fid that comes from an
***************
*** 1136,1141 ****
--- 1204,1210 ----
  char VNComputerName[] = "%COMPUTERNAME%";
  char VNLCComputerName[] = "%LCCOMPUTERNAME%";
  
+ #ifdef DJGPP
  /* List available shares */
  int smb_ListShares()
  {
***************
*** 1199,1204 ****
--- 1268,1304 ----
  
  	return num_shares;
  }
+ #endif /* DJGPP */
+ 
+ typedef struct smb_findShare_rock {
+     char * shareName;
+     char * match;
+     int matchType;
+ } smb_findShare_rock_t;
+ 
+ #define SMB_FINDSHARE_EXACT_MATCH 1
+ #define SMB_FINDSHARE_PARTIAL_MATCH 2
+ 
+ long smb_FindShareProc(cm_scache_t *scp, cm_dirEntry_t *dep, void *rockp,
+ 	osi_hyper_t *offp)
+ {
+     int matchType = 0;
+     smb_findShare_rock_t * vrock = (smb_findShare_rock_t *) rockp;
+     if(!strnicmp(dep->name, vrock->shareName, 12)) {
+         if(!stricmp(dep->name, vrock->shareName))
+             matchType = SMB_FINDSHARE_EXACT_MATCH;
+         else
+             matchType = SMB_FINDSHARE_PARTIAL_MATCH;
+         if(vrock->match) free(vrock->match);
+         vrock->match = strdup(dep->name);
+         vrock->matchType = matchType;
+ 
+         if(matchType == SMB_FINDSHARE_EXACT_MATCH)
+             return CM_ERROR_STOPNOW;
+     }
+     return 0;
+ }
+ 
  
  /* find a shareName in the table of submounts */
  int smb_FindShare(smb_vc_t *vcp, smb_user_t *uidp, char *shareName,
***************
*** 1209,1225 ****
  	char *var;
  	char temp[1024];
  	DWORD sizeTemp;
      char sbmtpath[MAX_PATH];
      char *p, *q;
  	HKEY parmKey;
  	DWORD code;
      DWORD allSubmount = 1;
  
- 	if (strcmp(shareName, "IPC$") == 0) {
- 		*pathNamep = NULL;
- 		return 0;
- 	}
- 
      /* if allSubmounts == 0, only return the //mountRoot/all share 
       * if in fact it has been been created in the subMounts table.  
       * This is to allow sites that want to restrict access to the 
--- 1309,1322 ----
  	char *var;
  	char temp[1024];
  	DWORD sizeTemp;
+ #ifdef DJGPP
      char sbmtpath[MAX_PATH];
+ #endif
      char *p, *q;
  	HKEY parmKey;
  	DWORD code;
      DWORD allSubmount = 1;
  
      /* if allSubmounts == 0, only return the //mountRoot/all share 
       * if in fact it has been been created in the subMounts table.  
       * This is to allow sites that want to restrict access to the 
***************
*** 1250,1263 ****
  		return 1;
  	}
  
  #ifndef DJGPP
!     strcpy(sbmtpath, "afsdsbmt.ini");
  #else /* DJGPP */
      strcpy(sbmtpath, cm_confDir);
      strcat(sbmtpath, "/afsdsbmt.ini");
- #endif /* !DJGPP */
  	len = GetPrivateProfileString("AFS Submounts", shareName, "",
                                    pathName, sizeof(pathName), sbmtpath);
  	if (len != 0 && len != sizeof(pathName) - 1) {
          /* We can accept either unix or PC style AFS pathnames.  Convert
           * Unix-style to PC style here for internal use. 
--- 1347,1379 ----
  		return 1;
  	}
  
+     if (_stricmp(shareName, "IPC$") == 0 ||
+         _stricmp(shareName, SMB_IOCTL_FILENAME_NOSLASH) == 0 ||
+         _stricmp(shareName, "DESKTOP.INI") == 0
+          ) {
+ 		*pathNamep = NULL;
+ 		return 0;
+ 	}
+ 
  #ifndef DJGPP
! 	code = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\OpenAFS\\Client\\Submounts",
! 						0, KEY_QUERY_VALUE, &parmKey);
! 	if (code == ERROR_SUCCESS) {
!         len = sizeof(pathName);
!         code = RegQueryValueEx(parmKey, shareName, NULL, NULL,
!                                 (BYTE *) pathName, &len);
! 		if (code != ERROR_SUCCESS)
! 			len = 0;
!         RegCloseKey (parmKey);
! 	} else {
!         len = 0;
!     }   
  #else /* DJGPP */
      strcpy(sbmtpath, cm_confDir);
      strcat(sbmtpath, "/afsdsbmt.ini");
  	len = GetPrivateProfileString("AFS Submounts", shareName, "",
                                    pathName, sizeof(pathName), sbmtpath);
+ #endif /* !DJGPP */
  	if (len != 0 && len != sizeof(pathName) - 1) {
          /* We can accept either unix or PC style AFS pathnames.  Convert
           * Unix-style to PC style here for internal use. 
***************
*** 1307,1317 ****
          *pathNamep = strdup(p);
          return 1;
      } 
!     else /* create  \\<netbiosName>\<cellname>  */
      {
          char * p = shareName; 
          int rw = 0;
  
          if ( *p == '.' ) {
              p++;
              rw = 1;
--- 1423,1462 ----
          *pathNamep = strdup(p);
          return 1;
      } 
!     else
      {
+         /* First lookup shareName in root.afs */
+         cm_req_t req;
+         smb_findShare_rock_t vrock;
+         osi_hyper_t thyper;
          char * p = shareName; 
          int rw = 0;
  
+         /*  attempt to locate a partial match in root.afs.  This is because
+             when using the ANSI RAP calls, the share name is limited to 13 chars
+             and hence is truncated. Of course we prefer exact matches. */
+         cm_InitReq(&req);
+         thyper.HighPart = 0;
+         thyper.LowPart = 0;
+ 
+         vrock.shareName = shareName;
+         vrock.match = NULL;
+         vrock.matchType = 0;
+ 
+         cm_HoldSCache(cm_rootSCachep);
+         code = cm_ApplyDir(cm_rootSCachep, smb_FindShareProc, &vrock, &thyper,
+             (uidp? (uidp->unp ? uidp->unp->userp : NULL) : NULL), &req, NULL);
+         cm_ReleaseSCache(cm_rootSCachep);
+ 
+         if(vrock.matchType) {
+             sprintf(pathName,"/%s/",vrock.match);
+             *pathNamep = strdup(strlwr(pathName));
+             free(vrock.match);
+             return 1;
+         }
+ 
+         /* if we get here, there was no match for the share in root.afs */
+         /* so try to create  \\<netbiosName>\<cellname>  */
          if ( *p == '.' ) {
              p++;
              rw = 1;
***************
*** 1346,1381 ****
  {
  	DWORD len;
  	char policy[1024];
! 	char sbmtpath[256];
! 
! #ifndef DJGPP
!         strcpy(sbmtpath, "afsdsbmt.ini");
! #else /* DJGPP */
!         strcpy(sbmtpath, cm_confDir);
!         strcat(sbmtpath, "/afsdsbmt.ini");
! #endif /* !DJGPP */
! 	len = GetPrivateProfileString("CSC Policy", shareName, "",
! 				      policy, sizeof(policy), sbmtpath);
! 	if (len == 0 || len == sizeof(policy) - 1) {
! 		return CSC_POLICY_MANUAL;
! 	}
! 	
! 	if (stricmp(policy, "documents") == 0)
  	{
! 		return CSC_POLICY_DOCUMENTS;
  	}
! 	
! 	if (stricmp(policy, "programs") == 0)
  	{
! 		return CSC_POLICY_PROGRAMS;
  	}
! 	
! 	if (stricmp(policy, "disable") == 0)
  	{
! 		return CSC_POLICY_DISABLE;
  	}
  	
! 	return CSC_POLICY_MANUAL;
  }
  
  /* find a dir search structure by cookie value, and return it held.
--- 1491,1530 ----
  {
  	DWORD len;
  	char policy[1024];
!     DWORD dwType;
!     HKEY hkCSCPolicy;
!     int  retval = CSC_POLICY_MANUAL;
! 
!     RegCreateKeyEx( HKEY_LOCAL_MACHINE, 
!                     "SOFTWARE\\OpenAFS\\Client\\CSCPolicy",
!                     0, 
!                     "AFS", 
!                     REG_OPTION_NON_VOLATILE,
!                     KEY_READ,
!                     NULL, 
!                     &hkCSCPolicy,
!                     NULL );
! 
!     len = sizeof(policy);
!     if ( RegQueryValueEx( hkCSCPolicy, shareName, 0, &dwType, policy, &len ) ||
!          len == 0) {
! 		retval = CSC_POLICY_MANUAL;
!     }
! 	else if (stricmp(policy, "documents") == 0)
  	{
! 		retval = CSC_POLICY_DOCUMENTS;
  	}
! 	else if (stricmp(policy, "programs") == 0)
  	{
! 		retval = CSC_POLICY_PROGRAMS;
  	}
! 	else if (stricmp(policy, "disable") == 0)
  	{
! 		retval = CSC_POLICY_DISABLE;
  	}
  	
!     RegCloseKey(hkCSCPolicy);
! 	return retval;
  }
  
  /* find a dir search structure by cookie value, and return it held.
***************
*** 2097,2108 ****
      else if (code == CM_ERROR_AMBIGUOUS_FILENAME) {
  		NTStatus = 0xC0000035L;	/* Object name collision */
      }
  	else {
  		NTStatus = 0xC0982001L;	/* SMB non-specific error */
  	}
  
  	*NTStatusp = NTStatus;
! 	osi_Log2(smb_logp, "SMB SEND code %x as NT %x", code, NTStatus);
  }
  
  void smb_MapCoreError(long code, smb_vc_t *vcp, unsigned short *scodep,
--- 2246,2266 ----
      else if (code == CM_ERROR_AMBIGUOUS_FILENAME) {
  		NTStatus = 0xC0000035L;	/* Object name collision */
      }
+ 	else if (code == CM_ERROR_BADPASSWORD) {
+ 		NTStatus = 0xC000006DL; /* unknown username or bad password */
+ 	}
+ 	else if (code == CM_ERROR_BADLOGONTYPE) {
+ 		NTStatus = 0xC000015BL; /* logon type not granted */
+ 	}
+ 	else if (code == CM_ERROR_GSSCONTINUE) {
+ 		NTStatus = 0xC0000016L; /* more processing required */
+ 	}
  	else {
  		NTStatus = 0xC0982001L;	/* SMB non-specific error */
  	}
  
  	*NTStatusp = NTStatus;
! 	osi_Log2(smb_logp, "SMB SEND code %lX as NT %lX", code, NTStatus);
  }
  
  void smb_MapCoreError(long code, smb_vc_t *vcp, unsigned short *scodep,
***************
*** 2248,2253 ****
--- 2406,2416 ----
  		class = 1;
  		error = 183;     /* Samba uses this */
  	}
+ 	else if (code == CM_ERROR_BADPASSWORD || code == CM_ERROR_BADLOGONTYPE) {
+ 		/* we don't have a good way of reporting CM_ERROR_BADLOGONTYPE */
+ 		class = 2;
+ 		error = 2; /* bad password */
+ 	}
  	else {
  		class = 2;
  		error = 1;
***************
*** 2255,2261 ****
  
  	*scodep = error;
  	*classp = class;
! 	osi_Log3(smb_logp, "SMB SEND code %x as SMB %d: %d", code, class, error);
  }
  
  long smb_SendCoreBadOp(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp)
--- 2418,2424 ----
  
  	*scodep = error;
  	*classp = class;
! 	osi_Log3(smb_logp, "SMB SEND code %lX as SMB %d: %d", code, class, error);
  }
  
  long smb_SendCoreBadOp(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp)
***************
*** 2423,2440 ****
  long smb_ReceiveNegotiate(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp)
  {
  	char *namep;
  	int coreProtoIndex;
  	int v3ProtoIndex;
  	int NTProtoIndex;
! 	int protoIndex;			/* index we're using */
  	int namex;
  	int dbytes;
  	int entryLength;
  	int tcounter;
! 	char protocol_array[10][1024]; /* protocol signature of the client */
  
!         
! 	osi_Log1(smb_logp, "SMB receive negotiate; %d + 1 ongoing ops",
  			 ongoingOps - 1);
  	if (!isGateway) {
  		if (active_vcp) {
--- 2586,2607 ----
  long smb_ReceiveNegotiate(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp)
  {
  	char *namep;
+     char *datap;
  	int coreProtoIndex;
  	int v3ProtoIndex;
  	int NTProtoIndex;
! 	int protoIndex;			        /* index we're using */
  	int namex;
  	int dbytes;
  	int entryLength;
  	int tcounter;
! 	char protocol_array[10][1024];  /* protocol signature of the client */
!     int caps;                       /* capabilities */
!     time_t unixTime;
! 	long dosTime;
! 	TIME_ZONE_INFORMATION tzi;
  
!     osi_Log1(smb_logp, "SMB receive negotiate; %d + 1 ongoing ops",
  			 ongoingOps - 1);
  	if (!isGateway) {
  		if (active_vcp) {
***************
*** 2490,2532 ****
          namep += entryLength;
          tcounter++;		/* which proto entry we're looking at */
  	}
- #ifndef NOMOREFILESFIX
- 	/* 
- 	 * NOTE: We can determine what OS (NT4.0, W2K, W9X, etc)
- 	 * the client is running by reading the protocol signature.
- 	 * ie. the order in which it sends us the protocol list.
- 	 *
- 	 * Special handling for Windows 2000 clients (defect 11765 )
-      * <asanka:11Jun03> Proto signature is the same for Win XP. </>
- 	 */
- 	if (tcounter == 6) {
- 		int i = 0;
- 		smb_t *ip = (smb_t *) inp;
- 		smb_t *op = (smb_t *) outp;
- 
- 		if ((strcmp("PC NETWORK PROGRAM 1.0", protocol_array[0]) == 0) &&
- 			 (strcmp("LANMAN1.0", protocol_array[1]) == 0) &&
- 			 (strcmp("Windows for Workgroups 3.1a", protocol_array[2]) == 0) &&
- 			 (strcmp("LM1.2X002", protocol_array[3]) == 0) &&
- 			 (strcmp("LANMAN2.1", protocol_array[4]) == 0) &&
- 			 (strcmp("NT LM 0.12", protocol_array[5]) == 0)) {
- 			isWindows2000 = TRUE;
- 			osi_Log0(smb_logp, "Looks like a Windows 2000 client");
- 			/* 
- 			 * HACK: for now - just negotiate a lower protocol till we 
- 			 * figure out which flag/flag2 or some other field 
- 			 * (capabilities maybe?) to set in order for this to work
- 			 * correctly with Windows 2000 clients (defect 11765)
- 			 */
- 			NTProtoIndex = -1;
- 			/* Things to try (after looking at tcpdump output could be
- 			 * setting flags and flags2 to 0x98 and 0xc853 like this
- 			 * op->reb = 0x98; op->flg2 = 0xc853;
- 			 * osi_Log2(smb_logp, "Flags:0x%x Flags2:0x%x", ip->reb, ip->flg2);
- 			 */
- 		}	
- 	}	
- #endif /* NOMOREFILESFIX */
  
  	if (NTProtoIndex != -1) {
  		protoIndex = NTProtoIndex;
--- 2657,2662 ----
***************
*** 2545,2556 ****
  	if (protoIndex == -1)
  		return CM_ERROR_INVAL;
  	else if (NTProtoIndex != -1) {
! 		smb_SetSMBParm(outp, 0, protoIndex);
!         smb_SetSMBParmByte(outp, 1, 0);	/* share level security, no passwd encrypt */
          smb_SetSMBParm(outp, 1, smb_maxMpxRequests);	/* max multiplexed requests */
          smb_SetSMBParm(outp, 2, smb_maxVCPerServer);	/* max VCs per consumer/server connection */
!         smb_SetSMBParmLong(outp, 3, SMB_PACKETSIZE); /* xmit buffer size */
! 		smb_SetSMBParmLong(outp, 5, 65536);	/* raw buffer size */
          smb_SetSMBParm(outp, 7, 1);	/* next 2: session key */
          smb_SetSMBParm(outp, 8, 1);
  		/* 
--- 2675,2697 ----
  	if (protoIndex == -1)
  		return CM_ERROR_INVAL;
  	else if (NTProtoIndex != -1) {
!         smb_SetSMBParm(outp, 0, protoIndex);
! 		if (smb_authType != SMB_AUTH_NONE) {
! 			smb_SetSMBParmByte(outp, 1,
! 				NEGOTIATE_SECURITY_USER_LEVEL |
! 				NEGOTIATE_SECURITY_CHALLENGE_RESPONSE);	/* user level security, challenge response */
! 		} else {
!             smb_SetSMBParmByte(outp, 1, 0); /* share level auth with plaintext password. */
! 		}
          smb_SetSMBParm(outp, 1, smb_maxMpxRequests);	/* max multiplexed requests */
          smb_SetSMBParm(outp, 2, smb_maxVCPerServer);	/* max VCs per consumer/server connection */
!         smb_SetSMBParmLong(outp, 3, SMB_PACKETSIZE);    /* xmit buffer size */
! 		smb_SetSMBParmLong(outp, 5, SMB_MAXRAWSIZE);	/* raw buffer size */
!         /* The session key is not a well documented field however most clients
!          * will echo back the session key to the server.  Currently we are using
!          * the same value for all sessions.  We should generate a random value
!          * and store it into the vcp 
!          */
          smb_SetSMBParm(outp, 7, 1);	/* next 2: session key */
          smb_SetSMBParm(outp, 8, 1);
  		/* 
***************
*** 2568,2597 ****
  		 * and NT Find *
  		 * and NT SMB's *
  		 * and raw mode */
! 		smb_SetSMBParmLong(outp, 9, 0x251);	
! 		smb_SetSMBParmLong(outp, 11, 0);/* XXX server time: do we need? */
! 		smb_SetSMBParmLong(outp, 13, 0);/* XXX server date: do we need? */
! 		smb_SetSMBParm(outp, 15, 0);	/* XXX server tzone: do we need? */
! 		smb_SetSMBParmByte(outp, 16, 0);/* Encryption key length */
! 		smb_SetSMBDataLength(outp, 0);	/* perhaps should specify 8 bytes anyway */
  	}
  	else if (v3ProtoIndex != -1) {
  		smb_SetSMBParm(outp, 0, protoIndex);
! 		smb_SetSMBParm(outp, 1, 0);	/* share level security, no passwd encrypt */
  		smb_SetSMBParm(outp, 2, SMB_PACKETSIZE);
  		smb_SetSMBParm(outp, 3, smb_maxMpxRequests);	/* max multiplexed requests */
  		smb_SetSMBParm(outp, 4, smb_maxVCPerServer);	/* max VCs per consumer/server connection */
  		smb_SetSMBParm(outp, 5, 0);	/* no support of block mode for read or write */
  		smb_SetSMBParm(outp, 6, 1);	/* next 2: session key */
  		smb_SetSMBParm(outp, 7, 1);
! 		smb_SetSMBParm(outp, 8, 0);	/* XXX server time: do we need? */
! 		smb_SetSMBParm(outp, 9, 0);	/* XXX server date: do we need? */
! 		smb_SetSMBParm(outp, 10, 0);	/* XXX server tzone: do we need? */
! 		smb_SetSMBParm(outp, 11, 0);	/* resvd */
! 		smb_SetSMBParm(outp, 12, 0);	/* resvd */
! 		smb_SetSMBDataLength(outp, 0);	/* perhaps should specify 8 bytes anyway */
  	}
! 	else if (coreProtoIndex != -1) {
  		smb_SetSMBParm(outp, 0, protoIndex);
  		smb_SetSMBDataLength(outp, 0);
  	}
--- 2709,2808 ----
  		 * and NT Find *
  		 * and NT SMB's *
  		 * and raw mode */
!         caps = NTNEGOTIATE_CAPABILITY_NTSTATUS |
! 			   NTNEGOTIATE_CAPABILITY_NTFIND |
!                NTNEGOTIATE_CAPABILITY_RAWMODE |
! 			   NTNEGOTIATE_CAPABILITY_NTSMB;
! 
!         if ( smb_authType == SMB_AUTH_EXTENDED )
!             caps |= NTNEGOTIATE_CAPABILITY_EXTENDED_SECURITY;
! 
!         smb_SetSMBParmLong(outp, 9, caps);
! 		time(&unixTime);
! 		smb_SearchTimeFromUnixTime(&dosTime, unixTime);
! 		smb_SetSMBParmLong(outp, 11, LOWORD(dosTime));/* server time */
! 		smb_SetSMBParmLong(outp, 13, HIWORD(dosTime));/* server date */
! 
! 		GetTimeZoneInformation(&tzi);
! 		smb_SetSMBParm(outp, 15, (unsigned short) tzi.Bias);	/* server tzone */
! 
! 		if (smb_authType == SMB_AUTH_NTLM) {
! 			smb_SetSMBParmByte(outp, 16, MSV1_0_CHALLENGE_LENGTH);/* Encryption key length */
! 			smb_SetSMBDataLength(outp, MSV1_0_CHALLENGE_LENGTH + smb_ServerDomainNameLength);
! 			/* paste in encryption key */
! 			datap = smb_GetSMBData(outp, NULL);
! 			memcpy(datap,vcp->encKey,MSV1_0_CHALLENGE_LENGTH);
! 			/* and the faux domain name */
! 			strcpy(datap + MSV1_0_CHALLENGE_LENGTH,smb_ServerDomainName);
! 		} else if ( smb_authType == SMB_AUTH_EXTENDED ) {
!             void * secBlob;
! 			int secBlobLength;
! 
! 			smb_SetSMBParmByte(outp, 16, 0); /* Encryption key length */
! 
! 			smb_NegotiateExtendedSecurity(&secBlob, &secBlobLength);
! 
! 			smb_SetSMBDataLength(outp, secBlobLength + sizeof(smb_ServerGUID));
! 			
! 			datap = smb_GetSMBData(outp, NULL);
! 			memcpy(datap, &smb_ServerGUID, sizeof(smb_ServerGUID));
! 
! 			if (secBlob) {
! 				datap += sizeof(smb_ServerGUID);
! 				memcpy(datap, secBlob, secBlobLength);
! 				free(secBlob);
! 			}
!         } else {
! 			smb_SetSMBParmByte(outp, 16, 0); /* Encryption key length */
! 			smb_SetSMBDataLength(outp, 0);   /* Perhaps we should specify 8 bytes anyway */
! 		}
  	}
  	else if (v3ProtoIndex != -1) {
  		smb_SetSMBParm(outp, 0, protoIndex);
! 
!         /* NOTE: Extended authentication cannot be negotiated with v3
!          * therefore we fail over to NTLM 
!          */
!         if (smb_authType == SMB_AUTH_NTLM || smb_authType == SMB_AUTH_EXTENDED) {
! 			smb_SetSMBParm(outp, 1,
! 				NEGOTIATE_SECURITY_USER_LEVEL |
! 				NEGOTIATE_SECURITY_CHALLENGE_RESPONSE);	/* user level security, challenge response */
! 		} else {
! 			smb_SetSMBParm(outp, 1, 0); /* share level auth with clear password */
! 		}
  		smb_SetSMBParm(outp, 2, SMB_PACKETSIZE);
  		smb_SetSMBParm(outp, 3, smb_maxMpxRequests);	/* max multiplexed requests */
  		smb_SetSMBParm(outp, 4, smb_maxVCPerServer);	/* max VCs per consumer/server connection */
  		smb_SetSMBParm(outp, 5, 0);	/* no support of block mode for read or write */
  		smb_SetSMBParm(outp, 6, 1);	/* next 2: session key */
  		smb_SetSMBParm(outp, 7, 1);
! 		time(&unixTime);
! 		smb_SearchTimeFromUnixTime(&dosTime, unixTime);
! 		smb_SetSMBParm(outp, 8, LOWORD(dosTime));	/* server time */
! 		smb_SetSMBParm(outp, 9, HIWORD(dosTime));	/* server date */
! 
! 		GetTimeZoneInformation(&tzi);
! 		smb_SetSMBParm(outp, 10, (unsigned short) tzi.Bias);	/* server tzone */
! 
!         /* NOTE: Extended authentication cannot be negotiated with v3
!          * therefore we fail over to NTLM 
!          */
! 		if (smb_authType == SMB_AUTH_NTLM || smb_authType == SMB_AUTH_EXTENDED) {
! 			smb_SetSMBParm(outp, 11, MSV1_0_CHALLENGE_LENGTH);	/* encryption key length */
!             smb_SetSMBParm(outp, 12, 0);	/* resvd */
! 			smb_SetSMBDataLength(outp, MSV1_0_CHALLENGE_LENGTH + smb_ServerDomainNameLength);	/* perhaps should specify 8 bytes anyway */
! 			datap = smb_GetSMBData(outp, NULL);
! 			/* paste in a new encryption key */
! 			memcpy(datap, vcp->encKey, MSV1_0_CHALLENGE_LENGTH);
! 			/* and the faux domain name */
! 			strcpy(datap + MSV1_0_CHALLENGE_LENGTH, smb_ServerDomainName);
! 		} else {
! 			smb_SetSMBParm(outp, 11, 0); /* encryption key length */
! 			smb_SetSMBParm(outp, 12, 0); /* resvd */
! 			smb_SetSMBDataLength(outp, 0);
! 		}
  	}
! 	else if (coreProtoIndex != -1) {     /* not really supported anymore */
  		smb_SetSMBParm(outp, 0, protoIndex);
  		smb_SetSMBDataLength(outp, 0);
  	}
***************
*** 2605,2612 ****
  	while(1) {
  		count++;
  		thrd_Sleep(10000);
! 		if ((count % 360) == 0)		/* every hour */
! 			smb_CalculateNowTZ();
  		/* XXX GC dir search entries */
  	}
  }
--- 2816,2836 ----
  	while(1) {
  		count++;
  		thrd_Sleep(10000);
! 		if ((count % 360) == 0)	{	/* every hour */
!             struct tm myTime;
! 		 
!             /* Initialize smb_localZero */
!             myTime.tm_isdst = -1;		/* compute whether on DST or not */
!             myTime.tm_year = 70;
!             myTime.tm_mon = 0;
!             myTime.tm_mday = 1;
!             myTime.tm_hour = 0;
!             myTime.tm_min = 0;
!             myTime.tm_sec = 0;
!             smb_localZero = mktime(&myTime);
! 
!             smb_CalculateNowTZ();
!         }
  		/* XXX GC dir search entries */
  	}
  }
***************
*** 3140,3146 ****
  		spacep = inp->spacep;
  		smb_StripLastComponent(spacep->data, NULL, pathp);
  		lock_ReleaseMutex(&dsp->mx);
! 		tidPathp = smb_GetTIDPath(vcp, ((smb_t *)inp)->tid);
  		code = cm_NameI(cm_rootSCachep, spacep->data,
  						caseFold | CM_FLAG_FOLLOW, userp, tidPathp, &req, &scp);
  		lock_ObtainMutex(&dsp->mx);
--- 3364,3377 ----
  		spacep = inp->spacep;
  		smb_StripLastComponent(spacep->data, NULL, pathp);
  		lock_ReleaseMutex(&dsp->mx);
! 		code = smb_LookupTIDPath(vcp, ((smb_t *)inp)->tid, &tidPathp);
!         if(code) {
!             lock_ReleaseMutex(&dsp->mx);
!             cm_ReleaseUser(userp);
!             smb_DeleteDirSearch(dsp);
!             smb_ReleaseDirSearch(dsp);
!             return CM_ERROR_NOFILES;
!         }
  		code = cm_NameI(cm_rootSCachep, spacep->data,
  						caseFold | CM_FLAG_FOLLOW, userp, tidPathp, &req, &scp);
  		lock_ObtainMutex(&dsp->mx);
***************
*** 3517,3523 ****
  
  	caseFold = CM_FLAG_CASEFOLD;
  
! 	tidPathp = smb_GetTIDPath(vcp, ((smb_t *)inp)->tid);
  	code = cm_NameI(rootScp, pathp,
  					 caseFold | CM_FLAG_FOLLOW | CM_FLAG_CHECKPATH,
  					 userp, tidPathp, &req, &newScp);
--- 3748,3758 ----
  
  	caseFold = CM_FLAG_CASEFOLD;
  
! 	code = smb_LookupTIDPath(vcp, ((smb_t *)inp)->tid, &tidPathp);
!     if(code) {
!         cm_ReleaseUser(userp);
!         return CM_ERROR_NOSUCHPATH;
!     }
  	code = cm_NameI(rootScp, pathp,
  					 caseFold | CM_FLAG_FOLLOW | CM_FLAG_CHECKPATH,
  					 userp, tidPathp, &req, &newScp);
***************
*** 3586,3592 ****
  
  	caseFold = CM_FLAG_CASEFOLD;
  
! 	tidPathp = smb_GetTIDPath(vcp, ((smb_t *)inp)->tid);
  	code = cm_NameI(rootScp, pathp, caseFold | CM_FLAG_FOLLOW, userp,
  					tidPathp, &req, &newScp);
  
--- 3821,3831 ----
  
  	caseFold = CM_FLAG_CASEFOLD;
  
! 	code = smb_LookupTIDPath(vcp, ((smb_t *)inp)->tid, &tidPathp);
!     if(code) {
!         cm_ReleaseUser(userp);
!         return CM_ERROR_NOSUCHFILE;
!     }
  	code = cm_NameI(rootScp, pathp, caseFold | CM_FLAG_FOLLOW, userp,
  					tidPathp, &req, &newScp);
  
***************
*** 3684,3690 ****
  	/* we shouldn't need this for V3 requests, but we seem to */
  	caseFold = CM_FLAG_CASEFOLD;
  
! 	tidPathp = smb_GetTIDPath(vcp, ((smb_t *)inp)->tid);
  
  	/*
  	 * XXX Strange hack XXX
--- 3923,3933 ----
  	/* we shouldn't need this for V3 requests, but we seem to */
  	caseFold = CM_FLAG_CASEFOLD;
  
! 	code = smb_LookupTIDPath(vcp, ((smb_t *)inp)->tid, &tidPathp);
!     if(code) {
!         cm_ReleaseUser(userp);
!         return CM_ERROR_NOSUCHFILE;
!     }
  
  	/*
  	 * XXX Strange hack XXX
***************
*** 3862,3868 ****
  
  	caseFold = CM_FLAG_CASEFOLD;
  
! 	tidPathp = smb_GetTIDPath(vcp, ((smb_t *)inp)->tid);
      code = cm_NameI(cm_rootSCachep, pathp, caseFold | CM_FLAG_FOLLOW, userp,
                      tidPathp, &req, &scp);
          
--- 4105,4115 ----
  
  	caseFold = CM_FLAG_CASEFOLD;
  
! 	code = smb_LookupTIDPath(vcp, ((smb_t *)inp)->tid, &tidPathp);
!     if(code) {
!         cm_ReleaseUser(userp);
!         return CM_ERROR_NOSUCHPATH;
!     }
      code = cm_NameI(cm_rootSCachep, pathp, caseFold | CM_FLAG_FOLLOW, userp,
                      tidPathp, &req, &scp);
          
***************
*** 4012,4018 ****
  
  	caseFold = CM_FLAG_FOLLOW | CM_FLAG_CASEFOLD;
  
! 	tidPathp = smb_GetTIDPath(vcp, ((smb_t *)inp)->tid);
  	code = cm_NameI(cm_rootSCachep, spacep->data, caseFold, userp, tidPathp,
  					&req, &dscp);
  
--- 4259,4269 ----
  
  	caseFold = CM_FLAG_FOLLOW | CM_FLAG_CASEFOLD;
  
! 	code = smb_LookupTIDPath(vcp, ((smb_t *)inp)->tid, &tidPathp);
!     if(code) {
!         cm_ReleaseUser(userp);
!         return CM_ERROR_NOSUCHPATH;
!     }
  	code = cm_NameI(cm_rootSCachep, spacep->data, caseFold, userp, tidPathp,
  					&req, &dscp);
  
***************
*** 4162,4168 ****
    */
  	caseFold = CM_FLAG_FOLLOW | CM_FLAG_CASEFOLD;
  
! 	tidPathp = smb_GetTIDPath(vcp, ((smb_t *)inp)->tid);
  	code = cm_NameI(cm_rootSCachep, spacep->data, caseFold,
  					userp, tidPathp, &req, &oldDscp);
  
--- 4413,4423 ----
    */
  	caseFold = CM_FLAG_FOLLOW | CM_FLAG_CASEFOLD;
  
! 	code = smb_LookupTIDPath(vcp, ((smb_t *)inp)->tid, &tidPathp);
!     if(code) {
!         cm_ReleaseUser(userp);
!         return CM_ERROR_NOSUCHPATH;
!     }
  	code = cm_NameI(cm_rootSCachep, spacep->data, caseFold,
  					userp, tidPathp, &req, &oldDscp);
  
***************
*** 4361,4367 ****
  
  	caseFold = CM_FLAG_CASEFOLD;
  
! 	tidPathp = smb_GetTIDPath(vcp, ((smb_t *)inp)->tid);
  	code = cm_NameI(cm_rootSCachep, spacep->data, caseFold | CM_FLAG_FOLLOW,
  					userp, tidPathp, &req, &dscp);
  
--- 4616,4626 ----
  
  	caseFold = CM_FLAG_CASEFOLD;
  
! 	code = smb_LookupTIDPath(vcp, ((smb_t *)inp)->tid, &tidPathp);
!     if(code) {
!         cm_ReleaseUser(userp);
!         return CM_ERROR_NOSUCHPATH;
!     }
  	code = cm_NameI(cm_rootSCachep, spacep->data, caseFold | CM_FLAG_FOLLOW,
  					userp, tidPathp, &req, &dscp);
  
***************
*** 4758,4763 ****
--- 5017,5025 ----
  	DWORD filter = 0;
  	cm_req_t req;
  
+     osi_Log3(smb_logp, "smb_WriteData fid %d, off 0x%x, size 0x%x",
+               fidp->fid, offsetp->LowPart, count);
+ 
  	cm_InitReq(&req);
  
  	bufferp = NULL;
***************
*** 4769,4778 ****
--- 5031,5044 ----
  	lock_ObtainMutex(&scp->mx);
  
  	/* start by looking up the file's end */
+     osi_Log1(smb_logp, "smb_WriteData fid %d calling cm_SyncOp NEEDCALLBACK|SETSTATUS|GETSTATUS",
+               fidp->fid);
  	code = cm_SyncOp(scp, NULL, userp, &req, 0,
  					 CM_SCACHESYNC_NEEDCALLBACK
  					 | CM_SCACHESYNC_SETSTATUS
  					 | CM_SCACHESYNC_GETSTATUS);
+     osi_Log2(smb_logp, "smb_WriteData fid %d calling cm_SyncOp NEEDCALLBACK|SETSTATUS|GETSTATUS returns %d",
+               fidp->fid,code);
  	if (code) 
  		goto done;
          
***************
*** 4850,4859 ****
--- 5116,5129 ----
  
  			/* now get the data in the cache */
  			while (1) {
+                 osi_Log1(smb_logp, "smb_WriteData fid %d calling cm_SyncOp NEEDCALLBACK|WRITE|BUFLOCKED",
+                           fidp->fid);
  				code = cm_SyncOp(scp, bufferp, userp, &req, 0,
  								 CM_SCACHESYNC_NEEDCALLBACK
  								 | CM_SCACHESYNC_WRITE
  								 | CM_SCACHESYNC_BUFLOCKED);
+                 osi_Log2(smb_logp, "smb_WriteData fid %d calling cm_SyncOp NEEDCALLBACK|WRITE|BUFLOCKED returns %d",
+                           fidp->fid,code);
  				if (code) 
  					goto done;
                                  
***************
*** 4956,4968 ****
  	}
  
  	if (code == 0 && doWriteBack) {
  		lock_ObtainMutex(&scp->mx);
! 		cm_SyncOp(scp, NULL, userp, &req, 0, CM_SCACHESYNC_ASYNCSTORE);
  		lock_ReleaseMutex(&scp->mx);
  		cm_QueueBKGRequest(scp, cm_BkgStore, writeBackOffset.LowPart,
  						   writeBackOffset.HighPart, cm_chunkSize, 0, userp);
  	}
  
  	return code;
  }
  
--- 5226,5245 ----
  	}
  
  	if (code == 0 && doWriteBack) {
+         long code2;
  		lock_ObtainMutex(&scp->mx);
!         osi_Log1(smb_logp, "smb_WriteData fid %d calling cm_SyncOp ASYNCSTORE",
!                   fidp->fid);
! 		code2 = cm_SyncOp(scp, NULL, userp, &req, 0, CM_SCACHESYNC_ASYNCSTORE);
!         osi_Log2(smb_logp, "smb_WriteData fid %d calling cm_SyncOp ASYNCSTORE returns %d",
!                   fidp->fid,code2);
  		lock_ReleaseMutex(&scp->mx);
  		cm_QueueBKGRequest(scp, cm_BkgStore, writeBackOffset.LowPart,
  						   writeBackOffset.HighPart, cm_chunkSize, 0, userp);
  	}
  
+     osi_Log2(smb_logp, "smb_WriteData fid %d returns %d",
+               fidp->fid, code);
  	return code;
  }
  
***************
*** 4986,4992 ****
      op = smb_GetSMBData(inp, NULL);
  	op = smb_ParseDataBlock(op, NULL, &inDataBlockCount);
  
!     osi_Log3(smb_logp, "smb_ReceiveCoreWrite fd %d, off 0x%x, size 0x%x",
               fd, offset.LowPart, count);
          
  	fd = smb_ChainFID(fd, inp);
--- 5263,5269 ----
      op = smb_GetSMBData(inp, NULL);
  	op = smb_ParseDataBlock(op, NULL, &inDataBlockCount);
  
!     osi_Log3(smb_logp, "smb_ReceiveCoreWrite fid %d, off 0x%x, size 0x%x",
               fd, offset.LowPart, count);
          
  	fd = smb_ChainFID(fd, inp);
***************
*** 5346,5352 ****
  
      caseFold = CM_FLAG_CASEFOLD;
  
! 	tidPathp = smb_GetTIDPath(vcp, ((smb_t *)inp)->tid);
  
  	code = cm_NameI(cm_rootSCachep, spacep->data,
                      caseFold | CM_FLAG_FOLLOW | CM_FLAG_CHECKPATH,
--- 5623,5633 ----
  
      caseFold = CM_FLAG_CASEFOLD;
  
! 	code = smb_LookupTIDPath(vcp, ((smb_t *)inp)->tid, &tidPathp);
!     if(code) {
!         cm_ReleaseUser(userp);
!         return CM_ERROR_NOSUCHPATH;
!     }
  
  	code = cm_NameI(cm_rootSCachep, spacep->data,
                      caseFold | CM_FLAG_FOLLOW | CM_FLAG_CHECKPATH,
***************
*** 5453,5459 ****
  
      caseFold = CM_FLAG_CASEFOLD;
  
! 	tidPathp = smb_GetTIDPath(vcp, ((smb_t *)inp)->tid);
  	code = cm_NameI(cm_rootSCachep, spacep->data, caseFold | CM_FLAG_FOLLOW,
                      userp, tidPathp, &req, &dscp);
  
--- 5734,5744 ----
  
      caseFold = CM_FLAG_CASEFOLD;
  
! 	code = smb_LookupTIDPath(vcp, ((smb_t *)inp)->tid, &tidPathp);
!     if(code) {
!         cm_ReleaseUser(userp);
!         return CM_ERROR_NOSUCHPATH;
!     }
  	code = cm_NameI(cm_rootSCachep, spacep->data, caseFold | CM_FLAG_FOLLOW,
                      userp, tidPathp, &req, &dscp);
  
***************
*** 5822,5830 ****
  				outWctp = outp->wctp;
  				smbp = (smb_t *) &outp->data;
  				if (code != CM_ERROR_PARTIALWRITE
! 				    && code != CM_ERROR_BUFFERTOOSMALL) {
  					/* nuke wct and bcc.  For a partial
! 					 * write, assume they're OK.
  					 */
  					*outWctp++ = 0;
  					*outWctp++ = 0;
--- 6107,6117 ----
  				outWctp = outp->wctp;
  				smbp = (smb_t *) &outp->data;
  				if (code != CM_ERROR_PARTIALWRITE
! 				    && code != CM_ERROR_BUFFERTOOSMALL 
!                     && code != CM_ERROR_GSSCONTINUE) {
  					/* nuke wct and bcc.  For a partial
! 					 * write or an in-process authentication handshake, 
!                      * assume they're OK.
  					 */
  					*outWctp++ = 0;
  					*outWctp++ = 0;
***************
*** 7084,7089 ****
--- 7371,7380 ----
  	smb_dispatchTable[0x23].procp = smb_ReceiveV3GetAttributes;
  	smb_dispatchTable[0x24].procp = smb_ReceiveV3LockingX;
  	smb_dispatchTable[0x24].flags |= SMB_DISPATCHFLAG_CHAINED;
+ 	smb_dispatchTable[0x25].procp = smb_ReceiveV3Trans;
+ 	smb_dispatchTable[0x25].flags |= SMB_DISPATCHFLAG_NORESPONSE;
+ 	smb_dispatchTable[0x26].procp = smb_ReceiveV3Trans;
+ 	smb_dispatchTable[0x26].flags |= SMB_DISPATCHFLAG_NORESPONSE;
  	smb_dispatchTable[0x29].procp = smb_SendCoreBadOp;	/* copy file */
  	smb_dispatchTable[0x2b].procp = smb_ReceiveCoreEcho;
  	/* Set NORESPONSE because smb_ReceiveCoreEcho() does the responses itself */
***************
*** 7138,7145 ****
--- 7429,7515 ----
  	smb_tran2DispatchTable[12].procp = smb_ReceiveTran2FindNotifyNext;
  	smb_tran2DispatchTable[13].procp = smb_ReceiveTran2MKDir;
  
+     /* setup the rap dispatch table */
+     memset(smb_rapDispatchTable, 0, sizeof(smb_rapDispatchTable));
+     smb_rapDispatchTable[0].procp = smb_ReceiveRAPNetShareEnum;
+     smb_rapDispatchTable[1].procp = smb_ReceiveRAPNetShareGetInfo;
+     smb_rapDispatchTable[63].procp = smb_ReceiveRAPNetWkstaGetInfo;
+     smb_rapDispatchTable[13].procp = smb_ReceiveRAPNetServerGetInfo;
+ 
  	smb3_Init();
  
+ 	/* if we are doing SMB authentication we have register outselves as a logon process */
+ 	if (smb_authType != SMB_AUTH_NONE) {
+         NTSTATUS nts;
+ 		LSA_STRING afsProcessName;
+ 		LSA_OPERATIONAL_MODE dummy; /*junk*/
+ 
+ 		afsProcessName.Buffer = "OpenAFSClientDaemon";
+ 		afsProcessName.Length = strlen(afsProcessName.Buffer);
+ 		afsProcessName.MaximumLength = afsProcessName.Length + 1;
+ 
+ 		nts = LsaRegisterLogonProcess(&afsProcessName, &smb_lsaHandle, &dummy);
+ 
+ 		if (nts == STATUS_SUCCESS) {
+ 			LSA_STRING packageName;
+ 			/* we are registered. Find out the security package id */
+ 			packageName.Buffer = MSV1_0_PACKAGE_NAME;
+ 			packageName.Length = strlen(packageName.Buffer);
+ 			packageName.MaximumLength = packageName.Length + 1;
+ 			nts = LsaLookupAuthenticationPackage(smb_lsaHandle, &packageName , &smb_lsaSecPackage);
+ 			if (nts == STATUS_SUCCESS) {
+ 				smb_lsaLogonOrigin.Buffer = "OpenAFS";
+ 				smb_lsaLogonOrigin.Length = strlen(smb_lsaLogonOrigin.Buffer);
+ 				smb_lsaLogonOrigin.MaximumLength = smb_lsaLogonOrigin.Length + 1;
+ 			} else {
+ 				afsi_log("Can't determine security package name for NTLM!! NTSTATUS=[%l]",nts);
+ 			}
+ 		} else {
+ 			afsi_log("Can't register logon process!! NTSTATUS=[%l]",nts);
+ 		}
+ 
+ 		if (nts != STATUS_SUCCESS) {
+ 			/* something went wrong. We report the error and revert back to no authentication
+ 			   because we can't perform any auth requests without a successful lsa handle
+ 			   or sec package id. */
+ 			afsi_log("Reverting to NO SMB AUTH");
+ 			smb_authType = SMB_AUTH_NONE;
+ 		} 
+ #ifdef COMMENT
+         /* Don't fallback to SMB_AUTH_NTLM.  Apparently, allowing SPNEGO to be used each
+          * time prevents the failure of authentication when logged into Windows with an
+          * external Kerberos principal mapped to a local account.
+          */
+         else if ( smb_authType == SMB_AUTH_EXTENDED) {
+             /* Test to see if there is anything to negotiate.  If SPNEGO is not going to be used 
+             * then the only option is NTLMSSP anyway; so just fallback. 
+             */
+             void * secBlob;
+             int secBlobLength;
+ 
+             smb_NegotiateExtendedSecurity(&secBlob, &secBlobLength);
+             if (secBlobLength == 0) {
+                 smb_authType = SMB_AUTH_NTLM;
+                 afsi_log("Reverting to SMB AUTH NTLM");
+             } else
+                 free(secBlob);
+         }
+ #endif
+ 	}
+ 
+ 	{
+ 		DWORD bufsize;
+ 		/* Now get ourselves a domain name. */
+ 		/* For now we are using the local computer name as the domain name.
+ 		* It is actually the domain for local logins, and we are acting as
+ 		* a local SMB server. 
+ 		*/
+ 		bufsize = sizeof(smb_ServerDomainName) - 1;
+ 		GetComputerName(smb_ServerDomainName, &bufsize);
+ 		smb_ServerDomainNameLength = bufsize + 1; /* bufsize doesn't include terminator */
+ 		afsi_log("Setting SMB server domain name to [%s]", smb_ServerDomainName);
+ 	}
+ 
  	/* Start listeners, waiters, servers, and daemons */
  
  	for (i = 0; i < lana_list.length; i++) {
Index: openafs/src/WINNT/afsd/smb.h
diff -c openafs/src/WINNT/afsd/smb.h:1.10 openafs/src/WINNT/afsd/smb.h:1.13
*** openafs/src/WINNT/afsd/smb.h:1.10	Thu Jun  3 23:10:45 2004
--- openafs/src/WINNT/afsd/smb.h	Mon Jul 26 19:22:20 2004
***************
*** 14,19 ****
--- 14,21 ----
  #include "netbios95.h"
  #endif /* DJGPP */
  
+ #include <ntsecapi.h>
+ 
  /* basic core protocol SMB structure */
  typedef struct smb {
  	unsigned char id[4];
***************
*** 43,49 ****
  #define SMB_FLAG_CREATE		1	/* create the structure if necessary */
  
  /* max # of bytes we'll receive in an incoming SMB message */
! #define SMB_PACKETSIZE	8400
  
  /* a packet structure for receiving SMB messages; locked by smb_globalLock.
   * Most of the work involved is in handling chained requests and responses.
--- 45,79 ----
  #define SMB_FLAG_CREATE		1	/* create the structure if necessary */
  
  /* max # of bytes we'll receive in an incoming SMB message */
! /* the maximum is 2^18-1 for NBT and 2^25-1 for Raw transport messages */
! /* we will use something smaller but large enough to be efficient */
! #define SMB_PACKETSIZE	32768 /* was 8400 */
! /* raw mode is considered obsolete and cannot be used with message signing */
! #define SMB_MAXRAWSIZE  65536
! 
! /* Negotiate protocol constants */
! /* Security */
! #define NEGOTIATE_SECURITY_USER_LEVEL               0x01
! #define NEGOTIATE_SECURITY_CHALLENGE_RESPONSE       0x02
! #define NEGOTIATE_SECURITY_SIGNATURES_ENABLED       0x04
! #define NEGOTIATE_SECURITY_SIGNATURES_REQUIRED      0x08
! 
! /* Capabilities */
! #define NTNEGOTIATE_CAPABILITY_RAWMODE				0x00000001L
! #define NTNEGOTIATE_CAPABILITY_MPXMODE				0x00000002L
! #define NTNEGOTIATE_CAPABILITY_UNICODE				0x00000004L
! #define NTNEGOTIATE_CAPABILITY_LARGEFILES			0x00000008L
! #define NTNEGOTIATE_CAPABILITY_NTSMB				0x00000010L
! #define NTNEGOTIATE_CAPABILITY_RPCAPI				0x00000020L
! #define NTNEGOTIATE_CAPABILITY_NTSTATUS				0x00000040L
! #define NTNEGOTIATE_CAPABILITY_LEVEL_II_OPLOCKS		0x00000080L
! #define NTNEGOTIATE_CAPABILITY_LOCK_AND_READ		0x00000100L
! #define NTNEGOTIATE_CAPABILITY_NTFIND				0x00000200L
! #define NTNEGOTIATE_CAPABILITY_DFS					0x00001000L
! #define NTNEGOTIATE_CAPABILITY_NT_INFO_PASSTHRU		0x00002000L
! #define NTNEGOTIATE_CAPABILITY_BULK_TRANSFER		0x20000000L
! #define NTNEGOTIATE_CAPABILITY_COMPRESSED			0x40000000L
! #define NTNEGOTIATE_CAPABILITY_EXTENDED_SECURITY	0x80000000L
  
  /* a packet structure for receiving SMB messages; locked by smb_globalLock.
   * Most of the work involved is in handling chained requests and responses.
***************
*** 111,133 ****
  /* one per virtual circuit */
  typedef struct smb_vc {
  	struct smb_vc *nextp;		/* not used */
!         int refCount;			/* the reference count */
!         long flags;			/* the flags, if any; locked by mx */
!         osi_mutex_t mx;			/* the mutex */
  	long vcID;			/* VC id */
!         unsigned short lsn;		/* the NCB LSN associated with this */
  	unsigned short uidCounter;	/* session ID counter */
!         unsigned short tidCounter;	/* tree ID counter */
!         unsigned short fidCounter;	/* file handle ID counter */
!         struct smb_tid *tidsp;		/* the first child in the tid list */
!         struct smb_user *usersp;	/* the first child in the user session list */
!         struct smb_fid *fidsp;		/* the first child in the open file list */
  	struct smb_user *justLoggedOut;	/* ready for profile upload? */
  	unsigned long logoffTime;	/* tick count when logged off */
  	/*struct cm_user *logonDLLUser;	/* integrated logon user */
  	unsigned char errorCount;
!         char rname[17];
  	int lana;
  } smb_vc_t;
  
  					/* have we negotiated ... */
--- 141,167 ----
  /* one per virtual circuit */
  typedef struct smb_vc {
  	struct smb_vc *nextp;		/* not used */
!     int refCount;			/* the reference count */
!     long flags;			/* the flags, if any; locked by mx */
!     osi_mutex_t mx;			/* the mutex */
  	long vcID;			/* VC id */
!     unsigned short lsn;		/* the NCB LSN associated with this */
  	unsigned short uidCounter;	/* session ID counter */
!     unsigned short tidCounter;	/* tree ID counter */
!     unsigned short fidCounter;	/* file handle ID counter */
!     struct smb_tid *tidsp;		/* the first child in the tid list */
!     struct smb_user *usersp;	/* the first child in the user session list */
!     struct smb_fid *fidsp;		/* the first child in the open file list */
  	struct smb_user *justLoggedOut;	/* ready for profile upload? */
  	unsigned long logoffTime;	/* tick count when logged off */
  	/*struct cm_user *logonDLLUser;	/* integrated logon user */
  	unsigned char errorCount;
!     char rname[17];
  	int lana;
+ 	char encKey[MSV1_0_CHALLENGE_LENGTH]; /* MSV1_0_CHALLENGE_LENGTH is 8 */
+     void * secCtx;              /* security context when negotiating SMB extended auth
+                                  * valid when SMB_VCFLAG_AUTH_IN_PROGRESS is set
+                                  */
  } smb_vc_t;
  
  					/* have we negotiated ... */
***************
*** 137,142 ****
--- 171,178 ----
  #define SMB_VCFLAG_STATUS32	8	/* use 32-bit NT status codes */
  #define SMB_VCFLAG_REMOTECONN	0x10	/* bad: remote conns not allowed */
  #define SMB_VCFLAG_ALREADYDEAD	0x20	/* do not get tokens from this vc */
+ #define SMB_VCFLAG_SESSX_RCVD	0x40	/* we received at least one session setups on this vc */
+ #define SMB_VCFLAG_AUTH_IN_PROGRESS 0x80 /* a SMB NT extended authentication is in progress */
  
  /* one per user session */
  typedef struct smb_user {
***************
*** 161,166 ****
--- 197,204 ----
  
  #define SMB_USERFLAG_DELETE	1	/* delete struct when ref count zero */
  
+ #define SMB_MAX_USERNAME_LENGTH 256
+ 
  /* one per tree-connect */
  typedef struct smb_tid {
  	struct smb_tid *nextp;		/* next sibling */
***************
*** 175,180 ****
--- 213,219 ----
  } smb_tid_t;
  
  #define SMB_TIDFLAG_DELETE	1	/* delete struct when ref count zero */
+ #define SMB_TIDFLAG_IPC	2 /* IPC$ */
  
  /* one per process ID */
  typedef struct smb_pid {
***************
*** 373,379 ****
  
  extern cm_user_t *smb_GetUser(smb_vc_t *vcp, smb_packet_t *inp);
  
! extern char *smb_GetTIDPath(smb_vc_t *vcp, unsigned short tid);
  
  extern smb_fid_t *smb_FindFID(smb_vc_t *vcp, unsigned short fid, int flags);
  
--- 412,418 ----
  
  extern cm_user_t *smb_GetUser(smb_vc_t *vcp, smb_packet_t *inp);
  
! extern long smb_LookupTIDPath(smb_vc_t *vcp, unsigned short tid, char ** tidPathp);
  
  extern smb_fid_t *smb_FindFID(smb_vc_t *vcp, unsigned short fid, int flags);
  
***************
*** 433,438 ****
--- 472,478 ----
  extern void smb_HoldVC(smb_vc_t *vcp);
  
  /* some globals, too */
+ extern char *smb_localNamep;
  extern int loggedOut;
  extern unsigned long loggedOutTime;
  extern char *loggedOutName;
***************
*** 453,465 ****
  extern int smb_hideDotFiles;
  extern unsigned int smb_IsDotFile(char *lastComp);
  
  extern void smb_FormatResponsePacket(smb_vc_t *vcp, smb_packet_t *inp,
  	smb_packet_t *op);
  
! extern char *myCrt_2Dispatch(int i); 
  
  extern char *myCrt_2Dispatch(int i);
  
  extern unsigned int smb_Attributes(cm_scache_t *scp);
  
  extern int smb_ChainFID(int fid, smb_packet_t *inp);
--- 493,540 ----
  extern int smb_hideDotFiles;
  extern unsigned int smb_IsDotFile(char *lastComp);
  
+ /* the following are used for smb auth */
+ extern int smb_authType; /* Type of SMB authentication to be used. One from below. */
+ 
+ #define SMB_AUTH_NONE 0
+ #define SMB_AUTH_NTLM 1
+ #define SMB_AUTH_EXTENDED 2
+ 
+ extern HANDLE smb_lsaHandle; /* LSA handle obtained during smb_init if using SMB auth */
+ extern ULONG smb_lsaSecPackage; /* LSA security package id. Set during smb_init */
+ extern char smb_ServerDomainName[];
+ extern int smb_ServerDomainNameLength;
+ extern char smb_ServerOS[];
+ extern int smb_ServerOSLength;
+ extern char smb_ServerLanManager[];
+ extern int smb_ServerLanManagerLength;
+ extern GUID smb_ServerGUID;
+ extern LSA_STRING smb_lsaLogonOrigin;
+ 
+ /* used for getting a challenge for SMB auth */
+ typedef struct _MSV1_0_LM20_CHALLENGE_REQUEST {  
+ 	MSV1_0_PROTOCOL_MESSAGE_TYPE MessageType;
+ } MSV1_0_LM20_CHALLENGE_REQUEST, *PMSV1_0_LM20_CHALLENGE_REQUEST;
+ 
+ typedef struct _MSV1_0_LM20_CHALLENGE_RESPONSE {  
+ 	MSV1_0_PROTOCOL_MESSAGE_TYPE MessageType;  
+ 	UCHAR ChallengeToClient[MSV1_0_CHALLENGE_LENGTH];
+ } MSV1_0_LM20_CHALLENGE_RESPONSE, *PMSV1_0_LM20_CHALLENGE_RESPONSE;
+ /**/
+ 
+ extern long smb_AuthenticateUserLM(smb_vc_t *vcp, char * accountName, char * primaryDomain, char * ciPwd, unsigned ciPwdLength, char * csPwd, unsigned csPwdLength);
+ 
+ extern long smb_GetNormalizedUsername(char * usern, const char * accountName, const char * domainName);
+ 
  extern void smb_FormatResponsePacket(smb_vc_t *vcp, smb_packet_t *inp,
  	smb_packet_t *op);
  
! extern char *myCrt_Dispatch(int i); 
  
  extern char *myCrt_2Dispatch(int i);
  
+ extern char *myCrt_RapDispatch(int i);
+ 
  extern unsigned int smb_Attributes(cm_scache_t *scp);
  
  extern int smb_ChainFID(int fid, smb_packet_t *inp);
Index: openafs/src/WINNT/afsd/smb3.c
diff -c openafs/src/WINNT/afsd/smb3.c:1.32 openafs/src/WINNT/afsd/smb3.c:1.39
*** openafs/src/WINNT/afsd/smb3.c:1.32	Thu Jun  3 23:10:45 2004
--- openafs/src/WINNT/afsd/smb3.c	Mon Jul 26 19:22:20 2004
***************
*** 12,17 ****
--- 12,20 ----
  
  #ifndef DJGPP
  #include <windows.h>
+ #define SECURITY_WIN32
+ #include <security.h>
+ #include <lmaccess.h>
  #endif /* !DJGPP */
  #include <stdlib.h>
  #include <malloc.h>
***************
*** 32,37 ****
--- 35,42 ----
  
  smb_tran2Dispatch_t smb_tran2DispatchTable[SMB_TRAN2_NOPCODES];
  
+ smb_tran2Dispatch_t smb_rapDispatchTable[SMB_RAP_NOPCODES];
+ 
  /* protected by the smb_globalLock */
  smb_tran2Packet_t *smb_tran2AssemblyQueuep;
  
***************
*** 106,140 ****
      return inp;
  }   
  
  long smb_ReceiveV3SessionSetupX(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp)
  {
      char *tp;
-     char *usern, *pwd, *pwdx;
      smb_user_t *uidp;
      unsigned short newUid;
!     unsigned long caps;
      cm_user_t *userp;
      smb_username_t *unp;
      char *s1 = " ";
  
      /* Check for bad conns */
      if (vcp->flags & SMB_VCFLAG_REMOTECONN)
          return CM_ERROR_REMOTECONN;
  
-     /* For NT LM 0.12 and up, get capabilities */
      if (vcp->flags & SMB_VCFLAG_USENT) {
!         caps = smb_GetSMBParm(inp, 11);
!         if (caps & 0x40)
              vcp->flags |= SMB_VCFLAG_STATUS32;
!         /* for now, ignore other capability bits */
!     }
  
!     /* Parse the data */
!     tp = smb_GetSMBData(inp, NULL);
!     if (vcp->flags & SMB_VCFLAG_USENT)
!         pwdx = smb_ParseString(tp, &tp);
!     pwd = smb_ParseString(tp, &tp);
!     usern = smb_ParseString(tp, &tp);
  
      /* On Windows 2000, this function appears to be called more often than
         it is expected to be called. This resulted in multiple smb_user_t
--- 111,784 ----
      return inp;
  }   
  
+ /*DEBUG do not checkin*/
+ void OutputDebugF(char * format, ...) {
+     va_list args;
+     int len;
+     char * buffer;
+ 
+     va_start( args, format );
+     len = _vscprintf( format, args ) // _vscprintf doesn't count
+                                + 3; // terminating '\0' + '\n'
+     buffer = malloc( len * sizeof(char) );
+     vsprintf( buffer, format, args );
+     strcat(buffer, "\n");
+     OutputDebugString(buffer);
+     free( buffer );
+ }
+ 
+ void OutputDebugHexDump(unsigned char * buffer, int len) {
+     int i,j,k;
+     char buf[256];
+     static char tr[16] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
+ 
+     OutputDebugF("Hexdump length [%d]",len);
+ 
+     for(i=0;i<len;i++) {
+         if(!(i%16)) {
+             if(i)
+                 OutputDebugString(buf);
+             sprintf(buf,"%5x",i);
+             memset(buf+5,' ',80);
+             buf[85] = 0;
+             strcat(buf,"\n");
+         }
+ 
+         j = (i%16);
+         j = j*3 + 7 + ((j>7)?1:0);
+         k = buffer[i];
+ 
+         buf[j] = tr[k / 16]; buf[j+1] = tr[k % 16];
+ 
+         j = (i%16);
+         j = j + 56 + ((j>7)?1:0);
+ 
+         buf[j] = (k>32 && k<127)?k:'.';
+     }    
+     if(i)
+         OutputDebugString(buf);
+ }   
+ /**/
+ 
+ #define SMB_EXT_SEC_PACKAGE_NAME "Negotiate"
+ void smb_NegotiateExtendedSecurity(void ** secBlob, int * secBlobLength){
+     SECURITY_STATUS status, istatus;
+ 	CredHandle creds = {0,0};
+ 	TimeStamp expiry;
+ 	SecBufferDesc secOut;
+ 	SecBuffer secTok;
+ 	CtxtHandle ctx;
+ 	ULONG flags;
+ 
+ 	*secBlob = NULL;
+ 	*secBlobLength = 0;
+ 
+     OutputDebugF("Negotiating Extended Security");
+ 
+ 	status = AcquireCredentialsHandle(
+ 		NULL,
+ 		SMB_EXT_SEC_PACKAGE_NAME,
+ 		SECPKG_CRED_INBOUND,
+ 		NULL,
+ 		NULL,
+ 		NULL,
+ 		NULL,
+ 		&creds,
+ 		&expiry);
+ 
+ 	if (status != SEC_E_OK) {
+ 		/* Really bad. We return an empty security blob */
+ 		OutputDebugF("AcquireCredentialsHandle failed with %lX", status);
+ 		goto nes_0;
+ 	}
+ 
+ 	secOut.cBuffers = 1;
+ 	secOut.pBuffers = &secTok;
+ 	secOut.ulVersion = SECBUFFER_VERSION;
+ 
+ 	secTok.BufferType = SECBUFFER_TOKEN;
+ 	secTok.cbBuffer = 0;
+ 	secTok.pvBuffer = NULL;
+ 
+         ctx.dwLower = ctx.dwUpper = 0;
+ 
+ 	status = AcceptSecurityContext(
+ 		&creds,
+ 		NULL,
+ 		NULL,
+         ASC_REQ_CONNECTION | ASC_REQ_EXTENDED_ERROR | ASC_REQ_ALLOCATE_MEMORY,
+ 		SECURITY_NETWORK_DREP,
+ 		&ctx,
+ 		&secOut,
+ 		&flags,
+ 		&expiry
+ 		);
+ 
+ 	if (status == SEC_I_COMPLETE_NEEDED || status == SEC_I_COMPLETE_AND_CONTINUE) {
+ 		OutputDebugF("Completing token...");
+ 		istatus = CompleteAuthToken(&ctx, &secOut);
+         if ( istatus != SEC_E_OK )
+             OutputDebugF("Token completion failed: %x", istatus);
+ 	}
+ 
+ 	if (status == SEC_I_COMPLETE_AND_CONTINUE || status == SEC_I_CONTINUE_NEEDED) {
+ 		if (secTok.pvBuffer) {
+ 			*secBlobLength = secTok.cbBuffer;
+ 			*secBlob = malloc( secTok.cbBuffer );
+ 			memcpy(*secBlob, secTok.pvBuffer, secTok.cbBuffer );
+ 		}
+ 	} else {
+         if ( status != SEC_E_OK )
+             OutputDebugF("AcceptSecurityContext status != CONTINUE  %lX", status);
+     }
+ 
+     /* Discard partial security context */
+     DeleteSecurityContext(&ctx);
+ 
+ 	if (secTok.pvBuffer) FreeContextBuffer( secTok.pvBuffer );
+ 
+ 	/* Discard credentials handle.  We'll reacquire one when we get the session setup X */
+ 	FreeCredentialsHandle(&creds);
+ 
+   nes_0:
+ 	return;
+ }
+ 
+ struct smb_ext_context {
+ 	CredHandle creds;
+ 	CtxtHandle ctx;
+ 	int partialTokenLen;
+ 	void * partialToken;
+ };
+ 
+ long smb_AuthenticateUserExt(smb_vc_t * vcp, char * usern, char * secBlobIn, int secBlobInLength, char ** secBlobOut, int * secBlobOutLength) {
+     SECURITY_STATUS status, istatus;
+ 	CredHandle creds;
+ 	TimeStamp expiry;
+ 	long code = 0;
+ 	SecBufferDesc secBufIn;
+ 	SecBuffer secTokIn;
+ 	SecBufferDesc secBufOut;
+ 	SecBuffer secTokOut;
+ 	CtxtHandle ctx;
+ 	struct smb_ext_context * secCtx = NULL;
+ 	struct smb_ext_context * newSecCtx = NULL;
+ 	void * assembledBlob = NULL;
+ 	int assembledBlobLength = 0;
+ 	ULONG flags;
+ 
+ 	OutputDebugF("In smb_AuthenticateUserExt");
+ 
+ 	*secBlobOut = NULL;
+ 	*secBlobOutLength = 0;
+ 
+ 	if (vcp->flags & SMB_VCFLAG_AUTH_IN_PROGRESS) {
+ 		secCtx = vcp->secCtx;
+ 		lock_ObtainMutex(&vcp->mx);
+ 		vcp->flags &= ~SMB_VCFLAG_AUTH_IN_PROGRESS;
+ 		vcp->secCtx = NULL;
+ 		lock_ReleaseMutex(&vcp->mx);
+ 	}
+ 
+     if (secBlobIn) {
+         OutputDebugF("Received incoming token:");
+         OutputDebugHexDump(secBlobIn,secBlobInLength);
+     }
+     
+     if (secCtx) {
+         OutputDebugF("Continuing with existing context.");		
+         creds = secCtx->creds;
+         ctx = secCtx->ctx;
+ 
+ 		if (secCtx->partialToken) {
+ 			assembledBlobLength = secCtx->partialTokenLen + secBlobInLength;
+ 			assembledBlob = malloc(assembledBlobLength);
+             memcpy(assembledBlob,secCtx->partialToken, secCtx->partialTokenLen);
+ 			memcpy(((BYTE *)assembledBlob) + secCtx->partialTokenLen, secBlobIn, secBlobInLength);
+ 		}
+ 	} else {
+ 		status = AcquireCredentialsHandle(
+ 			NULL,
+ 			SMB_EXT_SEC_PACKAGE_NAME,
+ 			SECPKG_CRED_INBOUND,
+ 			NULL,
+ 			NULL,
+ 			NULL,
+ 			NULL,
+ 			&creds,
+ 			&expiry);
+ 
+ 		if (status != SEC_E_OK) {
+ 			OutputDebugF("Can't acquire Credentials handle [%lX]", status);
+ 			code = CM_ERROR_BADPASSWORD; /* means "try again when I'm sober" */
+ 			goto aue_0;
+ 		}
+ 
+ 		ctx.dwLower = 0;
+ 		ctx.dwUpper = 0;
+ 	}
+ 
+     secBufIn.cBuffers = 1;
+ 	secBufIn.pBuffers = &secTokIn;
+ 	secBufIn.ulVersion = SECBUFFER_VERSION;
+ 
+ 	secTokIn.BufferType = SECBUFFER_TOKEN;
+ 	if (assembledBlob) {
+ 		secTokIn.cbBuffer = assembledBlobLength;
+ 		secTokIn.pvBuffer = assembledBlob;
+ 	} else {
+ 		secTokIn.cbBuffer = secBlobInLength;
+ 		secTokIn.pvBuffer = secBlobIn;
+ 	}
+ 
+ 	secBufOut.cBuffers = 1;
+ 	secBufOut.pBuffers = &secTokOut;
+ 	secBufOut.ulVersion = SECBUFFER_VERSION;
+ 
+ 	secTokOut.BufferType = SECBUFFER_TOKEN;
+ 	secTokOut.cbBuffer = 0;
+ 	secTokOut.pvBuffer = NULL;
+ 
+ 	status = AcceptSecurityContext(
+ 		&creds,
+ 		((secCtx)?&ctx:NULL),
+ 		&secBufIn,
+ 		ASC_REQ_CONNECTION | ASC_REQ_EXTENDED_ERROR	| ASC_REQ_ALLOCATE_MEMORY,
+ 		SECURITY_NETWORK_DREP,
+ 		&ctx,
+ 		&secBufOut,
+ 		&flags,
+ 		&expiry
+ 		);
+ 
+ 	if (status == SEC_I_COMPLETE_NEEDED || status == SEC_I_COMPLETE_AND_CONTINUE) {
+ 		OutputDebugF("Completing token...");
+ 		istatus = CompleteAuthToken(&ctx, &secBufOut);
+         if ( istatus != SEC_E_OK )
+             OutputDebugF("Token completion failed: %lX", istatus);
+ 	}
+ 
+ 	if (status == SEC_I_COMPLETE_AND_CONTINUE || status == SEC_I_CONTINUE_NEEDED) {
+ 		OutputDebugF("Continue needed");
+ 
+ 		newSecCtx = malloc(sizeof(*newSecCtx));
+ 
+ 		newSecCtx->creds = creds;
+ 		newSecCtx->ctx = ctx;
+ 		newSecCtx->partialToken = NULL;
+ 		newSecCtx->partialTokenLen = 0;
+ 
+ 		lock_ObtainMutex( &vcp->mx );
+ 		vcp->flags |= SMB_VCFLAG_AUTH_IN_PROGRESS;
+ 		vcp->secCtx = newSecCtx;
+ 		lock_ReleaseMutex( &vcp->mx );
+ 
+ 		code = CM_ERROR_GSSCONTINUE;
+ 	}
+ 
+ 	if ((status == SEC_I_COMPLETE_NEEDED || status == SEC_E_OK || 
+          status == SEC_I_COMPLETE_AND_CONTINUE || status == SEC_I_CONTINUE_NEEDED) && 
+         secTokOut.pvBuffer) {
+ 		OutputDebugF("Need to send token back to client");
+ 
+ 		*secBlobOutLength = secTokOut.cbBuffer;
+ 		*secBlobOut = malloc(secTokOut.cbBuffer);
+ 		memcpy(*secBlobOut, secTokOut.pvBuffer, secTokOut.cbBuffer);
+ 
+         OutputDebugF("Outgoing token:");
+         OutputDebugHexDump(*secBlobOut,*secBlobOutLength);
+ 	} else if (status == SEC_E_INCOMPLETE_MESSAGE) {
+ 		OutputDebugF("Incomplete message");
+ 
+ 		newSecCtx = malloc(sizeof(*newSecCtx));
+ 
+ 		newSecCtx->creds = creds;
+ 		newSecCtx->ctx = ctx;
+ 		newSecCtx->partialToken = malloc(secTokOut.cbBuffer);
+ 		memcpy(newSecCtx->partialToken, secTokOut.pvBuffer, secTokOut.cbBuffer);
+ 		newSecCtx->partialTokenLen = secTokOut.cbBuffer;
+ 
+ 		lock_ObtainMutex( &vcp->mx );
+ 		vcp->flags |= SMB_VCFLAG_AUTH_IN_PROGRESS;
+ 		vcp->secCtx = newSecCtx;
+ 		lock_ReleaseMutex( &vcp->mx );
+ 
+ 		code = CM_ERROR_GSSCONTINUE;
+ 	}
+ 
+ 	if (status == SEC_E_OK || status == SEC_I_COMPLETE_NEEDED) {
+ 		/* woo hoo! */
+ 		SecPkgContext_Names names;
+ 
+ 		OutputDebugF("Authentication completed");
+         OutputDebugF("Returned flags : [%lX]", flags);
+ 
+ 		if (!QueryContextAttributes(&ctx, SECPKG_ATTR_NAMES, &names)) {
+             OutputDebugF("Received name [%s]", names.sUserName);
+             strcpy(usern, names.sUserName);
+             strlwr(usern); /* in tandem with smb_GetNormalizedUsername */
+             FreeContextBuffer(names.sUserName);
+         } else {
+             /* Force the user to retry if the context is invalid */
+             OutputDebugF("QueryContextAttributes Names failed [%x]", GetLastError());
+             code = CM_ERROR_BADPASSWORD; 
+         }
+ 	} else if (!code) {
+         switch ( status ) {
+         case SEC_E_INVALID_TOKEN:
+             OutputDebugF("Returning bad password :: INVALID_TOKEN");
+             break;
+         case SEC_E_INVALID_HANDLE:
+             OutputDebugF("Returning bad password :: INVALID_HANDLE");
+             break;
+         case SEC_E_LOGON_DENIED:
+             OutputDebugF("Returning bad password :: LOGON_DENIED");
+             break;
+         case SEC_E_UNKNOWN_CREDENTIALS:
+             OutputDebugF("Returning bad password :: UNKNOWN_CREDENTIALS");
+             break;
+         case SEC_E_NO_CREDENTIALS:
+             OutputDebugF("Returning bad password :: NO_CREDENTIALS");
+             break;
+         case SEC_E_CONTEXT_EXPIRED:
+             OutputDebugF("Returning bad password :: CONTEXT_EXPIRED");
+             break;
+         case SEC_E_INCOMPLETE_CREDENTIALS:
+             OutputDebugF("Returning bad password :: INCOMPLETE_CREDENTIALS");
+             break;
+         case SEC_E_WRONG_PRINCIPAL:
+             OutputDebugF("Returning bad password :: WRONG_PRINCIPAL");
+             break;
+         case SEC_E_TIME_SKEW:
+             OutputDebugF("Returning bad password :: TIME_SKEW");
+             break;
+         default:
+             OutputDebugF("Returning bad password :: Status == %lX", status);
+         }
+ 		code = CM_ERROR_BADPASSWORD;
+ 	}
+ 
+ 	if (secCtx) {
+ 		if (secCtx->partialToken) free(secCtx->partialToken);
+ 		free(secCtx);
+ 	}
+ 
+ 	if (assembledBlob) {
+ 		free(assembledBlob);
+ 	}
+ 
+ 	if (secTokOut.pvBuffer)
+ 		FreeContextBuffer(secTokOut.pvBuffer);
+ 
+ 	if (code != CM_ERROR_GSSCONTINUE) {
+ 		DeleteSecurityContext(&ctx);
+ 		FreeCredentialsHandle(&creds);
+ 	}
+ 
+   aue_0:
+ 	return code;
+ }
+ 
+ #define P_LEN 256
+ #define P_RESP_LEN 128
+ 
+ /* LsaLogonUser expects input parameters to be in a contiguous block of memory. 
+    So put stuff in a struct. */
+ struct Lm20AuthBlob {
+ 	MSV1_0_LM20_LOGON lmlogon;
+ 	BYTE ciResponse[P_RESP_LEN];    /* Unicode representation */
+ 	BYTE csResponse[P_RESP_LEN];    /* ANSI representation */
+ 	WCHAR accountNameW[P_LEN];
+ 	WCHAR primaryDomainW[P_LEN];
+ 	WCHAR workstationW[MAX_COMPUTERNAME_LENGTH + 1];
+ 	TOKEN_GROUPS tgroups;
+ 	TOKEN_SOURCE tsource;
+ };
+ 
+ long smb_AuthenticateUserLM(smb_vc_t *vcp, char * accountName, char * primaryDomain, char * ciPwd, unsigned ciPwdLength, char * csPwd, unsigned csPwdLength) {
+ 
+ 	NTSTATUS nts, ntsEx;
+ 	struct Lm20AuthBlob lmAuth;
+ 	PMSV1_0_LM20_LOGON_PROFILE lmprofilep;
+ 	QUOTA_LIMITS quotaLimits;
+ 	DWORD size;
+ 	ULONG lmprofilepSize;
+ 	LUID lmSession;
+ 	HANDLE lmToken;
+ 
+ 	OutputDebugF("In smb_AuthenticateUser for user [%s] domain [%s]", accountName, primaryDomain);
+ 	OutputDebugF("ciPwdLength is %d and csPwdLength is %d", ciPwdLength, csPwdLength);
+ 
+ 	if (ciPwdLength > P_RESP_LEN || csPwdLength > P_RESP_LEN) {
+ 		OutputDebugF("ciPwdLength or csPwdLength is too long");
+ 		return CM_ERROR_BADPASSWORD;
+ 	}
+ 
+ 	memset(&lmAuth,0,sizeof(lmAuth));
+ 
+ 	lmAuth.lmlogon.MessageType = MsV1_0NetworkLogon;
+ 	
+ 	lmAuth.lmlogon.LogonDomainName.Buffer = lmAuth.primaryDomainW;
+ 	mbstowcs(lmAuth.primaryDomainW, primaryDomain, P_LEN);
+ 	lmAuth.lmlogon.LogonDomainName.Length = wcslen(lmAuth.primaryDomainW) * sizeof(WCHAR);
+ 	lmAuth.lmlogon.LogonDomainName.MaximumLength = P_LEN * sizeof(WCHAR);
+ 
+ 	lmAuth.lmlogon.UserName.Buffer = lmAuth.accountNameW;
+ 	mbstowcs(lmAuth.accountNameW, accountName, P_LEN);
+ 	lmAuth.lmlogon.UserName.Length = wcslen(lmAuth.accountNameW) * sizeof(WCHAR);
+ 	lmAuth.lmlogon.UserName.MaximumLength = P_LEN * sizeof(WCHAR);
+ 
+ 	lmAuth.lmlogon.Workstation.Buffer = lmAuth.workstationW;
+ 	lmAuth.lmlogon.Workstation.MaximumLength = (MAX_COMPUTERNAME_LENGTH + 1) * sizeof(WCHAR);
+ 	size = MAX_COMPUTERNAME_LENGTH + 1;
+ 	GetComputerNameW(lmAuth.workstationW, &size);
+     lmAuth.lmlogon.Workstation.Length = wcslen(lmAuth.workstationW) * sizeof(WCHAR);
+ 
+ 	memcpy(lmAuth.lmlogon.ChallengeToClient, vcp->encKey, MSV1_0_CHALLENGE_LENGTH);
+ 
+ 	lmAuth.lmlogon.CaseInsensitiveChallengeResponse.Buffer = lmAuth.ciResponse;
+ 	lmAuth.lmlogon.CaseInsensitiveChallengeResponse.Length = ciPwdLength;
+ 	lmAuth.lmlogon.CaseInsensitiveChallengeResponse.MaximumLength = P_RESP_LEN;
+ 	memcpy(lmAuth.ciResponse, ciPwd, ciPwdLength);
+ 
+ 	lmAuth.lmlogon.CaseSensitiveChallengeResponse.Buffer = lmAuth.csResponse;
+ 	lmAuth.lmlogon.CaseSensitiveChallengeResponse.Length = csPwdLength;
+ 	lmAuth.lmlogon.CaseSensitiveChallengeResponse.MaximumLength = P_RESP_LEN;
+ 	memcpy(lmAuth.csResponse, csPwd, csPwdLength);
+ 
+ 	lmAuth.lmlogon.ParameterControl = 0;
+ 
+ 	lmAuth.tgroups.GroupCount = 0;
+ 	lmAuth.tgroups.Groups[0].Sid = NULL;
+ 	lmAuth.tgroups.Groups[0].Attributes = 0;
+ 
+ 	lmAuth.tsource.SourceIdentifier.HighPart = 0;
+ 	lmAuth.tsource.SourceIdentifier.LowPart = (DWORD) vcp;
+ 	strcpy(lmAuth.tsource.SourceName,"OpenAFS"); /* 8 char limit */
+ 
+ 	nts = LsaLogonUser(
+ 		smb_lsaHandle,
+ 		&smb_lsaLogonOrigin,
+ 		Network, /*3*/
+         smb_lsaSecPackage,
+ 		&lmAuth,
+ 		sizeof(lmAuth),
+         &lmAuth.tgroups,
+ 		&lmAuth.tsource,
+ 		&lmprofilep,
+ 		&lmprofilepSize,
+ 		&lmSession,
+ 		&lmToken,
+ 		&quotaLimits,
+ 		&ntsEx);
+ 
+ 	OutputDebugF("Return from LsaLogonUser is 0x%lX", nts);
+ 	OutputDebugF("Extended status is 0x%lX", ntsEx);
+ 
+ 	if (nts == ERROR_SUCCESS) {
+ 		/* free the token */
+ 		LsaFreeReturnBuffer(lmprofilep);
+         CloseHandle(lmToken);
+ 		return 0;
+ 	} else {
+ 		/* No AFS for you */
+ 		if (nts == 0xC000015BL)
+ 			return CM_ERROR_BADLOGONTYPE;
+ 		else /* our catchall is a bad password though we could be more specific */
+ 			return CM_ERROR_BADPASSWORD;
+ 	}
+ }
+ 
+ /* The buffer pointed to by usern is assumed to be at least SMB_MAX_USERNAME_LENGTH bytes */
+ long smb_GetNormalizedUsername(char * usern, const char * accountName, const char * domainName) {
+ 
+ 	char * atsign;
+ 	const char * domain;
+ 
+ 	/* check if we have sane input */
+ 	if ((strlen(accountName) + strlen(domainName) + 1) > SMB_MAX_USERNAME_LENGTH)
+ 		return 1;
+ 
+ 	/* we could get : [accountName][domainName]
+ 	   [user][domain]
+ 	   [user@domain][]
+ 	   [user][]/[user][?]
+ 	   [][]/[][?] */
+ 
+ 	atsign = strchr(accountName, '@');
+ 
+ 	if (atsign) /* [user@domain][] -> [user@domain][domain] */
+ 		domain = atsign + 1;
+ 	else
+ 		domain = domainName;
+ 
+ 	/* if for some reason the client doesn't know what domain to use,
+ 		   it will either return an empty string or a '?' */
+ 	if (!domain[0] || domain[0] == '?')
+ 		/* Empty domains and empty usernames are usually sent from tokenless contexts.
+ 		   This way such logins will get an empty username (easy to check).  I don't know 
+ 		   when a non-empty username would be supplied with an anonymous domain, but *shrug* */
+ 		strcpy(usern,accountName);
+ 	else {
+ 		/* TODO: what about WIN.MIT.EDU\user vs. WIN\user? */
+ 		strcpy(usern,domain);
+ 		strcat(usern,"\\");
+ 		if (atsign)
+ 			strncat(usern,accountName,atsign - accountName);
+ 		else
+ 			strcat(usern,accountName);
+ 	}
+ 
+ 	strlwr(usern);
+ 
+ 	return 0;
+ }
+ 
+ /* When using SMB auth, all SMB sessions have to pass through here first to
+  * authenticate the user. 
+  * Caveat: If not use the SMB auth the protocol does not require sending a
+  * session setup packet, which means that we can't rely on a UID in subsequent
+  * packets.  Though in practice we get one anyway.
+  */
  long smb_ReceiveV3SessionSetupX(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp)
  {
      char *tp;
      smb_user_t *uidp;
      unsigned short newUid;
!     unsigned long caps = 0;
      cm_user_t *userp;
      smb_username_t *unp;
      char *s1 = " ";
+     long code = 0; 
+     char usern[SMB_MAX_USERNAME_LENGTH];
+     char *secBlobOut = NULL;
+     int  secBlobOutLength = 0;
  
      /* Check for bad conns */
      if (vcp->flags & SMB_VCFLAG_REMOTECONN)
          return CM_ERROR_REMOTECONN;
  
      if (vcp->flags & SMB_VCFLAG_USENT) {
!         if (smb_authType == SMB_AUTH_EXTENDED) {
!             /* extended authentication */
!             char *secBlobIn;
!             int secBlobInLength;
!         
!             if (!(vcp->flags & SMB_VCFLAG_SESSX_RCVD)) {
!                 caps = smb_GetSMBParm(inp,10) | (((unsigned long) smb_GetSMBParm(inp,11)) << 16);
!             }
! 
!             secBlobInLength = smb_GetSMBParm(inp, 7);
!             secBlobIn = smb_GetSMBData(inp, NULL);
! 
!             code = smb_AuthenticateUserExt(vcp, usern, secBlobIn, secBlobInLength, &secBlobOut, &secBlobOutLength);
! 
!             if (code == CM_ERROR_GSSCONTINUE) {
!                 smb_SetSMBParm(outp, 2, 0);
!                 smb_SetSMBParm(outp, 3, secBlobOutLength);
!                 smb_SetSMBDataLength(outp, secBlobOutLength + smb_ServerOSLength + smb_ServerLanManagerLength + smb_ServerDomainNameLength);
!                 tp = smb_GetSMBData(outp, NULL);
!                 if (secBlobOutLength) {
!                     memcpy(tp, secBlobOut, secBlobOutLength);
!                     free(secBlobOut);
!                     tp += secBlobOutLength;
!                 }	
!                 memcpy(tp,smb_ServerOS,smb_ServerOSLength);
!                 tp += smb_ServerOSLength;
!                 memcpy(tp,smb_ServerLanManager,smb_ServerLanManagerLength);
!                 tp += smb_ServerLanManagerLength;
!                 memcpy(tp,smb_ServerDomainName,smb_ServerDomainNameLength);
!                 tp += smb_ServerDomainNameLength;
!             }
! 
!             /* TODO: handle return code and continue auth. Also free secBlobOut if applicable. */
!         } else {
!             unsigned ciPwdLength, csPwdLength;
!             char *ciPwd, *csPwd;
!             char *accountName;
!             char *primaryDomain;
!             int  datalen;
! 
!             /* TODO: parse for extended auth as well */
!             ciPwdLength = smb_GetSMBParm(inp, 7); /* case insensitive password length */
!             csPwdLength = smb_GetSMBParm(inp, 8); /* case sensitive password length */
! 
!             tp = smb_GetSMBData(inp, &datalen);
! 
!             OutputDebugF("Session packet data size [%d]",datalen);
! 
!             ciPwd = tp;
!             tp += ciPwdLength;
!             csPwd = tp;
!             tp += csPwdLength;
! 
!             accountName = smb_ParseString(tp, &tp);
!             primaryDomain = smb_ParseString(tp, NULL);
! 
!             if (smb_GetNormalizedUsername(usern, accountName, primaryDomain)) {
!                 /* shouldn't happen */
!                 code = CM_ERROR_BADSMB;
!                 goto after_read_packet;
!             }
! 
!             /* capabilities are only valid for first session packet */
!             if (!(vcp->flags & SMB_VCFLAG_SESSX_RCVD)) {
!                 caps = smb_GetSMBParm(inp, 11) | (((unsigned long)smb_GetSMBParm(inp, 12)) << 16);
!             }
! 
!             if (smb_authType == SMB_AUTH_NTLM) {
!                 code = smb_AuthenticateUserLM(vcp, accountName, primaryDomain, ciPwd, ciPwdLength, csPwd, csPwdLength);
!             }
!         }
!     }  else { /* V3 */
!         unsigned ciPwdLength;
!         char *ciPwd;
! 		char *accountName;
! 		char *primaryDomain;
! 
! 		ciPwdLength = smb_GetSMBParm(inp, 7);
!         tp = smb_GetSMBData(inp, NULL);
! 		ciPwd = tp;
! 		tp += ciPwdLength;
! 
! 		accountName = smb_ParseString(tp, &tp);
! 		primaryDomain = smb_ParseString(tp, NULL);
! 
! 		if ( smb_GetNormalizedUsername(usern, accountName, primaryDomain)) {
! 			/* shouldn't happen */
! 			code = CM_ERROR_BADSMB;
!             goto after_read_packet;
! 		}
! 
!         /* even if we wanted extended auth, if we only negotiated V3, we have to fallback
!          * to NTLM.
!          */
! 		if (smb_authType == SMB_AUTH_NTLM || smb_authType == SMB_AUTH_EXTENDED) {
! 			code = smb_AuthenticateUserLM(vcp,accountName,primaryDomain,ciPwd,ciPwdLength,"",0);
! 		}
! 	}
! 
!   after_read_packet:
! 	/* note down that we received a session setup X and set the capabilities flag */
! 	if (!(vcp->flags & SMB_VCFLAG_SESSX_RCVD)) {
! 		lock_ObtainMutex(&vcp->mx);
! 		vcp->flags |= SMB_VCFLAG_SESSX_RCVD;
!         /* for the moment we can only deal with NTSTATUS */
!         if (caps & NTNEGOTIATE_CAPABILITY_NTSTATUS) {
              vcp->flags |= SMB_VCFLAG_STATUS32;
!         }
! 		lock_ReleaseMutex(&vcp->mx);
! 	}
! 
! 	/* code would be non-zero if there was an authentication failure.
! 	   Ideally we would like to invalidate the uid for this session or break
! 	   early to avoid accidently stealing someone else's tokens. */
! 
! 	if (code) {
! 		return code;
! 	}
  
! 	OutputDebugF("Received username=[%s]", usern);
  
      /* On Windows 2000, this function appears to be called more often than
         it is expected to be called. This resulted in multiple smb_user_t
***************
*** 189,196 ****
  
      osi_Log3(smb_logp, "SMB3 session setup name %s creating ID %d%s",
               osi_LogSaveString(smb_logp, usern), newUid, osi_LogSaveString(smb_logp, s1));
      smb_SetSMBParm(outp, 2, 0);
!     smb_SetSMBDataLength(outp, 0);
      return 0;
  }
  
--- 833,875 ----
  
      osi_Log3(smb_logp, "SMB3 session setup name %s creating ID %d%s",
               osi_LogSaveString(smb_logp, usern), newUid, osi_LogSaveString(smb_logp, s1));
+ 
      smb_SetSMBParm(outp, 2, 0);
! 
!     if (vcp->flags & SMB_VCFLAG_USENT) {
!         if (smb_authType == SMB_AUTH_EXTENDED) {
!             smb_SetSMBParm(outp, 3, secBlobOutLength);
!             smb_SetSMBDataLength(outp, secBlobOutLength + smb_ServerOSLength + smb_ServerLanManagerLength + smb_ServerDomainNameLength);
!             tp = smb_GetSMBData(outp, NULL);
!             if (secBlobOutLength) {
!                 memcpy(tp, secBlobOut, secBlobOutLength);
!                 free(secBlobOut);
!                 tp += secBlobOutLength;
!             }	
!             memcpy(tp,smb_ServerOS,smb_ServerOSLength);
!             tp += smb_ServerOSLength;
!             memcpy(tp,smb_ServerLanManager,smb_ServerLanManagerLength);
!             tp += smb_ServerLanManagerLength;
!             memcpy(tp,smb_ServerDomainName,smb_ServerDomainNameLength);
!             tp += smb_ServerDomainNameLength;
!         } else {
!             smb_SetSMBDataLength(outp, 0);
!         }
!     } else {
!         if (smb_authType == SMB_AUTH_EXTENDED) {
!             smb_SetSMBDataLength(outp, smb_ServerOSLength + smb_ServerLanManagerLength + smb_ServerDomainNameLength);
!             tp = smb_GetSMBData(outp, NULL);
!             memcpy(tp,smb_ServerOS,smb_ServerOSLength);
!             tp += smb_ServerOSLength;
!             memcpy(tp,smb_ServerLanManager,smb_ServerLanManagerLength);
!             tp += smb_ServerLanManagerLength;
!             memcpy(tp,smb_ServerDomainName,smb_ServerDomainNameLength);
!             tp += smb_ServerDomainNameLength;
!         } else {
!             smb_SetSMBDataLength(outp, 0);
!         }
!     }
! 
      return 0;
  }
  
***************
*** 212,221 ****
  		if (s2 == NULL) s2 = " ";
  		if (s1 == NULL) {s1 = s2; s2 = " ";}
  
! 		osi_Log4(smb_logp, "SMB3 user logoffX uid %d name %s%s%s",
!                   uidp->userID,
!                   osi_LogSaveString(smb_logp,
!                                     (uidp->unp) ? uidp->unp->name: " "), s1, s2);
  
  		lock_ObtainMutex(&uidp->mx);
  		uidp->flags |= SMB_USERFLAG_DELETE;
--- 891,898 ----
  		if (s2 == NULL) s2 = " ";
  		if (s1 == NULL) {s1 = s2; s2 = " ";}
  
! 		osi_Log4(smb_logp, "SMB3 user logoffX uid %d name %s%s%s", uidp->userID,
!                  osi_LogSaveString(smb_logp, (uidp->unp) ? uidp->unp->name: " "), s1, s2);
  
  		lock_ObtainMutex(&uidp->mx);
  		uidp->flags |= SMB_USERFLAG_DELETE;
***************
*** 247,252 ****
--- 924,930 ----
      char *passwordp;
  	char *servicep;
      cm_user_t *userp;
+ 	int ipc = 0;
          
  	osi_Log0(smb_logp, "SMB3 receive tree connect");
  
***************
*** 262,269 ****
      }
      strcpy(shareName, tp+1);
  
! 	if (strcmp(servicep, "IPC") == 0 || strcmp(shareName, "IPC$") == 0)
  		return CM_ERROR_NOIPC;
  
      userp = smb_GetUser(vcp, inp);
  
--- 940,957 ----
      }
      strcpy(shareName, tp+1);
  
!     osi_Log2(smb_logp, "Tree connect pathp[%s] shareName[%s]",
!         osi_LogSaveString(smb_logp, pathp),
!         osi_LogSaveString(smb_logp, shareName));
! 
! 	if (strcmp(servicep, "IPC") == 0 || strcmp(shareName, "IPC$") == 0) {
! #ifndef NO_IPC
! 		osi_Log0(smb_logp, "TreeConnectX connecting to IPC$");
! 		ipc = 1;
! #else
  		return CM_ERROR_NOIPC;
+ #endif
+ 	}
  
      userp = smb_GetUser(vcp, inp);
  
***************
*** 272,277 ****
--- 960,967 ----
  	lock_ReleaseMutex(&vcp->mx);
          
  	tidp = smb_FindTID(vcp, newTid, SMB_FLAG_CREATE);
+ 
+ 	if(!ipc) {
      uidp = smb_FindUID(vcp, ((smb_t *)inp)->uid, 0);
  	shareFound = smb_FindShare(vcp, uidp, shareName, &sharePath);
      if (uidp)
***************
*** 280,304 ****
  		smb_ReleaseTID(tidp);
  		return CM_ERROR_BADSHARENAME;
  	}
-     lock_ObtainMutex(&tidp->mx);
-     tidp->userp = userp;
- 	tidp->pathname = sharePath;
-     lock_ReleaseMutex(&tidp->mx);
-     smb_ReleaseTID(tidp);
  
  	if (vcp->flags & SMB_VCFLAG_USENT)
      {
          int policy = smb_FindShareCSCPolicy(shareName);
          smb_SetSMBParm(outp, 2, SMB_SUPPORT_SEARCH_BITS | (policy << 2));
      }
  
  	((smb_t *)outp)->tid = newTid;
  	((smb_t *)inp)->tid = newTid;
  	tp = smb_GetSMBData(outp, NULL);
      *tp++ = 'A';
      *tp++ = ':';
      *tp++ = 0;
      smb_SetSMBDataLength(outp, 3);
  
      osi_Log1(smb_logp, "SMB3 tree connect created ID %d", newTid);
      return 0;
--- 970,1005 ----
  		smb_ReleaseTID(tidp);
  		return CM_ERROR_BADSHARENAME;
  	}
  
  	if (vcp->flags & SMB_VCFLAG_USENT)
      {
          int policy = smb_FindShareCSCPolicy(shareName);
          smb_SetSMBParm(outp, 2, SMB_SUPPORT_SEARCH_BITS | (policy << 2));
      }
+ 	} else {
+ 		smb_SetSMBParm(outp, 2, 0);
+ 		sharePath = NULL;
+ 	}
+ 
+     lock_ObtainMutex(&tidp->mx);
+     tidp->userp = userp;
+ 	tidp->pathname = sharePath;
+ 	if(ipc) tidp->flags |= SMB_TIDFLAG_IPC;
+     lock_ReleaseMutex(&tidp->mx);
+     smb_ReleaseTID(tidp);
  
  	((smb_t *)outp)->tid = newTid;
  	((smb_t *)inp)->tid = newTid;
  	tp = smb_GetSMBData(outp, NULL);
+ 	if(!ipc) {
      *tp++ = 'A';
      *tp++ = ':';
      *tp++ = 0;
      smb_SetSMBDataLength(outp, 3);
+ 	} else {
+ 		strcpy(tp, "IPC");
+ 		smb_SetSMBDataLength(outp, 4);
+ 	}
  
      osi_Log1(smb_logp, "SMB3 tree connect created ID %d", newTid);
      return 0;
***************
*** 338,348 ****
      tp->pid = smbp->pid;
  	tp->res[0] = smbp->res[0];
  	osi_QAdd((osi_queue_t **)&smb_tran2AssemblyQueuep, &tp->q);
-     tp->opcode = smb_GetSMBParm(inp, 14);
  	if (totalParms != 0)
          tp->parmsp = malloc(totalParms);
  	if (totalData != 0)
          tp->datap = malloc(totalData);
  	tp->flags |= SMB_TRAN2PFLAG_ALLOC;
      return tp;
  }
--- 1039,1054 ----
      tp->pid = smbp->pid;
  	tp->res[0] = smbp->res[0];
  	osi_QAdd((osi_queue_t **)&smb_tran2AssemblyQueuep, &tp->q);
  	if (totalParms != 0)
          tp->parmsp = malloc(totalParms);
  	if (totalData != 0)
          tp->datap = malloc(totalData);
+ 	if (smbp->com == 0x25 || smbp->com == 0x26)
+ 		tp->com = 0x25;
+ 	else {
+ 	    tp->opcode = smb_GetSMBParm(inp, 14);
+ 		tp->com = 0x32;
+ 	}
  	tp->flags |= SMB_TRAN2PFLAG_ALLOC;
      return tp;
  }
***************
*** 369,374 ****
--- 1075,1081 ----
      tp->pid = inp->pid;
  	tp->res[0] = inp->res[0];
      tp->opcode = inp->opcode;
+ 	tp->com = inp->com;
  
  	/*
  	 * We calculate where the parameters and data will start.
***************
*** 425,431 ****
  		smbp->flg2 |= 0x40;	/* IS_LONG_NAME */
          
      /* now copy important fields from the tran 2 packet */
!     smbp->com = 0x32;		/* tran 2 response */
      smbp->tid = t2p->tid;
      smbp->mid = t2p->mid;
      smbp->pid = t2p->pid;
--- 1132,1138 ----
  		smbp->flg2 |= 0x40;	/* IS_LONG_NAME */
          
      /* now copy important fields from the tran 2 packet */
!     smbp->com = t2p->com;
      smbp->tid = t2p->tid;
      smbp->mid = t2p->mid;
      smbp->pid = t2p->pid;
***************
*** 465,471 ****
  		smbp->flg2 |= 0x40;	/* IS_LONG_NAME */
  
      /* now copy important fields from the tran 2 packet */
!     smbp->com = 0x32;		/* tran 2 response */
      smbp->tid = t2p->tid;
      smbp->mid = t2p->mid;
      smbp->pid = t2p->pid;
--- 1172,1178 ----
  		smbp->flg2 |= 0x40;	/* IS_LONG_NAME */
  
      /* now copy important fields from the tran 2 packet */
!     smbp->com = t2p->com;
      smbp->tid = t2p->tid;
      smbp->mid = t2p->mid;
      smbp->pid = t2p->pid;
***************
*** 503,508 ****
--- 1210,1853 ----
      smb_SendPacket(vcp, tp);
  }   
  
+ long smb_ReceiveV3Trans(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp)
+ {
+     smb_tran2Packet_t *asp;
+     int totalParms;
+     int totalData;
+     int parmDisp;
+     int dataDisp;
+     int parmOffset;
+     int dataOffset;
+     int parmCount;
+     int dataCount;
+     int firstPacket;
+ 	int rapOp;
+     long code = 0;
+ 
+ 	/* We sometimes see 0 word count.  What to do? */
+ 	if (*inp->wctp == 0) {
+ #ifndef DJGPP
+ 		HANDLE h;
+ 		char *ptbuf[1];
+ 
+ 		osi_Log0(smb_logp, "TRANSACTION word count = 0"); 
+ 
+ 		h = RegisterEventSource(NULL, AFS_DAEMON_EVENT_NAME);
+ 		ptbuf[0] = "Transaction2 word count = 0";
+ 		ReportEvent(h, EVENTLOG_WARNING_TYPE, 0, 1003, NULL,
+ 			    1, inp->ncb_length, ptbuf, inp);
+ 		DeregisterEventSource(h);
+ #else /* DJGPP */
+ 		osi_Log0(smb_logp, "TRANSACTION word count = 0"); 
+ #endif /* !DJGPP */
+ 
+         smb_SetSMBDataLength(outp, 0);
+         smb_SendPacket(vcp, outp);
+ 		return 0;
+ 	}
+ 
+     totalParms = smb_GetSMBParm(inp, 0);
+     totalData = smb_GetSMBParm(inp, 1);
+         
+     firstPacket = (inp->inCom == 0x25);
+         
+ 	/* find the packet we're reassembling */
+ 	lock_ObtainWrite(&smb_globalLock);
+     asp = smb_FindTran2Packet(vcp, inp);
+     if (!asp) {
+         asp = smb_NewTran2Packet(vcp, inp, totalParms, totalData);
+ 	}
+     lock_ReleaseWrite(&smb_globalLock);
+         
+     /* now merge in this latest packet; start by looking up offsets */
+ 	if (firstPacket) {
+ 		parmDisp = dataDisp = 0;
+         parmOffset = smb_GetSMBParm(inp, 10);
+         dataOffset = smb_GetSMBParm(inp, 12);
+         parmCount = smb_GetSMBParm(inp, 9);
+         dataCount = smb_GetSMBParm(inp, 11);
+ 		asp->maxReturnParms = smb_GetSMBParm(inp, 2);
+         asp->maxReturnData = smb_GetSMBParm(inp, 3);
+ 
+ 		osi_Log3(smb_logp, "SMB3 received Trans init packet total data %d, cur data %d, max return data %d",
+                  totalData, dataCount, asp->maxReturnData);
+     }
+     else {
+         parmDisp = smb_GetSMBParm(inp, 4);
+         parmOffset = smb_GetSMBParm(inp, 3);
+         dataDisp = smb_GetSMBParm(inp, 7);
+         dataOffset = smb_GetSMBParm(inp, 6);
+         parmCount = smb_GetSMBParm(inp, 2);
+         dataCount = smb_GetSMBParm(inp, 5);
+ 
+         osi_Log2(smb_logp, "SMB3 received Trans aux packet parms %d, data %d",
+                  parmCount, dataCount);
+     }   
+ 
+     /* now copy the parms and data */
+     if ( parmCount != 0 )
+     {
+         memcpy(((char *)asp->parmsp) + parmDisp, inp->data + parmOffset, parmCount);
+     }
+     if ( dataCount != 0 ) {
+         memcpy(asp->datap + dataDisp, inp->data + dataOffset, dataCount);
+     }
+ 
+     /* account for new bytes */
+     asp->curData += dataCount;
+     asp->curParms += parmCount;
+ 
+     /* finally, if we're done, remove the packet from the queue and dispatch it */
+     if (asp->totalData <= asp->curData && asp->totalParms <= asp->curParms) {
+ 		/* we've received it all */
+         lock_ObtainWrite(&smb_globalLock);
+ 		osi_QRemove((osi_queue_t **) &smb_tran2AssemblyQueuep, &asp->q);
+         lock_ReleaseWrite(&smb_globalLock);
+ 
+         /* now dispatch it */
+ 		rapOp = asp->parmsp[0];
+ 
+         if ( rapOp >= 0 && rapOp < SMB_RAP_NOPCODES && smb_rapDispatchTable[rapOp].procp) {
+             osi_LogEvent("AFS-Dispatch-RAP[%s]",myCrt_RapDispatch(rapOp),"vcp[%x] lana[%d] lsn[%d]",(int)vcp,vcp->lana,vcp->lsn);
+             osi_Log4(smb_logp,"AFS Server - Dispatch-RAP %s vcp[%x] lana[%d] lsn[%d]",myCrt_RapDispatch(rapOp),vcp,vcp->lana,vcp->lsn);
+             code = (*smb_rapDispatchTable[rapOp].procp)(vcp, asp, outp);
+         }
+         else {
+             osi_LogEvent("AFS-Dispatch-RAP [invalid]", NULL, "op[%x] vcp[%x] lana[%d] lsn[%d]", rapOp, vcp, vcp->lana, vcp->lsn);
+             osi_Log4(smb_logp,"AFS Server - Dispatch-RAP [INVALID] op[%x] vcp[%x] lana[%d] lsn[%d]", rapOp, vcp, vcp->lana, vcp->lsn);
+             code = CM_ERROR_BADOP;
+         }
+ 
+ 		/* if an error is returned, we're supposed to send an error packet,
+          * otherwise the dispatched function already did the data sending.
+          * We give dispatched proc the responsibility since it knows how much
+          * space to allocate.
+          */
+         if (code != 0) {
+             smb_SendTran2Error(vcp, asp, outp, code);
+         }
+ 
+ 		/* free the input tran 2 packet */
+ 		lock_ObtainWrite(&smb_globalLock);
+         smb_FreeTran2Packet(asp);
+ 		lock_ReleaseWrite(&smb_globalLock);
+     }
+     else if (firstPacket) {
+ 		/* the first packet in a multi-packet request, we need to send an
+          * ack to get more data.
+          */
+         smb_SetSMBDataLength(outp, 0);
+         smb_SendPacket(vcp, outp);
+     }
+ 
+ 	return 0;
+ }
+ 
+ /* ANSI versions.  The unicode versions support arbitrary length
+    share names, but we don't support unicode yet. */
+ 
+ typedef struct smb_rap_share_info_0 {
+ 	char			shi0_netname[13];
+ } smb_rap_share_info_0_t;
+ 
+ typedef struct smb_rap_share_info_1 {
+ 	char			shi1_netname[13];
+ 	char			shi1_pad;
+ 	WORD			shi1_type;
+ 	DWORD			shi1_remark; /* char *shi1_remark; data offset */
+ } smb_rap_share_info_1_t;
+ 
+ typedef struct smb_rap_share_info_2 {
+ 	char				shi2_netname[13];
+ 	char				shi2_pad;
+ 	unsigned short		shi2_type;
+ 	DWORD				shi2_remark; /* char *shi2_remark; data offset */
+ 	unsigned short		shi2_permissions;
+ 	unsigned short		shi2_max_uses;
+ 	unsigned short		shi2_current_uses;
+ 	DWORD				shi2_path;  /* char *shi2_path; data offset */
+ 	unsigned short		shi2_passwd[9];
+ 	unsigned short		shi2_pad2;
+ } smb_rap_share_info_2_t;
+ 
+ #define SMB_RAP_MAX_SHARES 512
+ 
+ typedef struct smb_rap_share_list {
+ 	int cShare;
+ 	int maxShares;
+ 	smb_rap_share_info_0_t * shares;
+ } smb_rap_share_list_t;
+ 
+ int smb_rapCollectSharesProc(cm_scache_t *dscp, cm_dirEntry_t *dep, void *vrockp, osi_hyper_t *offp) {
+ 	smb_rap_share_list_t * sp;
+ 	char * name;
+ 
+ 	name = dep->name;
+ 
+ 	if(name[0] == '.' && (!name[1] || (name[1] == '.' && !name[2])))
+ 		return 0; /* skip over '.' and '..' */
+ 
+ 	sp = (smb_rap_share_list_t *) vrockp;
+ 
+ 	strncpy(sp->shares[sp->cShare].shi0_netname, name, 12);
+ 	sp->shares[sp->cShare].shi0_netname[12] = 0;
+ 
+ 	sp->cShare++;
+ 
+ 	if(sp->cShare >= sp->maxShares)
+ 		return CM_ERROR_STOPNOW;
+ 	else
+ 		return 0;
+ }
+ 
+ long smb_ReceiveRAPNetShareEnum(smb_vc_t *vcp, smb_tran2Packet_t *p, smb_packet_t *op)
+ {
+ 	smb_tran2Packet_t *outp;
+ 	unsigned short * tp;
+ 	int len;
+ 	int infoLevel;
+ 	int bufsize;
+ 	int outParmsTotal;	/* total parameter bytes */
+ 	int outDataTotal;	/* total data bytes */
+ 	int code = 0;
+ 	DWORD rv;
+ 	DWORD allSubmount;
+ 	USHORT nShares;
+ 	DWORD nRegShares;
+ 	DWORD nSharesRet;
+ 	HKEY hkParam;
+ 	HKEY hkSubmount = NULL;
+ 	smb_rap_share_info_1_t * shares;
+ 	USHORT cshare = 0;
+ 	char * cstrp;
+ 	char thisShare[256];
+ 	int i,j;
+ 	int nonrootShares;
+ 	smb_rap_share_list_t rootShares;
+ 	cm_req_t req;
+ 	cm_user_t * userp;
+ 	osi_hyper_t thyper;
+ 
+ 	tp = p->parmsp + 1; /* skip over function number (always 0) */
+ 	(void) smb_ParseString((char *) tp, (char **) &tp); /* skip over parm descriptor */
+ 	(void) smb_ParseString((char *) tp, (char **) &tp); /* skip over data descriptor */
+ 	infoLevel = tp[0];
+     bufsize = tp[1];
+ 
+ 	if(infoLevel != 1) {
+ 		return CM_ERROR_INVAL;
+ 	}
+ 
+ 	/* first figure out how many shares there are */
+     rv = RegOpenKeyEx(HKEY_LOCAL_MACHINE, AFSConfigKeyName, 0,
+ 		KEY_QUERY_VALUE, &hkParam);
+ 	if (rv == ERROR_SUCCESS) {
+         len = sizeof(allSubmount);
+         rv = RegQueryValueEx(hkParam, "AllSubmount", NULL, NULL,
+                                 (BYTE *) &allSubmount, &len);
+ 		if (rv != ERROR_SUCCESS || allSubmount != 0) {
+ 			allSubmount = 1;
+ 		}
+         RegCloseKey (hkParam);
+ 	}
+ 
+ 	rv = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\OpenAFS\\Client\\Submounts",
+ 		0, KEY_QUERY_VALUE, &hkSubmount);
+ 	if (rv == ERROR_SUCCESS) {
+         rv = RegQueryInfoKey(hkSubmount, NULL, NULL, NULL, NULL,
+ 			NULL, NULL, &nRegShares, NULL, NULL, NULL, NULL);
+ 		if (rv != ERROR_SUCCESS)
+ 			nRegShares = 0;
+ 	} else {
+ 		hkSubmount = NULL;
+ 	}
+ 
+ 	/* fetch the root shares */
+ 	rootShares.maxShares = SMB_RAP_MAX_SHARES;
+ 	rootShares.cShare = 0;
+ 	rootShares.shares = malloc( sizeof(smb_rap_share_info_0_t) * SMB_RAP_MAX_SHARES );
+ 
+ 	cm_InitReq(&req);
+ 
+ 	userp = smb_GetTran2User(vcp,p);
+ 
+ 	thyper.HighPart = 0;
+ 	thyper.LowPart = 0;
+ 
+ 	cm_HoldSCache(cm_rootSCachep);
+ 	cm_ApplyDir(cm_rootSCachep, smb_rapCollectSharesProc, &rootShares, &thyper, userp, &req, NULL);
+ 	cm_ReleaseSCache(cm_rootSCachep);
+ 
+ 	cm_ReleaseUser(userp);
+ 
+ 	nShares = rootShares.cShare + nRegShares + allSubmount;
+ 
+ #define REMARK_LEN 1
+ 	outParmsTotal = 8; /* 4 dwords */
+ 	outDataTotal = (sizeof(smb_rap_share_info_1_t) + REMARK_LEN) * nShares ;
+ 	if(outDataTotal > bufsize) {
+ 		nSharesRet = bufsize / (sizeof(smb_rap_share_info_1_t) + REMARK_LEN);
+ 		outDataTotal = (sizeof(smb_rap_share_info_1_t) + REMARK_LEN) * nSharesRet;
+ 	}
+ 	else {
+ 		nSharesRet = nShares;
+ 	}
+     
+ 	outp = smb_GetTran2ResponsePacket(vcp, p, op, outParmsTotal, outDataTotal);
+ 
+ 	/* now for the submounts */
+     shares = (smb_rap_share_info_1_t *) outp->datap;
+ 	cstrp = outp->datap + sizeof(smb_rap_share_info_1_t) * nSharesRet;
+ 
+ 	memset(outp->datap, 0, (sizeof(smb_rap_share_info_1_t) + REMARK_LEN) * nSharesRet);
+ 
+ 	if(allSubmount) {
+ 		strcpy( shares[cshare].shi1_netname, "all" );
+ 		shares[cshare].shi1_remark = cstrp - outp->datap;
+ 		/* type and pad are zero already */
+ 		cshare++;
+ 		cstrp+=REMARK_LEN;
+ 	}
+ 
+ 	if(hkSubmount) {
+ 		for(i=0; i < nRegShares && cshare < nSharesRet; i++) {
+ 			len = sizeof(thisShare);
+             rv = RegEnumValue(hkSubmount, i, thisShare, &len, NULL, NULL, NULL, NULL);
+ 			if(rv == ERROR_SUCCESS && strlen(thisShare) && (!allSubmount || stricmp(thisShare,"all"))) {
+ 				strncpy(shares[cshare].shi1_netname, thisShare, sizeof(shares->shi1_netname)-1);
+ 				shares[cshare].shi1_netname[sizeof(shares->shi1_netname)-1] = 0; /* unfortunate truncation */
+ 				shares[cshare].shi1_remark = cstrp - outp->datap;
+ 				cshare++;
+ 				cstrp+=REMARK_LEN;
+ 			}
+ 			else
+ 				nShares--; /* uncount key */
+ 		}
+ 
+ 		RegCloseKey(hkSubmount);
+ 	}
+ 
+ 	nonrootShares = cshare;
+ 
+ 	for(i=0; i < rootShares.cShare && cshare < nSharesRet; i++) {
+         /* in case there are collisions with submounts, submounts have higher priority */		
+ 		for(j=0; j < nonrootShares; j++)
+ 			if(!stricmp(shares[j].shi1_netname, rootShares.shares[i].shi0_netname))
+ 				break;
+ 		
+ 		if(j < nonrootShares) {
+ 			nShares--; /* uncount */
+ 			continue;
+ 		}
+ 
+ 		strcpy(shares[cshare].shi1_netname, rootShares.shares[i].shi0_netname);
+ 		shares[cshare].shi1_remark = cstrp - outp->datap;
+ 		cshare++;
+ 		cstrp+=REMARK_LEN;
+ 	}
+ 
+ 	outp->parmsp[0] = ((cshare == nShares)? ERROR_SUCCESS : ERROR_MORE_DATA);
+ 	outp->parmsp[1] = 0;
+ 	outp->parmsp[2] = cshare;
+ 	outp->parmsp[3] = nShares;
+ 
+ 	outp->totalData = cstrp - outp->datap;
+ 	outp->totalParms = outParmsTotal;
+ 
+ 	smb_SendTran2Packet(vcp, outp, op);
+ 	smb_FreeTran2Packet(outp);
+ 
+ 	free(rootShares.shares);
+ 
+ 	return code;
+ }
+ 
+ long smb_ReceiveRAPNetShareGetInfo(smb_vc_t *vcp, smb_tran2Packet_t *p, smb_packet_t *op)
+ {
+ 	smb_tran2Packet_t *outp;
+ 	unsigned short * tp;
+ 	char * shareName;
+ 	BOOL shareFound = FALSE;
+ 	unsigned short infoLevel;
+ 	unsigned short bufsize;
+ 	int totalData;
+ 	int totalParam;
+ 	DWORD len;
+ 	HKEY hkParam;
+ 	HKEY hkSubmount;
+ 	DWORD allSubmount;
+ 	LONG rv;
+ 	long code = 0;
+ 
+ 	tp = p->parmsp + 1; /* skip over function number (always 1) */
+ 	(void) smb_ParseString( (char *) tp, (char **) &tp); /* skip over param descriptor */
+ 	(void) smb_ParseString( (char *) tp, (char **) &tp); /* skip over data descriptor */
+ 	shareName = smb_ParseString( (char *) tp, (char **) &tp);
+     infoLevel = *tp++;
+     bufsize = *tp++;
+     
+ 	totalParam = 6;
+ 
+ 	if(infoLevel == 0)
+ 		totalData = sizeof(smb_rap_share_info_0_t);
+ 	else if(infoLevel == 1)
+ 		totalData = sizeof(smb_rap_share_info_1_t) + 1; /* + empty string */
+ 	else if(infoLevel == 2)
+ 		totalData = sizeof(smb_rap_share_info_2_t) + 2; /* + two empty strings */
+ 	else
+ 		return CM_ERROR_INVAL;
+ 
+ 	outp = smb_GetTran2ResponsePacket(vcp, p, op, totalParam, totalData);
+ 
+ 	if(!stricmp(shareName,"all")) {
+ 		rv = RegOpenKeyEx(HKEY_LOCAL_MACHINE, AFSConfigKeyName, 0,
+ 			KEY_QUERY_VALUE, &hkParam);
+ 		if (rv == ERROR_SUCCESS) {
+ 			len = sizeof(allSubmount);
+ 			rv = RegQueryValueEx(hkParam, "AllSubmount", NULL, NULL,
+ 									(BYTE *) &allSubmount, &len);
+ 			if (rv != ERROR_SUCCESS || allSubmount != 0) {
+ 				allSubmount = 1;
+ 			}
+ 			RegCloseKey (hkParam);
+ 		}
+ 
+ 		if(allSubmount)
+ 			shareFound = TRUE;
+ 
+ 	} else {
+ 		rv = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\OpenAFS\\Client\\Submounts", 0,
+ 			KEY_QUERY_VALUE, &hkSubmount);
+ 		if(rv == ERROR_SUCCESS) {
+             rv = RegQueryValueEx(hkSubmount, shareName, NULL, NULL, NULL, NULL);
+ 			if(rv == ERROR_SUCCESS) {
+ 				shareFound = TRUE;
+ 			}
+ 			RegCloseKey(hkSubmount);
+ 		}
+ 	}
+ 
+ 	if(!shareFound) {
+ 		smb_FreeTran2Packet(outp);
+ 		return CM_ERROR_BADSHARENAME;
+ 	}
+ 
+ 	memset(outp->datap, 0, totalData);
+ 
+ 	outp->parmsp[0] = 0;
+ 	outp->parmsp[1] = 0;
+ 	outp->parmsp[2] = totalData;
+ 
+ 	if(infoLevel == 0) {
+ 		smb_rap_share_info_0_t * info = (smb_rap_share_info_0_t *) outp->datap;
+ 		strncpy(info->shi0_netname, shareName, sizeof(info->shi0_netname)-1);
+ 		info->shi0_netname[sizeof(info->shi0_netname)-1] = 0;
+ 	} else if(infoLevel == 1) {
+ 		smb_rap_share_info_1_t * info = (smb_rap_share_info_1_t *) outp->datap;
+         strncpy(info->shi1_netname, shareName, sizeof(info->shi1_netname)-1);
+ 		info->shi1_netname[sizeof(info->shi1_netname)-1] = 0;
+ 		info->shi1_remark = ((unsigned char *) (info + 1)) - outp->datap;
+ 		/* type and pad are already zero */
+ 	} else { /* infoLevel==2 */
+ 		smb_rap_share_info_2_t * info = (smb_rap_share_info_2_t *) outp->datap;
+ 		strncpy(info->shi2_netname, shareName, sizeof(info->shi2_netname)-1);
+ 		info->shi2_netname[sizeof(info->shi2_netname)-1] = 0;
+ 		info->shi2_remark = ((unsigned char *) (info + 1)) - outp->datap;
+         info->shi2_permissions = ACCESS_ALL;
+ 		info->shi2_max_uses = (unsigned short) -1;
+         info->shi2_path = 1 + (((unsigned char *) (info + 1)) - outp->datap);
+ 	}
+ 
+ 	outp->totalData = totalData;
+ 	outp->totalParms = totalParam;
+ 
+ 	smb_SendTran2Packet(vcp, outp, op);
+ 	smb_FreeTran2Packet(outp);
+ 
+ 	return code;
+ }
+ 
+ typedef struct smb_rap_wksta_info_10 {
+ 	DWORD	wki10_computername;	/*char *wki10_computername;*/
+ 	DWORD	wki10_username; /* char *wki10_username; */
+ 	DWORD  	wki10_langroup;	/* char *wki10_langroup;*/
+ 	unsigned char  	wki10_ver_major;
+ 	unsigned char	wki10_ver_minor;
+ 	DWORD	wki10_logon_domain;	/*char *wki10_logon_domain;*/
+ 	DWORD	wki10_oth_domains; /* char *wki10_oth_domains;*/
+ } smb_rap_wksta_info_10_t;
+ 
+ 
+ long smb_ReceiveRAPNetWkstaGetInfo(smb_vc_t *vcp, smb_tran2Packet_t *p, smb_packet_t *op)
+ {
+ 	smb_tran2Packet_t *outp;
+     long code = 0;
+ 	int infoLevel;
+ 	int bufsize;
+ 	unsigned short * tp;
+ 	int totalData;
+ 	int totalParams;
+ 	smb_rap_wksta_info_10_t * info;
+ 	char * cstrp;
+ 	smb_user_t *uidp;
+ 
+ 	tp = p->parmsp + 1; /* Skip over function number */
+ 	(void) smb_ParseString((unsigned char*) tp, (char **) &tp); /* skip over param descriptor */
+ 	(void) smb_ParseString((unsigned char*) tp, (char **) &tp); /* skip over data descriptor */
+ 	infoLevel = *tp++;
+ 	bufsize = *tp++;
+ 
+ 	if(infoLevel != 10) {
+ 		return CM_ERROR_INVAL;
+ 	}
+ 
+ 	totalParams = 6;
+ 	
+ 	/* infolevel 10 */
+ 	totalData = sizeof(*info) +		/* info */
+ 		MAX_COMPUTERNAME_LENGTH +	/* wki10_computername */
+ 		SMB_MAX_USERNAME_LENGTH +	/* wki10_username */
+ 		MAX_COMPUTERNAME_LENGTH +	/* wki10_langroup */
+ 		MAX_COMPUTERNAME_LENGTH +	/* wki10_logon_domain */
+ 		1;							/* wki10_oth_domains (null)*/
+ 
+ 	outp = smb_GetTran2ResponsePacket(vcp, p, op, totalParams, totalData);
+ 
+ 	memset(outp->parmsp,0,totalParams);
+ 	memset(outp->datap,0,totalData);
+ 
+     info = (smb_rap_wksta_info_10_t *) outp->datap;
+ 	cstrp = (char *) (info + 1);
+ 
+ 	info->wki10_computername = (DWORD) (cstrp - outp->datap);
+ 	strcpy(cstrp, smb_localNamep);
+ 	cstrp += strlen(cstrp) + 1;
+ 
+ 	info->wki10_username = (DWORD) (cstrp - outp->datap);
+ 	uidp = smb_FindUID(vcp, p->uid, 0);
+ 	if(uidp) {
+ 		lock_ObtainMutex(&uidp->mx);
+ 		if(uidp->unp && uidp->unp->name)
+ 			strcpy(cstrp, uidp->unp->name);
+ 		lock_ReleaseMutex(&uidp->mx);
+ 		smb_ReleaseUID(uidp);
+ 	}
+ 	cstrp += strlen(cstrp) + 1;
+ 
+ 	info->wki10_langroup = (DWORD) (cstrp - outp->datap);
+ 	strcpy(cstrp, "WORKGROUP");
+ 	cstrp += strlen(cstrp) + 1;
+ 
+ 	/* TODO: Not sure what values these should take, but these work */
+ 	info->wki10_ver_major = 5;
+ 	info->wki10_ver_minor = 1;
+ 
+ 	info->wki10_logon_domain = (DWORD) (cstrp - outp->datap);
+ 	strcpy(cstrp, smb_ServerDomainName);
+ 	cstrp += strlen(cstrp) + 1;
+ 
+ 	info->wki10_oth_domains = (DWORD) (cstrp - outp->datap);
+ 	cstrp ++; /* no other domains */
+ 
+ 	outp->totalData = (unsigned short) (cstrp - outp->datap); /* actual data size */
+ 	outp->parmsp[2] = outp->totalData;
+ 	outp->totalParms = totalParams;
+ 
+ 	smb_SendTran2Packet(vcp,outp,op);
+ 	smb_FreeTran2Packet(outp);
+ 
+ 	return code;
+ }
+ 
+ typedef struct smb_rap_server_info_0 {
+     char    sv0_name[16];
+ } smb_rap_server_info_0_t;
+ 
+ typedef struct smb_rap_server_info_1 {
+     char            sv1_name[16];
+     char            sv1_version_major;
+     char            sv1_version_minor;
+     unsigned long   sv1_type;
+     DWORD           *sv1_comment_or_master_browser; /* char *sv1_comment_or_master_browser;*/
+ } smb_rap_server_info_1_t;
+ 
+ char smb_ServerComment[] = "OpenAFS Client";
+ int smb_ServerCommentLen = sizeof(smb_ServerComment);
+ 
+ #define SMB_SV_TYPE_SERVER      	0x00000002L
+ #define SMB_SV_TYPE_NT              0x00001000L
+ #define SMB_SV_TYPE_SERVER_NT       0x00008000L
+ 
+ long smb_ReceiveRAPNetServerGetInfo(smb_vc_t *vcp, smb_tran2Packet_t *p, smb_packet_t *op)
+ {
+ 	smb_tran2Packet_t *outp;
+     long code = 0;
+ 	int infoLevel;
+ 	int bufsize;
+ 	unsigned short * tp;
+ 	int totalData;
+ 	int totalParams;
+     smb_rap_server_info_0_t * info0;
+     smb_rap_server_info_1_t * info1;
+     char * cstrp;
+ 
+ 	tp = p->parmsp + 1; /* Skip over function number */
+ 	(void) smb_ParseString((unsigned char*) tp, (char **) &tp); /* skip over param descriptor */
+ 	(void) smb_ParseString((unsigned char*) tp, (char **) &tp); /* skip over data descriptor */
+ 	infoLevel = *tp++;
+ 	bufsize = *tp++;
+ 
+     if(infoLevel != 0 && infoLevel != 1) {
+         return CM_ERROR_INVAL;
+     }
+ 
+ 	totalParams = 6;
+ 	
+ 	totalData = 
+         (infoLevel == 0) ? sizeof(smb_rap_server_info_0_t)
+         : (sizeof(smb_rap_server_info_1_t) + smb_ServerCommentLen);
+ 
+ 	outp = smb_GetTran2ResponsePacket(vcp, p, op, totalParams, totalData);
+ 
+ 	memset(outp->parmsp,0,totalParams);
+ 	memset(outp->datap,0,totalData);
+ 
+     if(infoLevel == 0) {
+         info0 = (smb_rap_share_info_0_t *) outp->datap;
+         cstrp = (char *) (info0 + 1);
+         strcpy(info0->sv0_name, "AFS");
+     } else { /* infoLevel == 1 */
+         info1 = (smb_rap_share_info_1_t *) outp->datap;
+         cstrp = (char *) (info1 + 1);
+         strcpy(info1->sv1_name, "AFS");
+ 
+         info1->sv1_type = 
+             SMB_SV_TYPE_SERVER |
+             SMB_SV_TYPE_NT |
+             SMB_SV_TYPE_SERVER_NT;
+ 
+         info1->sv1_version_major = 5;
+         info1->sv1_version_minor = 1;
+         info1->sv1_comment_or_master_browser = (DWORD) (cstrp - outp->datap);
+ 
+         strcpy(cstrp, smb_ServerComment);
+ 
+         cstrp += smb_ServerCommentLen;
+     }
+ 
+     totalData = cstrp - outp->datap;
+ 	outp->totalData = min(bufsize,totalData); /* actual data size */
+     outp->parmsp[0] = (outp->totalData == totalData)? 0 : ERROR_MORE_DATA;
+ 	outp->parmsp[2] = totalData;
+ 	outp->totalParms = totalParams;
+ 
+ 	smb_SendTran2Packet(vcp,outp,op);
+ 	smb_FreeTran2Packet(outp);
+ 
+     return code;
+ }
+ 
  long smb_ReceiveV3Tran2A(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp)
  {
      smb_tran2Packet_t *asp;
***************
*** 742,754 ****
  
  	userp = smb_GetTran2User(vcp, p);
      /* In the off chance that userp is NULL, we log and abandon */
!     if(!userp) {
          osi_Log1(smb_logp, "ReceiveTran2Open user [%d] not resolvable", p->uid);
          smb_FreeTran2Packet(outp);
          return CM_ERROR_BADSMB;
      }
  
! 	tidPathp = smb_GetTIDPath(vcp, p->tid);
  
  	dscp = NULL;
  	code = cm_NameI(cm_rootSCachep, pathp,
--- 2087,2108 ----
  
  	userp = smb_GetTran2User(vcp, p);
      /* In the off chance that userp is NULL, we log and abandon */
!     if (!userp) {
          osi_Log1(smb_logp, "ReceiveTran2Open user [%d] not resolvable", p->uid);
          smb_FreeTran2Packet(outp);
          return CM_ERROR_BADSMB;
      }
  
! 	code = smb_LookupTIDPath(vcp, p->tid, &tidPathp);
!     if(code == CM_ERROR_TIDIPC) {
!         /* Attempt to use TID allocated for IPC.  The client is
!            probably trying to locate DCE RPC end points, which
!            we don't support. */
!         osi_Log0(smb_logp, "Tran2Open received IPC TID");
!         cm_ReleaseUser(userp);
!         smb_FreeTran2Packet(outp);
!         return CM_ERROR_NOSUCHPATH;
!     }
  
  	dscp = NULL;
  	code = cm_NameI(cm_rootSCachep, pathp,
***************
*** 1165,1177 ****
      }
          
      userp = smb_GetTran2User(vcp, p);
!     if(!userp) {
          osi_Log1(smb_logp, "ReceiveTran2QPathInfo unable to resolve user [%d]", p->uid);
          smb_FreeTran2Packet(outp);
          return CM_ERROR_BADSMB;
      }
  
! 	tidPathp = smb_GetTIDPath(vcp, p->tid);
  
  	/*
  	 * XXX Strange hack XXX
--- 2519,2537 ----
      }
          
      userp = smb_GetTran2User(vcp, p);
!     if (!userp) {
          osi_Log1(smb_logp, "ReceiveTran2QPathInfo unable to resolve user [%d]", p->uid);
          smb_FreeTran2Packet(outp);
          return CM_ERROR_BADSMB;
      }
  
! 	code = smb_LookupTIDPath(vcp, p->tid, &tidPathp);
!     if(code) {
!         cm_ReleaseUser(userp);
!         smb_SendTran2Error(vcp, p, opx, CM_ERROR_NOSUCHPATH);
!         smb_FreeTran2Packet(outp);
!         return 0;
!     }
  
  	/*
  	 * XXX Strange hack XXX
***************
*** 1366,1372 ****
  	outp->totalData = nbytesRequired;
  
  	userp = smb_GetTran2User(vcp, p);
!     if(!userp) {
      	osi_Log1(smb_logp, "ReceiveTran2QFileInfo unable to resolve user [%d]", p->uid);
      	code = CM_ERROR_BADSMB;
      	goto done;
--- 2726,2732 ----
  	outp->totalData = nbytesRequired;
  
  	userp = smb_GetTran2User(vcp, p);
!     if (!userp) {
      	osi_Log1(smb_logp, "ReceiveTran2QFileInfo unable to resolve user [%d]", p->uid);
      	code = CM_ERROR_BADSMB;
      	goto done;
***************
*** 1480,1486 ****
  	outp->totalData = 0;
  
  	userp = smb_GetTran2User(vcp, p);
!     if(!userp) {
      	osi_Log1(smb_logp,"ReceiveTran2SetFileInfo unable to resolve user [%d]", p->uid);
      	code = CM_ERROR_BADSMB;
      	goto done;
--- 2840,2846 ----
  	outp->totalData = 0;
  
  	userp = smb_GetTran2User(vcp, p);
!     if (!userp) {
      	osi_Log1(smb_logp,"ReceiveTran2SetFileInfo unable to resolve user [%d]", p->uid);
      	code = CM_ERROR_BADSMB;
      	goto done;
***************
*** 1677,1683 ****
  			/* Copy attributes */
  			lattr = smb_ExtAttributes(scp);
              /* merge in hidden (dot file) attribute */
!  			if( patchp->flags & SMB_DIRLISTPATCH_DOTFILE )
   				lattr |= SMB_ATTR_HIDDEN;
  			*((u_long *)dptr) = lattr;
  			dptr += 4;
--- 3037,3043 ----
  			/* Copy attributes */
  			lattr = smb_ExtAttributes(scp);
              /* merge in hidden (dot file) attribute */
!  			if ( patchp->flags & SMB_DIRLISTPATCH_DOTFILE )
   				lattr |= SMB_ATTR_HIDDEN;
  			*((u_long *)dptr) = lattr;
  			dptr += 4;
***************
*** 1727,1733 ****
  			/* finally copy out attributes as short */
  			attr = smb_Attributes(scp);
              /* merge in hidden (dot file) attribute */
!             if( patchp->flags & SMB_DIRLISTPATCH_DOTFILE )
                  attr |= SMB_ATTR_HIDDEN;
  			*dptr++ = attr & 0xff;
  			*dptr++ = (attr >> 8) & 0xff;
--- 3087,3093 ----
  			/* finally copy out attributes as short */
  			attr = smb_Attributes(scp);
              /* merge in hidden (dot file) attribute */
!             if ( patchp->flags & SMB_DIRLISTPATCH_DOTFILE )
                  attr |= SMB_ATTR_HIDDEN;
  			*dptr++ = attr & 0xff;
  			*dptr++ = (attr >> 8) & 0xff;
***************
*** 1760,1765 ****
--- 3120,3129 ----
         mapCaseTable[i] = toupper(i);
      // make '"' match '.' 
      mapCaseTable[(int)'"'] = toupper('.');
+     // make '<' match '*' 
+     mapCaseTable[(int)'<'] = toupper('*');
+     // make '>' match '?' 
+     mapCaseTable[(int)'>'] = toupper('?');    
  }
  
  // Compare 'pattern' (containing metacharacters '*' and '?') with the file
***************
*** 1778,1792 ****
     while (*name) {
        switch (*pattern) {
           case '?':
              if (*(++pattern) != '<' || *(++pattern) != '*') {
!                if (*name == '.') return FALSE;
                 ++name;
                 break;
              } /* endif */
           case '<':
           case '*':
!             while ((*pattern == '<') || (*pattern == '*') || (*pattern == '?')) ++pattern;
!             if (!*pattern) return TRUE;
              for (p = pename; p >= name; --p) {
                 if ((mapCaseTable[*p] == mapCaseTable[*pattern]) &&
                     szWildCardMatchFileName(pattern + 1, p + 1))
--- 3142,3160 ----
     while (*name) {
        switch (*pattern) {
           case '?':
+          case '>':
              if (*(++pattern) != '<' || *(++pattern) != '*') {
!                if (*name == '.') 
!                    return FALSE;
                 ++name;
                 break;
              } /* endif */
           case '<':
           case '*':
!             while ((*pattern == '<') || (*pattern == '*') || (*pattern == '?') || (*pattern == '>')) 
!                 ++pattern;
!             if (!*pattern) 
!                 return TRUE;
              for (p = pename; p >= name; --p) {
                 if ((mapCaseTable[*p] == mapCaseTable[*pattern]) &&
                     szWildCardMatchFileName(pattern + 1, p + 1))
***************
*** 1794,1804 ****
              } /* endfor */
              return FALSE;
           default:
!             if (mapCaseTable[*name] != mapCaseTable[*pattern]) return FALSE;
              ++pattern, ++name;
              break;
        } /* endswitch */
!    } /* endwhile */ return !*pattern;
  }
  
  /* do a case-folding search of the star name mask with the name in namep.
--- 3162,3174 ----
              } /* endfor */
              return FALSE;
           default:
!             if (mapCaseTable[*name] != mapCaseTable[*pattern]) 
!                 return FALSE;
              ++pattern, ++name;
              break;
        } /* endswitch */
!    } /* endwhile */ 
!    return !*pattern;
  }
  
  /* do a case-folding search of the star name mask with the name in namep.
***************
*** 2100,2106 ****
          smb_StripLastComponent(spacep->data, NULL, pathp);
          lock_ReleaseMutex(&dsp->mx);
  
! 		tidPathp = smb_GetTIDPath(vcp, p->tid);
          code = cm_NameI(cm_rootSCachep, spacep->data,
                          CM_FLAG_FOLLOW | CM_FLAG_CASEFOLD,
                          userp, tidPathp, &req, &scp);
--- 3470,3484 ----
          smb_StripLastComponent(spacep->data, NULL, pathp);
          lock_ReleaseMutex(&dsp->mx);
  
! 		code = smb_LookupTIDPath(vcp, p->tid, &tidPathp);
!         if(code) {
! 		    cm_ReleaseUser(userp);
!             smb_SendTran2Error(vcp, p, opx, CM_ERROR_NOFILES);
!             smb_FreeTran2Packet(outp);
! 		    smb_DeleteDirSearch(dsp);
! 		    smb_ReleaseDirSearch(dsp);
!             return 0;
!         }
          code = cm_NameI(cm_rootSCachep, spacep->data,
                          CM_FLAG_FOLLOW | CM_FLAG_CASEFOLD,
                          userp, tidPathp, &req, &scp);
***************
*** 2469,2475 ****
              }
  
  		}	/* if we're including this name */
!         else if(!NeedShortName &&
                   !starPattern &&
                   !foundInexact &&
                   					dep->fid.vnode != 0 &&
--- 3847,3853 ----
              }
  
  		}	/* if we're including this name */
!         else if (!NeedShortName &&
                   !starPattern &&
                   !foundInexact &&
                   					dep->fid.vnode != 0 &&
***************
*** 2690,2696 ****
      userp = smb_GetUser(vcp, inp);
  
  	dscp = NULL;
! 	tidPathp = smb_GetTIDPath(vcp, ((smb_t *)inp)->tid);
  	code = cm_NameI(cm_rootSCachep, pathp,
                      CM_FLAG_FOLLOW | CM_FLAG_CASEFOLD,
                      userp, tidPathp, &req, &scp);
--- 4068,4078 ----
      userp = smb_GetUser(vcp, inp);
  
  	dscp = NULL;
! 	code = smb_LookupTIDPath(vcp, ((smb_t *)inp)->tid, &tidPathp);
!     if(code) {
!         cm_ReleaseUser(userp);
!         return CM_ERROR_NOSUCHPATH;
!     }
  	code = cm_NameI(cm_rootSCachep, pathp,
                      CM_FLAG_FOLLOW | CM_FLAG_CASEFOLD,
                      userp, tidPathp, &req, &scp);
***************
*** 3278,3283 ****
--- 4660,4666 ----
  
      osi_Log1(smb_logp,"NTCreateX for [%s]",osi_LogSaveString(smb_logp,realPathp));
      osi_Log4(smb_logp,"NTCreateX da=[%x] ea=[%x] cd=[%x] co=[%x]", desiredAccess, extAttributes, createDisp, createOptions);
+     osi_Log1(smb_logp,"NTCreateX lastNamep=[%s]",osi_LogSaveString(smb_logp,(lastNamep?lastNamep:"null")));
  
  	if (lastNamep && strcmp(lastNamep, SMB_IOCTL_FILENAME) == 0) {
  		/* special case magic file name for receiving IOCTL requests
***************
*** 3285,3290 ****
--- 4668,4674 ----
  		 */
  		fidp = smb_FindFID(vcp, 0, SMB_FLAG_CREATE);
  		smb_SetupIoctlFid(fidp, spacep);
+ 		osi_Log1(smb_logp,"NTCreateX Setting up IOCTL on fid[%d]",fidp->fid);
  
  		/* set inp->fid so that later read calls in same msg can find fid */
  		inp->fid = fidp->fid;
***************
*** 3333,3339 ****
  
  	if (baseFid == 0) {
  		baseDirp = cm_rootSCachep;
! 		tidPathp = smb_GetTIDPath(vcp, ((smb_t *)inp)->tid);
  	}
  	else {
          baseFidp = smb_FindFID(vcp, baseFid, 0);
--- 4717,4732 ----
  
  	if (baseFid == 0) {
  		baseDirp = cm_rootSCachep;
! 		code = smb_LookupTIDPath(vcp, ((smb_t *)inp)->tid, &tidPathp);
!         if(code == CM_ERROR_TIDIPC) {
!             /* Attempt to use a TID allocated for IPC.  The client
!                is probably looking for DCE RPC end points which we
!                don't support. */
!             osi_Log0(smb_logp, "NTCreateX received IPC TID");
!             free(realPathp);
!             cm_ReleaseUser(userp);
!             return CM_ERROR_NOSUCHFILE;
!         }
  	}
  	else {
          baseFidp = smb_FindFID(vcp, baseFid, 0);
***************
*** 3411,3417 ****
                      treeStartp = realPathp + (tp - spacep->data);
  
                      if (*tp && !smb_IsLegalFilename(tp)) {
!                         if(baseFid != 0) 
                              smb_ReleaseFID(baseFidp);
                          cm_ReleaseUser(userp);
                          free(realPathp);
--- 4804,4810 ----
                      treeStartp = realPathp + (tp - spacep->data);
  
                      if (*tp && !smb_IsLegalFilename(tp)) {
!                         if (baseFid != 0) 
                              smb_ReleaseFID(baseFidp);
                          cm_ReleaseUser(userp);
                          free(realPathp);
***************
*** 3455,3461 ****
          }
  
          if (!foundscp && !treeCreate) {
!             if(createDisp == 2 || createDisp == 4)
                  code = cm_Lookup(dscp, lastNamep,
                                    CM_FLAG_FOLLOW, userp, &req, &scp);
              else
--- 4848,4854 ----
          }
  
          if (!foundscp && !treeCreate) {
!             if (createDisp == 2 || createDisp == 4)
                  code = cm_Lookup(dscp, lastNamep,
                                    CM_FLAG_FOLLOW, userp, &req, &scp);
              else
***************
*** 3571,3579 ****
  		cp = spacep->data;
  		tscp = dscp;
  
! 		while(pp && *pp) {
  			tp = strchr(pp, '\\');
! 			if(!tp) {
  				strcpy(cp,pp);
                  clen = strlen(cp);
  				isLast = 1; /* indicate last component.  the supplied path never ends in a slash */
--- 4964,4972 ----
  		cp = spacep->data;
  		tscp = dscp;
  
! 		while (pp && *pp) {
  			tp = strchr(pp, '\\');
! 			if (!tp) {
  				strcpy(cp,pp);
                  clen = strlen(cp);
  				isLast = 1; /* indicate last component.  the supplied path never ends in a slash */
***************
*** 3586,3592 ****
  			}
  			pp = tp;
  
! 			if(clen == 0) continue; /* the supplied path can't have consecutive slashes either , but */
  
  			/* cp is the next component to be created. */
  			code = cm_MakeDir(tscp, cp, 0, &setAttr, userp, &req);
--- 4979,4985 ----
  			}
  			pp = tp;
  
! 			if (clen == 0) continue; /* the supplied path can't have consecutive slashes either , but */
  
  			/* cp is the next component to be created. */
  			code = cm_MakeDir(tscp, cp, 0, &setAttr, userp, &req);
***************
*** 3605,3613 ****
  					code = cm_Lookup(tscp, cp, CM_FLAG_CASEFOLD,
  						userp, &req, &scp);
  				}
! 			if(code) break;
  
! 			if(!isLast) { /* for anything other than dscp, release it unless it's the last one */
  				cm_ReleaseSCache(tscp);
  				tscp = scp; /* Newly created directory will be next parent */
  			}
--- 4998,5006 ----
  					code = cm_Lookup(tscp, cp, CM_FLAG_CASEFOLD,
  						userp, &req, &scp);
  				}
! 			if (code) break;
  
! 			if (!isLast) { /* for anything other than dscp, release it unless it's the last one */
  				cm_ReleaseSCache(tscp);
  				tscp = scp; /* Newly created directory will be next parent */
  			}
***************
*** 3840,3846 ****
  #endif
  
  	userp = smb_GetUser(vcp, inp);
!     if(!userp) {
      	osi_Log1(smb_logp, "NTTranCreate invalid user [%d]", ((smb_t *) inp)->uid);
      	free(realPathp);
      	return CM_ERROR_INVAL;
--- 5233,5239 ----
  #endif
  
  	userp = smb_GetUser(vcp, inp);
!     if (!userp) {
      	osi_Log1(smb_logp, "NTTranCreate invalid user [%d]", ((smb_t *) inp)->uid);
      	free(realPathp);
      	return CM_ERROR_INVAL;
***************
*** 3848,3858 ****
  
  	if (baseFid == 0) {
  		baseDirp = cm_rootSCachep;
! 		tidPathp = smb_GetTIDPath(vcp, ((smb_t *)inp)->tid);
  	}
  	else {
          baseFidp = smb_FindFID(vcp, baseFid, 0);
!         if(!baseFidp) {
          	osi_Log1(smb_logp, "NTTranCreate Invalid fid [%d]", baseFid);
          	free(realPathp);
          	cm_ReleaseUser(userp);
--- 5241,5260 ----
  
  	if (baseFid == 0) {
  		baseDirp = cm_rootSCachep;
! 		code = smb_LookupTIDPath(vcp, ((smb_t *)inp)->tid, &tidPathp);
!         if(code == CM_ERROR_TIDIPC) {
!             /* Attempt to use TID allocated for IPC.  The client is
!                probably trying to locate DCE RPC endpoints, which we
!                don't support. */
!             osi_Log0(smb_logp, "NTTranCreate received IPC TID");
!             free(realPathp);
!             cm_ReleaseUser(userp);
!             return CM_ERROR_NOSUCHPATH;
!         }
  	}
  	else {
          baseFidp = smb_FindFID(vcp, baseFid, 0);
!         if (!baseFidp) {
          	osi_Log1(smb_logp, "NTTranCreate Invalid fid [%d]", baseFid);
          	free(realPathp);
          	cm_ReleaseUser(userp);
***************
*** 4393,4398 ****
--- 5795,5803 ----
  		otherAction = FILE_ACTION_RENAMED_NEW_NAME;
  	}
  
+     osi_Log2(smb_logp,"in smb_NotifyChange for file [%s] dscp [%x]",
+               osi_LogSaveString(smb_logp,filename),dscp);
+ 
  	lock_ObtainMutex(&smb_Dir_Watch_Lock);
  	watch = smb_Directory_Watches;
  	while (watch) {
***************
*** 4413,4418 ****
--- 5818,5824 ----
  
  		fidp = smb_FindFID(vcp, fid, 0);
          if (!fidp) {
+             osi_Log1(smb_logp," no fidp for fid[%d]",fid);
          	lastWatch = watch;
          	watch = watch->nextp;
          	continue;
***************
*** 4420,4426 ****
  		if (fidp->scp != dscp
  		    || (filter & notifyFilter) == 0
  		    || (!isDirectParent && !wtree)) {
! 			smb_ReleaseFID(fidp);
  			lastWatch = watch;
  			watch = watch->nextp;
  			continue;
--- 5826,5833 ----
  		if (fidp->scp != dscp
  		    || (filter & notifyFilter) == 0
  		    || (!isDirectParent && !wtree)) {
!             osi_Log1(smb_logp," passing fidp->scp[%x]", fidp->scp);
!             smb_ReleaseFID(fidp);
  			lastWatch = watch;
  			watch = watch->nextp;
  			continue;
***************
*** 4627,4635 ****
          lock_ObtainMutex(&unp->mx);
          unp->userp = cm_NewUser();
          lock_ReleaseMutex(&unp->mx);
! 		osi_LogEvent("AFS smb_FindCMUserByName : New User",NULL,"name[%s] machine[%s]",usern,machine);
      }  else	{
! 		osi_LogEvent("AFS smb_FindCMUserByName : Found",NULL,"name[%s] machine[%s]",usern,machine);
  	}
      return unp->userp;
  }
--- 6034,6044 ----
          lock_ObtainMutex(&unp->mx);
          unp->userp = cm_NewUser();
          lock_ReleaseMutex(&unp->mx);
! 		osi_Log2(smb_logp,"smb_FindCMUserByName New user name[%s] machine[%s]",osi_LogSaveString(smb_logp,usern),osi_LogSaveString(smb_logp,machine));
!         osi_LogEvent("AFS smb_FindCMUserByName : New User",NULL,"name[%s] machine[%s]",usern,machine);
      }  else	{
!         osi_Log2(smb_logp,"smb_FindCMUserByName Not found name[%s] machine[%s]",osi_LogSaveString(smb_logp,usern),osi_LogSaveString(smb_logp,machine));
!         osi_LogEvent("AFS smb_FindCMUserByName : Found",NULL,"name[%s] machine[%s]",usern,machine);
  	}
      return unp->userp;
  }
Index: openafs/src/WINNT/afsd/smb3.h
diff -c openafs/src/WINNT/afsd/smb3.h:1.5 openafs/src/WINNT/afsd/smb3.h:1.7
*** openafs/src/WINNT/afsd/smb3.h:1.5	Sun Mar 10 13:24:16 2002
--- openafs/src/WINNT/afsd/smb3.h	Wed Jul 21 00:43:07 2004
***************
*** 12,17 ****
--- 12,18 ----
  
  typedef struct smb_tran2Packet {
  	osi_queue_t q;			/* queue of all packets */
+ 		int com;			/* Trans or Trans2 (0x25 or 0x32) */
          int totalData;			/* total # of expected data bytes */
          int totalParms;			/* total # of expected parm bytes */
  	int oldTotalParms;		/* initial estimate of parm bytes */
***************
*** 86,97 ****
--- 87,112 ----
  
  extern smb_tran2Dispatch_t smb_tran2DispatchTable[SMB_TRAN2_NOPCODES];
  
+ #define SMB_RAP_NOPCODES	64
+ 
+ extern smb_tran2Dispatch_t smb_rapDispatchTable[SMB_RAP_NOPCODES];
+ 
  extern long smb_ReceiveV3SessionSetupX(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp);
  
  extern long smb_ReceiveV3TreeConnectX(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp);
  
+ extern long smb_ReceiveV3Trans(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp);
+ 
  extern long smb_ReceiveV3Tran2A(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp);
  
+ extern long smb_ReceiveRAPNetShareEnum(smb_vc_t *vcp, smb_tran2Packet_t *p, smb_packet_t *op);
+ 
+ extern long smb_ReceiveRAPNetShareGetInfo(smb_vc_t *vcp, smb_tran2Packet_t *p, smb_packet_t *op);
+ 
+ extern long smb_ReceiveRAPNetWkstaGetInfo(smb_vc_t *vcp, smb_tran2Packet_t *p, smb_packet_t *op);
+ 
+ extern long smb_ReceiveRAPNetServerGetInfo(smb_vc_t *vcp, smb_tran2Packet_t *p, smb_packet_t *op);
+ 
  extern long smb_ReceiveTran2Open(smb_vc_t *vcp, smb_tran2Packet_t *p,
  	smb_packet_t *outp);
  
***************
*** 168,173 ****
--- 183,191 ----
  extern void smb3_Init();
  extern cm_user_t *smb_FindCMUserByName(/*smb_vc_t *vcp,*/ char *usern, char *machine);
  
+ /* SMB auth related functions */
+ extern void smb_NegotiateExtendedSecurity(void ** secBlob, int * secBlobLength);
+ 
  #ifdef DJGPP
  #define DELETE (0x00010000)
  #define READ_CONTROL (0x00020000)
Index: openafs/src/WINNT/afsd/smb_ioctl.c
diff -c openafs/src/WINNT/afsd/smb_ioctl.c:1.13 openafs/src/WINNT/afsd/smb_ioctl.c:1.14
*** openafs/src/WINNT/afsd/smb_ioctl.c:1.13	Thu Jun  3 23:10:45 2004
--- openafs/src/WINNT/afsd/smb_ioctl.c	Mon Jul 26 19:22:21 2004
***************
*** 181,187 ****
          userp = smb_GetUser(vcp, inp);
  
  	/* Identify tree */
! 	iop->tidPathp = smb_GetTIDPath(vcp, ((smb_t *)inp)->tid);
  
  	/* turn the connection around, if required */
  	code = smb_IoctlPrepareRead(fidp, iop, userp);
--- 181,191 ----
          userp = smb_GetUser(vcp, inp);
  
  	/* Identify tree */
!     code = smb_LookupTIDPath(vcp, ((smb_t *)inp)->tid, &iop->tidPathp);
!     if(code) {
!         cm_ReleaseUser(userp);
!         return CM_ERROR_NOSUCHPATH;
!     }
  
  	/* turn the connection around, if required */
  	code = smb_IoctlPrepareRead(fidp, iop, userp);
***************
*** 294,300 ****
                       userp);
      }
  
! 	iop->tidPathp = smb_GetTIDPath(vcp, ((smb_t *)inp)->tid);
  
  	code = smb_IoctlPrepareRead(fidp, iop, userp);
      if (uidp) {
--- 298,310 ----
                       userp);
      }
  
! 	code = smb_LookupTIDPath(vcp, ((smb_t *)inp)->tid, &iop->tidPathp);
!     if(code) {
!         smb_ReleaseUID(uidp);
!         cm_ReleaseUser(userp);
!         smb_ReleaseFID(fidp);
!         return CM_ERROR_NOSUCHPATH;
!     }
  
  	code = smb_IoctlPrepareRead(fidp, iop, userp);
      if (uidp) {
***************
*** 392,398 ****
  		if (uidp) smb_ReleaseUID(uidp);
  	}
  
! 	iop->tidPathp = smb_GetTIDPath(vcp, ((smb_t *)inp)->tid);
  
  	code = smb_IoctlPrepareRead(fidp, iop, userp);
  	if (code) {
--- 402,413 ----
  		if (uidp) smb_ReleaseUID(uidp);
  	}
  
!     code = smb_LookupTIDPath(vcp, ((smb_t *)inp)->tid, &iop->tidPathp);
!     if(code) {
!         cm_ReleaseUser(userp);
!         smb_ReleaseFID(fidp);
!         return CM_ERROR_NOSUCHPATH;
!     }
  
  	code = smb_IoctlPrepareRead(fidp, iop, userp);
  	if (code) {
Index: openafs/src/WINNT/afsd/smb_ioctl.h
diff -c openafs/src/WINNT/afsd/smb_ioctl.h:1.3 openafs/src/WINNT/afsd/smb_ioctl.h:1.4
*** openafs/src/WINNT/afsd/smb_ioctl.h:1.3	Mon Apr 30 02:48:11 2001
--- openafs/src/WINNT/afsd/smb_ioctl.h	Mon Jul 19 18:40:12 2004
***************
*** 12,17 ****
--- 12,18 ----
  
  /* magic file name for ioctl opens */
  #define SMB_IOCTL_FILENAME	"\\_._AFS_IOCTL_._"	/* double backslashes for C compiler */
+ #define SMB_IOCTL_FILENAME_NOSLASH "_._AFS_IOCTL_._"
  
  /* max parms for ioctl, in either direction */
  #define SMB_IOCTL_MAXDATA	8192
Index: openafs/src/WINNT/afsreg/afsreg.h
diff -c openafs/src/WINNT/afsreg/afsreg.h:1.2 openafs/src/WINNT/afsreg/afsreg.h:1.3
*** openafs/src/WINNT/afsreg/afsreg.h:1.2	Sat Nov  4 05:01:48 2000
--- openafs/src/WINNT/afsreg/afsreg.h	Wed Jul 21 10:06:12 2004
***************
*** 168,175 ****
  /* AFSREG_CLT_SVC_PARAM_KEY values */
  #define AFSREG_CLT_SVC_PARAM_CELL_VALUE      "Cell"
  
! 
! 
  
  
  /* Extended (alternative) versions of registry access functions */
--- 168,175 ----
  /* AFSREG_CLT_SVC_PARAM_KEY values */
  #define AFSREG_CLT_SVC_PARAM_CELL_VALUE      "Cell"
  
! #define AFSREG_CLT_OPENAFS_KEY "HKEY_LOCAL_MACHINE\\Software\\OpenAFS\\Client"
! #define AFSREG_CLT_OPENAFS_CELLSERVDB_DIR_VALUE  "CellServDBDir"
  
  
  /* Extended (alternative) versions of registry access functions */
Index: openafs/src/WINNT/afsreg/afssw.c
diff -c openafs/src/WINNT/afsreg/afssw.c:1.2 openafs/src/WINNT/afsreg/afssw.c:1.3
*** openafs/src/WINNT/afsreg/afssw.c:1.2	Sat Nov  4 05:01:48 2000
--- openafs/src/WINNT/afsreg/afssw.c	Wed Jul 21 10:06:12 2004
***************
*** 63,68 ****
--- 63,82 ----
  			  bufPP);
  }
  
+ /*
+  * afssw_GetClientCellServDBDir() -- Get directory in which AFS client CellServDB
+  * file is installed.  Sets *bufPP to point to allocated buffer containing string.
+  *
+  * RETURN CODES: 0 success, -1 failed (errno set)
+  */
+ int
+ afssw_GetClientCellServDBDir(char **bufPP)   /* [out] data buffer */
+ {
+     return StringDataRead(AFSREG_CLT_OPENAFS_KEY,
+ 			  AFSREG_CLT_OPENAFS_CELLSERVDB_DIR_VALUE,
+ 			  bufPP);
+ }
+ 
  
  /*
   * afssw_GetClientCellName() -- Get name of cell in which AFS client is
Index: openafs/src/WINNT/afsreg/afssw.h
diff -c openafs/src/WINNT/afsreg/afssw.h:1.2 openafs/src/WINNT/afsreg/afssw.h:1.3
*** openafs/src/WINNT/afsreg/afssw.h:1.2	Sat Nov  4 05:01:48 2000
--- openafs/src/WINNT/afsreg/afssw.h	Wed Jul 21 10:06:13 2004
***************
*** 20,26 ****
  afssw_GetServerInstallDir(char **bufPP);
  
  extern int
! afssw_GetClientInstallDir(char **bufPP);
  
  extern int
  afssw_GetClientCellName(char **bufPP);
--- 20,29 ----
  afssw_GetServerInstallDir(char **bufPP);
  
  extern int
! afssw_GetClientCellServDBDir(char **bufPP);
! 
! extern int
! afssw_GetClientCellDir(char **bufPP);
  
  extern int
  afssw_GetClientCellName(char **bufPP);
Index: openafs/src/WINNT/afssvrcfg/services_page.cpp
diff -c openafs/src/WINNT/afssvrcfg/services_page.cpp:1.3 openafs/src/WINNT/afssvrcfg/services_page.cpp:1.4
*** openafs/src/WINNT/afssvrcfg/services_page.cpp:1.3	Sun Dec  7 17:49:14 2003
--- openafs/src/WINNT/afssvrcfg/services_page.cpp	Mon Jul 26 16:39:43 2004
***************
*** 394,403 ****
  
  static void CheckEnableSc()
  {
! 	BOOL bSccEnable;
  	UINT uiSccStatusMsg;
  	UINT uiSccActionMsg;
! 	BOOL bScsEnable;
  	UINT uiScsStatusMsg;
  	UINT uiScsActionMsg;
  
--- 394,403 ----
  
  static void CheckEnableSc()
  {
! 	BOOL bSccEnable = TRUE;
  	UINT uiSccStatusMsg;
  	UINT uiSccActionMsg;
! 	BOOL bScsEnable = TRUE;
  	UINT uiScsStatusMsg;
  	UINT uiScsActionMsg;
  
Index: openafs/src/WINNT/aklog/aklog.c
diff -c openafs/src/WINNT/aklog/aklog.c:1.2 openafs/src/WINNT/aklog/aklog.c:1.3
*** openafs/src/WINNT/aklog/aklog.c:1.2	Mon May 10 22:45:20 2004
--- openafs/src/WINNT/aklog/aklog.c	Thu Jul  8 09:25:40 2004
***************
*** 990,996 ****
  	linked_list paths;		/* List of paths to log to */
  	ll_node *cur_node;
  
! 	krb5_context context;
  
  	memset(&cellinfo, 0, sizeof(cellinfo));
  
--- 990,996 ----
  	linked_list paths;		/* List of paths to log to */
  	ll_node *cur_node;
  
! 	krb5_context context = 0;
  
  	memset(&cellinfo, 0, sizeof(cellinfo));
  
Index: openafs/src/WINNT/bosctlsvc/NTMakefile
diff -c openafs/src/WINNT/bosctlsvc/NTMakefile:1.4 openafs/src/WINNT/bosctlsvc/NTMakefile:1.5
*** openafs/src/WINNT/bosctlsvc/NTMakefile:1.4	Fri Nov 21 02:59:53 2003
--- openafs/src/WINNT/bosctlsvc/NTMakefile	Wed Jul 14 02:00:18 2004
***************
*** 22,31 ****
  	$(DESTDIR)\lib\afs\afsutil.lib \
  	$(DESTDIR)\lib\afs\afseventlog.lib \
  	$(DESTDIR)\lib\afs\afsreg.lib \
! 	$(DESTDIR)\lib\afs\afsprocmgmt.lib
  
  $(EXEFILE): $(EXEOBJS) $(EXELIBS)
! 	$(EXECONLINK)
  	$(EXEPREP)
  
  ############################################################################
--- 22,36 ----
  	$(DESTDIR)\lib\afs\afsutil.lib \
  	$(DESTDIR)\lib\afs\afseventlog.lib \
  	$(DESTDIR)\lib\afs\afsreg.lib \
! 	$(DESTDIR)\lib\afs\afsprocmgmt.lib \
!     $(DESTDIR)\lib\afsicf.obj
! 
! EXESDKLIBS=\
!     ole32.lib \
!     oleaut32.lib
  
  $(EXEFILE): $(EXEOBJS) $(EXELIBS)
! 	$(EXECONLINK) $(EXESDKLIBS)
  	$(EXEPREP)
  
  ############################################################################
Index: openafs/src/WINNT/bosctlsvc/bosctlsvc.c
diff -c openafs/src/WINNT/bosctlsvc/bosctlsvc.c:1.4 openafs/src/WINNT/bosctlsvc/bosctlsvc.c:1.5
*** openafs/src/WINNT/bosctlsvc/bosctlsvc.c:1.4	Fri Mar 26 02:42:21 2004
--- openafs/src/WINNT/bosctlsvc/bosctlsvc.c	Wed Jul 14 02:00:18 2004
***************
*** 30,36 ****
  #include <afs/procmgmt.h>
  #include <afs/dirpath.h>
  #include <afs/bnode.h>
! 
  
  /* Define globals */
  
--- 30,36 ----
  #include <afs/procmgmt.h>
  #include <afs/dirpath.h>
  #include <afs/bnode.h>
! #include <afs/afsicf.h>
  
  /* Define globals */
  
***************
*** 273,278 ****
--- 273,281 ----
  	return;
      }
  
+     /* For XP SP2 and above, open required ports */
+     icf_CheckAndAddAFSPorts(AFS_PORTSET_SERVER);
+ 
      /* Initialize the dirpath package so can access local bosserver binary */
      if (!(initAFSDirPath() & AFSDIR_SERVER_PATHS_OK)) {
  	/* sw install directory probably not in registry; can not continue */
Index: openafs/src/WINNT/client_config/NTMakefile
diff -c openafs/src/WINNT/client_config/NTMakefile:1.9 openafs/src/WINNT/client_config/NTMakefile:1.10
*** openafs/src/WINNT/client_config/NTMakefile:1.9	Fri Mar  5 18:09:27 2004
--- openafs/src/WINNT/client_config/NTMakefile	Thu Jul 15 01:22:14 2004
***************
*** 63,69 ****
  	$(DESTDIR)\lib\afsauthent.lib \
  	$(DESTDIR)\lib\libosi.lib \
  	$(DESTDIR)\lib\libafsconf.lib \
!     $(DESTDIR)\lib\lanahelper.lib
  
  ############################################################################
  #
--- 63,70 ----
  	$(DESTDIR)\lib\afsauthent.lib \
  	$(DESTDIR)\lib\libosi.lib \
  	$(DESTDIR)\lib\libafsconf.lib \
!     $(DESTDIR)\lib\lanahelper.lib \
!     $(DESTDIR)\lib\afs\afsreg.lib
  
  ############################################################################
  #
Index: openafs/src/WINNT/client_config/cellservdb.c
diff -c openafs/src/WINNT/client_config/cellservdb.c:1.2 openafs/src/WINNT/client_config/cellservdb.c:1.4
*** openafs/src/WINNT/client_config/cellservdb.c:1.2	Sat Nov  4 05:02:36 2000
--- openafs/src/WINNT/client_config/cellservdb.c	Wed Jul 21 10:06:14 2004
***************
*** 23,28 ****
--- 23,29 ----
  #include <sys/socket.h>
  #endif
  
+ char AFSLocalMachineKeyName[] = "SOFTWARE\\OpenAFS\\Client";
  
  /*
   * PROTOTYPES _________________________________________________________________
***************
*** 67,79 ****
  void CSDB_GetFileName (char *pszFilename)
  {
  #ifdef AFS_NT40_ENV
!    /* Find the appropriate AFSDCELL.INI */
!    GetWindowsDirectory (pszFilename, MAX_CSDB_PATH);
! 
!    if (pszFilename[ strlen(pszFilename)-1 ] != '\\')
        strcat (pszFilename, "\\");
  
!    strcat (pszFilename, "AFSDCELL.INI");
  #else
     strcpy (pszFilename, "/usr/vice/etc/CellServDB");
  #endif
--- 68,101 ----
  void CSDB_GetFileName (char *pszFilename)
  {
  #ifdef AFS_NT40_ENV
!    /* Find the appropriate CellServDB */
!     char * clientdir = 0;
! 	DWORD code, dummyLen;
! 	HKEY parmKey;
!     int tlen;
! 
! 	code = RegOpenKeyEx(HKEY_LOCAL_MACHINE, AFSLocalMachineKeyName,
! 				0, KEY_QUERY_VALUE, &parmKey);
! 	if (code != ERROR_SUCCESS)
!         goto dirpath;
! 
! 	dummyLen = MAX_CSDB_PATH;
! 	code = RegQueryValueEx(parmKey, "CellServDBDir", NULL, NULL,
! 				pszFilename, &dummyLen);
! 	RegCloseKey (parmKey);
! 
!   dirpath:
! 	if (code != ERROR_SUCCESS || pszFilename[0] == 0) {
!         afssw_GetClientInstallDir(&clientdir);
!         if (clientdir) {
!             strncpy(pszFilename, clientdir, MAX_CSDB_PATH);
!             pszFilename[MAX_CSDB_PATH - 1] = '\0';
!         }
!     }
!     if (pszFilename[ strlen(pszFilename)-1 ] != '\\')
        strcat (pszFilename, "\\");
  
!    strcat (pszFilename, "CellServDB");
  #else
     strcpy (pszFilename, "/usr/vice/etc/CellServDB");
  #endif
Index: openafs/src/WINNT/client_config/drivemap.cpp
diff -c openafs/src/WINNT/client_config/drivemap.cpp:1.23 openafs/src/WINNT/client_config/drivemap.cpp:1.26
*** openafs/src/WINNT/client_config/drivemap.cpp:1.23	Sat Apr  3 14:47:22 2004
--- openafs/src/WINNT/client_config/drivemap.cpp	Sun Jul 25 16:53:12 2004
***************
*** 21,27 ****
--- 21,29 ----
  #include "drivemap.h"
  #include <time.h>
  #include <adssts.h>
+ #ifdef DEBUG
  #define DEBUG_VERBOSE
+ #endif
  #include <osilog.h>
  #include <lanahelper.h>
  
***************
*** 43,57 ****
  
  #define cREALLOC_SUBMOUNTS   4
  
! static TCHAR cszINIFILE[] = TEXT("afsdsbmt.ini");
! static TCHAR cszSECTION_SUBMOUNTS[] = TEXT("AFS Submounts");
! static TCHAR cszSECTION_MAPPINGS[] = TEXT("AFS Mappings");
! static TCHAR cszSECTION_ACTIVE[] = TEXT("AFS Active");
  
  static TCHAR cszAUTOSUBMOUNT[] = TEXT("Auto");
  static TCHAR cszLANMANDEVICE[] = TEXT("\\Device\\LanmanRedirector\\");
  
  
  /*
   * STRINGS ____________________________________________________________________
   *
--- 45,126 ----
  
  #define cREALLOC_SUBMOUNTS   4
  
! static TCHAR cszSECTION_SUBMOUNTS[] = TEXT("SOFTWARE\\OpenAFS\\Client\\Submounts");
! static TCHAR cszSECTION_MAPPINGS[] = TEXT("SOFTWARE\\OpenAFS\\Client\\Mappings");
! static TCHAR cszSECTION_ACTIVE[] = TEXT("SOFTWARE\\OpenAFS\\Client\\Active Maps");
  
  static TCHAR cszAUTOSUBMOUNT[] = TEXT("Auto");
  static TCHAR cszLANMANDEVICE[] = TEXT("\\Device\\LanmanRedirector\\");
  
  
+ static BOOL 
+ WriteRegistryString(HKEY key, TCHAR * subkey, LPTSTR lhs, LPTSTR rhs)
+ {
+     HKEY hkSub = NULL;
+     RegCreateKeyEx( key,
+                     subkey,
+                     0,
+                     NULL,
+                     REG_OPTION_NON_VOLATILE,
+                     KEY_WRITE,
+                     NULL,
+                     &hkSub,
+                     NULL);
+ 
+     DWORD status = RegSetValueEx( hkSub, lhs, 0, REG_SZ, (const BYTE *)rhs, strlen(rhs)+1 );
+ 
+     if ( hkSub )
+         RegCloseKey( hkSub );
+ 
+     return (status == ERROR_SUCCESS);
+ }
+ 
+ static BOOL 
+ ReadRegistryString(HKEY key, TCHAR * subkey, LPTSTR lhs, LPTSTR rhs, DWORD * size)
+ {
+     HKEY hkSub = NULL;
+     RegCreateKeyEx( key,
+                     subkey,
+                     0,
+                     NULL,
+                     REG_OPTION_NON_VOLATILE,
+                     KEY_READ,
+                     NULL,
+                     &hkSub,
+                     NULL);
+ 
+     DWORD dwType;
+     DWORD status = RegQueryValueEx( hkSub, lhs, 0, &dwType, (LPBYTE)rhs, size );
+ 
+     if ( hkSub )
+         RegCloseKey( hkSub );
+ 
+     return (status == ERROR_SUCCESS);
+ }
+ 
+ static BOOL 
+ DeleteRegistryString(HKEY key, TCHAR * subkey, LPTSTR lhs)
+ {
+     HKEY hkSub = NULL;
+     RegCreateKeyEx( key,
+                     subkey,
+                     0,
+                     NULL,
+                     REG_OPTION_NON_VOLATILE,
+                     KEY_READ,
+                     NULL,
+                     &hkSub,
+                     NULL);
+ 
+     DWORD dwType;
+     DWORD status = RegDeleteValue( hkSub, lhs );
+ 
+     if ( hkSub )
+         RegCloseKey( hkSub );
+ 
+     return (status == ERROR_SUCCESS);
+ }
+ 
  /*
   * STRINGS ____________________________________________________________________
   *
***************
*** 307,398 ****
  
  void QueryDriveMapList_ReadSubmounts (PDRIVEMAPLIST pList)
  {
!    if (IsWindowsNT())
!       {
!       size_t cchLHS = 1024;
!       LPTSTR mszLHS = AllocateStringMemory (cchLHS);
! 
!       for (int iRetry = 0; iRetry < 5; ++iRetry)
!          {
!          DWORD rc = GetPrivateProfileString (cszSECTION_SUBMOUNTS, NULL, TEXT(""), mszLHS, cchLHS, cszINIFILE);
!          if ((rc != cchLHS-1) && (rc != cchLHS-2))
!             break;
! 
!          FreeStringMemory (mszLHS);
!          cchLHS *= 2;
!          mszLHS = AllocateStringMemory (cchLHS);
!          }
! 
!       for (LPTSTR psz = mszLHS; psz && *psz; psz += 1+lstrlen(psz))
!          {
!          SUBMOUNT Submount;
!          memset (&Submount, 0x00, sizeof(SUBMOUNT));
!          lstrcpy (Submount.szSubmount, psz);
! 
!          TCHAR szMapping[ MAX_PATH ] = TEXT("");
!          GetPrivateProfileString (cszSECTION_SUBMOUNTS, Submount.szSubmount, TEXT(""), szMapping, MAX_PATH, cszINIFILE);
!          if (szMapping[0] != TEXT('\0'))
!             {
!             AdjustAfsPath (Submount.szMapping, szMapping, FALSE, TRUE);
! 
!             for (size_t ii = 0; ii < pList->cSubmounts; ++ii)
!                {
!                if (!pList->aSubmounts[ii].szSubmount[0])
!                   break;
!                }
!             if (REALLOC (pList->aSubmounts, pList->cSubmounts, 1+ii, cREALLOC_SUBMOUNTS))
!                {
!                memcpy (&pList->aSubmounts[ii], &Submount, sizeof(SUBMOUNT));
!                }
              }
-          }
  
!       FreeStringMemory (mszLHS);
!       }
  }
  
  
  void QueryDriveMapList_ReadMappings (PDRIVEMAPLIST pList)
  {
!    size_t cchLHS = 1024;
!    LPTSTR mszLHS = AllocateStringMemory (cchLHS);
! 
!    for (int iRetry = 0; iRetry < 5; ++iRetry)
!       {
!       DWORD rc = GetPrivateProfileString (cszSECTION_MAPPINGS, NULL, TEXT(""), mszLHS, cchLHS, cszINIFILE);
!       if ((rc != cchLHS-1) && (rc != cchLHS-2))
!          break;
! 
!       FreeStringMemory (mszLHS);
!       cchLHS *= 2;
!       mszLHS = AllocateStringMemory (cchLHS);
!       }
! 
!    for (LPTSTR psz = mszLHS; psz && *psz; psz += 1+lstrlen(psz))
!       {
!       DRIVEMAP DriveMap;
!       memset (&DriveMap, 0x00, sizeof(DRIVEMAP));
!       DriveMap.chDrive = toupper(*psz);
!       DriveMap.fPersistent = TRUE;
!       if ((DriveMap.chDrive < chDRIVE_A) || (DriveMap.chDrive > chDRIVE_Z))
!          continue;
! 
!       TCHAR szMapping[ MAX_PATH ] = TEXT("");
!       GetPrivateProfileString (cszSECTION_MAPPINGS, psz, TEXT(""), szMapping, MAX_PATH, cszINIFILE);
!       if (szMapping[0] != TEXT('\0'))
!          {
!          AdjustAfsPath (DriveMap.szMapping, szMapping, TRUE, TRUE);
!          if (DriveMap.szMapping[ lstrlen(DriveMap.szMapping)-1 ] == TEXT('*'))
!             {
!             DriveMap.fPersistent = FALSE;
!             DriveMap.szMapping[ lstrlen(DriveMap.szMapping)-1 ] = TEXT('\0');
!             }
!          size_t iDrive = DriveMap.chDrive - chDRIVE_A;
!          memcpy (&pList->aDriveMap[ iDrive ], &DriveMap, sizeof(DRIVEMAP));
!          }
!       }
  
!    FreeStringMemory (mszLHS);
  }
  
  BOOL ForceMapActive (TCHAR chDrive)
--- 376,503 ----
  
  void QueryDriveMapList_ReadSubmounts (PDRIVEMAPLIST pList)
  {
!     if (IsWindowsNT())
!     {
!         HKEY hkSubmounts;
! 
!         RegCreateKeyEx( HKEY_LOCAL_MACHINE, 
!                         "SOFTWARE\\OpenAFS\\Client\\Submounts",
!                         0, 
!                         "AFS", 
!                         REG_OPTION_NON_VOLATILE,
!                         KEY_READ|KEY_QUERY_VALUE,
!                         NULL, 
!                         &hkSubmounts,
!                         NULL );
! 
!         DWORD dwSubmounts;
!         RegQueryInfoKey( hkSubmounts,
!                          NULL,  /* lpClass */
!                          NULL,  /* lpcClass */
!                          NULL,  /* lpReserved */
!                          NULL,  /* lpcSubKeys */
!                          NULL,  /* lpcMaxSubKeyLen */
!                          NULL,  /* lpcMaxClassLen */
!                          &dwSubmounts, /* lpcValues */
!                          NULL,  /* lpcMaxValueNameLen */
!                          NULL,  /* lpcMaxValueLen */
!                          NULL,  /* lpcbSecurityDescriptor */
!                          NULL   /* lpftLastWriteTime */
!                          );
! 
!         for ( DWORD dwIndex = 0; dwIndex < dwSubmounts; dwIndex ++ ) {
!             TCHAR submountPath[MAX_PATH] = "";
!             DWORD submountPathLen = MAX_PATH;
!             TCHAR submountName[MAX_PATH];
!             DWORD submountNameLen = MAX_PATH;
!             DWORD dwType;
! 
!             RegEnumValue( hkSubmounts, dwIndex, submountName, &submountNameLen, NULL,
!                           &dwType, (LPBYTE)submountPath, &submountPathLen);
! 
!             SUBMOUNT Submount;
!             memset (&Submount, 0x00, sizeof(SUBMOUNT));
!             lstrcpy (Submount.szSubmount, submountName);
! 
!             if ( submountPath[0] != TEXT('\0') ) {
!                 AdjustAfsPath (Submount.szMapping, submountPath, FALSE, TRUE);
! 
!                 for (size_t ii = 0; ii < pList->cSubmounts; ++ii)
!                 {
!                     if (!pList->aSubmounts[ii].szSubmount[0])
!                         break;
!                 }
!                 if (REALLOC (pList->aSubmounts, pList->cSubmounts, 1+ii, cREALLOC_SUBMOUNTS))
!                 {
!                     memcpy (&pList->aSubmounts[ii], &Submount, sizeof(SUBMOUNT));
!                 }
              }
  
!         }
!         RegCloseKey(hkSubmounts);
!     }
  }
  
  
  void QueryDriveMapList_ReadMappings (PDRIVEMAPLIST pList)
  {
!     HKEY hkMappings;
!     RegCreateKeyEx( HKEY_CURRENT_USER,
!                     "SOFTWARE\\OpenAFS\\Client\\Mappings",
!                     0, 
!                     "AFS", 
!                     REG_OPTION_NON_VOLATILE,
!                     KEY_READ|KEY_QUERY_VALUE,
!                     NULL, 
!                     &hkMappings,
!                     NULL );
! 
!     DWORD dwMappings;
!     RegQueryInfoKey( hkMappings,
!                      NULL,  /* lpClass */
!                      NULL,  /* lpcClass */
!                      NULL,  /* lpReserved */
!                      NULL,  /* lpcSubKeys */
!                      NULL,  /* lpcMaxSubKeyLen */
!                      NULL,  /* lpcMaxClassLen */
!                      &dwMappings, /* lpcValues */
!                      NULL,  /* lpcMaxValueNameLen */
!                      NULL,  /* lpcMaxValueLen */
!                      NULL,  /* lpcbSecurityDescriptor */
!                      NULL   /* lpftLastWriteTime */
!                      );
! 
!     for ( DWORD dwIndex = 0; dwIndex < dwMappings; dwIndex ++ ) {
!         TCHAR mapping[MAX_PATH] = "";
!         DWORD mappingLen = MAX_PATH;
!         TCHAR drive[MAX_PATH];
!         DWORD driveLen = MAX_PATH;
!         DWORD dwType;
! 
!         RegEnumValue( hkMappings, dwIndex, drive, &driveLen, NULL,
!                       &dwType, (LPBYTE)mapping, &mappingLen);
! 
!        DRIVEMAP DriveMap;
!        memset (&DriveMap, 0x00, sizeof(DRIVEMAP));
!        DriveMap.chDrive = toupper(*drive);
!        DriveMap.fPersistent = TRUE;
!        if ((DriveMap.chDrive < chDRIVE_A) || (DriveMap.chDrive > chDRIVE_Z))
!            continue;
! 
!        if (mapping[0] != TEXT('\0'))
!        {
!            AdjustAfsPath (DriveMap.szMapping, mapping, TRUE, TRUE);
!            if (DriveMap.szMapping[ lstrlen(DriveMap.szMapping)-1 ] == TEXT('*'))
!            {
!                DriveMap.fPersistent = FALSE;
!                DriveMap.szMapping[ lstrlen(DriveMap.szMapping)-1 ] = TEXT('\0');
!            }
!            size_t iDrive = DriveMap.chDrive - chDRIVE_A;
!            memcpy (&pList->aDriveMap[ iDrive ], &DriveMap, sizeof(DRIVEMAP));
!        }
!     }
  
!     RegCloseKey(hkMappings);
  }
  
  BOOL ForceMapActive (TCHAR chDrive)
***************
*** 403,409 ****
      szDrive[0] = chDrive;
      szDrive[1] = 0;
  
!     GetPrivateProfileString (cszSECTION_ACTIVE, szDrive, TEXT("0"), szActive, sizeof(szActive), cszINIFILE);
  
      if ( !lstrcmp(szActive,"1") || !lstrcmpi(szActive,"true") || !lstrcmpi(szActive,"on") || !lstrcmpi(szActive,"yes") )
          return TRUE;
--- 508,515 ----
      szDrive[0] = chDrive;
      szDrive[1] = 0;
  
!     DWORD len = sizeof(szActive);
!     ReadRegistryString( HKEY_CURRENT_USER, cszSECTION_ACTIVE, szDrive, szActive, &len);
  
      if ( !lstrcmp(szActive,"1") || !lstrcmpi(szActive,"true") || !lstrcmpi(szActive,"on") || !lstrcmpi(szActive,"yes") )
          return TRUE;
***************
*** 418,451 ****
      szDrive[0] = chDrive;
      szDrive[1] = 0;
  
!     WritePrivateProfileString (cszSECTION_ACTIVE, szDrive, on ? "1" : "0", cszINIFILE);
  }
  
  void QueryDriveMapList_WriteMappings (PDRIVEMAPLIST pList)
  {
!    WriteDriveMappings (pList);
  }
  
  
  void WriteDriveMappings (PDRIVEMAPLIST pList)
  {
!    WritePrivateProfileString (cszSECTION_MAPPINGS, NULL, NULL, cszINIFILE);
  
!    for (size_t iDrive = 0; iDrive < 26; ++iDrive)
!       {
!       if (pList->aDriveMap[iDrive].szMapping[0] != TEXT('\0'))
!          {
!          TCHAR szLHS[] = TEXT("*");
!          szLHS[0] = pList->aDriveMap[iDrive].chDrive;
  
!          TCHAR szRHS[MAX_PATH];
!          AdjustAfsPath (szRHS, pList->aDriveMap[iDrive].szMapping, TRUE, TRUE);
!          if (!pList->aDriveMap[iDrive].fPersistent)
!             lstrcat (szRHS, TEXT("*"));
  
!          WritePrivateProfileString (cszSECTION_MAPPINGS, szLHS, szRHS, cszINIFILE);
!          }
!       }
  }
  
  BOOL DriveIsGlobalAfsDrive(TCHAR chDrive)
--- 524,592 ----
      szDrive[0] = chDrive;
      szDrive[1] = 0;
  
!     WriteRegistryString(HKEY_CURRENT_USER, cszSECTION_ACTIVE, szDrive, on ? "1" : "0");
  }
  
  void QueryDriveMapList_WriteMappings (PDRIVEMAPLIST pList)
  {
!     WriteDriveMappings (pList);
  }
  
  
  void WriteDriveMappings (PDRIVEMAPLIST pList)
  {
!     HKEY hkMappings;
!     RegCreateKeyEx( HKEY_CURRENT_USER, 
!                     "SOFTWARE\\OpenAFS\\Client\\Mappings",
!                     0, 
!                     "AFS", 
!                     REG_OPTION_NON_VOLATILE,
!                     KEY_READ|KEY_QUERY_VALUE|KEY_WRITE,
!                     NULL, 
!                     &hkMappings,
!                     NULL );
! 
!     DWORD dwMappings;
!     RegQueryInfoKey( hkMappings,
!                      NULL,  /* lpClass */
!                      NULL,  /* lpcClass */
!                      NULL,  /* lpReserved */
!                      NULL,  /* lpcSubKeys */
!                      NULL,  /* lpcMaxSubKeyLen */
!                      NULL,  /* lpcMaxClassLen */
!                      &dwMappings, /* lpcValues */
!                      NULL,  /* lpcMaxValueNameLen */
!                      NULL,  /* lpcMaxValueLen */
!                      NULL,  /* lpcbSecurityDescriptor */
!                      NULL   /* lpftLastWriteTime */
!                      );
! 
!     if ( dwMappings > 0 ) {
!         for ( long dwIndex = dwMappings - 1; dwIndex >= 0; dwIndex-- ) {
!             TCHAR drive[MAX_PATH];
!             DWORD driveLen = MAX_PATH;
  
!             RegEnumValue( hkMappings, dwIndex, drive, &driveLen, NULL, NULL, NULL, NULL);
!             RegDeleteValue( hkMappings, drive );
!         }
!     }
  
!    for (size_t iDrive = 0; iDrive < 26; ++iDrive)
!    {
!        if (pList->aDriveMap[iDrive].szMapping[0] != TEXT('\0'))
!        {
!            TCHAR szLHS[] = TEXT("*");
!            szLHS[0] = pList->aDriveMap[iDrive].chDrive;
! 
!            TCHAR szRHS[MAX_PATH];
!            AdjustAfsPath (szRHS, pList->aDriveMap[iDrive].szMapping, TRUE, TRUE);
!            if (!pList->aDriveMap[iDrive].fPersistent)
!                lstrcat (szRHS, TEXT("*"));
  
!            RegSetValueEx( hkMappings, szLHS, 0, REG_SZ, (const BYTE *)szRHS, lstrlen(szRHS) + 1);
!        }
!    }
!    RegCloseKey( hkMappings );
  }
  
  BOOL DriveIsGlobalAfsDrive(TCHAR chDrive)
***************
*** 636,664 ****
  
  BOOL InactivateDriveMap (TCHAR chDrive, DWORD *pdwStatus)
  {
!    DWORD rc = DisMountDOSDrive(chDrive, FALSE);
!    if (rc == NO_ERROR)
!       return TRUE;
  
!    if (pdwStatus)
!       *pdwStatus = rc;
!    return FALSE;
  }
  
  
  void AddSubMount (LPTSTR pszSubmount, LPTSTR pszMapping)
  {
!    TCHAR szRHS[ MAX_PATH ];
!    AdjustAfsPath (szRHS, pszMapping, FALSE, TRUE);
!    if (!szRHS[0])
!       lstrcpy (szRHS, TEXT("/"));
!    WritePrivateProfileString (cszSECTION_SUBMOUNTS, pszSubmount, szRHS, cszINIFILE);
  }
  
  
  void RemoveSubMount (LPTSTR pszSubmount)
  {
!    WritePrivateProfileString (cszSECTION_SUBMOUNTS, pszSubmount, NULL, cszINIFILE);
  }
  
  
--- 777,806 ----
  
  BOOL InactivateDriveMap (TCHAR chDrive, DWORD *pdwStatus)
  {
!     DWORD rc = DisMountDOSDrive(chDrive, FALSE);
!     if (rc == NO_ERROR)
!         return TRUE;
  
!     if (pdwStatus)
!         *pdwStatus = rc;
!     return FALSE;
  }
  
  
  void AddSubMount (LPTSTR pszSubmount, LPTSTR pszMapping)
  {
!     TCHAR szRHS[ MAX_PATH ];
!     AdjustAfsPath (szRHS, pszMapping, FALSE, TRUE);
!     if (!szRHS[0])
!         lstrcpy (szRHS, TEXT("/"));
! 
!     WriteRegistryString(HKEY_LOCAL_MACHINE, cszSECTION_SUBMOUNTS, pszSubmount, szRHS);
  }
  
  
  void RemoveSubMount (LPTSTR pszSubmount)
  {
!     DeleteRegistryString(HKEY_LOCAL_MACHINE, cszSECTION_SUBMOUNTS, pszSubmount);
  }
  
  
***************
*** 826,832 ****
     if (read)
     {
  	   rval=0;
! 		if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, AFSLogonOptionName,0, KEY_QUERY_VALUE, &hk)==ERROR_SUCCESS)
  		{
  			LSPsize=sizeof(rval);
  			RegQueryValueEx(hk, "LogonOptions", NULL,
--- 968,974 ----
     if (read)
     {
  	   rval=0;
! 		if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, AFSLogonOptionName, 0, KEY_QUERY_VALUE, &hk)==ERROR_SUCCESS)
  		{
  			LSPsize=sizeof(rval);
  			RegQueryValueEx(hk, "LogonOptions", NULL,
***************
*** 1177,1183 ****
      nr.dwType=RESOURCETYPE_DISK;
      nr.lpLocalName=szDrive;
      nr.lpRemoteName=szPath;
!     nr.dwDisplayType = RESOURCEDISPLAYTYPE_SHARE;
      DWORD res=WNetAddConnection2(&nr,NULL,pUsername,(bPersistent)?CONNECT_UPDATE_PROFILE:0);
      DEBUG_EVENT5("AFS DriveMap","Mount %s Local[%s] Remote[%s] User[%s]=%x",
                    (bPersistent)?"Persistant" : "NonPresistant",
--- 1319,1325 ----
      nr.dwType=RESOURCETYPE_DISK;
      nr.lpLocalName=szDrive;
      nr.lpRemoteName=szPath;
!     nr.dwDisplayType = RESOURCEDISPLAYTYPE_SHARE; /* ignored parameter */
      DWORD res=WNetAddConnection2(&nr,NULL,pUsername,(bPersistent)?CONNECT_UPDATE_PROFILE:0);
      DEBUG_EVENT5("AFS DriveMap","Mount %s Local[%s] Remote[%s] User[%s]=%x",
                    (bPersistent)?"Persistant" : "NonPresistant",
Index: openafs/src/WINNT/client_config/tab_general.cpp
diff -c openafs/src/WINNT/client_config/tab_general.cpp:1.3 openafs/src/WINNT/client_config/tab_general.cpp:1.4
*** openafs/src/WINNT/client_config/tab_general.cpp:1.3	Sat Nov 10 17:31:10 2001
--- openafs/src/WINNT/client_config/tab_general.cpp	Mon Jul 26 19:01:31 2004
***************
*** 11,16 ****
--- 11,17 ----
  #include <afs/param.h>
  #include <afs/stds.h>
  #include <rx/rxkad.h>
+ #include <afs/cm_config.h>
  }
  
  #include "afs_config.h"
***************
*** 657,671 ****
  BOOL fIsCellInCellServDB (LPCTSTR pszCell)
  {
     BOOL fFound = FALSE;
- 
     CELLSERVDB CellServDB;
-    if (CSDB_ReadFile (&CellServDB, NULL))
-       {
-       if (CSDB_FindCell (&CellServDB, pszCell))
-          fFound = TRUE;
-       CSDB_FreeFile (&CellServDB);
-       }
  
     return fFound;
  }
  
--- 658,684 ----
  BOOL fIsCellInCellServDB (LPCTSTR pszCell)
  {
     BOOL fFound = FALSE;
     CELLSERVDB CellServDB;
  
+    if (CSDB_ReadFile (&CellServDB, NULL))
+    {
+        if (CSDB_FindCell (&CellServDB, pszCell))
+            fFound = TRUE;
+        CSDB_FreeFile (&CellServDB);
+    }
+ #ifdef AFS_AFSDB_ENV
+     if ( fFound == FALSE ) {
+         int ttl;
+         char cellname[128], i;
+ 
+         /* we pray for all ascii cellnames */
+         for ( i=0 ; pszCell[i] && i < (sizeof(cellname)-1) ; i++ )
+             cellname[i] = pszCell[i];
+         cellname[i] = '\0';
+ 
+         fFound = !cm_SearchCellByDNS(cellname, NULL, &ttl, NULL, NULL);
+     }
+ #endif
     return fFound;
  }
  
Index: openafs/src/WINNT/client_config/tab_hosts.cpp
diff -c openafs/src/WINNT/client_config/tab_hosts.cpp:1.2 openafs/src/WINNT/client_config/tab_hosts.cpp:1.3
*** openafs/src/WINNT/client_config/tab_hosts.cpp:1.2	Sat Nov  4 05:02:40 2000
--- openafs/src/WINNT/client_config/tab_hosts.cpp	Mon Jul 26 19:01:31 2004
***************
*** 10,15 ****
--- 10,16 ----
  extern "C" {
  #include <afs/param.h>
  #include <afs/stds.h>
+ #include <afs/cm_config.h>
  }
  
  #include "afs_config.h"
***************
*** 181,188 ****
  
        if (!CSDB_FindCell (&g.Configuration.CellServDB, szCell))
           {
!          Message (MB_ICONASTERISK | MB_OK, GetErrorTitle(), IDS_BADCELL_DESC_CC);
!          return FALSE;
           }
  
        if (!Config_SetCellName (szCell))
--- 182,202 ----
  
        if (!CSDB_FindCell (&g.Configuration.CellServDB, szCell))
           {
! #ifdef AFS_AFSDB_ENV
!              int ttl;
!              char cellname[128], i;
! 
!              /* we pray for all ascii cellnames */
!              for ( i=0 ; szCell[i] && i < (sizeof(cellname)-1) ; i++ )
!                  cellname[i] = szCell[i];
!              cellname[i] = '\0';
! 
!              if (cm_SearchCellByDNS(cellname, NULL, &ttl, NULL, NULL))
! #endif
!              {
!                  Message (MB_ICONASTERISK | MB_OK, GetErrorTitle(), IDS_BADCELL_DESC_CC);
!                  return FALSE;
!              }
           }
  
        if (!Config_SetCellName (szCell))
Index: openafs/src/WINNT/client_cpa/afs_cpa_stub.rc
diff -c openafs/src/WINNT/client_cpa/afs_cpa_stub.rc:1.3 openafs/src/WINNT/client_cpa/afs_cpa_stub.rc:1.4
*** openafs/src/WINNT/client_cpa/afs_cpa_stub.rc:1.3	Thu Jun 19 15:01:43 2003
--- openafs/src/WINNT/client_cpa/afs_cpa_stub.rc	Thu Jul 15 23:38:32 2004
***************
*** 16,18 ****
--- 16,19 ----
  #include "..\..\config\NTVersioninfo.rc"
  
  IDI_AFSD                ICON    DISCARDABLE     "afs_conf.ico"
+ IDI_CCENTER		        ICON	DISCARDABLE	    "afs_ccenter.ico"
Index: openafs/src/WINNT/client_cpa/cpl_interface.cpp
diff -c openafs/src/WINNT/client_cpa/cpl_interface.cpp:1.2 openafs/src/WINNT/client_cpa/cpl_interface.cpp:1.3
*** openafs/src/WINNT/client_cpa/cpl_interface.cpp:1.2	Sat Nov  4 05:02:43 2000
--- openafs/src/WINNT/client_cpa/cpl_interface.cpp	Thu Jul 15 23:38:32 2004
***************
*** 69,74 ****
--- 69,75 ----
  extern "C" LONG APIENTRY CPlApplet(HWND hwndCPl, UINT uMsg, LONG lParam1, LONG lParam2)
  {
      LPNEWCPLINFO lpNewCPlInfo;
+     LPCPLINFO lpCPlInfo;
  
      switch (uMsg) {
          case CPL_INIT:      /* first message, sent once  */
***************
*** 80,85 ****
--- 81,94 ----
              return 1;
              break;
  
+         case CPL_INQUIRE:  /* in case we receive this we should indicate that we like NEWINQUIRE better. */
+ 			lpCPlInfo = (CPLINFO *) lParam2;
+ 			lpCPlInfo->idIcon = ((IsClientInstalled() || !IsWindowsNT())? IDI_AFSD : IDI_CCENTER);
+ 			lpCPlInfo->idName = CPL_DYNAMIC_RES;
+ 			lpCPlInfo->idInfo = CPL_DYNAMIC_RES;
+ 			lpCPlInfo->lData = 0;
+ 			break;
+ 
          case CPL_NEWINQUIRE: /* third message, sent once per app */
              lpNewCPlInfo = (LPNEWCPLINFO) lParam2;
  
Index: openafs/src/WINNT/client_creds/advtab.cpp
diff -c openafs/src/WINNT/client_creds/advtab.cpp:1.6 openafs/src/WINNT/client_creds/advtab.cpp:1.7
*** openafs/src/WINNT/client_creds/advtab.cpp:1.6	Thu Feb 26 14:22:48 2004
--- openafs/src/WINNT/client_creds/advtab.cpp	Sun Jul 25 16:53:13 2004
***************
*** 10,15 ****
--- 10,16 ----
  extern "C" {
  #include <afs/param.h>
  #include <afs/stds.h>
+ #include <afs/afskfw.h>
  }
  
  #include "afscreds.h"
***************
*** 214,219 ****
--- 215,226 ----
                  if (StartService (hService, 0, 0))
                  {
                      TestAndDoMapShare(SERVICE_START_PENDING);
+                     if ( KFW_is_available() && KFW_AFS_wait_for_service_start() ) {
+ #ifdef USE_MS2MIT
+                         KFW_import_windows_lsa();
+ #endif /* USE_MS2MIT */
+                         KFW_AFS_renew_tokens_for_all_cells();
+                     }
                      fSuccess = TRUE;
                  }
                  CloseServiceHandle (hService);
Index: openafs/src/WINNT/client_creds/afswiz.cpp
diff -c openafs/src/WINNT/client_creds/afswiz.cpp:1.7 openafs/src/WINNT/client_creds/afswiz.cpp:1.9
*** openafs/src/WINNT/client_creds/afswiz.cpp:1.7	Fri Mar 19 20:01:07 2004
--- openafs/src/WINNT/client_creds/afswiz.cpp	Sun Jul 25 16:53:13 2004
***************
*** 231,237 ****
                                         SERVICE_QUERY_STATUS | SERVICE_START)) != NULL)
           {
           if (StartService (hService, 0, 0))
! 			TestAndDoMapShare(SERVICE_START_PENDING);
  
           CloseServiceHandle (hService);
           }
--- 231,237 ----
                                         SERVICE_QUERY_STATUS | SERVICE_START)) != NULL)
           {
           if (StartService (hService, 0, 0))
!              TestAndDoMapShare(SERVICE_START_PENDING);
  
           CloseServiceHandle (hService);
           }
***************
*** 345,351 ****
     HKEY hk;
  
     TCHAR szCell[ cchRESOURCE ] = TEXT("");
-    (void)GetDefaultCell (szCell);
     SetDlgItemText (hDlg, IDC_NEWCREDS_CELL, szCell);
  
     TCHAR szUser[ cchRESOURCE ] = TEXT("");
--- 345,350 ----
Index: openafs/src/WINNT/client_creds/creds.cpp
diff -c openafs/src/WINNT/client_creds/creds.cpp:1.8 openafs/src/WINNT/client_creds/creds.cpp:1.11
*** openafs/src/WINNT/client_creds/creds.cpp:1.8	Sun May  9 00:39:05 2004
--- openafs/src/WINNT/client_creds/creds.cpp	Tue Jul 20 11:51:07 2004
***************
*** 437,458 ****
  
  int GetDefaultCell (LPTSTR pszCell)
  {
!    int rc = KTC_NOCM;
!    *pszCell = TEXT('\0');
  
!    if (!Creds_OpenLibraries())
!       {
!       rc = ERROR_DLL_INIT_FAILED;
!       }
!    else if (IsServiceRunning())
!       {
!       char szCellA[ 256 ];
  
!       int rc;
!       if ((rc = cm_GetRootCellName (szCellA)) == 0)
!          CopyAnsiToString (pszCell, szCellA);
!       }
  
!    return rc;
  }
  
--- 437,471 ----
  
  int GetDefaultCell (LPTSTR pszCell)
  {
!     int rc = KTC_NOCM;
!     *pszCell = TEXT('\0');
  
!     if (!Creds_OpenLibraries())
!     {
!         rc = ERROR_DLL_INIT_FAILED;
!     }
!     else if (IsServiceRunning())
!     {
!         char szCellA[ 256 ] = "";
!         int rc;
!         HKEY hk;
  
!         if (RegOpenKey (HKEY_CURRENT_USER, REGSTR_PATH_OPENAFS_CLIENT, &hk) == 0)
!         {
!             DWORD dwSize = sizeof(szCellA);
!             DWORD dwType = REG_SZ;
!             RegQueryValueEx (hk, TEXT("Authentication Cell"), NULL, &dwType, (PBYTE)szCellA, &dwSize);
!             RegCloseKey (hk);
!         }
  
!         if (szCellA[0] == '\0') {
!             rc = cm_GetRootCellName (szCellA);
!         } else {
!             rc = 0;
!         }
! 		if (rc == 0)
! 			CopyAnsiToString(pszCell, szCellA);
!     }
!     return rc;
  }
  
Index: openafs/src/WINNT/client_creds/credstab.cpp
diff -c openafs/src/WINNT/client_creds/credstab.cpp:1.4 openafs/src/WINNT/client_creds/credstab.cpp:1.5
*** openafs/src/WINNT/client_creds/credstab.cpp:1.4	Fri Mar 19 20:01:07 2004
--- openafs/src/WINNT/client_creds/credstab.cpp	Mon Jun 28 12:33:20 2004
***************
*** 329,347 ****
  
  void NewCreds_OnEnable (HWND hDlg)
  {
!    BOOL fEnable = TRUE;
  
!    TCHAR szUser[ cchRESOURCE ];
!    GetDlgItemText (hDlg, IDC_NEWCREDS_USER, szUser, cchRESOURCE);
!    if (!szUser[0])
!       fEnable = FALSE;
! 
!    TCHAR szPassword[ cchRESOURCE ];
!    GetDlgItemText (hDlg, IDC_NEWCREDS_PASSWORD, szPassword, cchRESOURCE);
!    if (!szPassword[0])
!       fEnable = FALSE;
! 
!    EnableWindow (GetDlgItem (hDlg, IDOK), fEnable);
  }
  
  
--- 329,348 ----
  
  void NewCreds_OnEnable (HWND hDlg)
  {
!     BOOL fEnable = TRUE;
  
!     TCHAR szUser[ cchRESOURCE ];
!     GetDlgItemText (hDlg, IDC_NEWCREDS_USER, szUser, cchRESOURCE);
!     if (!szUser[0])
!         fEnable = FALSE;
! 
!     if ( !strchr(szUser, '@') ) {
!         TCHAR szPassword[ cchRESOURCE ];
!         GetDlgItemText (hDlg, IDC_NEWCREDS_PASSWORD, szPassword, cchRESOURCE);
!         if (!szPassword[0])
!             fEnable = FALSE;
!     }
!     EnableWindow (GetDlgItem (hDlg, IDOK), fEnable);
  }
  
  
Index: openafs/src/WINNT/client_creds/window.cpp
diff -c openafs/src/WINNT/client_creds/window.cpp:1.9 openafs/src/WINNT/client_creds/window.cpp:1.10
*** openafs/src/WINNT/client_creds/window.cpp:1.9	Tue May  4 18:48:15 2004
--- openafs/src/WINNT/client_creds/window.cpp	Sun Jul 25 16:53:13 2004
***************
*** 208,213 ****
--- 208,216 ----
                        if (StartService (hService, 0, 0))
                            TestAndDoMapShare(SERVICE_START_PENDING);
  		                  if ( KFW_is_available() && KFW_AFS_wait_for_service_start() ) {
+ #ifdef USE_MS2MIT
+                               KFW_import_windows_lsa();
+ #endif /* USE_MS2MIT */
  			                  KFW_AFS_renew_tokens_for_all_cells();
  						  }
  
Index: openafs/src/WINNT/client_creds/lang/de_DE/afscreds.rc
diff -c openafs/src/WINNT/client_creds/lang/de_DE/afscreds.rc:1.5 openafs/src/WINNT/client_creds/lang/de_DE/afscreds.rc:1.6
*** openafs/src/WINNT/client_creds/lang/de_DE/afscreds.rc:1.5	Thu Apr  1 14:09:59 2004
--- openafs/src/WINNT/client_creds/lang/de_DE/afscreds.rc	Sun Jul 25 16:53:14 2004
***************
*** 479,485 ****
      MENUITEM "Token an&zeigen...",          M_ACTIVATE
      MENUITEM "Vor Ablauf &warnen",          M_REMIND, CHECKED
      MENUITEM SEPARATOR
!     MENUITEM "Symbol entfe&rnen",           M_TERMINATE
  END
  
  
--- 479,485 ----
      MENUITEM "Token an&zeigen...",          M_ACTIVATE
      MENUITEM "Vor Ablauf &warnen",          M_REMIND, CHECKED
      MENUITEM SEPARATOR
!     MENUITEM "Symbol entfe&rnen...",           M_TERMINATE
  END
  
  
Index: openafs/src/WINNT/client_creds/lang/en_US/afscreds.rc
diff -c openafs/src/WINNT/client_creds/lang/en_US/afscreds.rc:1.5 openafs/src/WINNT/client_creds/lang/en_US/afscreds.rc:1.6
*** openafs/src/WINNT/client_creds/lang/en_US/afscreds.rc:1.5	Thu Apr  1 14:09:59 2004
--- openafs/src/WINNT/client_creds/lang/en_US/afscreds.rc	Sun Jul 25 16:53:14 2004
***************
*** 475,481 ****
      MENUITEM "&Show Tokens...",             M_ACTIVATE
      MENUITEM "&Warn Before Expiration",     M_REMIND, CHECKED
      MENUITEM SEPARATOR
!     MENUITEM "&Remove Icon",                M_TERMINATE
  END
  
  
--- 475,481 ----
      MENUITEM "&Show Tokens...",             M_ACTIVATE
      MENUITEM "&Warn Before Expiration",     M_REMIND, CHECKED
      MENUITEM SEPARATOR
!     MENUITEM "&Remove Icon...",                M_TERMINATE
  END
  
  
Index: openafs/src/WINNT/client_creds/lang/es_ES/afscreds.rc
diff -c openafs/src/WINNT/client_creds/lang/es_ES/afscreds.rc:1.5 openafs/src/WINNT/client_creds/lang/es_ES/afscreds.rc:1.6
*** openafs/src/WINNT/client_creds/lang/es_ES/afscreds.rc:1.5	Thu Apr  1 14:10:01 2004
--- openafs/src/WINNT/client_creds/lang/es_ES/afscreds.rc	Sun Jul 25 16:53:15 2004
***************
*** 503,509 ****
      MENUITEM "&Mostrar señales...",         M_ACTIVATE
      MENUITEM "A&visar antes de la caducidad", M_REMIND, CHECKED
      MENUITEM SEPARATOR
!     MENUITEM "&Eliminar icono",             M_TERMINATE
  END
  
  
--- 503,509 ----
      MENUITEM "&Mostrar señales...",         M_ACTIVATE
      MENUITEM "A&visar antes de la caducidad", M_REMIND, CHECKED
      MENUITEM SEPARATOR
!     MENUITEM "&Eliminar icono...",             M_TERMINATE
  END
  
  
Index: openafs/src/WINNT/client_creds/lang/ja_JP/afscreds.rc
diff -c openafs/src/WINNT/client_creds/lang/ja_JP/afscreds.rc:1.5 openafs/src/WINNT/client_creds/lang/ja_JP/afscreds.rc:1.6
*** openafs/src/WINNT/client_creds/lang/ja_JP/afscreds.rc:1.5	Thu Apr  1 14:10:03 2004
--- openafs/src/WINNT/client_creds/lang/ja_JP/afscreds.rc	Sun Jul 25 16:53:15 2004
***************
*** 489,495 ****
      MENUITEM "ƒg[ƒNƒ“‚Ì•\Ž¦(&S)...",       M_ACTIVATE
      MENUITEM "ŠúŒÀØ‚ê‘O‚ÉŒx(&W)",        M_REMIND, CHECKED
      MENUITEM SEPARATOR
!     MENUITEM "ƒAƒCƒRƒ“‚Ìíœ(&R)",          M_TERMINATE
  END
  
  
--- 489,495 ----
      MENUITEM "ƒg[ƒNƒ“‚Ì•\Ž¦(&S)...",       M_ACTIVATE
      MENUITEM "ŠúŒÀØ‚ê‘O‚ÉŒx(&W)",        M_REMIND, CHECKED
      MENUITEM SEPARATOR
!     MENUITEM "ƒAƒCƒRƒ“‚Ìíœ(&R)...",          M_TERMINATE
  END
  
  
Index: openafs/src/WINNT/client_creds/lang/ko_KR/afscreds.rc
diff -c openafs/src/WINNT/client_creds/lang/ko_KR/afscreds.rc:1.5 openafs/src/WINNT/client_creds/lang/ko_KR/afscreds.rc:1.6
*** openafs/src/WINNT/client_creds/lang/ko_KR/afscreds.rc:1.5	Thu Apr  1 14:10:06 2004
--- openafs/src/WINNT/client_creds/lang/ko_KR/afscreds.rc	Sun Jul 25 16:53:16 2004
***************
*** 471,477 ****
      MENUITEM "ÅäÅ« Ç¥½Ã(&S)...",            M_ACTIVATE
      MENUITEM "¸¸±â Àü °æ°í(&W)",            M_REMIND, CHECKED
      MENUITEM SEPARATOR
!     MENUITEM "¾ÆÀÌÄÜ Á¦°Å(&R)",             M_TERMINATE
  END
  
  
--- 471,477 ----
      MENUITEM "ÅäÅ« Ç¥½Ã(&S)...",            M_ACTIVATE
      MENUITEM "¸¸±â Àü °æ°í(&W)",            M_REMIND, CHECKED
      MENUITEM SEPARATOR
!     MENUITEM "¾ÆÀÌÄÜ Á¦°Å(&R)...",             M_TERMINATE
  END
  
  
Index: openafs/src/WINNT/client_creds/lang/pt_BR/afscreds.rc
diff -c openafs/src/WINNT/client_creds/lang/pt_BR/afscreds.rc:1.4 openafs/src/WINNT/client_creds/lang/pt_BR/afscreds.rc:1.5
*** openafs/src/WINNT/client_creds/lang/pt_BR/afscreds.rc:1.4	Thu Apr  1 14:10:09 2004
--- openafs/src/WINNT/client_creds/lang/pt_BR/afscreds.rc	Sun Jul 25 16:53:16 2004
***************
*** 478,484 ****
      MENUITEM "&Mostrar Tokens...",          M_ACTIVATE
      MENUITEM "&Avisar Antes do Vencimento",  M_REMIND, CHECKED
      MENUITEM SEPARATOR
!     MENUITEM "&Remover Ícone",              M_TERMINATE
  END
  
  
--- 478,484 ----
      MENUITEM "&Mostrar Tokens...",          M_ACTIVATE
      MENUITEM "&Avisar Antes do Vencimento",  M_REMIND, CHECKED
      MENUITEM SEPARATOR
!     MENUITEM "&Remover Ícone...",              M_TERMINATE
  END
  
  
Index: openafs/src/WINNT/client_creds/lang/zh_CN/afscreds.rc
diff -c openafs/src/WINNT/client_creds/lang/zh_CN/afscreds.rc:1.5 openafs/src/WINNT/client_creds/lang/zh_CN/afscreds.rc:1.6
*** openafs/src/WINNT/client_creds/lang/zh_CN/afscreds.rc:1.5	Thu Apr  1 14:10:12 2004
--- openafs/src/WINNT/client_creds/lang/zh_CN/afscreds.rc	Sun Jul 25 16:53:17 2004
***************
*** 468,474 ****
      MENUITEM "ÏÔÊ¾ÁîÅÆ(&S)...",             M_ACTIVATE
      MENUITEM "µ½ÆÚÇ°¾¯¸æ(&W)",              M_REMIND, CHECKED
      MENUITEM SEPARATOR
!     MENUITEM "³ýÈ¥Í¼±ê(&R)",                M_TERMINATE
  END
  
  
--- 468,474 ----
      MENUITEM "ÏÔÊ¾ÁîÅÆ(&S)...",             M_ACTIVATE
      MENUITEM "µ½ÆÚÇ°¾¯¸æ(&W)",              M_REMIND, CHECKED
      MENUITEM SEPARATOR
!     MENUITEM "³ýÈ¥Í¼±ê(&R)...",                M_TERMINATE
  END
  
  
Index: openafs/src/WINNT/client_creds/lang/zh_TW/afscreds.rc
diff -c openafs/src/WINNT/client_creds/lang/zh_TW/afscreds.rc:1.5 openafs/src/WINNT/client_creds/lang/zh_TW/afscreds.rc:1.6
*** openafs/src/WINNT/client_creds/lang/zh_TW/afscreds.rc:1.5	Thu Apr  1 14:10:14 2004
--- openafs/src/WINNT/client_creds/lang/zh_TW/afscreds.rc	Sun Jul 25 16:53:17 2004
***************
*** 482,488 ****
      MENUITEM "Åã¥Ü°O¸¹(&S)...",             M_ACTIVATE
      MENUITEM "¹L´Á«e¥ýÄµ§i(&W)",            M_REMIND, CHECKED
      MENUITEM SEPARATOR
!     MENUITEM "²¾°£¹Ï¥Ü(&R)",                M_TERMINATE
  END
  
  
--- 482,488 ----
      MENUITEM "Åã¥Ü°O¸¹(&S)...",             M_ACTIVATE
      MENUITEM "¹L´Á«e¥ýÄµ§i(&W)",            M_REMIND, CHECKED
      MENUITEM SEPARATOR
!     MENUITEM "²¾°£¹Ï¥Ü(&R)...",                M_TERMINATE
  END
  
  
Index: openafs/src/WINNT/client_exp/stdafx.h
diff -c openafs/src/WINNT/client_exp/stdafx.h:1.3 openafs/src/WINNT/client_exp/stdafx.h:1.4
*** openafs/src/WINNT/client_exp/stdafx.h:1.3	Fri Nov 21 02:59:58 2003
--- openafs/src/WINNT/client_exp/stdafx.h	Thu Jul 15 23:38:33 2004
***************
*** 16,21 ****
--- 16,25 ----
  
  #define VC_EXTRALEAN		// Exclude rarely-used stuff from Windows headers
  
+ // Don't include stuff we don't need.
+ #define _AFX_NO_DB_SUPPORT
+ #define _AFX_NO_DAO_SUPPORT
+ 
  #include <afxwin.h>         // MFC core and standard components
  #include <afxext.h>         // MFC extensions
  
Index: openafs/src/WINNT/client_exp/submounts_dlg.cpp
diff -c openafs/src/WINNT/client_exp/submounts_dlg.cpp:1.2 openafs/src/WINNT/client_exp/submounts_dlg.cpp:1.3
*** openafs/src/WINNT/client_exp/submounts_dlg.cpp:1.2	Sat Nov  4 05:02:55 2000
--- openafs/src/WINNT/client_exp/submounts_dlg.cpp	Tue Jul 13 23:28:43 2004
***************
*** 44,55 ****
  
  	char pathName[1024];
  
! 	len = GetPrivateProfileString("AFS Submounts",
! 				      PCCHAR(strShareName),
! 				      "", pathName, sizeof(pathName),
! 				      "afsdsbmt.ini");
  
! 	if (len == 0 || len == sizeof(pathName) - 1)
  		return pInfo;
  
  	pInfo = new CSubmountInfo();
--- 44,68 ----
  
  	char pathName[1024];
  
!     HKEY hkSubmounts;
!     RegCreateKeyEx( HKEY_LOCAL_MACHINE, 
!                     "SOFTWARE\\OpenAFS\\Client\\Submounts",
!                     0, 
!                     "AFS", 
!                     REG_OPTION_NON_VOLATILE,
!                     KEY_READ,
!                     NULL, 
!                     &hkSubmounts,
!                     NULL );
! 
!     DWORD dwType;
!     DWORD status;
!     len = sizeof(pathName);
!     status = RegQueryValueEx( hkSubmounts, (LPCSTR)PCCHAR(strShareName), 0,
!                               &dwType, (LPBYTE)pathName, &len);
!     RegCloseKey( hkSubmounts );
  
! 	if (status || len == 0)
  		return pInfo;
  
  	pInfo = new CSubmountInfo();
***************
*** 148,179 ****
  {
  	HOURGLASS hourglass;
  
! 	DWORD lsize, size = 500;
! 	char *buf = NULL, *next;
  
! 	/*
! 	 * We don't know how large a buffer we need.  Keep doubling it until
! 	 * we're sure we have enough.
! 	 */
! 	do {
! 		size *= 2;
! 		if (buf != NULL) free(buf);
! 		buf = (char *)malloc(size);
! 		lsize = GetPrivateProfileSection("AFS Submounts", buf, size,
! 						 "afsdsbmt.ini");
! 	}
! 	while (lsize >= size - 2);
  
! 	if (lsize != 0) {
! 		next = buf;
! 		do {
! 			m_SubmtList.AddString(next);
! 			next += (strlen(next) + 1);
! 		}
! 		while (*next);
! 	}
  
! 	free(buf);
  
  	return TRUE;
  }
--- 161,208 ----
  {
  	HOURGLASS hourglass;
  
!     HKEY hkSubmounts;
!     DWORD dwType, dwSize;
!     DWORD status;
!     DWORD dwIndex;
!     DWORD dwSubmounts;
! 
!     RegCreateKeyEx( HKEY_LOCAL_MACHINE, 
!                     "SOFTWARE\\OpenAFS\\Client\\Submounts",
!                     0, 
!                     "AFS", 
!                     REG_OPTION_NON_VOLATILE,
!                     KEY_READ|KEY_WRITE|KEY_QUERY_VALUE,
!                     NULL, 
!                     &hkSubmounts,
!                     NULL );
! 
!     RegQueryInfoKey( hkSubmounts,
!                  NULL,  /* lpClass */
!                  NULL,  /* lpcClass */
!                  NULL,  /* lpReserved */
!                  NULL,  /* lpcSubKeys */
!                  NULL,  /* lpcMaxSubKeyLen */
!                  NULL,  /* lpcMaxClassLen */
!                  &dwSubmounts, /* lpcValues */
!                  NULL,  /* lpcMaxValueNameLen */
!                  NULL,  /* lpcMaxValueLen */
!                  NULL,  /* lpcbSecurityDescriptor */
!                  NULL   /* lpftLastWriteTime */
!                  );
! 
! 
!     for ( dwIndex = 0; dwIndex < dwSubmounts; dwIndex ++ ) {
!         char submountName[256];
!         DWORD submountNameLen = sizeof(submountName);
  
!         RegEnumValue( hkSubmounts, dwIndex, submountName, &submountNameLen, NULL,
!               &dwType, NULL, NULL);
  
!         m_SubmtList.AddString(submountName);
!     }
  
!     RegCloseKey( hkSubmounts );
  
  	return TRUE;
  }
***************
*** 219,243 ****
  {
  	HOURGLASS hourglass;
  
! 	BOOL written =
! 		WritePrivateProfileString("AFS Submounts",
! 					  PCCHAR(pInfo->GetShareName()),
! 					  PCCHAR(pInfo->GetPathName()),
! 					  "afsdsbmt.ini");
  
! 	return written;
  }
  
  static BOOL DeleteSubmt(CSubmountInfo *pInfo)
  {
  	HOURGLASS hourglass;
  
! 	BOOL written =
! 		WritePrivateProfileString("AFS Submounts",
! 					  PCCHAR(pInfo->GetShareName()),
! 					  NULL,
! 					  "afsdsbmt.ini");
! 	return written;
  }
  
  void CSubmountsDlg::OnAdd() 
--- 248,290 ----
  {
  	HOURGLASS hourglass;
  
!     HKEY hkSubmounts;
!     RegCreateKeyEx( HKEY_LOCAL_MACHINE, 
!                     "SOFTWARE\\OpenAFS\\Client\\Submounts",
!                     0, 
!                     "AFS", 
!                     REG_OPTION_NON_VOLATILE,
!                     KEY_WRITE,
!                     NULL, 
!                     &hkSubmounts,
!                     NULL );
  
!     DWORD status = RegSetValueEx( hkSubmounts, PCCHAR(pInfo->GetShareName()), 0, REG_SZ,
!                    (const BYTE *)PCCHAR(pInfo->GetPathName()), strlen(PCCHAR(pInfo->GetPathName())) + 1);
! 
!     RegCloseKey(hkSubmounts);
! 	return (status == ERROR_SUCCESS);
  }
  
  static BOOL DeleteSubmt(CSubmountInfo *pInfo)
  {
  	HOURGLASS hourglass;
  
!     HKEY hkSubmounts;
!     RegCreateKeyEx( HKEY_LOCAL_MACHINE, 
!                     "SOFTWARE\\OpenAFS\\Client\\Submounts",
!                     0, 
!                     "AFS", 
!                     REG_OPTION_NON_VOLATILE,
!                     KEY_WRITE,
!                     NULL, 
!                     &hkSubmounts,
!                     NULL );
! 
!     DWORD status = RegDeleteValue( hkSubmounts, PCCHAR(pInfo->GetShareName()));
! 
!     RegCloseKey(hkSubmounts);
! 	return (status == ERROR_SUCCESS);
  }
  
  void CSubmountsDlg::OnAdd() 
Index: openafs/src/WINNT/client_osi/osilog.c
diff -c openafs/src/WINNT/client_osi/osilog.c:1.7 openafs/src/WINNT/client_osi/osilog.c:1.8
*** openafs/src/WINNT/client_osi/osilog.c:1.7	Thu Feb 26 14:22:49 2004
--- openafs/src/WINNT/client_osi/osilog.c	Wed Jul 21 17:41:33 2004
***************
*** 342,349 ****
  }
  
  #define REG_CLIENT_PARMS_KEY  "SYSTEM\\CurrentControlSet\\Services\\TransarcAFSDaemon\\Parameters"
! #define TRACE_OPTION_EVENT 1
! #define ISLOGONTRACE(v) ( ((v) & TRACE_OPTION_EVENT)==TRACE_OPTION_EVENT)
  
  DWORD osi_TraceOption=0;
  
--- 342,349 ----
  }
  
  #define REG_CLIENT_PARMS_KEY  "SYSTEM\\CurrentControlSet\\Services\\TransarcAFSDaemon\\Parameters"
! #define TRACE_OPTION_EVENT 2
! #define ISCLIENTTRACE(v) ( ((v) & TRACE_OPTION_EVENT)==TRACE_OPTION_EVENT)
  
  DWORD osi_TraceOption=0;
  
***************
*** 364,370 ****
  {
  	HANDLE h; 
      char *ptbuf[1];
! 	if (!ISLOGONTRACE(osi_TraceOption))
  		return;
  	h = RegisterEventSource(NULL, AFS_DAEMON_EVENT_NAME);
  	ptbuf[0] = b;
--- 364,370 ----
  {
  	HANDLE h; 
      char *ptbuf[1];
! 	if (!ISCLIENTTRACE(osi_TraceOption))
  		return;
  	h = RegisterEventSource(NULL, AFS_DAEMON_EVENT_NAME);
  	ptbuf[0] = b;
***************
*** 377,383 ****
  {
  	HANDLE h; char *ptbuf[1],buf[MAXBUF_+1];
  	va_list marker;
! 	if (!ISLOGONTRACE(osi_TraceOption))
  		return;
      h = RegisterEventSource(NULL, AFS_DAEMON_EVENT_NAME);
  	va_start(marker,c);
--- 377,383 ----
  {
  	HANDLE h; char *ptbuf[1],buf[MAXBUF_+1];
  	va_list marker;
! 	if (!ISCLIENTTRACE(osi_TraceOption))
  		return;
      h = RegisterEventSource(NULL, AFS_DAEMON_EVENT_NAME);
  	va_start(marker,c);
Index: openafs/src/WINNT/install/NSIS/AFSCell.ini
diff -c openafs/src/WINNT/install/NSIS/AFSCell.ini:1.3 openafs/src/WINNT/install/NSIS/AFSCell.ini:1.4
*** openafs/src/WINNT/install/NSIS/AFSCell.ini:1.3	Fri Mar 19 14:44:31 2004
--- openafs/src/WINNT/install/NSIS/AFSCell.ini	Sun Jul 11 17:23:08 2004
***************
*** 1,5 ****
  [Settings]
! NumFields=13
  
  [Field 1]
  Type=label
--- 1,5 ----
  [Settings]
! NumFields=11
  
  [Field 1]
  Type=label
***************
*** 49,63 ****
  Top=65
  Bottom=75
  
! [Field 11]
  Type=Checkbox
! State=0
  Left=50
  Right=60
  Top=75
  Bottom=85
  
! [Field 12]
  Type=label
  Text=Use DNS to Search for Cell Servers
  Left=65
--- 49,63 ----
  Top=65
  Bottom=75
  
! [Field 9]
  Type=Checkbox
! State=1
  Left=50
  Right=60
  Top=75
  Bottom=85
  
! [Field 10]
  Type=label
  Text=Use DNS to Search for Cell Servers
  Left=65
***************
*** 81,103 ****
  Top=85
  Bottom=95
  
! [Field 9]
! Type=Checkbox
! State=0
! Left=50
! Right=60
! Top=95
! Bottom=105
! 
! [Field 10]
! Type=label
! Text=Enable Integrated Logon high security
! Left=65
! Right=-1
! Top=95
! Bottom=105
! 
! [Field 13]
  Type=label
  Text=You may now configure some installation options that control how the AFS Client behaves.
  Left=35
--- 81,87 ----
  Top=85
  Bottom=95
  
! [Field 11]
  Type=label
  Text=You may now configure some installation options that control how the AFS Client behaves.
  Left=35
Index: openafs/src/WINNT/install/NSIS/CellServDB
diff -c /dev/null openafs/src/WINNT/install/NSIS/CellServDB:1.2
*** /dev/null	Tue Jul 27 19:19:59 2004
--- openafs/src/WINNT/install/NSIS/CellServDB	Thu Jul 15 23:38:34 2004
***************
*** 0 ****
--- 1,498 ----
+ >grand.central.org      #GCO Public CellServDB 29 Jun 2004
+ 18.7.14.88                      #grand-opening.mit.edu
+ 128.2.191.224                   #penn.central.org
+ >wu-wien.ac.at          #University of Economics, Vienna, Austria
+ 137.208.3.33                    #afsdb1.wu-wien.ac.at
+ 137.208.7.4                     #afsdb2.wu-wien.ac.at
+ 137.208.7.7                     #afsdb3.wu-wien.ac.at
+ >hephy.at               #hephy-vienna
+ 193.170.243.10                  #mowgli.oeaw.ac.at
+ 193.170.243.12                  #baloo.oeaw.ac.at
+ 193.170.243.14                  #akela.oeaw.ac.at
+ >itp.tugraz.at          #Institute for Theoretical Physics, TU Graz, Austria
+ 129.27.157.6                    #fubphsv2.tu-graz.ac.at
+ 129.27.161.7                    #faepsv01.tu-graz.ac.at
+ 129.27.161.15                   #faepsv02.tu-graz.ac.at
+ >cern.ch                #European Laboratory for Particle Physics, Geneva
+ 137.138.128.148                 #afsdb1.cern.ch
+ 137.138.246.50                  #afsdb3.cern.ch
+ 137.138.246.51                  #afsdb2.cern.ch
+ >ams.cern.ch            #AMS Experiment
+ 137.138.206.77                  #pcamsf2.cern.ch
+ 137.138.206.123                 #pcamsf4.cern.ch
+ >ethz.ch                #Swiss Federal Inst. of Tech. - Zurich, Switzerland
+ 129.132.97.19                   #amalthea.ethz.ch
+ 129.132.97.27                   #nethzafs-001.ethz.ch
+ 129.132.115.3                   #himalia.ethz.ch
+ 129.132.115.37                  #nethzafs-005.ethz.ch
+ 129.132.115.38                  #nethzafs-006.ethz.ch
+ >psi.ch                 #Paul Scherrer Institut - Villigen, Switzerland
+ 129.129.16.10                   #afs1.psi.ch
+ 129.129.16.11                   #afs2.psi.ch
+ >extundo.com            #Simon Josefsson's cell
+ 195.42.214.241                  #slipsten.extundo.com
+ >mekinok.com            #Mekinok, Inc.
+ 4.36.43.98                      #loggerhead.mekinok.com
+ >membrain.com           #membrain.com
+ 66.93.118.125                   #stormy
+ 130.85.24.11                    #weasel
+ 130.85.24.13                    #straykitten
+ >midnightlinux.com      #Midnight Linux, Pittsburgh PA
+ 66.93.62.18                     #romulus.midnihtlinux.com
+ 66.93.62.20                     #yar.midnightlinux.com
+ >setfilepointer.com     #SetFilePointer.com
+ 63.224.10.2                     #hamlet.SetFilePointer.com
+ 63.224.10.4                     #troilus.SetFilePointer.com
+ >sodre.cx               #Sodre.cx
+ 128.8.140.165                   #greed.sodre.cx
+ >desy.de                #Deutsches Elektronen-Synchrotron
+ 131.169.40.62                   #vayu.desy.de
+ 131.169.244.60                  #solar00.desy.de
+ >gppc.de                #GPP Chemnitz mbH
+ 213.187.92.33                   #gpp1.gppc.de
+ 213.187.92.34                   #paulchen.gppc.de
+ 213.187.92.35                   #lotus.gppc.de
+ >ifh.de                 #DESY Zeuthen
+ 141.34.22.10                    #romulus.ifh.de
+ 141.34.22.11                    #remus.ifh.de
+ 141.34.22.29                    #hekate.ifh.de
+ >lrz-muenchen.de        #Leibniz Computing Centre, Germany
+ 129.187.10.36                   #afs1.lrz-muenchen.de
+ 129.187.10.56                   #afs3.lrz-muenchen.de
+ 129.187.10.57                   #afs2.lrz-muenchen.de
+ >ipp-garching.mpg.de    #Institut fuer Plasmaphysik
+ 130.183.9.5                     #afs-db1.rzg.mpg.de
+ 130.183.100.10                  #afs-db2.aug.ipp-garching.mpg.de
+ 130.183.100.23                  #afs-db3.aug.ipp-garching.mpg.de
+ >mpe.mpg.de             #MPE cell
+ 130.183.130.7                   #irafs1.mpe-garching.mpg.de
+ 130.183.134.20                  #irafs2.mpe-garching.mpg.de
+ >i1.informatik.rwth-aachen.de #Informatik I, RWTH Aachen
+ 137.226.244.79                  #remus.informatik.rwth-aachen.de
+ >tu-chemnitz.de         #Technische Universitaet Chemnitz, Germany
+ 134.109.2.1                     #zuse.hrz.tu-chemnitz.de
+ 134.109.2.15                    #phoenix.hrz.tu-chemnitz.de
+ 134.109.200.7                   #aetius.hrz.tu-chemnitz.de
+ >e18.ph.tum.de          #Experimental Physics, TU Munich, Germany
+ 129.187.154.223                 #hamlet.e18.physik.tu-muenchen.de
+ >uni-bonn.de            #University of Bonn, Computing Center
+ 131.220.14.198                  #work15-eth.rhrz.uni-bonn.de
+ 131.220.14.205                  #node05.rhrz.uni-bonn.de
+ 131.220.15.197                  #afs-db1.rhrz.uni-bonn.de
+ >atlass01.physik.uni-bonn.de #Bonn ATLAS
+ 131.220.165.43                  #atlass01.physik.uni-bonn.de
+ >uni-freiburg.de        #Albert-Ludwigs-Universitat Freiburg
+ 132.230.6.235                   #sv6.ruf.uni-freiburg.de
+ 132.230.6.236                   #sv7.ruf.uni-freiburg.de
+ 132.230.6.237                   #sv8.ruf.uni-freiburg.de
+ >physik.uni-freiburg.de #institute of physics, university Freiburg, Germany
+ 132.230.77.16                   #hepafs.physik.uni-freiburg.de
+ >urz.uni-heidelberg.de  #Uni Heidelberg (Rechenzentrum)
+ 129.206.119.10                  #afsdb.urz.uni-heidelberg.de
+ 129.206.119.16                  #afsdb1.urz.uni-heidelberg.de
+ 129.206.119.17                  #afsdb2.urz.uni-heidelberg.de
+ >uni-hohenheim.de       #University of Hohenheim
+ 144.41.2.2                      #rs13.serv.uni-hohenheim.de
+ 144.41.2.3                      #rs14.serv.uni-hohenheim.de
+ 144.41.2.4                      #rs15.serv.uni-hohenheim.de
+ >rz.uni-jena.de         #Rechenzentrum University of Jena, Germany
+ 141.35.2.160                    #lc00.rz.uni-jena.de
+ 141.35.7.9                      #fsuj01.rz.uni-jena.de
+ 141.35.7.10                     #zaphod.rz.uni-jena
+ >meteo.uni-koeln.de     #Univ. of Cologne - Inst. for Geophysics & Meteorology
+ 134.95.144.22                   #afs1.meteo.uni-koeln.de
+ 134.95.144.24                   #afs2.meteo.uni-koeln.de
+ >rrz.uni-koeln.de       #University of Cologne - Reg Comp Center
+ 134.95.19.3                     #afsdb1.rrz.uni-koeln.de
+ 134.95.19.30                    #fileserv3.rrz.uni-koeln.de
+ 134.95.67.97                    #afs.thp.uni-koeln.de
+ 134.95.140.190                  #rzkbserv.rrz.uni-koeln.de
+ >physik.uni-mainz.de    #institute of physics, university Mainz, Germany
+ 134.93.130.93                   #hardy.physik.uni-mainz.de
+ >uni-mannheim.de        #Uni Mannheim (Rechenzentrum)
+ 134.155.97.204                  #afsdb1.uni-mannheim.de
+ 134.155.97.205                  #afsdb2.uni-mannheim.de
+ 134.155.97.206                  #afsdb3.uni-mannheim.de
+ >physik.uni-wuppertal.de #Physics department of Bergische Universität Wuppertal
+ 132.195.104.3                   #afs1.physik.uni-wuppertal.de
+ 132.195.104.230                 #afs2.physik.uni-wuppertal.de
+ >ies.auc.dk             #Aalborg Univ., Inst. of Electronic Systems, Denmark
+ 130.225.51.73                   #afsdb1.kom.auc.dk
+ 130.225.51.74                   #afsdb2.kom.auc.dk
+ 130.225.51.85                   #afsdb3.kom.auc.dk
+ >asu.edu                #Arizona State University
+ 129.219.10.69                   #authen2.asu.edu
+ 129.219.10.70                   #authen1.asu.edu
+ 129.219.10.72                   #authen3.asu.edu
+ 129.219.100.16                  #authen4.asu.edu
+ >hep.caltech.edu        #CalTech High Energy Physics
+ 131.215.126.150                 #afs.hep.caltech.edu
+ >andrew.cmu.edu         #Carnegie Mellon University - Computing Services Cell
+ 128.2.10.2                      #vice2.fs.andrew.cmu.edu
+ 128.2.10.7                      #vice7.fs.andrew.cmu.edu
+ 128.2.10.11                     #vice11.fs.andrew.cmu.edu
+ 128.2.10.28                     #vice28.fs.andrew.cmu.edu
+ 128.2.32.44                     #new-vice12.fs.andrew.cmu.edu
+ >club.cc.cmu.edu        #Carnegie Mellon University Computer Club
+ 128.2.4.131                     #yttrium.club.cc.cmu.edu
+ 128.2.4.132                     #zirconium.club.cc.cmu.edu
+ >chem.cmu.edu           #Carnegie Mellon University - Chemistry Dept.
+ 128.2.40.134                    #afs.chem.cmu.edu
+ 128.2.40.140                    #afs2.chem.cmu.edu
+ >cs.cmu.edu             #Carnegie Mellon University - School of Comp. Sci.
+ 128.2.194.178                   #cherry.srv.cs.cmu.edu
+ 128.2.194.179                   #pumpkin.srv.cs.cmu.edu
+ 128.2.194.180                   #strawberry.srv.cs.cmu.edu
+ >ece.cmu.edu            #Carnegie Mellon University - Elec. Comp. Eng. Dept.
+ 128.2.129.7                     #porok.ece.cmu.edu
+ 128.2.129.8                     #vicio.ece.cmu.edu
+ 128.2.129.9                     #e-xing.ece.cmu.edu
+ >scotch.ece.cmu.edu     #CMU ECE CALCM research group
+ 128.2.134.82                    #lagavulin.ece.cmu.edu
+ >qatar.cmu.edu          #Carnegie Mellon University - Qatar Campus Cell
+ 204.194.25.7                    #afs1.qatar.cmu.edu
+ 204.194.25.8                    #afs2.qatar.cmu.edu
+ >msc.cornell.edu        #Cornell University Materials Science Center
+ 128.84.231.242                  #miranda.ccmr.cornell.edu
+ 128.84.241.35                   #co.ccmr.cornell.edu
+ 128.84.249.78                   #dax.ccmr.cornell.edu
+ >dbic.dartmouth.edu     #Dartmouth Brain Imaging Center
+ 129.170.30.143                  #dbicafs1.dartmouth.edu
+ 129.170.30.144                  #dbicafs2.dartmouth.edu
+ 129.170.30.145                  #dbicafs3.dartmouth.edu
+ >northstar.dartmouth.edu #Dartmouth College Research Computing
+ 129.170.16.22                   #halley.dartmouth.edu
+ 129.170.16.42                   #oort.dartmouth.edu
+ 129.170.16.43                   #cygnusx1.dartmouth.edu
+ >iastate.edu            #Iowa State University
+ 129.186.1.243                   #afsdb-1.iastate.edu
+ 129.186.6.243                   #afsdb-2.iastate.edu
+ 129.186.142.243                 #afsdb-3.iastate.edu
+ >athena.mit.edu         #MIT/Athena cell
+ 18.7.1.66                       #paris.mit.edu.
+ 18.7.1.74                       #chimera.mit.edu.
+ 18.158.0.37                     #prill.mit.edu.
+ >dev.mit.edu            #MIT/IS Development cell
+ 18.7.1.70                       #wham.mit.edu.
+ 18.7.15.89                      #rattle.mit.edu.
+ 18.7.15.93                      #hum.mit.edu.
+ >net.mit.edu            #MIT/Network Group cell
+ 18.7.7.73                       #gracie.mit.edu
+ 18.7.21.95                      #george.mit.edu
+ >sipb.mit.edu           #MIT/SIPB cell
+ 18.181.0.19                     #reynelda.mit.edu.
+ 18.181.0.22                     #rosebud.mit.edu.
+ 18.181.0.23                     #ronald-ann.mit.edu.
+ >msu.edu                #Michigan State University Main Cell
+ 35.9.7.10                       #afsdb0.cl.msu.edu
+ >nd.edu                 #University of Notre Dame
+ 129.74.223.17                   #john.helios.nd.edu
+ 129.74.223.33                   #lizardo.helios.nd.edu
+ 129.74.223.65                   #buckaroo.helios.nd.edu
+ >pitt.edu               #University of Pittsburgh
+ 136.142.8.15                    #afs09.srv.cis.pitt.edu
+ 136.142.8.20                    #afs10.srv.cis.pitt.edu
+ 136.142.8.21                    #afs11.srv.cis.pitt.edu
+ >cs.pitt.edu            #University of Pittsburgh - Computer Science
+ 130.49.220.11                   #afs01.cs.pitt.edu
+ 130.49.220.12                   #afs02.cs.pitt.edu
+ 130.49.220.13                   #afs03.cs.pitt.edu
+ >psc.edu                #PSC (Pittsburgh Supercomputing Center)
+ 128.182.59.182                  #shaggy.psc.edu
+ 128.182.66.184                  #velma.psc.edu
+ 128.182.66.185                  #daphne.psc.edu
+ >scoobydoo.psc.edu      #PSC Test Cell
+ 128.182.59.181                  #scooby.psc.edu
+ >cede.psu.edu           #Penn State - Center for Engr. Design & Entrepeneurship
+ 146.186.218.10                  #greenly.cede.psu.edu
+ 146.186.218.60                  #b50.cede.psu.edu
+ 146.186.218.246                 #stalin.cede.psu.edu
+ >rose-hulman.edu        #Rose-Hulman Institute of Technology
+ 137.112.7.11                    #afs1.rose-hulman.edu
+ 137.112.7.12                    #afs2.rose-hulman.edu
+ 137.112.7.13                    #afs3.rose-hulman.edu
+ >cs.rose-hulman.edu     #Rose-Hulman CS Department
+ 137.112.40.10                   #galaxy.cs.rose-hulman.edu
+ >rpi.edu                #Rensselaer Polytechnic Institute
+ 128.113.22.11                   #saul.server.rpi.edu
+ 128.113.22.12                   #joab.server.rpi.edu
+ 128.113.22.13                   #korah.server.rpi.edu
+ 128.113.22.14                   #achan.server.rpi.edu
+ >hep.sc.edu             #University of South Carolina, Dept. of Physics
+ 129.252.78.77                   #cpeven.physics.sc.edu
+ >cs.stanford.edu        #Stanford University Computer Science Department
+ 171.64.64.10                    #cs-afs-1.Stanford.EDU
+ 171.64.64.66                    #cs-afs-2.stanford.edu
+ 171.64.64.69                    #cs-afs-3.stanford.edu
+ >ir.stanford.edu        #Stanford University
+ 171.64.7.222                    #afsdb1.stanford.edu
+ 171.64.7.234                    #afsdb2.stanford.edu
+ 171.64.7.246                    #afsdb3.stanford.edu
+ >slac.stanford.edu      #Stanford Linear Accelerator Center
+ 134.79.18.25                    #afsdb1.slac.stanford.edu
+ 134.79.18.26                    #afsdb2.slac.stanford.edu
+ 134.79.18.27                    #afsdb3.slac.stanford.edu
+ >cats.ucsc.edu          #UC Santa Cruz, Comm. and Tech. Services, California U.S.A
+ 128.114.129.14                  #elan.ucsc.edu
+ 128.114.129.15                  #ichabod.ucsc.edu
+ 128.114.129.18                  #maneki.ucsc.edu
+ >acm.uiuc.edu           #ACM at the University of Illinois
+ 128.174.251.8                   #alnitak.acm.uiuc.edu
+ 128.174.251.9                   #alnilam.acm.uiuc.edu
+ 128.174.251.10                  #mintaka.acm.uiuc.edu
+ >ncsa.uiuc.edu          #University of Illinois
+ 141.142.3.5                     #congo.ncsa.uiuc.edu
+ 141.142.3.8                     #nile.ncsa.uiuc.edu
+ 141.142.3.9                     #kaskaskia.ncsa.uiuc.edu
+ >umbc.edu               #University of Maryland, Baltimore County
+ 130.85.24.23                    #db2.afs.umbc.edu
+ 130.85.24.87                    #db3.afs.umbc.edu
+ 130.85.24.101                   #db1.afs.umbc.edu
+ >glue.umd.edu           #University of Maryland - Project Glue
+ 128.8.70.11                     #olmec.umd.edu
+ 128.8.73.3                      #babylon.umd.edu
+ 129.2.128.53                    #egypt.umd.edu
+ >wam.umd.edu            #University of Maryland Network WAM Project
+ 128.8.70.9                      #csc-srv.wam.umd.edu
+ 128.8.73.9                      #pg2-srv.wam.umd.edu
+ 129.2.128.54                    #avw-srv.wam.umd.edu
+ >umich.edu              #University of Michigan - Campus
+ 141.211.1.32                    #fear.ifs.umich.edu
+ 141.211.1.33                    #surprise.ifs.umich.edu
+ 141.211.1.34                    #ruthless.ifs.umich.edu
+ >atlas.umich.edu        #ATLAS group cell in physics at University of Michigan
+ 141.211.43.102                  #linat02.grid.umich.edu
+ 141.211.43.106                  #linat06.grid.umich.edu
+ 141.211.43.109                  #atgrid.grid.umich.edu
+ >citi.umich.edu         #Center for Information Technology Integration
+ 141.211.133.5                   #babylon.citi.umich.edu
+ >lsa.umich.edu          #University of Michigan - College of LS&A
+ 141.211.54.132                  #curtis.admin.lsa.umich.edu
+ 141.211.211.53                  #gerow.lsa.umich.edu
+ 141.211.211.72                  #collines.lsa.umich.edu
+ 141.211.211.153                 #hodges.lsa.umich.edu
+ >math.lsa.umich.edu     #University of Michigan - Math Department
+ 141.211.61.40                   #ike.math.lsa.umich.edu
+ 141.211.61.41                   #clark.math.lsa.umich.edu
+ 141.211.61.42                   #nimitz.math.lsa.umich.edu
+ >umr.edu                #University of Missouri - Rolla
+ 131.151.1.59                    #afsdb1.umr.edu
+ 131.151.1.70                    #afsdb3.umr.edu
+ 131.151.1.146                   #afsdb2.umr.edu
+ >physics.unc.edu        #Univ. of NC at Chapel Hill, Dept. of Physics
+ 152.2.5.2                       #valerian.physics.unc.edu
+ 152.2.5.3                       #augustus.physics.unc.edu
+ 152.2.7.67                      #nerva.astro.unc.edu
+ >uncc.edu               #University of NC at Charlotte Mosaic AFS Cell
+ 152.15.10.70                    #as-sm1.uncc.edu
+ 152.15.13.7                     #as-sm2.uncc.edu
+ 152.15.30.27                    #fs-kenn3.uncc.edu
+ >eng.utah.edu           #University of Utah - Engineering
+ 155.99.222.9                    #lenny.eng.utah.edu
+ 155.99.222.10                   #carl.eng.utah.edu
+ >cs.uwm.edu             #University of Wisconsin--Milwaukee
+ 129.89.38.124                   #solomons.cs.uwm.edu
+ >cs.wisc.edu            #Univ. of Wisconsin-Madison, Computer Sciences Dept.
+ 128.105.132.14                  #timon.cs.wisc.edu
+ 128.105.132.15                  #pumbaa.cs.wisc.edu
+ 128.105.132.16                  #zazu.cs.wisc.edu
+ >engr.wisc.edu          #University of Wisconsin-Madison, College of Engineering
+ 144.92.13.14                    #larry.cae.wisc.edu
+ 144.92.13.15                    #curly.cae.wisc.edu
+ 144.92.13.16                    #moe.cae.wisc.edu
+ >hep.wisc.edu           #University of Wisconsin -- High Energy Physics
+ 128.104.28.219                  #anise.physics.wisc.edu
+ >physics.wisc.edu       #Univ. of Wisconsin-Madison, Physics Department
+ 128.104.220.51                  #bubbles.physics.wisc.edu
+ 128.104.220.52                  #buttercup.physics.wisc.edu
+ 128.104.220.53                  #blossom.physics.wisc.edu
+ >ifca.unican.es         #Instituto de Fisica de Cantabria (IFCA), Santander, Spain
+ 193.144.209.20                  #gridwall.ifca.unican.es
+ >ific.uv.es             #Instituto de Fisica Corpuscular, Valencia, Spain
+ 147.156.163.11                  #alpha.ific.uv.es
+ >biocenter.helsinki.fi  #University of Helsinki, Institute of Biotechnology
+ 128.214.58.174                  #afsdb1.biocenter.helsinki.fi
+ 128.214.88.114                  #afsdb2.biocenter.helsinki.fi
+ >dapnia.saclay.cea.fr   #CEA DAPNIA
+ 132.166.32.7                    #dphrsg.saclay.cea.fr
+ 132.166.32.12                   #dphrsl.saclay.cea.fr
+ >in2p3.fr               #IN2P3 production cell
+ 134.158.232.11                  #ccafsdb1.in2p3.fr
+ 134.158.232.12                  #ccafsdb2.in2p3.fr
+ 134.158.232.13                  #ccafsdb3.in2p3.fr
+ >anl.gov                #Argonne National Laboratory
+ 146.137.96.33                   #arteus.ctd.anl.gov
+ 146.137.162.88                  #agamemnon.ctd.anl.gov
+ 146.137.194.80                  #antenor.ctd.anl.gov
+ >rhic.bnl.gov           #Relativistic Heavy Ion Collider
+ 130.199.6.51                    #rafs03.rcf.bnl.gov
+ 130.199.6.52                    #rafs02.rcf.bnl.gov
+ 130.199.6.69                    #rafs01.rcf.bnl.gov
+ >usatlas.bnl.gov        #US Atlas Tier 1 Facility at BNL
+ 130.199.48.32                   #aafs01.usatlas.bnl.gov
+ 130.199.48.33                   #aafs02.usatlas.bnl.gov
+ 130.199.48.34                   #aafs03.usatlas.bnl.gov
+ >fnal.gov               #Fermi National Acclerator Laboratory
+ 131.225.68.1                    #fsus01.fnal.gov
+ 131.225.68.4                    #fsus03.fnal.gov
+ 131.225.68.14                   #fsus04.fnal.gov
+ >ic-afs.arc.nasa.gov    #Code IC, Ames Research Center
+ 128.102.105.62                  #udanax.arc.nasa.gov
+ >nersc.gov              #National Energy Research Supercomputer Center
+ 128.55.128.250                  #mars.nersc.gov
+ 128.55.128.252                  #alfred.nersc.gov
+ 128.55.128.254                  #lurch.nersc.gov
+ >caspur.it              #CASPUR Inter-University Computing Consortium, Rome
+ 193.204.5.45                    #pomodoro.caspur.it
+ 193.204.5.46                    #banana.caspur.it
+ 193.204.5.50                    #maslo.caspur.it
+ >fusione.it             #Assoz. FUSIONE/Euratom, ENEA, Frascati-Italy
+ 192.107.90.2                    #fusafs1.frascati.enea.it
+ 192.107.90.3                    #fusafs2.frascati.enea.it
+ 192.107.90.4                    #fusafs3.frascati.enea.it
+ >icemb.it               #ICEMB, Universita' La Sapienza - Rome - Italy
+ 193.204.6.130                   #icembfs.caspur.it
+ >infn.it                #Istituto Nazionale di Fisica Nucleare (INFN), Italia
+ 131.154.1.7                     #afs3.infn.it
+ 141.108.3.252                   #afs1.infn.it
+ 192.84.134.75                   #afs2.infn.it
+ >kloe.infn.it           #INFN, KLOE experiment at Laboratori di Frascati
+ 192.135.25.111                  #kloeafs1.lnf.infn.it
+ 192.135.25.112                  #kloeafs2.lnf.infn.it
+ >le.infn.it             #INFN, Sezione di Lecce
+ 192.84.152.40                   #afs01.le.infn.it
+ 192.84.152.148                  #afs02.le.infn.it
+ >lnf.infn.it            #INFN, Laboratori Nazionali di Frascati
+ 193.206.84.121                  #afs1.lnf.infn.it
+ 193.206.84.122                  #afs2.lnf.infn.it
+ 193.206.84.123                  #afs3.lnf.infn.it
+ >lngs.infn.it           #INFN, Laboratori Nazionali di Gran Sasso
+ 192.84.135.21                   #rsgs05.lngs.infn.it
+ >pi.infn.it             #INFN, Sezione di Pisa
+ 131.114.134.26                  #unknownhost.pi.infn.it
+ 192.84.133.50                   #aix1.pi.infn.it
+ >psm.it                 #Progetto San Marco, Universita' di Roma-1
+ 151.100.1.65                    #atlante.psm.uniroma1.it
+ >tgrid.it               #CASPUR-CILEA-CINECA Grid Cell
+ 193.204.5.33                    #cccgrid.caspur.it
+ >ictp.trieste.it        #The Abdus Salam International Centre for Theoretical Physics (IC
+ 140.105.16.8                    #fs1.ictp.trieste.it
+ 140.105.16.9                    #fs2.ictp.trieste.it
+ >ing.uniroma1.it        #Universita' La Sapienza, Fac. Ingeneria
+ 151.100.85.253                  #alfa.ing.uniroma1.it
+ >vn.uniroma3.it         #University of Rome 3, Area Vasca Navale
+ 193.204.161.136                 #alfa.dia.uniroma3.it
+ 193.204.161.137                 #beta.dia.uniroma3.it
+ 193.204.161.138                 #gamma.dia.uniroma3.it
+ >italia                 #Italian public AFS cell
+ 193.204.5.9                     #afs.caspur.it
+ >cmf.nrl.navy.mil       #Naval Research Lab - CCS
+ 134.207.10.68                   #picard.cmf.nrl.navy.mil
+ 134.207.10.69                   #riker.cmf.nrl.navy.mil
+ 134.207.10.70                   #kirk.cmf.nrl.navy.mil
+ >lcp.nrl.navy.mil       #Naval Research Lab - Lab for Computational Physics
+ 132.250.114.2                   #afs1.lcp.nrl.navy.mil
+ 132.250.114.4                   #afs2.lcp.nrl.navy.mil
+ 132.250.114.6                   #afs3.lcp.nrl.navy.mil
+ >es.net                 #Energy Sciences Net
+ 198.128.3.21                    #fs1.es.net
+ 198.128.3.22                    #fs2.es.net
+ 198.128.3.23                    #fs3.es.net
+ >laroia.net             #Laroia Networks
+ 66.66.102.254                   #supercore.laroia.net
+ >sinenomine.net         #Sine Nomine Associates
+ 66.92.236.139                   #afs.sinenomine.net
+ >slackers.net           #The Slackers' Network
+ 63.201.48.27                    #alexandria.slackers.net
+ >nikhef.nl              #The Dutch National Institute for High Energy Physics
+ 192.16.185.26                   #afs1.nikhef.nl
+ 192.16.185.27                   #afs2.nikhef.nl
+ >1ts.org                #KCR/private Karl Ramm, Cambridge, MA
+ 4.36.43.102                     #dol-guldur.1ts.org
+ >bazquux.org            #Baz Quux Organization
+ 66.207.142.196                  #baxquux.org
+ >coed.org               #Adam Pennington's Cell
+ 66.93.61.184                    #vice1.coed.org
+ 128.2.4.163                     #vice3.coed.org
+ >dementia.org           #Dementia Unlimited
+ 128.2.12.45                     #alycia.dementia.org
+ 128.2.120.216                   #meredith.dementia.org
+ >hackish.org            #Hackish.org
+ 24.167.65.213                   #avatar.sys.hackish.org
+ 128.2.120.138                   #kurma.sys.hackish.org
+ >idahofuturetruck.org   #University of Idaho hybrid vehicle development
+ 12.18.238.210                   #dsle210.fsr.net
+ >nimlabs.org            #Nimlabs, Ink. Cell.
+ 18.238.1.103                    #olfin.nimlabs.org
+ 18.238.1.105                    #caerbanog.nimlabs.org
+ >nomh.org               #nomh.org
+ 204.29.154.12                   #iota.nomh.org
+ 204.29.154.32                   #adversity.xi.nomh.org
+ >oc7.org                #The OC7 Project
+ 128.2.6.107                     #vice3.oc7.org
+ 128.2.122.140                   #vice2.oc7.org
+ >openafs.org            #OpenAFS Project
+ 128.2.13.199                    #new-virtue.openafs.org
+ 128.2.121.218                   #virtue.openafs.org
+ 130.237.48.87                   #andrew.e.kth.se
+ 130.237.48.107                  #onyx.e.kth.se
+ >e.kth.se               #Royal Institute of Technology, Elektro
+ 130.237.32.145                  #sonen.e.kth.se
+ 130.237.48.7                    #anden.e.kth.se
+ 130.237.48.244                  #fadern.e.kth.se
+ >hallf.kth.se           #Royal Institute of Technology, HALLF
+ 130.237.24.141                  #rasmus13.hallf.kth.se
+ 130.237.24.152                  #rasmus3.hallf.kth.se
+ 130.237.24.177                  #rasmus29.hallf.kth.se
+ >isk.kth.se             #Royal Institute of Technology, ISK
+ 130.237.202.12                  #afsdb2.isk.kth.se
+ 130.237.206.13                  #afsdb1.isk.kth.se
+ 130.237.209.141                 #afsdb3.isk.kth.se
+ >it.kth.se              #Royal Institute of Technology, IT
+ 130.237.212.15                  #ptah.it.kth.se
+ 130.237.212.16                  #toth.it.kth.se
+ 130.237.215.7                   #isis.it.kth.se
+ >md.kth.se              #Royal Institute of Technology, MMK
+ 130.237.57.68                   #trinity.md.kth.se
+ 130.237.57.72                   #morpheus.md.kth.se
+ 130.237.67.230                  #neo.speech.kth.se
+ >mech.kth.se            #Royal Institute of Technology, MECH
+ 130.237.233.143                 #castor.mech.kth.se
+ 130.237.233.144                 #pollux.mech.kth.se
+ >nada.kth.se            #Royal Institute of Technology, NADA
+ 130.237.222.20                  #kosmos.nada.kth.se
+ 130.237.223.12                  #sputnik.nada.kth.se
+ 130.237.224.78                  #mir.nada.kth.se
+ 130.237.227.23                  #gagarin.nada.kth.se
+ 130.237.228.28                  #laika.nada.kth.se
+ >pdc.kth.se             #Royal Institute of Technology, PDC
+ 130.237.232.29                  #crab.pdc.kth.se
+ 130.237.232.112                 #anna.pdc.kth.se
+ 130.237.232.114                 #hokkigai.pdc.kth.se
+ >stacken.kth.se         #Stacken Computer Club
+ 130.237.234.3                   #milko.stacken.kth.se
+ 130.237.234.43                  #hot.stacken.kth.se
+ 130.237.237.230                 #fishburger.stacken.kth.se
+ >syd.kth.se             #Royal Institute of Technology, KTH-Syd
+ 130.237.83.23                   #afs.haninge.kth.se
+ >physto.se              #Physics department Stockholm University
+ 130.237.205.36                  #sysafs1.physto.se
+ 130.237.205.72                  #sysafs2.physto.se
+ >sanchin.se             #Sanchin Consulting AB, Sweden
+ 192.195.148.10                  #sesan.sanchin.se
+ >su.se                  #Stockholm University
+ 130.237.162.81                  #afsdb1.su.se
+ 130.237.162.82                  #afsdb2.su.se
+ 130.237.162.230                 #afsdb3.su.se
+ >f9.ijs.si              #F9, Jozef Stefan Institue
+ 194.249.156.1                   #brenta.ijs.si
+ >p-ng.si                #Nova Gorica Polytechnic
+ 193.2.120.2                     #solkan.p-ng.si
+ >phy.bris.ac.uk         #Bristol University - phyics
+ 137.222.58.9                    #afs1.phy.bris.ac.uk
+ >hep.man.ac.uk          #Manchester HEP
+ 194.36.2.3                      #afs1.hep.man.ac.uk
+ 194.36.2.4                      #afs2.hep.man.ac.uk
+ 194.36.2.5                      #afs3.hep.man.ac.uk
+ >rl.ac.uk               #Rutherford Appleton Lab, England
+ 130.246.183.164                 #wallace.cc.rl.ac.uk
Index: openafs/src/WINNT/install/NSIS/OpenAFS.nsi
diff -c openafs/src/WINNT/install/NSIS/OpenAFS.nsi:1.59 openafs/src/WINNT/install/NSIS/OpenAFS.nsi:1.65
*** openafs/src/WINNT/install/NSIS/OpenAFS.nsi:1.59	Thu Jun 24 14:57:51 2004
--- openafs/src/WINNT/install/NSIS/OpenAFS.nsi	Mon Jul 26 16:39:54 2004
***************
*** 530,536 ****
    File "${AFS_CLIENT_BUILDDIR}\afscreds.exe"
    !insertmacro ReplaceDLL "${AFS_CLIENT_BUILDDIR}\afs_shl_ext.dll" "$INSTDIR\Client\Program\afs_shl_ext.dll" "$INSTDIR"
    File "${AFS_CLIENT_BUILDDIR}\afsd_service.exe"
-   !insertmacro ReplaceDLL "${AFS_CLIENT_BUILDDIR}\afslogon.dll" "$INSTDIR\Client\Program\afslogon.dll" "$INSTDIR"
    File "${AFS_CLIENT_BUILDDIR}\symlink.exe"
    File "${AFS_DESTDIR}\bin\kpasswd.exe"
    File "${AFS_SERVER_BUILDDIR}\pts.exe"
--- 530,535 ----
***************
*** 541,557 ****
    File "${AFS_DESTDIR}\bin\translate_et.exe"
    File "${AFS_DESTDIR}\etc\rxdebug.exe"
    File "${AFS_DESTDIR}\etc\backup.exe"
    
!    Call AFSLangFiles
     
  
-    
-   ; Do WINDOWSDIR components
-   
-   ; Do Windows SYSDIR (Control panel)
-   SetOutPath "$SYSDIR"
-   !insertmacro ReplaceDLL "${AFS_CLIENT_BUILDDIR}\afs_cpa.cpl" "$SYSDIR\afs_cpa.cpl" "$INSTDIR"
-   
    ; Get AFS CellServDB file
    Call afs.GetCellServDB
  
--- 540,552 ----
    File "${AFS_DESTDIR}\bin\translate_et.exe"
    File "${AFS_DESTDIR}\etc\rxdebug.exe"
    File "${AFS_DESTDIR}\etc\backup.exe"
+   !insertmacro ReplaceDLL "${AFS_CLIENT_BUILDDIR}\afs_cpa.cpl" "$INSTDIR\Client\Program\afs_cpa.cpl" "$INSTDIR"
    
!   SetOutPath "$SYSDIR"
!   !insertmacro ReplaceDLL "${AFS_CLIENT_BUILDDIR}\afslogon.dll" "$SYSDIR\afslogon.dll" "$INSTDIR"
     
+    Call AFSLangFiles
  
    ; Get AFS CellServDB file
    Call afs.GetCellServDB
  
***************
*** 574,579 ****
--- 569,575 ----
    WriteRegStr HKCR "CLSID\{DC515C27-6CAC-11D1-BAE7-00C04FD140D2}\InprocServer32" "ThreadingModel" "Apartment"
    WriteRegStr HKCR "FOLDER\shellex\ContextMenuHandlers\AFS Client Shell Extension" "" "{DC515C27-6CAC-11D1-BAE7-00C04FD140D2}"
    WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Approved" "{DC515C27-6CAC-11D1-BAE7-00C04FD140D2}" "AFS Client Shell Extension"
+   WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Control Panel\Cpls" "afs_cpa" "$INSTDIR\Client\Program\afs_cpa.cpl"
    
    ; AFS Reg entries
    DeleteRegKey HKLM "${AFS_REGKEY_ROOT}\AFS Client\CurrentVersion"
***************
*** 636,643 ****
    StrCmp $R1 "1" +1 +2
    CreateShortCut "$SMSTARTUP\AFS Credentials.lnk" "$INSTDIR\Client\Program\afscreds.exe" "$R2"
  
-   
-   
    Push "$INSTDIR\Client\Program"
    Call AddToUniquePath
    Push "$INSTDIR\Common"
--- 632,637 ----
***************
*** 665,673 ****
  
    ; Daemon entries
    WriteRegStr HKLM "SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon" "" ""
!   WriteRegStr HKLM "SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\NetworkProvider" "ProviderPath" "$INSTDIR\Client\Program\afslogon.dll"
!   WriteRegStr HKLM "SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\NetworkProvider" "AuthentProviderPath" "$INSTDIR\Client\Program\afslogon.dll"
!   WriteRegStr HKLM "SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\NetworkProvider" "AuthentProviderPath" "$INSTDIR\Client\Program\afslogon.dll"
    WriteRegDWORD HKLM "SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\NetworkProvider" "Class" 2
    WriteRegDWORD HKLM "SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\NetworkProvider" "VerboseLogging" 10
  
--- 659,666 ----
  
    ; Daemon entries
    WriteRegStr HKLM "SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon" "" ""
!   WriteRegStr HKLM "SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\NetworkProvider" "ProviderPath" "$SYSDIR\afslogon.dll"
!   WriteRegStr HKLM "SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\NetworkProvider" "AuthentProviderPath" "$SYSDIR\afslogon.dll"
    WriteRegDWORD HKLM "SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\NetworkProvider" "Class" 2
    WriteRegDWORD HKLM "SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\NetworkProvider" "VerboseLogging" 10
  
***************
*** 676,686 ****
    ; to also include the service name.
    Call AddProvider
    ReadINIStr $R0 $1 "Field 7" "State"
!   ReadINIStr $R1 $1 "Field 9" "State"
!   ; Complicated way to do $R1 = ($R1 *2) + $R0
!   IntOp $R2 $R1 * 2
!   IntOp $R1 $R2 + $R0
!   WriteRegDWORD HKLM "SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\NetworkProvider" "LogonOptions" $R1
    WriteRegStr HKLM "SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\NetworkProvider" "LogonScript" "$INSTDIR\Client\Program\afscreds.exe -:%s -x -a -m -n -q"
    WriteRegStr HKLM "SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\NetworkProvider" "Name" "OpenAFSDaemon"
  
--- 669,675 ----
    ; to also include the service name.
    Call AddProvider
    ReadINIStr $R0 $1 "Field 7" "State"
!   WriteRegDWORD HKLM "SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\NetworkProvider" "LogonOptions" $R0
    WriteRegStr HKLM "SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\NetworkProvider" "LogonScript" "$INSTDIR\Client\Program\afscreds.exe -:%s -x -a -m -n -q"
    WriteRegStr HKLM "SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\NetworkProvider" "Name" "OpenAFSDaemon"
  
***************
*** 692,698 ****
    WriteRegDWORD HKLM "SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\Parameters" "SecurityLevel" $R0
    ReadINIStr $R0 $1 "Field 5" "State"  
    WriteRegDWORD HKLM "SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\Parameters" "FreelanceClient" $R0
!   ReadINIStr $R0 $1 "Field 11" "State"
    WriteRegDWORD HKLM "SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\Parameters" "UseDNS" $R0
    WriteRegStr HKLM "SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\Parameters" "NetbiosName" "AFS"
    WriteRegStr HKLM "SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\Parameters" "MountRoot" "/afs"
--- 681,687 ----
    WriteRegDWORD HKLM "SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\Parameters" "SecurityLevel" $R0
    ReadINIStr $R0 $1 "Field 5" "State"  
    WriteRegDWORD HKLM "SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\Parameters" "FreelanceClient" $R0
!   ReadINIStr $R0 $1 "Field 9" "State"
    WriteRegDWORD HKLM "SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\Parameters" "UseDNS" $R0
    WriteRegStr HKLM "SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\Parameters" "NetbiosName" "AFS"
    WriteRegStr HKLM "SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\Parameters" "MountRoot" "/afs"
***************
*** 717,722 ****
--- 706,718 ----
    strcpy $REG_DATA_3  "RpcSs"
    Call RegWriteMultiStr
  
+   ; WinLogon Event Notification
+   WriteRegDWORD HKLM "Software\Microsoft\Windows NT\CurrentVersion\WinLogon\Notify\AfsLogon" "Asynchronous" 0
+   WriteRegDWORD HKLM "Software\Microsoft\Windows NT\CurrentVersion\WinLogon\Notify\AfsLogon" "Impersonate"  1
+   WriteRegStr HKLM "Software\Microsoft\Windows NT\CurrentVersion\WinLogon\Notify\AfsLogon" "DLLName" "afslogon.dll"
+   WriteRegStr HKLM "Software\Microsoft\Windows NT\CurrentVersion\WinLogon\Notify\AfsLogon" "Logoff" "AFS_Logoff_Event"
+   WriteRegStr HKLM "Software\Microsoft\Windows NT\CurrentVersion\WinLogon\Notify\AfsLogon" "Startup" "AFS_Startup_Event"
+ 
    SetRebootFlag true
    
    WriteUninstaller "$INSTDIR\Uninstall.exe"
***************
*** 880,955 ****
   Call AFSLangFiles
   SetOutPath "$INSTDIR\Common"
  
-   SetOutPath "$INSTDIR\Common"
- !IFDEF DEBUG
- !IFDEF CL_1310
-    File "${SYSTEMDIR}\msvcr71d.dll"
-    File "${SYSTEMDIR}\msvcp71d.dll"
-    File "${SYSTEMDIR}\mfc71d.dll"
-    File "${SYSTEMDIR}\MFC71CHS.DLL"
-    File "${SYSTEMDIR}\MFC71CHT.DLL"
-    File "${SYSTEMDIR}\MFC71DEU.DLL"
-    File "${SYSTEMDIR}\MFC71ENU.DLL"
-    File "${SYSTEMDIR}\MFC71ESP.DLL"
-    File "${SYSTEMDIR}\MFC71FRA.DLL"
-    File "${SYSTEMDIR}\MFC71ITA.DLL"
-    File "${SYSTEMDIR}\MFC71JPN.DLL"
-    File "${SYSTEMDIR}\MFC71KOR.DLL"
- !ELSE
- !IFDEF CL_1300
-    File "${SYSTEMDIR}\msvcr70d.dll"
-    File "${SYSTEMDIR}\msvcp70d.dll"
-    File "${SYSTEMDIR}\mfc70d.dll"
-    File "${SYSTEMDIR}\MFC70CHS.DLL"
-    File "${SYSTEMDIR}\MFC70CHT.DLL"
-    File "${SYSTEMDIR}\MFC70DEU.DLL"
-    File "${SYSTEMDIR}\MFC70ENU.DLL"
-    File "${SYSTEMDIR}\MFC70ESP.DLL"
-    File "${SYSTEMDIR}\MFC70FRA.DLL"
-    File "${SYSTEMDIR}\MFC70ITA.DLL"
-    File "${SYSTEMDIR}\MFC70JPN.DLL"
-    File "${SYSTEMDIR}\MFC70KOR.DLL"
- !ELSE
-    File "${SYSTEMDIR}\mfc42d.dll"
-    File "${SYSTEMDIR}\msvcp60d.dll"
-    File "${SYSTEMDIR}\msvcrtd.dll"
- !ENDIF
- !ENDIF
- !ELSE
- !IFDEF CL_1310
-    File "${SYSTEMDIR}\mfc71.dll"
-    File "${SYSTEMDIR}\msvcr71.dll"
-    File "${SYSTEMDIR}\msvcp71.dll"
-    File "${SYSTEMDIR}\MFC71CHS.DLL"
-    File "${SYSTEMDIR}\MFC71CHT.DLL"
-    File "${SYSTEMDIR}\MFC71DEU.DLL"
-    File "${SYSTEMDIR}\MFC71ENU.DLL"
-    File "${SYSTEMDIR}\MFC71ESP.DLL"
-    File "${SYSTEMDIR}\MFC71FRA.DLL"
-    File "${SYSTEMDIR}\MFC71ITA.DLL"
-    File "${SYSTEMDIR}\MFC71JPN.DLL"
-    File "${SYSTEMDIR}\MFC71KOR.DLL"
- !ELSE
- !IFDEF CL_1300
-    File "${SYSTEMDIR}\mfc70.dll"
-    File "${SYSTEMDIR}\msvcr70.dll"
-    File "${SYSTEMDIR}\msvcp70.dll"
-    File "${SYSTEMDIR}\MFC70CHS.DLL"
-    File "${SYSTEMDIR}\MFC70CHT.DLL"
-    File "${SYSTEMDIR}\MFC70DEU.DLL"
-    File "${SYSTEMDIR}\MFC70ENU.DLL"
-    File "${SYSTEMDIR}\MFC70ESP.DLL"
-    File "${SYSTEMDIR}\MFC70FRA.DLL"
-    File "${SYSTEMDIR}\MFC70ITA.DLL"
-    File "${SYSTEMDIR}\MFC70JPN.DLL"
-    File "${SYSTEMDIR}\MFC70KOR.DLL"
- !ELSE
-    File "${SYSTEMDIR}\mfc42.dll"
-    File "${SYSTEMDIR}\msvcp60.dll"
-    File "${SYSTEMDIR}\msvcrt.dll"
- !ENDIF
- !ENDIF
- !ENDIF   
     ;Store install folder
    WriteRegStr HKCU "${AFS_REGKEY_ROOT}\AFS Control Center\CurrentVersion" "PathName" $INSTDIR
    WriteRegStr HKLM "${AFS_REGKEY_ROOT}\AFS Control Center\CurrentVersion" "VersionString" ${AFS_VERSION}
--- 876,881 ----
***************
*** 1185,1191 ****
    File "${AFS_CLIENT_BUILDDIR}\afscreds.pdb"
    File "${AFS_CLIENT_BUILDDIR}\afs_shl_ext.pdb"
    File "${AFS_CLIENT_BUILDDIR}\afsd_service.pdb"
-   File "${AFS_CLIENT_BUILDDIR}\afslogon.pdb"
    File "${AFS_CLIENT_BUILDDIR}\symlink.pdb"
    File "${AFS_DESTDIR}\bin\kpasswd.pdb"
    File "${AFS_DESTDIR}\bin\pts.pdb"
--- 1111,1116 ----
***************
*** 1196,1204 ****
    File "${AFS_DESTDIR}\bin\translate_et.pdb"
    File "${AFS_DESTDIR}\etc\rxdebug.pdb"
    File "${AFS_DESTDIR}\etc\backup.pdb"
  
    SetOutPath "$SYSDIR"
!   File "${AFS_CLIENT_BUILDDIR}\afs_cpa.pdb"
    
  DoServer:
    	SectionGetFlags ${secServer} $R0
--- 1121,1130 ----
    File "${AFS_DESTDIR}\bin\translate_et.pdb"
    File "${AFS_DESTDIR}\etc\rxdebug.pdb"
    File "${AFS_DESTDIR}\etc\backup.pdb"
+   File "${AFS_CLIENT_BUILDDIR}\afs_cpa.pdb"
  
    SetOutPath "$SYSDIR"
!   File "${AFS_CLIENT_BUILDDIR}\afslogon.pdb"
    
  DoServer:
    	SectionGetFlags ${secServer} $R0
***************
*** 1761,1778 ****
  !ENDIF
    
     IfSilent SkipDel
! ;  IfFileExists "$WINDIR\afsdcell.ini" CellExists SkipDelAsk
  ;  CellExists:
    MessageBox MB_YESNO "Would you like to keep your configuration files?" IDYES SkipDel
!   Delete "$WINDIR\afsdcell.ini"
  
-   Delete "$WINDIR\afsdsbmt.ini"
  ; Only remove krb5.ini if KfW was installed
  !IFDEF INSTALL_KFW
    Delete "$WINDIR\krb5.ini"
  !ENDIF
!   Delete "$WINDIR\afsdns.ini"
!   Delete "$WINDIR\afs_freelance.ini"
    
    SkipDel:
    Delete "$WINDIR\afsd_init.log"
--- 1687,1702 ----
  !ENDIF
    
     IfSilent SkipDel
! ;  IfFileExists "$INSTDIR\Client\CellServDB" CellExists SkipDelAsk
  ;  CellExists:
    MessageBox MB_YESNO "Would you like to keep your configuration files?" IDYES SkipDel
!   Delete "$INSTDIR\Client\CellServDB"
  
  ; Only remove krb5.ini if KfW was installed
  !IFDEF INSTALL_KFW
    Delete "$WINDIR\krb5.ini"
  !ENDIF
!   Delete "$INSTDIR\Client\afsdns.ini"
    
    SkipDel:
    Delete "$WINDIR\afsd_init.log"
***************
*** 1958,1963 ****
--- 1882,1891 ----
    DeleteRegKey HKCR "CLSID\{DC515C27-6CAC-11D1-BAE7-00C04FD140D2}"
    DeleteRegKey HKCR "FOLDER\shellex\ContextMenuHandlers\AFS Client Shell Extension"
    DeleteRegValue HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Approved" "{DC515C27-6CAC-11D1-BAE7-00C04FD140D2}"
+   DeleteRegValue HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Control Panel\Cpls" "afs_cpa"
+ 
+   ; WinLogon Event Notification
+   DeleteRegKey HKLM "Software\Microsoft\Windows NT\CurrentVersion\Winlogon\Notify\AfsLogon"
  
    DeleteRegKey HKLM "${AFS_REGKEY_ROOT}\AFS Client\CurrentVersion"
    DeleteRegKey HKLM "${AFS_REGKEY_ROOT}\AFS Client"
***************
*** 2017,2037 ****
  
  DoDownload:
     ReadINIStr $R0 $0 "Field 5" "State"
!    NSISdl::download $R0 "$WINDIR\afsdcell.ini"
     Pop $R0 ;Get the return value
     StrCmp $R0 "success" +2
        MessageBox MB_OK|MB_ICONSTOP "Download failed: $R0"
     goto done
  
  UsePackaged:
!    SetOutPath "$WINDIR"
!    File "afsdcell.ini"
     goto done
     
  CheckOther:
     ReadINIStr $R0 $0 "Field 7" "State"
     StrCmp $R0 "" done
!    CopyFiles $R0 "$WINDIR\afsdcell.ini"
     
  done:
  
--- 1945,1965 ----
  
  DoDownload:
     ReadINIStr $R0 $0 "Field 5" "State"
!    NSISdl::download $R0 "$INSTDIR\Client\CellServDB"
     Pop $R0 ;Get the return value
     StrCmp $R0 "success" +2
        MessageBox MB_OK|MB_ICONSTOP "Download failed: $R0"
     goto done
  
  UsePackaged:
!    SetOutPath "$INSTDIR\Client"
!    File "CellServDB"
     goto done
     
  CheckOther:
     ReadINIStr $R0 $0 "Field 7" "State"
     StrCmp $R0 "" done
!    CopyFiles $R0 "$INSTDIR\Client\CellServDB"
     
  done:
  
***************
*** 2182,2189 ****
    WriteINISTR $0 "Field 4" "State" "0"
    WriteINIStr $0 "Field 6" "State" "0"
    
!   ; If there is an existing afsdcell.ini file, allow the user to choose it and make it default
!   IfFileExists "$WINDIR\afsdcell.ini" +1 notpresent
    WriteINIStr $0 "Field 2" "Flags" "ENABLED"
    WriteINIStr $0 "Field 2" "State" "1"
    WriteINIStr $0 "Field 3" "State" "0"
--- 2110,2121 ----
    WriteINISTR $0 "Field 4" "State" "0"
    WriteINIStr $0 "Field 6" "State" "0"
    
!   ; If there is an existing afsdcell.ini file, migrate it to CellServDB
!   IfFileExists "$WINDIR\afsdcell.ini" +1 +3
!   CopyFiles /SILENT "$WINDIR\afsdcell.ini" "$INSTDIR\Client\CellServDB"
!   Delete "$WINDIR\afsdcell.ini"
!   ; If there is an existing CellServDB file, allow the user to choose it and make it default
!   IfFileExists "$INSTDIR\Client\CellServDB" +1 notpresent
    WriteINIStr $0 "Field 2" "Flags" "ENABLED"
    WriteINIStr $0 "Field 2" "State" "1"
    WriteINIStr $0 "Field 3" "State" "0"
***************
*** 2637,2734 ****
     ; Common files
     SetOutPath "$INSTDIR\Common"
     File "${AFS_CLIENT_BUILDDIR}\afs_config.exe"
-    File "${AFS_SERVER_BUILDDIR}\afsadminutil.dll"
    !insertmacro ReplaceDLL "${AFS_DESTDIR}\lib\afsauthent.dll" "$INSTDIR\Common\afsauthent.dll" "$INSTDIR"
    !insertmacro ReplaceDLL "${AFS_DESTDIR}\lib\afspthread.dll" "$INSTDIR\Common\afspthread.dll" "$INSTDIR"
    !insertmacro ReplaceDLL "${AFS_DESTDIR}\lib\afsrpc.dll" "$INSTDIR\Common\afsrpc.dll" "$INSTDIR"
!    File "${AFS_SERVER_BUILDDIR}\afsclientadmin.dll"
!    File "${AFS_SERVER_BUILDDIR}\afsprocmgmt.dll"
!    File "${AFS_SERVER_BUILDDIR}\afsvosadmin.dll"
!    File "${AFS_SERVER_BUILDDIR}\TaAfsAppLib.dll"
!    File "${AFS_SERVER_BUILDDIR}\afsvosadmin.dll"
!    File "${AFS_SERVER_BUILDDIR}\afsbosadmin.dll"
!    File "${AFS_SERVER_BUILDDIR}\afscfgadmin.dll"
!    File "${AFS_SERVER_BUILDDIR}\afskasadmin.dll"
!    File "${AFS_SERVER_BUILDDIR}\afsptsadmin.dll"
  
  !IFDEF DEBUG
  !IFDEF CL_1310
!    File "${SYSTEMDIR}\msvcr71d.dll"
!    File "${SYSTEMDIR}\msvcr71d.pdb"
!    File "${SYSTEMDIR}\msvcp71d.dll"
!    File "${SYSTEMDIR}\msvcp71d.pdb"
!    File "${SYSTEMDIR}\mfc71d.dll"
!    File "${SYSTEMDIR}\mfc71d.pdb"
!    File "${SYSTEMDIR}\MFC71CHS.DLL"
!    File "${SYSTEMDIR}\MFC71CHT.DLL"
!    File "${SYSTEMDIR}\MFC71DEU.DLL"
!    File "${SYSTEMDIR}\MFC71ENU.DLL"
!    File "${SYSTEMDIR}\MFC71ESP.DLL"
!    File "${SYSTEMDIR}\MFC71FRA.DLL"
!    File "${SYSTEMDIR}\MFC71ITA.DLL"
!    File "${SYSTEMDIR}\MFC71JPN.DLL"
!    File "${SYSTEMDIR}\MFC71KOR.DLL"
  !ELSE
  !IFDEF CL_1300
!    File "${SYSTEMDIR}\msvcr70d.dll"
!    File "${SYSTEMDIR}\msvcr70d.pdb"
!    File "${SYSTEMDIR}\msvcp70d.dll"
!    File "${SYSTEMDIR}\msvcp70d.pdb"
!    File "${SYSTEMDIR}\mfc70d.dll"
!    File "${SYSTEMDIR}\mfc70d.pdb"
!    File "${SYSTEMDIR}\MFC70CHS.DLL"
!    File "${SYSTEMDIR}\MFC70CHT.DLL"
!    File "${SYSTEMDIR}\MFC70DEU.DLL"
!    File "${SYSTEMDIR}\MFC70ENU.DLL"
!    File "${SYSTEMDIR}\MFC70ESP.DLL"
!    File "${SYSTEMDIR}\MFC70FRA.DLL"
!    File "${SYSTEMDIR}\MFC70ITA.DLL"
!    File "${SYSTEMDIR}\MFC70JPN.DLL"
!    File "${SYSTEMDIR}\MFC70KOR.DLL"
! !ELSE
!    File "${SYSTEMDIR}\mfc42d.dll"
!    File "${SYSTEMDIR}\mfc42d.pdb"
!    File "${SYSTEMDIR}\msvcp60d.dll"
!    File "${SYSTEMDIR}\msvcp60d.pdb"
!    File "${SYSTEMDIR}\msvcrtd.dll"
!    File "${SYSTEMDIR}\msvcrtd.pdb"
  !ENDIF
  !ENDIF
  !ELSE
  !IFDEF CL_1310
!    File "${SYSTEMDIR}\mfc71.dll"
!    File "${SYSTEMDIR}\msvcr71.dll"
!    File "${SYSTEMDIR}\msvcp71.dll"
!    File "${SYSTEMDIR}\MFC71CHS.DLL"
!    File "${SYSTEMDIR}\MFC71CHT.DLL"
!    File "${SYSTEMDIR}\MFC71DEU.DLL"
!    File "${SYSTEMDIR}\MFC71ENU.DLL"
!    File "${SYSTEMDIR}\MFC71ESP.DLL"
!    File "${SYSTEMDIR}\MFC71FRA.DLL"
!    File "${SYSTEMDIR}\MFC71ITA.DLL"
!    File "${SYSTEMDIR}\MFC71JPN.DLL"
!    File "${SYSTEMDIR}\MFC71KOR.DLL"
  !ELSE
  !IFDEF CL_1300
!    File "${SYSTEMDIR}\mfc70.dll"
!    File "${SYSTEMDIR}\msvcr70.dll"
!    File "${SYSTEMDIR}\msvcp70.dll"
!    File "${SYSTEMDIR}\MFC70CHS.DLL"
!    File "${SYSTEMDIR}\MFC70CHT.DLL"
!    File "${SYSTEMDIR}\MFC70DEU.DLL"
!    File "${SYSTEMDIR}\MFC70ENU.DLL"
!    File "${SYSTEMDIR}\MFC70ESP.DLL"
!    File "${SYSTEMDIR}\MFC70FRA.DLL"
!    File "${SYSTEMDIR}\MFC70ITA.DLL"
!    File "${SYSTEMDIR}\MFC70JPN.DLL"
!    File "${SYSTEMDIR}\MFC70KOR.DLL"
! !ELSE
!    File "${SYSTEMDIR}\mfc42.dll"
!    File "${SYSTEMDIR}\msvcp60.dll"
!    File "${SYSTEMDIR}\msvcrt.dll"
! !ENDIF
  !ENDIF
  !ENDIF
  
     StrCmp $LANGUAGE ${LANG_ENGLISH} DoEnglish
     StrCmp $LANGUAGE ${LANG_GERMAN} DoGerman
--- 2569,2659 ----
     ; Common files
     SetOutPath "$INSTDIR\Common"
     File "${AFS_CLIENT_BUILDDIR}\afs_config.exe"
    !insertmacro ReplaceDLL "${AFS_DESTDIR}\lib\afsauthent.dll" "$INSTDIR\Common\afsauthent.dll" "$INSTDIR"
    !insertmacro ReplaceDLL "${AFS_DESTDIR}\lib\afspthread.dll" "$INSTDIR\Common\afspthread.dll" "$INSTDIR"
    !insertmacro ReplaceDLL "${AFS_DESTDIR}\lib\afsrpc.dll" "$INSTDIR\Common\afsrpc.dll" "$INSTDIR"
!   !insertmacro ReplaceDLL "${AFS_SERVER_BUILDDIR}\afsadminutil.dll"    "$INSTDIR\Common\afsadminutil.dll"    "$INSTDIR"
!   !insertmacro ReplaceDLL "${AFS_SERVER_BUILDDIR}\afsclientadmin.dll"  "$INSTDIR\Common\afsclientadmin.dll"  "$INSTDIR" 
!   !insertmacro ReplaceDLL "${AFS_SERVER_BUILDDIR}\afsprocmgmt.dll"     "$INSTDIR\Common\afsprocmgmt.dll"     "$INSTDIR" 
!   !insertmacro ReplaceDLL "${AFS_SERVER_BUILDDIR}\afsvosadmin.dll"     "$INSTDIR\Common\afsvosadmin.dll"     "$INSTDIR" 
!   !insertmacro ReplaceDLL "${AFS_SERVER_BUILDDIR}\TaAfsAppLib.dll"     "$INSTDIR\Common\TaAfsAppLib.dll"     "$INSTDIR" 
!   !insertmacro ReplaceDLL "${AFS_SERVER_BUILDDIR}\afsvosadmin.dll"     "$INSTDIR\Common\afsvosadmin.dll"     "$INSTDIR" 
!   !insertmacro ReplaceDLL "${AFS_SERVER_BUILDDIR}\afsbosadmin.dll"     "$INSTDIR\Common\afsbosadmin.dll"     "$INSTDIR" 
!   !insertmacro ReplaceDLL "${AFS_SERVER_BUILDDIR}\afscfgadmin.dll"     "$INSTDIR\Common\afscfgadmin.dll"     "$INSTDIR" 
!   !insertmacro ReplaceDLL "${AFS_SERVER_BUILDDIR}\afskasadmin.dll"     "$INSTDIR\Common\afskasadmin.dll"     "$INSTDIR" 
!   !insertmacro ReplaceDLL "${AFS_SERVER_BUILDDIR}\afsptsadmin.dll"     "$INSTDIR\Common\afsptsadmin.dll"     "$INSTDIR" 
! 
!  SetOutPath "$INSTDIR\Common"
  
  !IFDEF DEBUG
  !IFDEF CL_1310
!    !insertmacro ReplaceDLL "${SYSTEMDIR}\msvcr71d.dll" "$INSTDIR\Common\msvcr71d.dll" "$INSTDIR"
!    !insertmacro ReplaceDLL "${SYSTEMDIR}\msvcp71d.dll" "$INSTDIR\Common\msvcp71d.dll" "$INSTDIR"
!    !insertmacro ReplaceDLL "${SYSTEMDIR}\mfc71d.dll" "$INSTDIR\Common\mfc71d.dll" "$INSTDIR"
!    !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC71CHS.DLL" "$INSTDIR\Common\MFC71CHS.DLL" "$INSTDIR"
!    !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC71CHT.DLL" "$INSTDIR\Common\MFC71CHT.DLL" "$INSTDIR"
!    !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC71DEU.DLL" "$INSTDIR\Common\MFC71DEU.DLL" "$INSTDIR"
!    !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC71ENU.DLL" "$INSTDIR\Common\MFC71ENU.DLL" "$INSTDIR"
!    !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC71ESP.DLL" "$INSTDIR\Common\MFC71ESP.DLL" "$INSTDIR"
!    !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC71FRA.DLL" "$INSTDIR\Common\MFC71FRA.DLL" "$INSTDIR"
!    !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC71ITA.DLL" "$INSTDIR\Common\MFC71ITA.DLL" "$INSTDIR"
!    !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC71JPN.DLL" "$INSTDIR\Common\MFC71JPN.DLL" "$INSTDIR"
!    !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC71KOR.DLL" "$INSTDIR\Common\MFC71KOR.DLL" "$INSTDIR"
  !ELSE
  !IFDEF CL_1300
!    !insertmacro ReplaceDLL "${SYSTEMDIR}\msvcr70d.dll" "$INSTDIR\Common\msvcr70d.dll" "$INSTDIR"
!    !insertmacro ReplaceDLL "${SYSTEMDIR}\msvcp70d.dll" "$INSTDIR\Common\msvcp70d.dll" "$INSTDIR"
!    !insertmacro ReplaceDLL "${SYSTEMDIR}\mfc70d.dll" "$INSTDIR\Common\mfc70d.dll" "$INSTDIR"
!    !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC70CHS.DLL" "$INSTDIR\Common\MFC70CHS.DLL" "$INSTDIR"
!    !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC70CHT.DLL" "$INSTDIR\Common\MFC70CHT.DLL" "$INSTDIR"
!    !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC70DEU.DLL" "$INSTDIR\Common\MFC70DEU.DLL" "$INSTDIR"
!    !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC70ENU.DLL" "$INSTDIR\Common\MFC70ENU.DLL" "$INSTDIR"
!    !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC70ESP.DLL" "$INSTDIR\Common\MFC70ESP.DLL" "$INSTDIR"
!    !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC70FRA.DLL" "$INSTDIR\Common\MFC70FRA.DLL" "$INSTDIR"
!    !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC70ITA.DLL" "$INSTDIR\Common\MFC70ITA.DLL" "$INSTDIR"
!    !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC70JPN.DLL" "$INSTDIR\Common\MFC70JPN.DLL" "$INSTDIR"
!    !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC70KOR.DLL" "$INSTDIR\Common\MFC70KOR.DLL" "$INSTDIR"
! !ELSE
!    !insertmacro ReplaceDLL "${SYSTEMDIR}\mfc42d.dll" "$INSTDIR\Common\mfc42d.dll" "$INSTDIR"
!    !insertmacro ReplaceDLL "${SYSTEMDIR}\msvcp60d.dll" "$INSTDIR\Common\msvcp60d.dll" "$INSTDIR"
!    !insertmacro ReplaceDLL "${SYSTEMDIR}\msvcrtd.dll" "$INSTDIR\Common\msvcrtd.dll" "$INSTDIR"
  !ENDIF
  !ENDIF
  !ELSE
  !IFDEF CL_1310
!    !insertmacro ReplaceDLL "${SYSTEMDIR}\mfc71.dll" "$INSTDIR\Common\mfc71.dll" "$INSTDIR"
!    !insertmacro ReplaceDLL "${SYSTEMDIR}\msvcr71.dll" "$INSTDIR\Common\msvcr71.dll" "$INSTDIR"
!    !insertmacro ReplaceDLL "${SYSTEMDIR}\msvcp71.dll" "$INSTDIR\Common\msvcp71.dll" "$INSTDIR"
!    !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC71CHS.DLL" "$INSTDIR\Common\MFC71CHS.DLL" "$INSTDIR"
!    !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC71CHT.DLL" "$INSTDIR\Common\MFC71CHT.DLL" "$INSTDIR"
!    !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC71DEU.DLL" "$INSTDIR\Common\MFC71DEU.DLL" "$INSTDIR"
!    !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC71ENU.DLL" "$INSTDIR\Common\MFC71ENU.DLL" "$INSTDIR"
!    !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC71ESP.DLL" "$INSTDIR\Common\MFC71ESP.DLL" "$INSTDIR"
!    !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC71FRA.DLL" "$INSTDIR\Common\MFC71FRA.DLL" "$INSTDIR"
!    !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC71ITA.DLL" "$INSTDIR\Common\MFC71ITA.DLL" "$INSTDIR"
!    !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC71JPN.DLL" "$INSTDIR\Common\MFC71JPN.DLL" "$INSTDIR"
!    !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC71KOR.DLL" "$INSTDIR\Common\MFC71KOR.DLL" "$INSTDIR"
  !ELSE
  !IFDEF CL_1300
!    !insertmacro ReplaceDLL "${SYSTEMDIR}\mfc70.dll" "$INSTDIR\Common\mfc70.dll" "$INSTDIR"
!    !insertmacro ReplaceDLL "${SYSTEMDIR}\msvcr70.dll" "$INSTDIR\Common\msvcr70.dll" "$INSTDIR"
!    !insertmacro ReplaceDLL "${SYSTEMDIR}\msvcp70.dll" "$INSTDIR\Common\msvcp70.dll" "$INSTDIR"
!    !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC70CHS.DLL" "$INSTDIR\Common\MFC70CHS.DLL" "$INSTDIR"
!    !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC70CHT.DLL" "$INSTDIR\Common\MFC70CHT.DLL" "$INSTDIR"
!    !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC70DEU.DLL" "$INSTDIR\Common\MFC70DEU.DLL" "$INSTDIR"
!    !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC70ENU.DLL" "$INSTDIR\Common\MFC70ENU.DLL" "$INSTDIR"
!    !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC70ESP.DLL" "$INSTDIR\Common\MFC70ESP.DLL" "$INSTDIR"
!    !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC70FRA.DLL" "$INSTDIR\Common\MFC70FRA.DLL" "$INSTDIR"
!    !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC70ITA.DLL" "$INSTDIR\Common\MFC70ITA.DLL" "$INSTDIR"
!    !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC70JPN.DLL" "$INSTDIR\Common\MFC70JPN.DLL" "$INSTDIR"
!    !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC70KOR.DLL" "$INSTDIR\Common\MFC70KOR.DLL" "$INSTDIR"
! !ELSE
!    !insertmacro ReplaceDLL "${SYSTEMDIR}\mfc42.dll" "$INSTDIR\Common\mfc42.dll" "$INSTDIR"
!    !insertmacro ReplaceDLL "${SYSTEMDIR}\msvcp60.dll" "$INSTDIR\Common\msvcp60.dll" "$INSTDIR"
!    !insertmacro ReplaceDLL "${SYSTEMDIR}\msvcrt.dll" "$INSTDIR\Common\msvcrt.dll" "$INSTDIR"
  !ENDIF
  !ENDIF
+ !ENDIF   
  
     StrCmp $LANGUAGE ${LANG_ENGLISH} DoEnglish
     StrCmp $LANGUAGE ${LANG_GERMAN} DoGerman
Index: openafs/src/WINNT/install/NSIS/afsdcell.ini
diff -c openafs/src/WINNT/install/NSIS/afsdcell.ini:1.3 openafs/src/WINNT/install/NSIS/afsdcell.ini:removed
*** openafs/src/WINNT/install/NSIS/afsdcell.ini:1.3	Tue May 11 18:31:51 2004
--- openafs/src/WINNT/install/NSIS/afsdcell.ini	Tue Jul 27 19:19:59 2004
***************
*** 1,483 ****
- >grand.central.org      #GCO Public CellServDB 11 May 2004
- 18.7.14.88                      #grand-opening.mit.edu
- 128.2.191.224                   #penn.central.org
- >wu-wien.ac.at          #University of Economics, Vienna, Austria
- 137.208.3.33                    #afsdb1.wu-wien.ac.at
- 137.208.7.4                     #afsdb2.wu-wien.ac.at
- 137.208.7.7                     #afsdb3.wu-wien.ac.at
- >hephy.at               #hephy-vienna
- 193.170.243.10                  #mowgli.oeaw.ac.at
- 193.170.243.12                  #baloo.oeaw.ac.at
- 193.170.243.14                  #akela.oeaw.ac.at
- >itp.tugraz.at          #Institute for Theoretical Physics, TU Graz, Austria
- 129.27.157.6                    #fubphsv2.tu-graz.ac.at
- 129.27.161.7                    #faepsv01.tu-graz.ac.at
- 129.27.161.15                   #faepsv02.tu-graz.ac.at
- >cern.ch                #European Laboratory for Particle Physics, Geneva
- 137.138.128.148                 #afsdb1.cern.ch
- 137.138.246.50                  #afsdb3.cern.ch
- 137.138.246.51                  #afsdb2.cern.ch
- >ams.cern.ch            #AMS Experiment
- 137.138.206.77                  #pcamsf2.cern.ch
- 137.138.206.123                 #pcamsf4.cern.ch
- >ethz.ch                #Swiss Federal Inst. of Tech. - Zurich, Switzerland
- 129.132.97.19                   #amalthea.ethz.ch
- 129.132.97.27                   #nethzafs-001.ethz.ch
- 129.132.115.3                   #himalia.ethz.ch
- 129.132.115.37                  #nethzafs-005.ethz.ch
- 129.132.115.38                  #nethzafs-006.ethz.ch
- >psi.ch                 #Paul Scherrer Institut - Villigen, Switzerland
- 129.129.16.10                   #afs1.psi.ch
- 129.129.16.11                   #afs2.psi.ch
- >extundo.com            #Simon Josefsson's cell
- 195.42.214.241                  #slipsten.extundo.com
- >mekinok.com            #Mekinok, Inc.
- 4.36.43.98                      #loggerhead.mekinok.com
- >membrain.com           #membrain.com
- 66.93.118.125                   #stormy
- 130.85.24.11                    #weasel
- 130.85.24.13                    #straykitten
- >midnightlinux.com      #Midnight Linux, Pittsburgh PA
- 66.93.62.18                     #romulus.midnihtlinux.com
- 66.93.62.20                     #yar.midnightlinux.com
- >setfilepointer.com     #SetFilePointer.com
- 63.224.10.2                     #hamlet.SetFilePointer.com
- 63.224.10.4                     #troilus.SetFilePointer.com
- >sodre.cx               #Sodre.cx
- 128.8.140.165                   #greed.sodre.cx
- >desy.de                #Deutsches Elektronen-Synchrotron
- 131.169.40.62                   #vayu.desy.de
- 131.169.244.60                  #solar00.desy.de
- >gppc.de                #GPP Chemnitz mbH
- 213.187.92.33                   #gpp1.gppc.de
- 213.187.92.34                   #paulchen.gppc.de
- 213.187.92.35                   #lotus.gppc.de
- >ifh.de                 #DESY Zeuthen
- 141.34.22.10                    #romulus.ifh.de
- 141.34.22.11                    #remus.ifh.de
- 141.34.22.29                    #hekate.ifh.de
- >lrz-muenchen.de        #Leibniz Computing Centre, Germany
- 129.187.10.36                   #afs1.lrz-muenchen.de
- 129.187.10.56                   #afs3.lrz-muenchen.de
- 129.187.10.57                   #afs2.lrz-muenchen.de
- >ipp-garching.mpg.de    #Institut fuer Plasmaphysik
- 130.183.9.5                     #afs-db1.rzg.mpg.de
- 130.183.100.10                  #afs-db2.aug.ipp-garching.mpg.de
- 130.183.100.23                  #afs-db3.aug.ipp-garching.mpg.de
- >mpe.mpg.de             #MPE cell
- 130.183.130.7                   #irafs1.mpe-garching.mpg.de
- 130.183.134.20                  #irafs2.mpe-garching.mpg.de
- >i1.informatik.rwth-aachen.de #Informatik I, RWTH Aachen
- 137.226.244.79                  #remus.informatik.rwth-aachen.de
- >tu-chemnitz.de         #Technische Universitaet Chemnitz, Germany
- 134.109.2.1                     #zuse.hrz.tu-chemnitz.de
- 134.109.2.15                    #phoenix.hrz.tu-chemnitz.de
- 134.109.200.7                   #aetius.hrz.tu-chemnitz.de
- >e18.ph.tum.de          #Experimental Physics, TU Munich, Germany
- 129.187.154.223                 #hamlet.e18.physik.tu-muenchen.de
- >uni-bonn.de            #Cell name
- 131.220.14.198                  #work15-eth.rhrz.uni-bonn.de
- 131.220.14.203                  #node03-en2.rhrz.uni-bonn.de
- 131.220.14.205                  #node05.rhrz.uni-bonn.de
- >uni-freiburg.de        #Albert-Ludwigs-Universitat Freiburg
- 132.230.6.235                   #sv6.ruf.uni-freiburg.de
- 132.230.6.236                   #sv7.ruf.uni-freiburg.de
- 132.230.6.237                   #sv8.ruf.uni-freiburg.de
- >physik.uni-freiburg.de #institute of physics, university Freiburg, Germany
- 132.230.77.16                   #hepafs.physik.uni-freiburg.de
- >urz.uni-heidelberg.de  #Uni Heidelberg (Rechenzentrum)
- 129.206.119.10                  #afsdb.urz.uni-heidelberg.de
- 129.206.119.16                  #afsdb1.urz.uni-heidelberg.de
- 129.206.119.17                  #afsdb2.urz.uni-heidelberg.de
- >uni-hohenheim.de       #University of Hohenheim
- 144.41.2.2                      #rs13.serv.uni-hohenheim.de
- 144.41.2.3                      #rs14.serv.uni-hohenheim.de
- 144.41.2.4                      #rs15.serv.uni-hohenheim.de
- >rz.uni-jena.de         #Rechenzentrum University of Jena, Germany
- 141.35.2.160                    #lc00.rz.uni-jena.de
- 141.35.7.9                      #fsuj01.rz.uni-jena.de
- 141.35.7.10                     #zaphod.rz.uni-jena
- >meteo.uni-koeln.de     #Univ. of Cologne - Inst. for Geophysics & Meteorology
- 134.95.144.22                   #afs1.meteo.uni-koeln.de
- 134.95.144.24                   #afs2.meteo.uni-koeln.de
- >rrz.uni-koeln.de       #University of Cologne - Reg Comp Center
- 134.95.19.3                     #afsdb1.rrz.uni-koeln.de
- 134.95.19.30                    #fileserv3.rrz.uni-koeln.de
- 134.95.67.97                    #afs.thp.uni-koeln.de
- 134.95.140.190                  #rzkbserv.rrz.uni-koeln.de
- >physik.uni-mainz.de    #institute of physics, university Mainz, Germany
- 134.93.130.93                   #hardy.physik.uni-mainz.de
- >uni-mannheim.de        #Uni Mannheim (Rechenzentrum)
- 134.155.50.165                  #afsdbx.uni-mannheim.de
- 134.155.50.166                  #afsdby.uni-mannheim.de
- 134.155.50.167                  #afsdbz.uni-mannheim.de
- >physik.uni-wuppertal.de #Physics department of Bergische Universität Wuppertal
- 132.195.104.3                   #afs1.physik.uni-wuppertal.de
- 132.195.104.230                 #afs2.physik.uni-wuppertal.de
- >ies.auc.dk             #Aalborg Univ., Inst. of Electronic Systems, Denmark
- 130.225.51.73                   #afsdb1.kom.auc.dk
- 130.225.51.74                   #afsdb2.kom.auc.dk
- 130.225.51.85                   #afsdb3.kom.auc.dk
- >hep.caltech.edu        #CalTech High Energy Physics
- 131.215.126.150                 #afs.hep.caltech.edu
- >andrew.cmu.edu         #Carnegie Mellon University - Computing Services Cell
- 128.2.10.2                      #vice2.fs.andrew.cmu.edu
- 128.2.10.7                      #vice7.fs.andrew.cmu.edu
- 128.2.10.11                     #vice11.fs.andrew.cmu.edu
- 128.2.10.28                     #vice28.fs.andrew.cmu.edu
- 128.2.32.44                     #new-vice12.fs.andrew.cmu.edu
- >club.cc.cmu.edu        #Carnegie Mellon University Computer Club
- 128.2.4.131                     #yttrium.club.cc.cmu.edu
- 128.2.4.132                     #zirconium.club.cc.cmu.edu
- >chem.cmu.edu           #Carnegie Mellon University - Chemistry Dept.
- 128.2.40.134                    #afs.chem.cmu.edu
- 128.2.40.140                    #afs2.chem.cmu.edu
- >cs.cmu.edu             #Carnegie Mellon University - School of Comp. Sci.
- 128.2.194.178                   #cherry.srv.cs.cmu.edu
- 128.2.194.179                   #pumpkin.srv.cs.cmu.edu
- 128.2.194.180                   #strawberry.srv.cs.cmu.edu
- >ece.cmu.edu            #Carnegie Mellon University - Elec. Comp. Eng. Dept.
- 128.2.129.7                     #porok.ece.cmu.edu
- 128.2.129.8                     #vicio.ece.cmu.edu
- 128.2.129.9                     #e-xing.ece.cmu.edu
- >scotch.ece.cmu.edu     #CMU ECE CALCM research group
- 128.2.134.82                    #lagavulin.ece.cmu.edu
- >msc.cornell.edu        #Cornell University Materials Science Center
- 128.84.231.242                  #miranda.ccmr.cornell.edu
- 128.84.241.35                   #co.ccmr.cornell.edu
- 128.84.249.78                   #dax.ccmr.cornell.edu
- >dbic.dartmouth.edu     #Dartmouth Brain Imaging Center
- 129.170.30.143                  #dbicafs1.dartmouth.edu
- 129.170.30.144                  #dbicafs2.dartmouth.edu
- 129.170.30.145                  #dbicafs3.dartmouth.edu
- >northstar.dartmouth.edu #Dartmouth College Research Computing
- 129.170.16.22                   #halley.dartmouth.edu
- 129.170.16.42                   #oort.dartmouth.edu
- 129.170.16.43                   #cygnusx1.dartmouth.edu
- >iastate.edu            #Iowa State University
- 129.186.1.243                   #afsdb-1.iastate.edu
- 129.186.6.243                   #afsdb-2.iastate.edu
- 129.186.142.243                 #afsdb-3.iastate.edu
- >athena.mit.edu         #MIT/Athena cell
- 18.7.1.66                       #paris.mit.edu.
- 18.7.1.74                       #chimera.mit.edu.
- 18.158.0.37                     #prill.mit.edu.
- >dev.mit.edu            #MIT/IS Development cell
- 18.7.1.70                       #wham.mit.edu.
- 18.7.15.89                      #rattle.mit.edu.
- 18.7.15.93                      #hum.mit.edu.
- >net.mit.edu            #MIT/Network Group cell
- 18.7.7.73                       #gracie.mit.edu
- 18.7.21.95                      #george.mit.edu
- >sipb.mit.edu           #MIT/SIPB cell
- 18.181.0.19                     #reynelda.mit.edu.
- 18.181.0.22                     #rosebud.mit.edu.
- 18.181.0.23                     #ronald-ann.mit.edu.
- >msu.edu                #Michigan State University Main Cell
- 35.9.7.10                       #afsdb0.cl.msu.edu
- >nd.edu                 #University of Notre Dame
- 129.74.223.17                   #john.helios.nd.edu
- 129.74.223.33                   #lizardo.helios.nd.edu
- 129.74.223.65                   #buckaroo.helios.nd.edu
- >pitt.edu               #University of Pittsburgh
- 136.142.8.15                    #afs09.srv.cis.pitt.edu
- 136.142.8.20                    #afs10.srv.cis.pitt.edu
- 136.142.8.21                    #afs11.srv.cis.pitt.edu
- >cs.pitt.edu            #University of Pittsburgh - Computer Science
- 130.49.220.11                   #afs01.cs.pitt.edu
- 130.49.220.12                   #afs02.cs.pitt.edu
- 130.49.220.13                   #afs03.cs.pitt.edu
- >psc.edu                #PSC (Pittsburgh Supercomputing Center)
- 128.182.59.182                  #shaggy.psc.edu
- 128.182.66.184                  #velma.psc.edu
- 128.182.66.185                  #daphne.psc.edu
- >scoobydoo.psc.edu      #PSC Test Cell
- 128.182.59.181                  #scooby.psc.edu
- >cede.psu.edu           #Penn State - Center for Engr. Design & Entrepeneurship
- 146.186.218.10                  #greenly.cede.psu.edu
- 146.186.218.60                  #b50.cede.psu.edu
- 146.186.218.246                 #stalin.cede.psu.edu
- >rose-hulman.edu        #Rose-Hulman Institute of Technology
- 137.112.7.11                    #afs1.rose-hulman.edu
- 137.112.7.12                    #afs2.rose-hulman.edu
- 137.112.7.13                    #afs3.rose-hulman.edu
- >cs.rose-hulman.edu     #Rose-Hulman CS Department
- 137.112.40.10                   #galaxy.cs.rose-hulman.edu
- >rpi.edu                #Rensselaer Polytechnic Institute
- 128.113.22.11                   #saul.server.rpi.edu
- 128.113.22.12                   #joab.server.rpi.edu
- 128.113.22.13                   #korah.server.rpi.edu
- 128.113.22.14                   #achan.server.rpi.edu
- >hep.sc.edu             #University of South Carolina, Dept. of Physics
- 129.252.78.77                   #cpeven.physics.sc.edu
- >cs.stanford.edu        #Stanford University Computer Science Department
- 171.64.64.10                    #cs-afs-1.Stanford.EDU
- 171.64.64.66                    #cs-afs-2.stanford.edu
- 171.64.64.69                    #cs-afs-3.stanford.edu
- >ir.stanford.edu        #Stanford University
- 171.64.7.222                    #afsdb1.stanford.edu
- 171.64.7.234                    #afsdb2.stanford.edu
- 171.64.7.246                    #afsdb3.stanford.edu
- >slac.stanford.edu      #Stanford Linear Accelerator Center
- 134.79.18.25                    #afsdb1.slac.stanford.edu
- 134.79.18.26                    #afsdb2.slac.stanford.edu
- 134.79.18.27                    #afsdb3.slac.stanford.edu
- >cats.ucsc.edu          #UC Santa Cruz, Comm. and Tech. Services, California U.S.A
- 128.114.129.14                  #elan.ucsc.edu
- 128.114.129.15                  #ichabod.ucsc.edu
- 128.114.129.18                  #maneki.ucsc.edu
- >acm.uiuc.edu           #ACM at the University of Illinois
- 128.174.251.8                   #alnitak.acm.uiuc.edu
- 128.174.251.9                   #alnilam.acm.uiuc.edu
- 128.174.251.10                  #mintaka.acm.uiuc.edu
- >ncsa.uiuc.edu          #University of Illinois
- 141.142.3.5                     #congo.ncsa.uiuc.edu
- 141.142.3.8                     #nile.ncsa.uiuc.edu
- 141.142.230.19                  #jinx.ncsa.uiuc.edu
- >umbc.edu               #University of Maryland, Baltimore County
- 130.85.24.23                    #db2.afs.umbc.edu
- 130.85.24.87                    #db3.afs.umbc.edu
- 130.85.24.101                   #db1.afs.umbc.edu
- >glue.umd.edu           #University of Maryland - Project Glue
- 128.8.70.11                     #olmec.umd.edu
- 128.8.73.3                      #babylon.umd.edu
- 129.2.128.53                    #egypt.umd.edu
- >wam.umd.edu            #University of Maryland Network WAM Project
- 128.8.70.9                      #csc-srv.wam.umd.edu
- 128.8.73.9                      #pg2-srv.wam.umd.edu
- 129.2.128.54                    #avw-srv.wam.umd.edu
- >umich.edu              #University of Michigan - Campus
- 141.211.1.32                    #fear.ifs.umich.edu
- 141.211.1.33                    #surprise.ifs.umich.edu
- 141.211.1.34                    #ruthless.ifs.umich.edu
- >atlas.umich.edu        #ATLAS group cell in physics at University of Michigan
- 141.211.43.102                  #linat02.grid.umich.edu
- 141.211.43.106                  #linat06.grid.umich.edu
- 141.211.43.109                  #atgrid.grid.umich.edu
- >citi.umich.edu         #Center for Information Technology Integration
- 141.211.133.5                   #babylon.citi.umich.edu
- >lsa.umich.edu          #University of Michigan - College of LS&A
- 141.211.54.132                  #curtis.admin.lsa.umich.edu
- 141.211.61.23                   #zee.admin.lsa.umich.edu
- 141.211.68.15                   #marshall.lsa.umich.edu
- >math.lsa.umich.edu     #University of Michigan - Math Department
- 141.211.61.40                   #ike.math.lsa.umich.edu
- 141.211.61.41                   #clark.math.lsa.umich.edu
- 141.211.61.42                   #nimitz.math.lsa.umich.edu
- >umr.edu                #University of Missouri - Rolla
- 131.151.1.59                    #afsdb1.umr.edu
- 131.151.1.70                    #afsdb3.umr.edu
- 131.151.1.146                   #afsdb2.umr.edu
- >physics.unc.edu        #Univ. of NC at Chapel Hill, Dept. of Physics
- 152.2.5.2                       #valerian.physics.unc.edu
- 152.2.5.3                       #augustus.physics.unc.edu
- 152.2.7.67                      #nerva.astro.unc.edu
- >uncc.edu               #University of NC at Charlotte Mosaic AFS Cell
- 152.15.10.70                    #as-sm1.uncc.edu
- 152.15.13.7                     #as-sm2.uncc.edu
- 152.15.30.27                    #fs-kenn3.uncc.edu
- >eng.utah.edu           #University of Utah - Engineering
- 155.99.222.9                    #lenny.eng.utah.edu
- 155.99.222.10                   #carl.eng.utah.edu
- >cs.uwm.edu             #University of Wisconsin--Milwaukee
- 129.89.38.124                   #solomons.cs.uwm.edu
- >cs.wisc.edu            #Univ. of Wisconsin-Madison, Computer Sciences Dept.
- 128.105.132.14                  #timon.cs.wisc.edu
- 128.105.132.15                  #pumbaa.cs.wisc.edu
- 128.105.132.16                  #zazu.cs.wisc.edu
- >engr.wisc.edu          #University of Wisconsin-Madison, College of Engineering
- 144.92.13.14                    #larry.cae.wisc.edu
- 144.92.13.15                    #curly.cae.wisc.edu
- 144.92.13.16                    #moe.cae.wisc.edu
- >hep.wisc.edu           #University of Wisconsin -- High Energy Physics
- 128.104.28.219                  #anise.physics.wisc.edu
- >physics.wisc.edu       #Univ. of Wisconsin-Madison, Physics Department
- 128.104.220.51                  #bubbles.physics.wisc.edu
- 128.104.220.52                  #buttercup.physics.wisc.edu
- 128.104.220.53                  #blossom.physics.wisc.edu
- >ifca.unican.es         #Instituto de Fisica de Cantabria (IFCA), Santander, Spain
- 193.144.209.20                  #gridwall.ifca.unican.es
- >ific.uv.es             #Instituto de Fisica Corpuscular, Valencia, Spain
- 147.156.163.11                  #alpha.ific.uv.es
- >biocenter.helsinki.fi  #University of Helsinki, Institute of Biotechnology
- 128.214.58.174                  #afsdb1.biocenter.helsinki.fi
- 128.214.88.114                  #afsdb2.biocenter.helsinki.fi
- >dapnia.saclay.cea.fr   #CEA DAPNIA
- 132.166.32.7                    #dphrsg.saclay.cea.fr
- 132.166.32.12                   #dphrsl.saclay.cea.fr
- >in2p3.fr               #IN2P3 production cell
- 134.158.232.11                  #ccafsdb1.in2p3.fr
- 134.158.232.12                  #ccafsdb2.in2p3.fr
- 134.158.232.13                  #ccafsdb3.in2p3.fr
- >anl.gov                #Argonne National Laboratory
- 146.137.96.33                   #arteus.ctd.anl.gov
- 146.137.162.88                  #agamemnon.ctd.anl.gov
- 146.137.194.80                  #antenor.ctd.anl.gov
- >rhic.bnl.gov           #Relativistic Heavy Ion Collider
- 130.199.6.51                    #rafs03.rcf.bnl.gov
- 130.199.6.52                    #rafs02.rcf.bnl.gov
- 130.199.6.69                    #rafs01.rcf.bnl.gov
- >usatlas.bnl.gov        #US Atlas Tier 1 Facility at BNL
- 130.199.48.32                   #aafs01.usatlas.bnl.gov
- 130.199.48.33                   #aafs02.usatlas.bnl.gov
- 130.199.48.34                   #aafs03.usatlas.bnl.gov
- >fnal.gov               #Fermi National Acclerator Laboratory
- 131.225.68.1                    #fsus01.fnal.gov
- 131.225.68.4                    #fsus03.fnal.gov
- 131.225.68.14                   #fsus04.fnal.gov
- >ic-afs.arc.nasa.gov    #Code IC, Ames Research Center
- 128.102.105.62                  #udanax.arc.nasa.gov
- >nersc.gov              #National Energy Research Supercomputer Center
- 128.55.128.250                  #mars.nersc.gov
- 128.55.128.252                  #alfred.nersc.gov
- 128.55.128.254                  #lurch.nersc.gov
- >caspur.it              #CASPUR Inter-University Computing Consortium, Rome
- 193.204.5.45                    #pomodoro.caspur.it
- 193.204.5.46                    #banana.caspur.it
- 193.204.5.50                    #maslo.caspur.it
- >fusione.it             #Assoz. FUSIONE/Euratom, ENEA, Frascati-Italy
- 192.107.90.2                    #fusafs1.frascati.enea.it
- 192.107.90.3                    #fusafs2.frascati.enea.it
- 192.107.90.4                    #fusafs3.frascati.enea.it
- >icemb.it               #ICEMB, Universita' La Sapienza - Rome - Italy
- 193.204.6.130                   #icembfs.caspur.it
- >infn.it                #Istituto Nazionale di Fisica Nucleare (INFN), Italia
- 131.154.1.7                     #afs3.infn.it
- 141.108.3.252                   #afs1.infn.it
- 192.84.134.75                   #afs2.infn.it
- >kloe.infn.it           #INFN, KLOE experiment at Laboratori di Frascati
- 192.135.25.111                  #kloeafs1.lnf.infn.it
- 192.135.25.112                  #kloeafs2.lnf.infn.it
- >le.infn.it             #INFN, Sezione di Lecce
- 192.84.152.40                   #afs01.le.infn.it
- 192.84.152.148                  #afs02.le.infn.it
- >lnf.infn.it            #INFN, Laboratori Nazionali di Frascati
- 193.206.84.121                  #afs1.lnf.infn.it
- 193.206.84.122                  #afs2.lnf.infn.it
- 193.206.84.123                  #afs3.lnf.infn.it
- >lngs.infn.it           #INFN, Laboratori Nazionali di Gran Sasso
- 192.84.135.21                   #rsgs05.lngs.infn.it
- >pi.infn.it             #INFN, Sezione di Pisa
- 131.114.134.26                  #unknownhost.pi.infn.it
- 192.84.133.50                   #aix1.pi.infn.it
- >psm.it                 #Progetto San Marco, Universita' di Roma-1
- 151.100.1.65                    #atlante.psm.uniroma1.it
- >tgrid.it               #CASPUR-CILEA-CINECA Grid Cell
- 193.204.5.33                    #cccgrid.caspur.it
- >ictp.trieste.it        #The Abdus Salam International Centre for Theoretical Physics (IC
- 140.105.16.8                    #fs1.ictp.trieste.it
- 140.105.16.9                    #fs2.ictp.trieste.it
- >ing.uniroma1.it        #Universita' La Sapienza, Fac. Ingeneria
- 151.100.85.253                  #alfa.ing.uniroma1.it
- >vn.uniroma3.it         #University of Rome 3, Area Vasca Navale
- 193.204.161.136                 #alfa.dia.uniroma3.it
- 193.204.161.137                 #beta.dia.uniroma3.it
- 193.204.161.138                 #gamma.dia.uniroma3.it
- >italia                 #Italian public AFS cell
- 193.204.5.9                     #afs.caspur.it
- >cmf.nrl.navy.mil       #Naval Research Lab - CCS
- 134.207.10.68                   #picard.cmf.nrl.navy.mil
- 134.207.10.69                   #riker.cmf.nrl.navy.mil
- 134.207.10.70                   #kirk.cmf.nrl.navy.mil
- >lcp.nrl.navy.mil       #Naval Research Lab - Lab for Computational Physics
- 132.250.114.2                   #afs1.lcp.nrl.navy.mil
- 132.250.114.4                   #afs2.lcp.nrl.navy.mil
- 132.250.114.6                   #afs3.lcp.nrl.navy.mil
- >es.net                 #Energy Sciences Net
- 198.128.3.21                    #fs1.es.net
- 198.128.3.22                    #fs2.es.net
- 198.128.3.23                    #fs3.es.net
- >laroia.net             #Laroia Networks
- 66.66.102.254                   #supercore.laroia.net
- >sinenomine.net         #Sine Nomine Associates
- 66.92.236.139                   #afs.sinenomine.net
- >slackers.net           #The Slackers' Network
- 63.201.48.27                    #alexandria.slackers.net
- >nikhef.nl              #The Dutch National Institute for High Energy Physics
- 192.16.185.26                   #afs1.nikhef.nl
- 192.16.185.27                   #afs2.nikhef.nl
- >1ts.org                #KCR/private Karl Ramm, Cambridge, MA
- 4.36.43.102                     #dol-guldur.1ts.org
- >bazquux.org            #Baz Quux Organization
- 66.207.142.196                  #baxquux.org
- >coed.org               #Adam Pennington's Cell
- 66.93.61.184                    #vice1.coed.org
- 128.2.4.163                     #vice3.coed.org
- >dementia.org           #Dementia Unlimited
- 128.2.12.45                     #alycia.dementia.org
- 128.2.120.216                   #meredith.dementia.org
- >idahofuturetruck.org   #University of Idaho hybrid vehicle development
- 12.18.238.210                   #dsle210.fsr.net
- >nimlabs.org            #Nimlabs, Ink. Cell.
- 18.238.1.103                    #olfin.nimlabs.org
- 18.238.1.105                    #caerbanog.nimlabs.org
- >nomh.org               #nomh.org
- 204.29.154.12                   #iota.nomh.org
- >oc7.org                #The OC7 Project
- 128.2.6.107                     #vice3.oc7.org
- 128.2.122.140                   #vice2.oc7.org
- >openafs.org            #OpenAFS Project
- 128.2.13.199                    #new-virtue.openafs.org
- 128.2.121.218                   #virtue.openafs.org
- 130.237.48.87                   #andrew.e.kth.se
- 130.237.48.107                  #onyx.e.kth.se
- >e.kth.se               #Royal Institute of Technology, Elektro
- 130.237.32.145                  #sonen.e.kth.se
- 130.237.48.7                    #anden.e.kth.se
- 130.237.48.244                  #fadern.e.kth.se
- >hallf.kth.se           #Royal Institute of Technology, HALLF
- 130.237.24.141                  #rasmus13.hallf.kth.se
- 130.237.24.152                  #rasmus3.hallf.kth.se
- 130.237.24.177                  #rasmus29.hallf.kth.se
- >isk.kth.se             #Royal Institute of Technology, ISK
- 130.237.202.12                  #afsdb2.isk.kth.se
- 130.237.206.13                  #afsdb1.isk.kth.se
- 130.237.209.141                 #afsdb3.isk.kth.se
- >it.kth.se              #Royal Institute of Technology, IT
- 130.237.212.15                  #ptah.it.kth.se
- 130.237.212.16                  #toth.it.kth.se
- 130.237.215.7                   #isis.it.kth.se
- >md.kth.se              #Royal Institute of Technology, MMK
- 130.237.57.68                   #trinity.md.kth.se
- 130.237.57.72                   #morpheus.md.kth.se
- 130.237.67.230                  #neo.speech.kth.se
- >mech.kth.se            #Royal Institute of Technology, MECH
- 130.237.233.142                 #matterhorn.mech.kth.se
- 130.237.233.143                 #castor.mech.kth.se
- 130.237.233.144                 #pollux.mech.kth.se
- >nada.kth.se            #Royal Institute of Technology, NADA
- 130.237.222.20                  #kosmos.nada.kth.se
- 130.237.223.12                  #sputnik.nada.kth.se
- 130.237.224.78                  #mir.nada.kth.se
- 130.237.227.23                  #gagarin.nada.kth.se
- 130.237.228.28                  #laika.nada.kth.se
- >pdc.kth.se             #Royal Institute of Technology, PDC
- 130.237.232.29                  #crab.pdc.kth.se
- 130.237.232.112                 #anna.pdc.kth.se
- 130.237.232.114                 #hokkigai.pdc.kth.se
- >stacken.kth.se         #Stacken Computer Club
- 130.237.234.3                   #milko.stacken.kth.se
- 130.237.234.43                  #hot.stacken.kth.se
- 130.237.237.230                 #fishburger.stacken.kth.se
- >syd.kth.se             #Royal Institute of Technology, KTH-Syd
- 130.237.83.23                   #afs.haninge.kth.se
- >physto.se              #Physics department Stockholm University
- 130.237.205.36                  #sysafs1.physto.se
- 130.237.205.72                  #sysafs2.physto.se
- >sanchin.se             #Sanchin Consulting AB, Sweden
- 192.195.148.10                  #sesan.sanchin.se
- >su.se                  #Stockholm University
- 130.237.162.81                  #afsdb1.su.se
- 130.237.162.82                  #afsdb2.su.se
- >f9.ijs.si              #F9, Jozef Stefan Institue
- 194.249.156.1                   #brenta.ijs.si
- >p-ng.si                #Nova Gorica Polytechnic
- 193.2.120.2                     #solkan.p-ng.si
- >phy.bris.ac.uk         #Bristol University - phyics
- 137.222.58.9                    #afs1.phy.bris.ac.uk
- >hep.man.ac.uk          #Manchester HEP
- 194.36.2.3                      #afs1.hep.man.ac.uk
- 194.36.2.4                      #afs2.hep.man.ac.uk
- 194.36.2.5                      #afs3.hep.man.ac.uk
- >rl.ac.uk               #Rutherford Appleton Lab, England
- 130.246.183.164                 #wallace.cc.rl.ac.uk
--- 0 ----
Index: openafs/src/WINNT/install/loopback/loopbackutils.cpp
diff -c openafs/src/WINNT/install/loopback/loopbackutils.cpp:1.5 openafs/src/WINNT/install/loopback/loopbackutils.cpp:1.6
*** openafs/src/WINNT/install/loopback/loopbackutils.cpp:1.5	Thu Jun 24 00:51:54 2004
--- openafs/src/WINNT/install/loopback/loopbackutils.cpp	Thu Jul 15 23:38:35 2004
***************
*** 696,709 ****
  	dwReporterType = REPORT_MSI;
  	hMsiHandle = h;
  
  	MSIHANDLE hRec = MsiCreateRecord(4);
! 	
! 	MsiRecordClearData(hRec);
  	MsiRecordSetStringA(hRec,1,strAction);
  	MsiRecordSetStringA(hRec,2,strDesc);
  	MsiRecordSetStringA(hRec,3,"[1]:([2])([3])([4])");
  
  	MsiProcessMessage(h,INSTALLMESSAGE_ACTIONSTART, hRec);
! 
! 	MsiCloseHandle(hRec);
  }
--- 696,712 ----
  	dwReporterType = REPORT_MSI;
  	hMsiHandle = h;
  
+ #ifdef DONT_NEED
+     /* this is performed in the Wix installer */
  	MSIHANDLE hRec = MsiCreateRecord(4);
!   
!     MsiRecordClearData(hRec);
  	MsiRecordSetStringA(hRec,1,strAction);
  	MsiRecordSetStringA(hRec,2,strDesc);
  	MsiRecordSetStringA(hRec,3,"[1]:([2])([3])([4])");
  
  	MsiProcessMessage(h,INSTALLMESSAGE_ACTIONSTART, hRec);
! 	
!     MsiCloseHandle(hRec);
! #endif
  }
Index: openafs/src/WINNT/install/wix/CellServDB
diff -c openafs/src/WINNT/install/wix/CellServDB:1.1 openafs/src/WINNT/install/wix/CellServDB:1.2
*** openafs/src/WINNT/install/wix/CellServDB:1.1	Mon Jun 21 01:21:44 2004
--- openafs/src/WINNT/install/wix/CellServDB	Thu Jul 15 23:38:36 2004
***************
*** 1,4 ****
! >grand.central.org      #GCO Public CellServDB 11 May 2004
  18.7.14.88                      #grand-opening.mit.edu
  128.2.191.224                   #penn.central.org
  >wu-wien.ac.at          #University of Economics, Vienna, Austria
--- 1,4 ----
! >grand.central.org      #GCO Public CellServDB 29 Jun 2004
  18.7.14.88                      #grand-opening.mit.edu
  128.2.191.224                   #penn.central.org
  >wu-wien.ac.at          #University of Economics, Vienna, Austria
***************
*** 75,84 ****
  134.109.200.7                   #aetius.hrz.tu-chemnitz.de
  >e18.ph.tum.de          #Experimental Physics, TU Munich, Germany
  129.187.154.223                 #hamlet.e18.physik.tu-muenchen.de
! >uni-bonn.de            #Cell name
  131.220.14.198                  #work15-eth.rhrz.uni-bonn.de
- 131.220.14.203                  #node03-en2.rhrz.uni-bonn.de
  131.220.14.205                  #node05.rhrz.uni-bonn.de
  >uni-freiburg.de        #Albert-Ludwigs-Universitat Freiburg
  132.230.6.235                   #sv6.ruf.uni-freiburg.de
  132.230.6.236                   #sv7.ruf.uni-freiburg.de
--- 75,86 ----
  134.109.200.7                   #aetius.hrz.tu-chemnitz.de
  >e18.ph.tum.de          #Experimental Physics, TU Munich, Germany
  129.187.154.223                 #hamlet.e18.physik.tu-muenchen.de
! >uni-bonn.de            #University of Bonn, Computing Center
  131.220.14.198                  #work15-eth.rhrz.uni-bonn.de
  131.220.14.205                  #node05.rhrz.uni-bonn.de
+ 131.220.15.197                  #afs-db1.rhrz.uni-bonn.de
+ >atlass01.physik.uni-bonn.de #Bonn ATLAS
+ 131.220.165.43                  #atlass01.physik.uni-bonn.de
  >uni-freiburg.de        #Albert-Ludwigs-Universitat Freiburg
  132.230.6.235                   #sv6.ruf.uni-freiburg.de
  132.230.6.236                   #sv7.ruf.uni-freiburg.de
***************
*** 108,116 ****
  >physik.uni-mainz.de    #institute of physics, university Mainz, Germany
  134.93.130.93                   #hardy.physik.uni-mainz.de
  >uni-mannheim.de        #Uni Mannheim (Rechenzentrum)
! 134.155.50.165                  #afsdbx.uni-mannheim.de
! 134.155.50.166                  #afsdby.uni-mannheim.de
! 134.155.50.167                  #afsdbz.uni-mannheim.de
  >physik.uni-wuppertal.de #Physics department of Bergische Universität Wuppertal
  132.195.104.3                   #afs1.physik.uni-wuppertal.de
  132.195.104.230                 #afs2.physik.uni-wuppertal.de
--- 110,118 ----
  >physik.uni-mainz.de    #institute of physics, university Mainz, Germany
  134.93.130.93                   #hardy.physik.uni-mainz.de
  >uni-mannheim.de        #Uni Mannheim (Rechenzentrum)
! 134.155.97.204                  #afsdb1.uni-mannheim.de
! 134.155.97.205                  #afsdb2.uni-mannheim.de
! 134.155.97.206                  #afsdb3.uni-mannheim.de
  >physik.uni-wuppertal.de #Physics department of Bergische Universität Wuppertal
  132.195.104.3                   #afs1.physik.uni-wuppertal.de
  132.195.104.230                 #afs2.physik.uni-wuppertal.de
***************
*** 118,123 ****
--- 120,130 ----
  130.225.51.73                   #afsdb1.kom.auc.dk
  130.225.51.74                   #afsdb2.kom.auc.dk
  130.225.51.85                   #afsdb3.kom.auc.dk
+ >asu.edu                #Arizona State University
+ 129.219.10.69                   #authen2.asu.edu
+ 129.219.10.70                   #authen1.asu.edu
+ 129.219.10.72                   #authen3.asu.edu
+ 129.219.100.16                  #authen4.asu.edu
  >hep.caltech.edu        #CalTech High Energy Physics
  131.215.126.150                 #afs.hep.caltech.edu
  >andrew.cmu.edu         #Carnegie Mellon University - Computing Services Cell
***************
*** 142,147 ****
--- 149,157 ----
  128.2.129.9                     #e-xing.ece.cmu.edu
  >scotch.ece.cmu.edu     #CMU ECE CALCM research group
  128.2.134.82                    #lagavulin.ece.cmu.edu
+ >qatar.cmu.edu          #Carnegie Mellon University - Qatar Campus Cell
+ 204.194.25.7                    #afs1.qatar.cmu.edu
+ 204.194.25.8                    #afs2.qatar.cmu.edu
  >msc.cornell.edu        #Cornell University Materials Science Center
  128.84.231.242                  #miranda.ccmr.cornell.edu
  128.84.241.35                   #co.ccmr.cornell.edu
***************
*** 233,239 ****
  >ncsa.uiuc.edu          #University of Illinois
  141.142.3.5                     #congo.ncsa.uiuc.edu
  141.142.3.8                     #nile.ncsa.uiuc.edu
! 141.142.230.19                  #jinx.ncsa.uiuc.edu
  >umbc.edu               #University of Maryland, Baltimore County
  130.85.24.23                    #db2.afs.umbc.edu
  130.85.24.87                    #db3.afs.umbc.edu
--- 243,249 ----
  >ncsa.uiuc.edu          #University of Illinois
  141.142.3.5                     #congo.ncsa.uiuc.edu
  141.142.3.8                     #nile.ncsa.uiuc.edu
! 141.142.3.9                     #kaskaskia.ncsa.uiuc.edu
  >umbc.edu               #University of Maryland, Baltimore County
  130.85.24.23                    #db2.afs.umbc.edu
  130.85.24.87                    #db3.afs.umbc.edu
***************
*** 258,265 ****
  141.211.133.5                   #babylon.citi.umich.edu
  >lsa.umich.edu          #University of Michigan - College of LS&A
  141.211.54.132                  #curtis.admin.lsa.umich.edu
! 141.211.61.23                   #zee.admin.lsa.umich.edu
! 141.211.68.15                   #marshall.lsa.umich.edu
  >math.lsa.umich.edu     #University of Michigan - Math Department
  141.211.61.40                   #ike.math.lsa.umich.edu
  141.211.61.41                   #clark.math.lsa.umich.edu
--- 268,276 ----
  141.211.133.5                   #babylon.citi.umich.edu
  >lsa.umich.edu          #University of Michigan - College of LS&A
  141.211.54.132                  #curtis.admin.lsa.umich.edu
! 141.211.211.53                  #gerow.lsa.umich.edu
! 141.211.211.72                  #collines.lsa.umich.edu
! 141.211.211.153                 #hodges.lsa.umich.edu
  >math.lsa.umich.edu     #University of Michigan - Math Department
  141.211.61.40                   #ike.math.lsa.umich.edu
  141.211.61.41                   #clark.math.lsa.umich.edu
***************
*** 406,411 ****
--- 417,425 ----
  >dementia.org           #Dementia Unlimited
  128.2.12.45                     #alycia.dementia.org
  128.2.120.216                   #meredith.dementia.org
+ >hackish.org            #Hackish.org
+ 24.167.65.213                   #avatar.sys.hackish.org
+ 128.2.120.138                   #kurma.sys.hackish.org
  >idahofuturetruck.org   #University of Idaho hybrid vehicle development
  12.18.238.210                   #dsle210.fsr.net
  >nimlabs.org            #Nimlabs, Ink. Cell.
***************
*** 413,418 ****
--- 427,433 ----
  18.238.1.105                    #caerbanog.nimlabs.org
  >nomh.org               #nomh.org
  204.29.154.12                   #iota.nomh.org
+ 204.29.154.32                   #adversity.xi.nomh.org
  >oc7.org                #The OC7 Project
  128.2.6.107                     #vice3.oc7.org
  128.2.122.140                   #vice2.oc7.org
***************
*** 442,448 ****
  130.237.57.72                   #morpheus.md.kth.se
  130.237.67.230                  #neo.speech.kth.se
  >mech.kth.se            #Royal Institute of Technology, MECH
- 130.237.233.142                 #matterhorn.mech.kth.se
  130.237.233.143                 #castor.mech.kth.se
  130.237.233.144                 #pollux.mech.kth.se
  >nada.kth.se            #Royal Institute of Technology, NADA
--- 457,462 ----
***************
*** 469,474 ****
--- 483,489 ----
  >su.se                  #Stockholm University
  130.237.162.81                  #afsdb1.su.se
  130.237.162.82                  #afsdb2.su.se
+ 130.237.162.230                 #afsdb3.su.se
  >f9.ijs.si              #F9, Jozef Stefan Institue
  194.249.156.1                   #brenta.ijs.si
  >p-ng.si                #Nova Gorica Polytechnic
Index: openafs/src/WINNT/install/wix/NTMakefile
diff -c openafs/src/WINNT/install/wix/NTMakefile:1.1 openafs/src/WINNT/install/wix/NTMakefile:1.2
*** openafs/src/WINNT/install/wix/NTMakefile:1.1	Mon Jun 21 01:21:44 2004
--- openafs/src/WINNT/install/wix/NTMakefile	Thu Jul 15 23:56:50 2004
***************
*** 57,63 ****
  		-dCellDbFile=CellServDB \
  		-v0 \
  		-w0 \
! 		openafs.wxs
  
  # Cleanup
  clean::
--- 57,63 ----
  		-dCellDbFile=CellServDB \
  		-v0 \
  		-w0 \
!         $(AFSDEV_AUXWIXDEFINES)	openafs.wxs
  
  # Cleanup
  clean::
Index: openafs/src/WINNT/install/wix/config.wxi
diff -c openafs/src/WINNT/install/wix/config.wxi:1.5 openafs/src/WINNT/install/wix/config.wxi:1.6
*** openafs/src/WINNT/install/wix/config.wxi:1.5	Thu Jun 24 12:28:51 2004
--- openafs/src/WINNT/install/wix/config.wxi	Sat Jul 24 03:35:04 2004
***************
*** 63,69 ****
  		<?define HideDotFiles="1"?>
      <?endif?>
      <?ifndef SecurityLevel?>
! 		<?define SecurityLevel="0"?>
      <?endif?>
  
      <?define InstallTimestamp="[Date] [Time]"?>
--- 63,72 ----
  		<?define HideDotFiles="1"?>
      <?endif?>
      <?ifndef SecurityLevel?>
! 		<?define SecurityLevel="1"?>
!     <?endif?>
!     <?ifndef SMBAuthType?>
! 		<?define SMBAuthType="2"?>
      <?endif?>
  
      <?define InstallTimestamp="[Date] [Time]"?>
Index: openafs/src/WINNT/install/wix/feature.wxi
diff -c openafs/src/WINNT/install/wix/feature.wxi:1.3 openafs/src/WINNT/install/wix/feature.wxi:1.4
*** openafs/src/WINNT/install/wix/feature.wxi:1.3	Thu Jun 24 00:11:02 2004
--- openafs/src/WINNT/install/wix/feature.wxi	Thu Jul 15 23:38:36 2004
***************
*** 39,44 ****
--- 39,45 ----
                      <ComponentRef Id="cmp_ClientProgramDebug" />
                      <ComponentRef Id="cmp_CommonCommonDebug" />
                      <ComponentRef Id="cmp_ClientCommonDebug" />
+                     <ComponentRef Id="cmp_ClientSystemDebug" />
                      <?include runtime_debug.wxi?>
  				</Feature>
  			<?endif?>
***************
*** 47,53 ****
  				<ComponentRef Id="cmp_CommonDir" />
  
                  <ComponentRef Id="efl_Readme_TXT_$(var.Language)" />
!                 <ComponentRef Id="efl_afsdcell_INI" />
                  <ComponentRef Id="cmf_afs_cpa_CPL" />
  
                  <ComponentRef Id="cmf_afsrpc_DLL" />
--- 48,54 ----
  				<ComponentRef Id="cmp_CommonDir" />
  
                  <ComponentRef Id="efl_Readme_TXT_$(var.Language)" />
!                 <ComponentRef Id="efl_CellServDB" />
                  <ComponentRef Id="cmf_afs_cpa_CPL" />
  
                  <ComponentRef Id="cmf_afsrpc_DLL" />
Index: openafs/src/WINNT/install/wix/files.wxi
diff -c openafs/src/WINNT/install/wix/files.wxi:1.4 openafs/src/WINNT/install/wix/files.wxi:1.6
*** openafs/src/WINNT/install/wix/files.wxi:1.4	Thu Jun 24 12:28:51 2004
--- openafs/src/WINNT/install/wix/files.wxi	Thu Jul 22 05:23:57 2004
***************
*** 1,9 ****
  <?xml version="1.0"?>
  <Include>
!     <Directory Id="WindowsFolder" Name="Windows">
!         <Component Id="efl_afsdcell_INI" Guid="009F9A2D-5B53-4449-824F-7B063AF6F81C" Permanent="yes" NeverOverwrite="yes">
!             <File Id="file_afsdcell_INI" Name="afsdcell.ini" LongName="afsdcell.ini" KeyPath="yes" DiskId="1" src="$(var.CellDbFile)"/>
          </Component>
      </Directory>
      <Directory Id="ProgramFilesFolder" Name=".">
          <Directory Id="AFSDIR" Name="OpenAFS" SourceName=".">
--- 1,23 ----
  <?xml version="1.0"?>
  <Include>
!     <Directory Id="WindowsFolder">
!     </Directory>
!     <Directory Id="SystemFolder">
!         <Component Id="cmf_afslogon_DLL" Guid="123197FE-4F53-4035-8D51-FCFB6B50A777">
!             <File Id="fileafslogon_DLL" Name="afslogon.dll" LongName="afslogon.dll" KeyPath="yes" DiskId="1" src="$(var.ClientDir)afslogon.dll" />
!             <Registry Id="reg_afslogon01" Root="HKLM" Key="SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon\Notify\AfsLogon" Name="*" />
!             <Registry Id="reg_afslogon02" Root="HKLM" Key="SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon\Notify\AfsLogon" />
!             <Registry Id="reg_afslogon03" Root="HKLM" Key="SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon\Notify\AfsLogon" Name="Asynchronous" Value="0" Type="integer" />
!             <Registry Id="reg_afslogon04" Root="HKLM" Key="SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon\Notify\AfsLogon" Name="Impersonate" Value="1" Type="integer" />
!             <Registry Id="reg_afslogon05" Root="HKLM" Key="SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon\Notify\AfsLogon" Name="DLLName" Value="#fileafslogon_DLL" />
!             <Registry Id="reg_afslogon06" Root="HKLM" Key="SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon\Notify\AfsLogon" Name="Logoff" Value="AFS_Logoff_Event" />
!             <Registry Id="reg_afslogon07" Root="HKLM" Key="SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon\Notify\AfsLogon" Name="Startup" Value="AFS_Startup_Event" />
!         </Component>
!     <?ifdef DebugSyms?>
!         <Component Id="cmp_ClientSystemDebug" Guid="DD34DA09-D9DA-4A5A-9521-87B7738A7D53">
! 			<File Id="fileafslogon_PDB" Name="afslogon.pdb" LongName="afslogon.pdb" KeyPath="yes" DiskId="1" src="$(var.ClientDir)afslogon.pdb" />
          </Component>
+     <?endif?>
      </Directory>
      <Directory Id="ProgramFilesFolder" Name=".">
          <Directory Id="AFSDIR" Name="OpenAFS" SourceName=".">
***************
*** 719,724 ****
--- 733,742 ----
              </Directory> <!-- Documentation -->
  
              <Directory Id="dirClient" Name="Client" LongName="Client" SourceName=".">
+                 <Component Id="efl_CellServDB" Guid="8E69FDAB-08C5-4927-B1AA-57FCEEB065F2">
+                     <File Id="file_CellServDB" Name="CelSrvDB" LongName="CellServDB" KeyPath="yes" DiskId="1" src="$(var.CellDbFile)"/>
+                     <CopyFile Id="copy_CellServDB" Delete="yes" DestinationFolder="dirClient" SourceFolder="WindowsFolder" SourceName="afsdcell.ini" />
+                 </Component>
                  <Directory Id="dirProgram" Name="Program" LongName="Program" SourceName="." src="$(var.ClientDir)">
                      <Component Id="cmf_afsshare_EXE" Guid="E972DA35-E950-4736-AE48-E6DDCE8C97D0">
                          <File Id="fileafsshare_EXE" Name="afsshare.exe" LongName="afsshare.exe" KeyPath="yes" DiskId="1" />
***************
*** 762,768 ****
                      <Component Id="cmf_afsd_service_EXE" Guid="37A90054-505D-4C57-B489-7EF4D97B86F6">
                          <File Id="fileafsd_service_EXE" Name="afsd_svc.exe" LongName="afsd_service.exe" KeyPath="yes" DiskId="1" />
                          <ServiceControl Id="TransarcAFSDaemon" Name="TransarcAFSDaemon" Stop="both" Delete="both" Wait="yes" />
!                         <ServiceInstall Id="svc_Client" Name="TransarcAFSDaemon" DisplayName="OpenAFS Client" Type="ownProcess" Start="auto" ErrorControl="normal">
  							<!-- ServiceConfig doesn't currently do what you think it does.
  							     We instead use a custom action to set the service failure actions.
                              <ServiceConfig FirstFailureActionType="restart" RestartServiceDelayInSeconds="10" SecondFailureActionType="restart" ThirdFailureActionType="none"/>
--- 780,786 ----
                      <Component Id="cmf_afsd_service_EXE" Guid="37A90054-505D-4C57-B489-7EF4D97B86F6">
                          <File Id="fileafsd_service_EXE" Name="afsd_svc.exe" LongName="afsd_service.exe" KeyPath="yes" DiskId="1" />
                          <ServiceControl Id="TransarcAFSDaemon" Name="TransarcAFSDaemon" Stop="both" Delete="both" Wait="yes" />
!                         <ServiceInstall Id="svc_Client" Name="TransarcAFSDaemon" DisplayName="OpenAFS Client" Type="ownProcess" Start="auto" ErrorControl="normal" Description="Provides access to files and directories stored in AFS">
  							<!-- ServiceConfig doesn't currently do what you think it does.
  							     We instead use a custom action to set the service failure actions.
                              <ServiceConfig FirstFailureActionType="restart" RestartServiceDelayInSeconds="10" SecondFailureActionType="restart" ThirdFailureActionType="none"/>
***************
*** 775,783 ****
                          <Environment Id="envClient" Name="PATH" Action="create" System="yes" Permanent="no" Part="last" Separator=";" Value="[AFSDIR]Client\Program" />
                          <RemoveFile Id="removeCache" Directory="WindowsVolume" LongName="AFSCache" Name="AFSCache" On="uninstall" />
                      </Component>
-                     <Component Id="cmf_afslogon_DLL" Guid="123197FE-4F53-4035-8D51-FCFB6B50A777">
-                         <File Id="fileafslogon_DLL" Name="afslogon.dll" LongName="afslogon.dll" KeyPath="yes" DiskId="1" />
-                     </Component>
                      <Component Id="cmf_symlink_EXE" Guid="01513839-36E5-418D-8337-04B5D74337CD">
                          <File Id="filesymlink_EXE" Name="symlink.exe" LongName="symlink.exe" KeyPath="yes" DiskId="1" />
                      </Component>
--- 793,798 ----
***************
*** 827,833 ****
                          <File Id="fileafscreds_PDB" Name="afscreds.pdb" LongName="afscreds.pdb" DiskId="1" />
                          <File Id="fileafs_shl_ext_PDB" Name="afsshext.pdb" LongName="afs_shl_ext.pdb" DiskId="1" />
                          <File Id="fileafsd_service_PDB" Name="afsd_svc.pdb" LongName="afsd_service.pdb" DiskId="1" />
-                         <File Id="fileaklogon_PDB" Name="afslogon.pdb" LongName="afslogon.pdb" DiskId="1" />
                          <File Id="filesymlink_PDB" Name="symlink.pdb" LongName="symlink.pdb" DiskId="1" />
                          <File Id="filekpasswd_PDB" Name="kpasswd.pdb" LongName="kpasswd.pdb" DiskId="1" src="$(var.BinDir)kpasswd.pdb" />
                          <File Id="filepts_PDB" Name="pts.pdb" LongName="pts.pdb" DiskId="1" src="$(var.BinDir)pts.pdb" />
--- 842,847 ----
***************
*** 1185,1191 ****
                              <Component Id="cmf_bosctlsvc_EXE" Guid="8F6F62A8-BB6D-46C1-BA80-4F207AA24F0D">
                                  <File Id="filebosctlsvc_EXE" Name="bosct.exe" LongName="bosctlsvc.exe" KeyPath="yes" DiskId="1" />
                                  <ServiceControl Id="TransarcAFSServer" Name="TransarcAFSServer" Stop="both" Delete="both" Wait="yes" />
!                                 <ServiceInstall Id="svc_Server" Name="TransarcAFSServer" DisplayName="OpenAFS Server" Type="ownProcess" Start="auto" ErrorControl="normal">
  									<!-- ServiceConfig does nothing 
                                      <ServiceConfig FirstFailureActionType="restart" RestartServiceDelayInSeconds="5" SecondFailureActionType="restart" ThirdFailureActionType="none"/>
                                      -->
--- 1199,1205 ----
                              <Component Id="cmf_bosctlsvc_EXE" Guid="8F6F62A8-BB6D-46C1-BA80-4F207AA24F0D">
                                  <File Id="filebosctlsvc_EXE" Name="bosct.exe" LongName="bosctlsvc.exe" KeyPath="yes" DiskId="1" />
                                  <ServiceControl Id="TransarcAFSServer" Name="TransarcAFSServer" Stop="both" Delete="both" Wait="yes" />
!                                 <ServiceInstall Id="svc_Server" Name="TransarcAFSServer" DisplayName="OpenAFS Server" Type="ownProcess" Start="auto" ErrorControl="normal" Description="Manages AFS server processes">
  									<!-- ServiceConfig does nothing 
                                      <ServiceConfig FirstFailureActionType="restart" RestartServiceDelayInSeconds="5" SecondFailureActionType="restart" ThirdFailureActionType="none"/>
                                      -->
Index: openafs/src/WINNT/install/wix/property.wxi
diff -c openafs/src/WINNT/install/wix/property.wxi:1.3 openafs/src/WINNT/install/wix/property.wxi:1.5
*** openafs/src/WINNT/install/wix/property.wxi:1.3	Thu Jun 24 12:28:51 2004
--- openafs/src/WINNT/install/wix/property.wxi	Sat Jul 24 03:35:04 2004
***************
*** 11,22 ****
  	<Property Id="RXMAXMTU">$(var.RxMaxMTU)</Property>
  	<Property Id="HIDEDOTFILES">$(var.HideDotFiles)</Property>
  	<Property Id="SECURITYLEVEL">$(var.SecurityLevel)</Property>
- 
  	<Property Id="CREDSSTARTUP">1</Property>
  	<Property Id="CREDSAUTOINIT">-a</Property>
  	<Property Id="CREDSRENEWDRMAP">-m</Property>
  	<Property Id="CREDSIPCHDET">-n</Property>
  	<Property Id="CREDSQUIET">-q</Property>
  	<!-- empty property 
  	<Property Id="CREDSSHOW"></Property>
  	-->
--- 11,22 ----
  	<Property Id="RXMAXMTU">$(var.RxMaxMTU)</Property>
  	<Property Id="HIDEDOTFILES">$(var.HideDotFiles)</Property>
  	<Property Id="SECURITYLEVEL">$(var.SecurityLevel)</Property>
  	<Property Id="CREDSSTARTUP">1</Property>
  	<Property Id="CREDSAUTOINIT">-a</Property>
  	<Property Id="CREDSRENEWDRMAP">-m</Property>
  	<Property Id="CREDSIPCHDET">-n</Property>
  	<Property Id="CREDSQUIET">-q</Property>
+ 	<Property Id="SMBAUTHTYPE">$(var.SMBAuthType)</Property>
  	<!-- empty property 
  	<Property Id="CREDSSHOW"></Property>
  	-->
Index: openafs/src/WINNT/install/wix/registry.wxi
diff -c openafs/src/WINNT/install/wix/registry.wxi:1.2 openafs/src/WINNT/install/wix/registry.wxi:1.4
*** openafs/src/WINNT/install/wix/registry.wxi:1.2	Thu Jun 24 12:28:51 2004
--- openafs/src/WINNT/install/wix/registry.wxi	Sat Jul 24 03:35:04 2004
***************
*** 82,92 ****
          <Registry Root="HKCR" Key="*\shellex\ContextMenuHandlers\AFS Client Shell Extension" Name="*" Id="reg_Client19" />
          <Registry Root="HKCR" Key="*\shellex\ContextMenuHandlers\AFS Client Shell Extension" Value="{DC515C27-6CAC-11D1-BAE7-00C04FD140D2}" Id="reg_Client20" />
          <Registry Root="HKLM" Key="SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\NetworkProvider" Name="*" Id="reg_Client21" />
!         <Registry Root="HKLM" Key="SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\NetworkProvider" Name="AuthentProviderPath" Type="expandable" Value="[AFSDIR]Client\PROGRAM\afslogon.dll" Id="reg_Client22" />
          <Registry Root="HKLM" Key="SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\NetworkProvider" Id="reg_Client23" />
          <Registry Root="HKLM" Key="SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\NetworkProvider" Name="LogonOptions" Type="integer" Value="[LOGONOPTIONS]" Id="reg_Client24" />
          <Registry Root="HKLM" Key="SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\NetworkProvider" Name="VerboseLogging" Type="integer" Value="10" Id="reg_Client25" />
!         <Registry Root="HKLM" Key="SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\NetworkProvider" Name="ProviderPath" Type="expandable" Value="[AFSDIR]Client\PROGRAM\afslogon.dll" Id="reg_Client26" />
          <Registry Root="HKLM" Key="SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\NetworkProvider" Name="LogonScript" Type="expandable" Value="[AFSDIR]Client\Program\afscreds.exe -:%s -x -a -m -n -q" Id="reg_Client27" />
          <Registry Root="HKLM" Key="SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\NetworkProvider" Name="Class" Type="integer" Value="2" Id="reg_Client29" />
          <Registry Root="HKLM" Key="SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\NetworkProvider" Name="Name" Value="TransarcAFSDaemon" Id="reg_Client30" />
--- 82,92 ----
          <Registry Root="HKCR" Key="*\shellex\ContextMenuHandlers\AFS Client Shell Extension" Name="*" Id="reg_Client19" />
          <Registry Root="HKCR" Key="*\shellex\ContextMenuHandlers\AFS Client Shell Extension" Value="{DC515C27-6CAC-11D1-BAE7-00C04FD140D2}" Id="reg_Client20" />
          <Registry Root="HKLM" Key="SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\NetworkProvider" Name="*" Id="reg_Client21" />
!         <Registry Root="HKLM" Key="SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\NetworkProvider" Name="AuthentProviderPath" Type="expandable" Value="[SystemFolder]afslogon.dll" Id="reg_Client22" />
          <Registry Root="HKLM" Key="SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\NetworkProvider" Id="reg_Client23" />
          <Registry Root="HKLM" Key="SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\NetworkProvider" Name="LogonOptions" Type="integer" Value="[LOGONOPTIONS]" Id="reg_Client24" />
          <Registry Root="HKLM" Key="SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\NetworkProvider" Name="VerboseLogging" Type="integer" Value="10" Id="reg_Client25" />
!         <Registry Root="HKLM" Key="SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\NetworkProvider" Name="ProviderPath" Type="expandable" Value="[SystemFolder]afslogon.dll" Id="reg_Client26" />
          <Registry Root="HKLM" Key="SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\NetworkProvider" Name="LogonScript" Type="expandable" Value="[AFSDIR]Client\Program\afscreds.exe -:%s -x -a -m -n -q" Id="reg_Client27" />
          <Registry Root="HKLM" Key="SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\NetworkProvider" Name="Class" Type="integer" Value="2" Id="reg_Client29" />
          <Registry Root="HKLM" Key="SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\NetworkProvider" Name="Name" Value="TransarcAFSDaemon" Id="reg_Client30" />
***************
*** 119,124 ****
--- 119,125 ----
          <Registry Root="HKLM" Key="SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\Parameters" Name="FreelanceClient" Type="integer" Value="[FREELANCEMODE]" Id="reg_Full_Client9" />
          <Registry Root="HKLM" Key="SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\Parameters" Name="UseDNS" Type="integer" Value="[USEDNS]" Id="reg_Full_Client10" />
          <Registry Root="HKLM" Key="SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\Parameters" Name="SecurityLevel" Type="integer" Value="[SECURITYLEVEL]" Id="reg_Full_Client12" />
+         <Registry Root="HKLM" Key="SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\Parameters" Name="SMBAuthType" Type="integer" Value="[SMBAUTHTYPE]" Id="reg_Full_Client13" />
      </Component>
      <Component Id="rcm_Documentation" Guid="97493526-4A5C-4C55-A1D6-EA38841B1B85">
          <Registry Root="HKLM" Key="SOFTWARE\TransarcCorporation\AFS Supplemental Documentation" KeyPath="yes" Id="reg_Docs2" />
Index: openafs/src/WINNT/install/wix/lang/en_US/ui.wxi
diff -c openafs/src/WINNT/install/wix/lang/en_US/ui.wxi:1.4 openafs/src/WINNT/install/wix/lang/en_US/ui.wxi:1.6
*** openafs/src/WINNT/install/wix/lang/en_US/ui.wxi:1.4	Thu Jun 24 12:28:56 2004
--- openafs/src/WINNT/install/wix/lang/en_US/ui.wxi	Sun Jul 25 16:53:20 2004
***************
*** 750,763 ****
          </Control>
          <Control Id="CellLabel" Type="Text" X="45" Y="73" Width="100" Height="15" TabSkip="no" Text="Default &amp;Cell" />
          <Control Id="CellEdit" Type="Edit" X="150" Y="73" Width="115" Height="18" Property="AFSCELLNAME" Text="{120}" />
!         <Control Id="LogonOptionsLabel" Type="Text" X="45" Y="93" Width="100" Height="15" Text="Integrated logon options" />
!         <Control Id="LogonOptionSel" Type="RadioButtonGroup" X="45" Y="108" Width="220" Height="60" Property="LOGONOPTIONS" />
!         <Control Id="SecurityLevelLabel" Type="Text" X="45" Y="168" Width="100" Height="15" Text="AFS crypt security" />
!         <Control Id="SecurityLevelSel" Type="RadioButtonGroup" X="150" Y="168" Width="120" Height="20" Property="SECURITYLEVEL" />
!         <Control Id="FreelanceLabel" Type="Text" X="45" Y="188" Width="100" Height="15" Text="Freelance mode" />
!         <Control Id="FreelanceSel" Type="RadioButtonGroup" X="150" Y="188" Width="120" Height="20" Property="FREELANCEMODE" />
!         <Control Id="DNSLabel" Type="Text" X="45" Y="208" Width="100" Height="15" Text="Lookup cells in DNS" />
!         <Control Id="DNSSel" Type="RadioButtonGroup" X="150" Y="208" Width="120" Height="20" Property="USEDNS" />
        </Dialog>
        <RadioGroup Property="SECURITYLEVEL">
  		<RadioButton X="5" Y="0" Width="55" Height="15" Text="Disable">0</RadioButton>
--- 750,763 ----
          </Control>
          <Control Id="CellLabel" Type="Text" X="45" Y="73" Width="100" Height="15" TabSkip="no" Text="Default &amp;Cell" />
          <Control Id="CellEdit" Type="Edit" X="150" Y="73" Width="115" Height="18" Property="AFSCELLNAME" Text="{120}" />
!         <Control Id="LogonOptionsLabel" Type="Text"				X="45"	Y="100"	Width="100" Height="15" Text="Integrated logon" />
!         <Control Id="LogonOptionSel" Type="RadioButtonGroup"	X="150"	Y="100"	Width="120" Height="20" Property="LOGONOPTIONS" />
!         <Control Id="SecurityLevelLabel" Type="Text"			X="45"	Y="120"	Width="100" Height="15" Text="AFS crypt security" />
!         <Control Id="SecurityLevelSel" Type="RadioButtonGroup"	X="150"	Y="120"	Width="120" Height="20" Property="SECURITYLEVEL" />
!         <Control Id="FreelanceLabel" Type="Text"				X="45"	Y="140"	Width="100" Height="15" Text="Freelance mode" />
!         <Control Id="FreelanceSel" Type="RadioButtonGroup"		X="150"	Y="140"	Width="120" Height="20" Property="FREELANCEMODE" />
!         <Control Id="DNSLabel" Type="Text"						X="45"	Y="160"	Width="100" Height="15" Text="Lookup cells in DNS" />
!         <Control Id="DNSSel" Type="RadioButtonGroup"			X="150"	Y="160"	Width="120" Height="20" Property="USEDNS" />
        </Dialog>
        <RadioGroup Property="SECURITYLEVEL">
  		<RadioButton X="5" Y="0" Width="55" Height="15" Text="Disable">0</RadioButton>
***************
*** 772,780 ****
  		<RadioButton X="65" Y="0" Width="55" Height="15" Text="Enable">1</RadioButton>
        </RadioGroup>
        <RadioGroup Property="LOGONOPTIONS">
! 		<RadioButton X="5" Y="0" Width="215" Height="15" Text="Disable integrated logon">0</RadioButton>
! 		<RadioButton X="5" Y="20" Width="215" Height="15" Text="Enable integrated logon">1</RadioButton>
! 		<RadioButton X="5" Y="40" Width="215" Height="15" Text="Enable integrated logon and high security">3</RadioButton>		
        </RadioGroup>
  
        <Dialog Id="ConfigCredsDlg" Width="370" Height="270" Title="[ProductName] [Setup]" NoMinimize="yes">
--- 772,779 ----
  		<RadioButton X="65" Y="0" Width="55" Height="15" Text="Enable">1</RadioButton>
        </RadioGroup>
        <RadioGroup Property="LOGONOPTIONS">
! 		<RadioButton X="5" Y="0" Width="55" Height="15" Text="Disable">0</RadioButton>
! 		<RadioButton X="65" Y="0" Width="55" Height="15" Text="Enable">1</RadioButton>
        </RadioGroup>
  
        <Dialog Id="ConfigCredsDlg" Width="370" Height="270" Title="[ProductName] [Setup]" NoMinimize="yes">
***************
*** 801,807 ****
          <Control Id="CredStartLabel" Type="Text" X="45" Y="53" Width="295" Height="15" TabSkip="yes" Text="Startup options for AFS Credentials" />
          <Control Id="CredStartup" Type="CheckBox" X="50" Y="73" Width="300" Height="15" Property="CREDSSTARTUP" CheckBoxValue="1" Text="Start AFS Credentials at startup" />
          <Control Id="CredCommandLabel" Type="Text" X="45" Y="93" Width="295" Height="15" TabSkip="yes" Text="Command line options for AFS Credentials" />
!         <Control Id="CredAutoInit" Type="CheckBox" X="50" Y="113" Width="300" Height="15" Property="CREDSAUTOINIT" CheckBoxValue="-a" Text="Auto initialize AFS Credentials." />
          <Control Id="CredRenew" Type="CheckBox" X="50" Y="133" Width="300" Height="15" Property="CREDSRENEWDRMAP" CheckBoxValue="-m" Text="Renew drive maps" />
          <Control Id="CredIPCg" Type="CheckBox" X="50" Y="153" Width="300" Height="15" Property="CREDSIPCHDET" CheckBoxValue="-n" Text="Detect IP address changes" />
          <Control Id="CredQuiet" Type="CheckBox" X="50" Y="173" Width="300" Height="15" Property="CREDSQUIET" CheckBoxValue="-q" Text="Quiet mode" />
--- 800,806 ----
          <Control Id="CredStartLabel" Type="Text" X="45" Y="53" Width="295" Height="15" TabSkip="yes" Text="Startup options for AFS Credentials" />
          <Control Id="CredStartup" Type="CheckBox" X="50" Y="73" Width="300" Height="15" Property="CREDSSTARTUP" CheckBoxValue="1" Text="Start AFS Credentials at startup" />
          <Control Id="CredCommandLabel" Type="Text" X="45" Y="93" Width="295" Height="15" TabSkip="yes" Text="Command line options for AFS Credentials" />
!         <Control Id="CredAutoInit" Type="CheckBox" X="50" Y="113" Width="300" Height="15" Property="CREDSAUTOINIT" CheckBoxValue="-a" Text="Auto initialize AFS Credentials" />
          <Control Id="CredRenew" Type="CheckBox" X="50" Y="133" Width="300" Height="15" Property="CREDSRENEWDRMAP" CheckBoxValue="-m" Text="Renew drive maps" />
          <Control Id="CredIPCg" Type="CheckBox" X="50" Y="153" Width="300" Height="15" Property="CREDSIPCHDET" CheckBoxValue="-n" Text="Detect IP address changes" />
          <Control Id="CredQuiet" Type="CheckBox" X="50" Y="173" Width="300" Height="15" Property="CREDSQUIET" CheckBoxValue="-q" Text="Quiet mode" />
***************
*** 820,826 ****
            <Text>{\VerdanaBold13}[ProductName] [Wizard] was interrupted</Text>
          </Control>
          <Control Id="Description1" Type="Text" X="135" Y="70" Width="220" Height="40" Transparent="yes" NoPrefix="yes">
!           <Text>[ProductName] setup was interrupted.  Your system has not been modified.  To install this program at a later time, please run the installation again.</Text>
          </Control>
          <Control Id="Description2" Type="Text" X="135" Y="115" Width="220" Height="20" Transparent="yes" NoPrefix="yes">
            <Text>Click the Finish button to exit the [Wizard].</Text>
--- 819,825 ----
            <Text>{\VerdanaBold13}[ProductName] [Wizard] was interrupted</Text>
          </Control>
          <Control Id="Description1" Type="Text" X="135" Y="70" Width="220" Height="40" Transparent="yes" NoPrefix="yes">
!           <Text>[ProductName] setup was interrupted.  Your system has not been modified.  To install or modify this program at a later time, please run the installation again.</Text>
          </Control>
          <Control Id="Description2" Type="Text" X="135" Y="115" Width="220" Height="20" Transparent="yes" NoPrefix="yes">
            <Text>Click the Finish button to exit the [Wizard].</Text>
***************
*** 911,918 ****
          </Control>
          <Control Id="BannerLine" Type="Line" X="0" Y="44" Width="374" Height="0" />
          <Control Id="BottomLine" Type="Line" X="0" Y="234" Width="374" Height="0" />
!         <Control Id="Title" Type="Text" X="15" Y="6" Width="200" Height="15" Transparent="no" NoPrefix="yes">
!           <Text>[DlgTitleFont]Remove [ProductName]</Text>
          </Control>
        </Dialog>
        <Dialog Id="VerifyRepairDlg" Width="370" Height="270" Title="[ProductName] [Setup]" NoMinimize="yes" TrackDiskSpace="yes">
--- 910,917 ----
          </Control>
          <Control Id="BannerLine" Type="Line" X="0" Y="44" Width="374" Height="0" />
          <Control Id="BottomLine" Type="Line" X="0" Y="234" Width="374" Height="0" />
!         <Control Id="Title" Type="Text" X="15" Y="6" Width="240" Height="15" Transparent="yes" NoPrefix="yes">
!           <Text>[DlgTitleFont]Remove OpenAFS for Windows</Text>
          </Control>
        </Dialog>
        <Dialog Id="VerifyRepairDlg" Width="370" Height="270" Title="[ProductName] [Setup]" NoMinimize="yes" TrackDiskSpace="yes">
***************
*** 940,947 ****
          </Control>
          <Control Id="BannerLine" Type="Line" X="0" Y="44" Width="374" Height="0" />
          <Control Id="BottomLine" Type="Line" X="0" Y="234" Width="374" Height="0" />
!         <Control Id="Title" Type="Text" X="15" Y="6" Width="200" Height="15" Transparent="yes" NoPrefix="yes">
!           <Text>[DlgTitleFont]Repair [ProductName]</Text>
          </Control>
        </Dialog>
        <Dialog Id="WaitForCostingDlg" Y="10" Width="260" Height="85" Title="[ProductName] [Setup]" NoMinimize="yes">
--- 939,946 ----
          </Control>
          <Control Id="BannerLine" Type="Line" X="0" Y="44" Width="374" Height="0" />
          <Control Id="BottomLine" Type="Line" X="0" Y="234" Width="374" Height="0" />
!         <Control Id="Title" Type="Text" X="15" Y="6" Width="240" Height="15" Transparent="yes" NoPrefix="yes">
!           <Text>[DlgTitleFont]Repair OpenAFS for Windows</Text>
          </Control>
        </Dialog>
        <Dialog Id="WaitForCostingDlg" Y="10" Width="260" Height="85" Title="[ProductName] [Setup]" NoMinimize="yes">
Index: openafs/src/WINNT/kfw/inc/krb4/krb.h
diff -c openafs/src/WINNT/kfw/inc/krb4/krb.h:1.1 openafs/src/WINNT/kfw/inc/krb4/krb.h:1.2
*** openafs/src/WINNT/kfw/inc/krb4/krb.h:1.1	Thu Feb 26 14:22:51 2004
--- openafs/src/WINNT/kfw/inc/krb4/krb.h	Sun Jul 25 17:45:19 2004
***************
*** 452,455 ****
--- 452,458 ----
  
  int krb_in_tkt(char *pname, char *pinst, char *prealm);
  
+ /* lifetime.c */
+ int krb_life_to_time(int start, int life);
+ int krb_time_to_life(int start, int end);
  #endif  /* KRB_DEFS */
Index: openafs/src/WINNT/kfw/inc/leash/leashwin.h
diff -c openafs/src/WINNT/kfw/inc/leash/leashwin.h:1.1 openafs/src/WINNT/kfw/inc/leash/leashwin.h:1.2
*** openafs/src/WINNT/kfw/inc/leash/leashwin.h:1.1	Thu Feb 26 14:22:55 2004
--- openafs/src/WINNT/kfw/inc/leash/leashwin.h	Sun Jul 25 17:45:24 2004
***************
*** 42,48 ****
      } out;
  } LSH_DLGINFO_EX, FAR *LPLSH_DLGINFO_EX;
  
! #define LSH_DLGINFO_EX_V1_SZ (sizeof(DWORD) + 3 * sizeof(LPSTR) * 8 * sizeof(int))
  
  typedef struct {                                                
      char    principal[MAX_K_NAME_SZ]; /* Principal name/instance/realm */
--- 42,49 ----
      } out;
  } LSH_DLGINFO_EX, FAR *LPLSH_DLGINFO_EX;
  
! #define LSH_DLGINFO_EX_V1_SZ (sizeof(DWORD) + 3 * sizeof(LPSTR) + 8 * sizeof(int))
! #define LSH_DLGINFO_EX_V2_SZ (sizeof(DWORD) + 3 * sizeof(LPSTR) + 8 * sizeof(int) + max(LEASH_USERNAME_SZ,LEASH_REALM_SZ))
  
  typedef struct {                                                
      char    principal[MAX_K_NAME_SZ]; /* Principal name/instance/realm */
***************
*** 129,133 ****
--- 130,140 ----
  DWORD Leash_get_default_uppercaserealm();
  DWORD Leash_set_default_uppercaserealm(DWORD onoff);
  DWORD Leash_reset_default_uppercaserealm();
+ DWORD Leash_get_default_mslsa_import();
+ DWORD Leash_set_default_mslsa_import(DWORD onoffmatch);
+ DWORD Leash_reset_default_mslsa_import();
+ DWORD Leash_get_default_preserve_kinit_settings();
+ DWORD Leash_set_default_preserve_kinit_settings(DWORD onoff);
+ DWORD Leash_reset_default_preserve_kinit_settings();
  
  #endif /* LEASHWIN */
Index: openafs/src/WINNT/kfw/inc/loadfuncs/loadfuncs-krb.h
diff -c openafs/src/WINNT/kfw/inc/loadfuncs/loadfuncs-krb.h:1.1 openafs/src/WINNT/kfw/inc/loadfuncs/loadfuncs-krb.h:1.2
*** openafs/src/WINNT/kfw/inc/loadfuncs/loadfuncs-krb.h:1.1	Thu Feb 26 14:22:56 2004
--- openafs/src/WINNT/kfw/inc/loadfuncs/loadfuncs-krb.h	Sun Jul 25 17:45:25 2004
***************
*** 302,306 ****
      lsh_LoadKrb4LeashErrorTables,
      (HMODULE hLeashDll, INT useCallBackFunction)
      );
! 
  #endif /* __LOADFUNCS_KRB_H__ */
--- 302,317 ----
      lsh_LoadKrb4LeashErrorTables,
      (HMODULE hLeashDll, INT useCallBackFunction)
      );
! TYPEDEF_FUNC(
!     int,
!     CALLCONV_C,
!     krb_life_to_time,
!     (int start, int life)
!     );
! TYPEDEF_FUNC(
!     int,
!     CALLCONV_C,
!     krb_time_to_life,
!     (int start, int end)
!     );
  #endif /* __LOADFUNCS_KRB_H__ */
Index: openafs/src/WINNT/kfw/inc/loadfuncs/loadfuncs-krb5.h
diff -c openafs/src/WINNT/kfw/inc/loadfuncs/loadfuncs-krb5.h:1.1 openafs/src/WINNT/kfw/inc/loadfuncs/loadfuncs-krb5.h:1.2
*** openafs/src/WINNT/kfw/inc/loadfuncs/loadfuncs-krb5.h:1.1	Thu Feb 26 14:22:56 2004
--- openafs/src/WINNT/kfw/inc/loadfuncs/loadfuncs-krb5.h	Sun Jul 25 17:45:25 2004
***************
*** 879,884 ****
--- 879,892 ----
  TYPEDEF_FUNC(
      krb5_error_code,
      KRB5_CALLCONV,
+     krb5_free_default_realm,
+     (krb5_context,
+      const char * )
+     );
+ 
+ TYPEDEF_FUNC(
+     krb5_error_code,
+     KRB5_CALLCONV,
      krb5_sname_to_principal,
      (krb5_context,
       const char *,
Index: openafs/src/WINNT/kfw/inc/loadfuncs/loadfuncs-leash.h
diff -c openafs/src/WINNT/kfw/inc/loadfuncs/loadfuncs-leash.h:1.1 openafs/src/WINNT/kfw/inc/loadfuncs/loadfuncs-leash.h:1.2
*** openafs/src/WINNT/kfw/inc/loadfuncs/loadfuncs-leash.h:1.1	Thu Feb 26 14:22:56 2004
--- openafs/src/WINNT/kfw/inc/loadfuncs/loadfuncs-leash.h	Sun Jul 25 17:45:25 2004
***************
*** 345,350 ****
--- 345,386 ----
      (void)
      );
  TYPEDEF_FUNC(
+     DWORD,
+     CALLCONV_C,
+     Leash_get_default_mslsa_import,
+     (void)
+     );
+ TYPEDEF_FUNC(
+     DWORD,
+     CALLCONV_C,
+     Leash_set_default_mslsa_import,
+     (DWORD)
+     );
+ TYPEDEF_FUNC(
+     DWORD,
+     CALLCONV_C,
+     Leash_reset_default_mslsa_import,
+     (void)
+     );
+ TYPEDEF_FUNC(
+     DWORD,
+     CALLCONV_C,
+     Leash_get_default_preserve_kinit_settings,
+     (void)
+     );
+ TYPEDEF_FUNC(
+     DWORD,
+     CALLCONV_C,
+     Leash_set_default_preserve_kinit_settings,
+     (DWORD)
+     );
+ TYPEDEF_FUNC(
+     DWORD,
+     CALLCONV_C,
+     Leash_reset_default_preserve_kinit_settings,
+     (void)
+     );
+ TYPEDEF_FUNC(
      BOOL,
      CALLCONV_C,
      Leash_import,
Index: openafs/src/WINNT/kfw/lib/i386/comerr32.lib
Index: openafs/src/WINNT/kfw/lib/i386/delaydlls.lib
Index: openafs/src/WINNT/kfw/lib/i386/getopt.lib
Index: openafs/src/WINNT/kfw/lib/i386/gssapi32.lib
Index: openafs/src/WINNT/kfw/lib/i386/kclnt32.lib
Index: openafs/src/WINNT/kfw/lib/i386/krb524.lib
Index: openafs/src/WINNT/kfw/lib/i386/krb5_32.lib
Index: openafs/src/WINNT/kfw/lib/i386/krbcc32.lib
Index: openafs/src/WINNT/kfw/lib/i386/krbv4w32.lib
Index: openafs/src/WINNT/kfw/lib/i386/leashw32.lib
Index: openafs/src/WINNT/kfw/lib/i386/loadfuncs.lib
Index: openafs/src/WINNT/kfw/lib/i386/wshelp32.lib
Index: openafs/src/WINNT/kfw/lib/i386/xpprof32.lib
Index: openafs/src/afs/afs_call.c
diff -c openafs/src/afs/afs_call.c:1.69 openafs/src/afs/afs_call.c:1.70
*** openafs/src/afs/afs_call.c:1.69	Thu Jun 24 13:38:22 2004
--- openafs/src/afs/afs_call.c	Tue Jul 13 01:45:14 2004
***************
*** 11,17 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_call.c,v 1.69 2004/06/24 17:38:22 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
--- 11,17 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_call.c,v 1.70 2004/07/13 05:45:14 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
***************
*** 775,781 ****
  #endif /* AFS_SGI53_ENV */
      else if (parm == AFSOP_SHUTDOWN) {
  	afs_cold_shutdown = 0;
! 	if (parm == 1)
  	    afs_cold_shutdown = 1;
  #ifndef AFS_DARWIN_ENV
  	if (afs_globalVFS != 0) {
--- 775,781 ----
  #endif /* AFS_SGI53_ENV */
      else if (parm == AFSOP_SHUTDOWN) {
  	afs_cold_shutdown = 0;
! 	if (parm2 == 1)
  	    afs_cold_shutdown = 1;
  #ifndef AFS_DARWIN_ENV
  	if (afs_globalVFS != 0) {
Index: openafs/src/afs/afs_vcache.c
diff -c openafs/src/afs/afs_vcache.c:1.64 openafs/src/afs/afs_vcache.c:1.65
*** openafs/src/afs/afs_vcache.c:1.64	Wed Jun 23 14:34:45 2004
--- openafs/src/afs/afs_vcache.c	Wed Jul 14 00:21:54 2004
***************
*** 39,45 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_vcache.c,v 1.64 2004/06/23 18:34:45 shadow Exp $");
  
  #include "afs/sysincludes.h"	/*Standard vendor system headers */
  #include "afsincludes.h"	/*AFS-based standard headers */
--- 39,45 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_vcache.c,v 1.65 2004/07/14 04:21:54 shadow Exp $");
  
  #include "afs/sysincludes.h"	/*Standard vendor system headers */
  #include "afsincludes.h"	/*AFS-based standard headers */
***************
*** 656,665 ****
      while ((cur = cur->next) != head) {
  	dentry = list_entry(cur, struct dentry, d_alias);
  
! 	afs_Trace3(afs_iclSetp, CM_TRACE_TRYFLUSHDCACHECHILDREN,
  		   ICL_TYPE_POINTER, ip, ICL_TYPE_STRING,
  		   dentry->d_parent->d_name.name, ICL_TYPE_STRING,
  		   dentry->d_name.name);
  
  	if (!list_empty(&dentry->d_hash) && !list_empty(&dentry->d_subdirs))
  	    __shrink_dcache_parent(dentry);
--- 656,669 ----
      while ((cur = cur->next) != head) {
  	dentry = list_entry(cur, struct dentry, d_alias);
  
! 	if (ICL_SETACTIVE(afs_iclSetp)) {
! 	    AFS_GLOCK();
! 	    afs_Trace3(afs_iclSetp, CM_TRACE_TRYFLUSHDCACHECHILDREN,
  		   ICL_TYPE_POINTER, ip, ICL_TYPE_STRING,
  		   dentry->d_parent->d_name.name, ICL_TYPE_STRING,
  		   dentry->d_name.name);
+ 	    AFS_GUNLOCK();
+ 	}
  
  	if (!list_empty(&dentry->d_hash) && !list_empty(&dentry->d_subdirs))
  	    __shrink_dcache_parent(dentry);
Index: openafs/src/afs/LINUX/osi_alloc.c
diff -c openafs/src/afs/LINUX/osi_alloc.c:1.21 openafs/src/afs/LINUX/osi_alloc.c:1.22
*** openafs/src/afs/LINUX/osi_alloc.c:1.21	Mon Apr 12 12:04:32 2004
--- openafs/src/afs/LINUX/osi_alloc.c	Wed Jul 14 00:14:31 2004
***************
*** 15,21 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/LINUX/osi_alloc.c,v 1.21 2004/04/12 16:04:32 shadow Exp $");
  
  #include "afs/sysincludes.h"
  #include "afsincludes.h"
--- 15,21 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/LINUX/osi_alloc.c,v 1.22 2004/07/14 04:14:31 shadow Exp $");
  
  #include "afs/sysincludes.h"
  #include "afsincludes.h"
***************
*** 335,343 ****
  
    free_error:
      if (new) {
- 	up(&afs_linux_alloc_sem);
  	linux_free(new);
- 	down(&afs_linux_alloc_sem);
      }
      new = NULL;
      goto error;
--- 335,341 ----
Index: openafs/src/afs/LINUX/osi_groups.c
diff -c openafs/src/afs/LINUX/osi_groups.c:1.23 openafs/src/afs/LINUX/osi_groups.c:1.25
*** openafs/src/afs/LINUX/osi_groups.c:1.23	Wed Jun  2 02:15:45 2004
--- openafs/src/afs/LINUX/osi_groups.c	Wed Jul 14 00:09:12 2004
***************
*** 17,23 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/LINUX/osi_groups.c,v 1.23 2004/06/02 06:15:45 shadow Exp $");
  
  #include "afs/sysincludes.h"
  #include "afsincludes.h"
--- 17,23 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/LINUX/osi_groups.c,v 1.25 2004/07/14 04:09:12 shadow Exp $");
  
  #include "afs/sysincludes.h"
  #include "afsincludes.h"
***************
*** 94,103 ****
  afs_getgroups(cred_t *cr, gid_t *groups)
  {
      int i;
      AFS_STATCNT(afs_getgroups);
  
!     gid_t *gp = cr->cr_groups;
!     int n = cr->cr_ngroups;
  
      for (i = 0; (i < n) && (*gp != (gid_t) NOGROUP); i++)
  	*groups++ = *gp++;
--- 94,106 ----
  afs_getgroups(cred_t *cr, gid_t *groups)
  {
      int i;
+     int n;
+     gid_t *gp;
+ 
      AFS_STATCNT(afs_getgroups);
  
!     gp = cr->cr_groups;
!     n = cr->cr_ngroups;
  
      for (i = 0; (i < n) && (*gp != (gid_t) NOGROUP); i++)
  	*groups++ = *gp++;
Index: openafs/src/afs/LINUX/osi_vfsops.c
diff -c openafs/src/afs/LINUX/osi_vfsops.c:1.27 openafs/src/afs/LINUX/osi_vfsops.c:1.28
*** openafs/src/afs/LINUX/osi_vfsops.c:1.27	Tue Apr 20 22:20:23 2004
--- openafs/src/afs/LINUX/osi_vfsops.c	Fri Jul 23 18:06:22 2004
***************
*** 16,22 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/LINUX/osi_vfsops.c,v 1.27 2004/04/21 02:20:23 shadow Exp $");
  
  #include "afs/sysincludes.h"
  #include "afsincludes.h"
--- 16,22 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/LINUX/osi_vfsops.c,v 1.28 2004/07/23 22:06:22 shadow Exp $");
  
  #include "afs/sysincludes.h"
  #include "afsincludes.h"
***************
*** 374,379 ****
--- 374,381 ----
  
      memset(&stat, 0, size);
      statp = &stat;
+ #else
+     memset(statp, 0, sizeof(*statp));
  #endif
  
      AFS_STATCNT(afs_statfs);
Index: openafs/src/afs/LINUX/osi_vnodeops.c
diff -c openafs/src/afs/LINUX/osi_vnodeops.c:1.78 openafs/src/afs/LINUX/osi_vnodeops.c:1.81
*** openafs/src/afs/LINUX/osi_vnodeops.c:1.78	Thu Jun 24 13:28:03 2004
--- openafs/src/afs/LINUX/osi_vnodeops.c	Wed Jul 21 18:23:38 2004
***************
*** 22,28 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/LINUX/osi_vnodeops.c,v 1.78 2004/06/24 17:28:03 shadow Exp $");
  
  #include "afs/sysincludes.h"
  #include "afsincludes.h"
--- 22,28 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/LINUX/osi_vnodeops.c,v 1.81 2004/07/21 22:23:38 shadow Exp $");
  
  #include "afs/sysincludes.h"
  #include "afsincludes.h"
***************
*** 270,279 ****
      cred_t *credp = crref();
      struct afs_fakestat_state fakestat;
  
-     AFS_GLOCK();
  #if defined(AFS_LINUX26_ENV)
      lock_kernel();
  #endif
      AFS_STATCNT(afs_readdir);
  
      code = afs_InitReq(&treq, credp);
--- 270,279 ----
      cred_t *credp = crref();
      struct afs_fakestat_state fakestat;
  
  #if defined(AFS_LINUX26_ENV)
      lock_kernel();
  #endif
+     AFS_GLOCK();
      AFS_STATCNT(afs_readdir);
  
      code = afs_InitReq(&treq, credp);
***************
*** 407,416 ****
  out:
      afs_PutFakeStat(&fakestat);
  out1:
  #if defined(AFS_LINUX26_ENV)
      unlock_kernel();
  #endif
-     AFS_GUNLOCK();
      return code;
  }
  
--- 407,416 ----
  out:
      afs_PutFakeStat(&fakestat);
  out1:
+     AFS_GUNLOCK();
  #if defined(AFS_LINUX26_ENV)
      unlock_kernel();
  #endif
      return code;
  }
  
***************
*** 567,581 ****
      int code;
      cred_t *credp = crref();
  
-     AFS_GLOCK();
  #ifdef AFS_LINUX24_ENV
      lock_kernel();
  #endif
      code = afs_open((struct vcache **)&ip, fp->f_flags, credp);
  #ifdef AFS_LINUX24_ENV
      unlock_kernel();
  #endif
-     AFS_GUNLOCK();
  
      crfree(credp);
      return -code;
--- 567,581 ----
      int code;
      cred_t *credp = crref();
  
  #ifdef AFS_LINUX24_ENV
      lock_kernel();
  #endif
+     AFS_GLOCK();
      code = afs_open((struct vcache **)&ip, fp->f_flags, credp);
+     AFS_GUNLOCK();
  #ifdef AFS_LINUX24_ENV
      unlock_kernel();
  #endif
  
      crfree(credp);
      return -code;
***************
*** 595,613 ****
      cred_t *credp = crref();
      struct vcache *vcp = ITOAFS(ip);
  
-     AFS_GLOCK();
  #ifdef AFS_LINUX24_ENV
      lock_kernel();
  #endif
      if (vcp->flushcnt) {
  	vcp->flushcnt--;	/* protected by AFS global lock. */
      } else {
  	code = afs_close(vcp, fp->f_flags, credp);
      }
  #ifdef AFS_LINUX24_ENV
      unlock_kernel();
  #endif
-     AFS_GUNLOCK();
  
      crfree(credp);
      return -code;
--- 595,613 ----
      cred_t *credp = crref();
      struct vcache *vcp = ITOAFS(ip);
  
  #ifdef AFS_LINUX24_ENV
      lock_kernel();
  #endif
+     AFS_GLOCK();
      if (vcp->flushcnt) {
  	vcp->flushcnt--;	/* protected by AFS global lock. */
      } else {
  	code = afs_close(vcp, fp->f_flags, credp);
      }
+     AFS_GUNLOCK();
  #ifdef AFS_LINUX24_ENV
      unlock_kernel();
  #endif
  
      crfree(credp);
      return -code;
***************
*** 625,639 ****
      struct inode *ip = FILE_INODE(fp);
      cred_t *credp = crref();
  
-     AFS_GLOCK();
  #ifdef AFS_LINUX24_ENV
      lock_kernel();
  #endif
      code = afs_fsync(ITOAFS(ip), credp);
  #ifdef AFS_LINUX24_ENV
      unlock_kernel();
  #endif
-     AFS_GUNLOCK();
      crfree(credp);
      return -code;
  
--- 625,639 ----
      struct inode *ip = FILE_INODE(fp);
      cred_t *credp = crref();
  
  #ifdef AFS_LINUX24_ENV
      lock_kernel();
  #endif
+     AFS_GLOCK();
      code = afs_fsync(ITOAFS(ip), credp);
+     AFS_GUNLOCK();
  #ifdef AFS_LINUX24_ENV
      unlock_kernel();
  #endif
      crfree(credp);
      return -code;
  
***************
*** 777,782 ****
--- 777,785 ----
      struct vcache *vcp = ITOAFS(dp->d_inode);
      struct vcache *rootvp = NULL;
  
+ #ifdef AFS_LINUX24_ENV
+     lock_kernel();
+ #endif
      AFS_GLOCK();
  
      if (afs_fakestat_enable && vcp->mvstat == 1 && vcp->mvid
***************
*** 785,793 ****
  	rootvp = afs_FindVCache(vcp->mvid, 0, 0);
  	ReleaseSharedLock(&afs_xvcache);
      }
- #ifdef AFS_LINUX24_ENV
-     lock_kernel();
- #endif
  
      /* Make this a fast path (no crref), since it's called so often. */
      if (vcp->states & CStatd) {
--- 788,793 ----
***************
*** 797,808 ****
  	    vcache2fakeinode(rootvp, vcp);
  	else
  	    vcache2inode(vcp);
- #ifdef AFS_LINUX24_ENV
- 	unlock_kernel();
- #endif
  	if (rootvp)
  	    afs_PutVCache(rootvp);
  	AFS_GUNLOCK();
  	return 0;
      }
  
--- 797,808 ----
  	    vcache2fakeinode(rootvp, vcp);
  	else
  	    vcache2inode(vcp);
  	if (rootvp)
  	    afs_PutVCache(rootvp);
  	AFS_GUNLOCK();
+ #ifdef AFS_LINUX24_ENV
+ 	unlock_kernel();
+ #endif
  	return 0;
      }
  
***************
*** 811,820 ****
      if (!code)
  	code = afs_VerifyVCache(vcp, &treq);
  
  #ifdef AFS_LINUX24_ENV
      unlock_kernel();
  #endif
-     AFS_GUNLOCK();
      crfree(credp);
  
      return -code;
--- 811,820 ----
      if (!code)
  	code = afs_VerifyVCache(vcp, &treq);
  
+     AFS_GUNLOCK();
  #ifdef AFS_LINUX24_ENV
      unlock_kernel();
  #endif
      crfree(credp);
  
      return -code;
***************
*** 856,863 ****
  
      sysState.allocked = 0;
  
!     AFS_GLOCK();
      lock_kernel();
  
      vcp = ITOAFS(dp->d_inode);
      parentvcp = ITOAFS(dp->d_parent->d_inode);
--- 856,865 ----
  
      sysState.allocked = 0;
  
! #ifdef AFS_LINUX24_ENV
      lock_kernel();
+ #endif
+     AFS_GLOCK();
  
      vcp = ITOAFS(dp->d_inode);
      parentvcp = ITOAFS(dp->d_parent->d_inode);
***************
*** 911,923 ****
      if (sysState.allocked)
  	osi_FreeLargeSpace(name);
  
      if (bad_dentry) {
  	shrink_dcache_parent(dp);
  	d_drop(dp);
      }
  
      unlock_kernel();
!     AFS_GUNLOCK();
      crfree(credp);
  
      return !bad_dentry;
--- 913,928 ----
      if (sysState.allocked)
  	osi_FreeLargeSpace(name);
  
+     AFS_GUNLOCK();
+ 
      if (bad_dentry) {
  	shrink_dcache_parent(dp);
  	d_drop(dp);
      }
  
+ #ifdef AFS_LINUX24_ENV
      unlock_kernel();
! #endif
      crfree(credp);
  
      return !bad_dentry;
***************
*** 928,939 ****
  static void
  afs_dentry_iput(struct dentry *dp, struct inode *ip)
  {
      if (ICL_SETACTIVE(afs_iclSetp)) {
! 	AFS_GLOCK();
  	afs_Trace3(afs_iclSetp, CM_TRACE_DENTRYIPUT, ICL_TYPE_POINTER, ip,
  		   ICL_TYPE_STRING, dp->d_parent->d_name.name,
  		   ICL_TYPE_STRING, dp->d_name.name);
! 	AFS_GUNLOCK();
      }
  
      osi_iput(ip);
--- 933,947 ----
  static void
  afs_dentry_iput(struct dentry *dp, struct inode *ip)
  {
+     int isglock;
+ 
      if (ICL_SETACTIVE(afs_iclSetp)) {
! 	isglock = ISAFS_GLOCK();
! 	if (!isglock) AFS_GLOCK();
  	afs_Trace3(afs_iclSetp, CM_TRACE_DENTRYIPUT, ICL_TYPE_POINTER, ip,
  		   ICL_TYPE_STRING, dp->d_parent->d_name.name,
  		   ICL_TYPE_STRING, dp->d_name.name);
! 	if (!isglock) AFS_GUNLOCK();
      }
  
      osi_iput(ip);
***************
*** 943,954 ****
  static int
  afs_dentry_delete(struct dentry *dp)
  {
      if (ICL_SETACTIVE(afs_iclSetp)) {
! 	AFS_GLOCK();
  	afs_Trace3(afs_iclSetp, CM_TRACE_DENTRYDELETE, ICL_TYPE_POINTER,
  		   dp->d_inode, ICL_TYPE_STRING, dp->d_parent->d_name.name,
  		   ICL_TYPE_STRING, dp->d_name.name);
! 	AFS_GUNLOCK();
      }
  
      if (dp->d_inode && (ITOAFS(dp->d_inode)->states & CUnlinked))
--- 951,964 ----
  static int
  afs_dentry_delete(struct dentry *dp)
  {
+     int isglock;
      if (ICL_SETACTIVE(afs_iclSetp)) {
! 	isglock = ISAFS_GLOCK();
! 	if (!isglock) AFS_GLOCK();
  	afs_Trace3(afs_iclSetp, CM_TRACE_DENTRYDELETE, ICL_TYPE_POINTER,
  		   dp->d_inode, ICL_TYPE_STRING, dp->d_parent->d_name.name,
  		   ICL_TYPE_STRING, dp->d_name.name);
! 	if (!isglock) AFS_GUNLOCK();
      }
  
      if (dp->d_inode && (ITOAFS(dp->d_inode)->states & CUnlinked))
***************
*** 990,999 ****
      VATTR_NULL(&vattr);
      vattr.va_mode = mode;
  
-     AFS_GLOCK();
  #if defined(AFS_LINUX26_ENV)
      lock_kernel();
  #endif
      code =
  	afs_create(ITOAFS(dip), name, &vattr, NONEXCL, mode,
  		   (struct vcache **)&ip, credp);
--- 1000,1009 ----
      VATTR_NULL(&vattr);
      vattr.va_mode = mode;
  
  #if defined(AFS_LINUX26_ENV)
      lock_kernel();
  #endif
+     AFS_GLOCK();
      code =
  	afs_create(ITOAFS(dip), name, &vattr, NONEXCL, mode,
  		   (struct vcache **)&ip, credp);
***************
*** 1027,1036 ****
  	d_instantiate(dp, ip);
      }
  
  #if defined(AFS_LINUX26_ENV)
      unlock_kernel();
  #endif
-     AFS_GUNLOCK();
      crfree(credp);
      return -code;
  }
--- 1037,1046 ----
  	d_instantiate(dp, ip);
      }
  
+     AFS_GUNLOCK();
  #if defined(AFS_LINUX26_ENV)
      unlock_kernel();
  #endif
      crfree(credp);
      return -code;
  }
***************
*** 1049,1059 ****
      struct vcache *vcp = NULL;
      const char *comp = dp->d_name.name;
  
-     AFS_GLOCK();
  #if defined(AFS_LINUX26_ENV)
      lock_kernel();
  #endif
      code = afs_lookup(ITOAFS(dip), comp, &vcp, credp);
      
      if (vcp) {
  	struct inode *ip = AFSTOI(vcp);
--- 1059,1070 ----
      struct vcache *vcp = NULL;
      const char *comp = dp->d_name.name;
  
  #if defined(AFS_LINUX26_ENV)
      lock_kernel();
  #endif
+     AFS_GLOCK();
      code = afs_lookup(ITOAFS(dip), comp, &vcp, credp);
+     AFS_GUNLOCK();
      
      if (vcp) {
  	struct inode *ip = AFSTOI(vcp);
***************
*** 1088,1094 ****
  #if defined(AFS_LINUX26_ENV)
      unlock_kernel();
  #endif
-     AFS_GUNLOCK();
      crfree(credp);
  
      /* It's ok for the file to not be found. That's noted by the caller by
--- 1099,1104 ----
***************
*** 1134,1150 ****
      cred_t *credp = crref();
      const char *name = dp->d_name.name;
  
-     AFS_GLOCK();
  #if defined(AFS_LINUX26_ENV)
      lock_kernel();
  #endif
      code = afs_remove(ITOAFS(dip), name, credp);
      if (!code)
  	d_drop(dp);
  #if defined(AFS_LINUX26_ENV)
      unlock_kernel();
  #endif
-     AFS_GUNLOCK();
      crfree(credp);
      return -code;
  }
--- 1144,1160 ----
      cred_t *credp = crref();
      const char *name = dp->d_name.name;
  
  #if defined(AFS_LINUX26_ENV)
      lock_kernel();
  #endif
+     AFS_GLOCK();
      code = afs_remove(ITOAFS(dip), name, credp);
+     AFS_GUNLOCK();
      if (!code)
  	d_drop(dp);
  #if defined(AFS_LINUX26_ENV)
      unlock_kernel();
  #endif
      crfree(credp);
      return -code;
  }
***************
*** 1180,1193 ****
      struct vattr vattr;
      const char *name = dp->d_name.name;
  
-     AFS_GLOCK();
  #if defined(AFS_LINUX26_ENV)
      lock_kernel();
  #endif
      VATTR_NULL(&vattr);
      vattr.va_mask = ATTR_MODE;
      vattr.va_mode = mode;
      code = afs_mkdir(ITOAFS(dip), name, &vattr, &tvcp, credp);
  
      if (tvcp) {
  	tvcp->v.v_op = &afs_dir_iops;
--- 1190,1204 ----
      struct vattr vattr;
      const char *name = dp->d_name.name;
  
  #if defined(AFS_LINUX26_ENV)
      lock_kernel();
  #endif
+     AFS_GLOCK();
      VATTR_NULL(&vattr);
      vattr.va_mask = ATTR_MODE;
      vattr.va_mode = mode;
      code = afs_mkdir(ITOAFS(dip), name, &vattr, &tvcp, credp);
+     AFS_GUNLOCK();
  
      if (tvcp) {
  	tvcp->v.v_op = &afs_dir_iops;
***************
*** 1202,1208 ****
  #if defined(AFS_LINUX26_ENV)
      unlock_kernel();
  #endif
-     AFS_GUNLOCK();
      crfree(credp);
      return -code;
  }
--- 1213,1218 ----
***************
*** 1214,1224 ****
      cred_t *credp = crref();
      const char *name = dp->d_name.name;
  
-     AFS_GLOCK();
  #if defined(AFS_LINUX26_ENV)
      lock_kernel();
  #endif
      code = afs_rmdir(ITOAFS(dip), name, credp);
  
      /* Linux likes to see ENOTEMPTY returned from an rmdir() syscall
       * that failed because a directory is not empty. So, we map
--- 1224,1235 ----
      cred_t *credp = crref();
      const char *name = dp->d_name.name;
  
  #if defined(AFS_LINUX26_ENV)
      lock_kernel();
  #endif
+     AFS_GLOCK();
      code = afs_rmdir(ITOAFS(dip), name, credp);
+     AFS_GUNLOCK();
  
      /* Linux likes to see ENOTEMPTY returned from an rmdir() syscall
       * that failed because a directory is not empty. So, we map
***************
*** 1235,1241 ****
  #if defined(AFS_LINUX26_ENV)
      unlock_kernel();
  #endif
-     AFS_GUNLOCK();
      crfree(credp);
      return -code;
  }
--- 1246,1251 ----
***************
*** 1251,1257 ****
      const char *oldname = olddp->d_name.name;
      const char *newname = newdp->d_name.name;
  
-     AFS_GLOCK();
  #if defined(AFS_LINUX26_ENV)
      lock_kernel();
  #endif
--- 1261,1266 ----
***************
*** 1271,1277 ****
--- 1280,1288 ----
      if (!list_empty(&newdp->d_hash))
  	d_drop(newdp);
  #endif
+     AFS_GLOCK();
      code = afs_rename(ITOAFS(oldip), oldname, ITOAFS(newip), newname, credp);
+     AFS_GUNLOCK();
  
      if (!code) {
  	/* update time so it doesn't expire immediately */
***************
*** 1282,1288 ****
  #if defined(AFS_LINUX26_ENV)
      unlock_kernel();
  #endif
-     AFS_GUNLOCK();
  
      crfree(credp);
      return -code;
--- 1293,1298 ----
***************
*** 1387,1399 ****
      int cnt = page_count(pp);
      struct vcache *avc = ITOAFS(ip);
  
!     AFS_GLOCK();
!     afs_Trace4(afs_iclSetp, CM_TRACE_READPAGE, ICL_TYPE_POINTER, ip, ICL_TYPE_POINTER, pp, ICL_TYPE_INT32, cnt, ICL_TYPE_INT32, 99999);	/* not a possible code value */
  #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
      address = kmap(pp);
      ClearPageError(pp);
- 
-     lock_kernel();
  #else
      atomic_add(1, &pp->count);
      set_bit(PG_locked, &pp->flags);	/* other bits? See mm.h */
--- 1397,1406 ----
      int cnt = page_count(pp);
      struct vcache *avc = ITOAFS(ip);
  
! 
  #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
      address = kmap(pp);
      ClearPageError(pp);
  #else
      atomic_add(1, &pp->count);
      set_bit(PG_locked, &pp->flags);	/* other bits? See mm.h */
***************
*** 1402,1409 ****
  
      setup_uio(&tuio, &iovec, (char *)address, offset, PAGESIZE, UIO_READ,
  	      AFS_UIOSYS);
      code = afs_rdwr(avc, &tuio, UIO_READ, 0, credp);
! #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
      unlock_kernel();
  #endif
  
--- 1409,1425 ----
  
      setup_uio(&tuio, &iovec, (char *)address, offset, PAGESIZE, UIO_READ,
  	      AFS_UIOSYS);
+ #ifdef AFS_LINUX24_ENV
+     lock_kernel();
+ #endif
+     AFS_GLOCK();
+     afs_Trace4(afs_iclSetp, CM_TRACE_READPAGE, ICL_TYPE_POINTER, ip, ICL_TYPE_POINTER, pp, ICL_TYPE_INT32, cnt, ICL_TYPE_INT32, 99999);	/* not a possible code value */
      code = afs_rdwr(avc, &tuio, UIO_READ, 0, credp);
!     afs_Trace4(afs_iclSetp, CM_TRACE_READPAGE, ICL_TYPE_POINTER, ip,
! 	       ICL_TYPE_POINTER, pp, ICL_TYPE_INT32, cnt, ICL_TYPE_INT32,
! 	       code);
!     AFS_GUNLOCK();
! #ifdef AFS_LINUX24_ENV
      unlock_kernel();
  #endif
  
***************
*** 1418,1423 ****
--- 1434,1440 ----
  	set_bit(PG_uptodate, &pp->flags);
  #endif
      }
+ 
  #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
      kunmap(pp);
      UnlockPage(pp);
***************
*** 1431,1436 ****
--- 1448,1454 ----
  	struct dcache *tdc;
  	struct vrequest treq;
  
+ 	AFS_GLOCK();
  	code = afs_InitReq(&treq, credp);
  	if (!code && !NBObtainWriteLock(&avc->lock, 534)) {
  	    tdc = afs_FindDCache(avc, offset);
***************
*** 1441,1453 ****
  	    }
  	    ReleaseWriteLock(&avc->lock);
  	}
      }
  
      crfree(credp);
-     afs_Trace4(afs_iclSetp, CM_TRACE_READPAGE, ICL_TYPE_POINTER, ip,
- 	       ICL_TYPE_POINTER, pp, ICL_TYPE_INT32, cnt, ICL_TYPE_INT32,
- 	       code);
-     AFS_GUNLOCK();
      return -code;
  }
  
--- 1459,1468 ----
  	    }
  	    ReleaseWriteLock(&avc->lock);
  	}
+ 	AFS_GUNLOCK();
      }
  
      crfree(credp);
      return -code;
  }
  
***************
*** 1620,1630 ****
  {
      int code;
  
-     AFS_GLOCK();
      lock_kernel();
      code = afs_linux_updatepage(file, page, offset, to - offset);
-     unlock_kernel();
      AFS_GUNLOCK();
      kunmap(page);
  
      return code;
--- 1635,1645 ----
  {
      int code;
  
      lock_kernel();
+     AFS_GLOCK();
      code = afs_linux_updatepage(file, page, offset, to - offset);
      AFS_GUNLOCK();
+     unlock_kernel();
      kunmap(page);
  
      return code;
***************
*** 1705,1719 ****
      char *p = (char *)kmap(page);
      int code;
  
-     AFS_GLOCK();
      lock_kernel();
      code = afs_linux_ireadlink(ip, p, PAGE_SIZE, AFS_UIOSYS);
  
      if (code < 0)
  	goto fail;
      p[code] = '\0';		/* null terminate? */
      unlock_kernel();
-     AFS_GUNLOCK();
  
      SetPageUptodate(page);
      kunmap(page);
--- 1720,1734 ----
      char *p = (char *)kmap(page);
      int code;
  
      lock_kernel();
+     AFS_GLOCK();
      code = afs_linux_ireadlink(ip, p, PAGE_SIZE, AFS_UIOSYS);
+     AFS_GUNLOCK();
  
      if (code < 0)
  	goto fail;
      p[code] = '\0';		/* null terminate? */
      unlock_kernel();
  
      SetPageUptodate(page);
      kunmap(page);
***************
*** 1722,1728 ****
  
    fail:
      unlock_kernel();
-     AFS_GUNLOCK();
  
      SetPageError(page);
      kunmap(page);
--- 1737,1742 ----
Index: openafs/src/afsd/afsd.c
diff -c openafs/src/afsd/afsd.c:1.41 openafs/src/afsd/afsd.c:1.42
*** openafs/src/afsd/afsd.c:1.41	Sat May  8 00:12:27 2004
--- openafs/src/afsd/afsd.c	Thu Jul  8 00:52:38 2004
***************
*** 56,62 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/afsd/afsd.c,v 1.41 2004/05/08 04:12:27 shadow Exp $");
  
  #define VFS 1
  
--- 56,62 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/afsd/afsd.c,v 1.42 2004/07/08 04:52:38 shadow Exp $");
  
  #define VFS 1
  
***************
*** 1049,1054 ****
--- 1049,1056 ----
  	}
  	if (statfsbuf.f_type == 0x52654973) {	/* REISERFS_SUPER_MAGIC */
  	    return "cannot use reiserfs as cache partition";
+ 	} else if  (statfsbuf.f_type == 0x58465342) { /* XFS_SUPER_MAGIC */
+ 	    return "cannot use xfs as cache partition";
  	}
      }
  #endif
***************
*** 1638,1644 ****
      sprintf(fullpn_VFile, "%s/", cacheBaseDir);
      vFilePtr = fullpn_VFile + strlen(fullpn_VFile);
  
!     if ((fsTypeMsg = CheckCacheBaseDir(cacheBaseDir))) {
  	printf("%s: WARNING: Cache dir check failed (%s)\n", rn, fsTypeMsg);
      }
  #if 0
--- 1640,1646 ----
      sprintf(fullpn_VFile, "%s/", cacheBaseDir);
      vFilePtr = fullpn_VFile + strlen(fullpn_VFile);
  
!     if  (!(cacheFlags & AFSCALL_INIT_MEMCACHE) && (fsTypeMsg = CheckCacheBaseDir(cacheBaseDir))) {
  	printf("%s: WARNING: Cache dir check failed (%s)\n", rn, fsTypeMsg);
      }
  #if 0
Index: openafs/src/auth/cellconfig.c
diff -c openafs/src/auth/cellconfig.c:1.37 openafs/src/auth/cellconfig.c:1.40
*** openafs/src/auth/cellconfig.c:1.37	Sat May 29 19:48:05 2004
--- openafs/src/auth/cellconfig.c	Thu Jul 22 05:42:40 2004
***************
*** 11,17 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/auth/cellconfig.c,v 1.37 2004/05/29 23:48:05 jaltman Exp $");
  
  #include <afs/stds.h>
  #include <afs/pthread_glock.h>
--- 11,17 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/auth/cellconfig.c,v 1.40 2004/07/22 09:42:40 jaltman Exp $");
  
  #include <afs/stds.h>
  #include <afs/pthread_glock.h>
***************
*** 204,218 ****
  static int
  afsconf_Check(register struct afsconf_dir *adir)
  {
!     char tbuffer[256];
      struct stat tstat;
      register afs_int32 code;
  
  #ifdef AFS_NT40_ENV
      /* NT client CellServDB has different file name than NT server or Unix */
      if (IsClientConfigDirectory(adir->name)) {
! 	strcompose(tbuffer, 256, adir->name, "/",
! 		   AFSDIR_CELLSERVDB_FILE_NTCLIENT, NULL);
      } else {
  	strcompose(tbuffer, 256, adir->name, "/", AFSDIR_CELLSERVDB_FILE,
  		   NULL);
--- 204,230 ----
  static int
  afsconf_Check(register struct afsconf_dir *adir)
  {
!     char tbuffer[256], *p;
      struct stat tstat;
      register afs_int32 code;
  
  #ifdef AFS_NT40_ENV
      /* NT client CellServDB has different file name than NT server or Unix */
      if (IsClientConfigDirectory(adir->name)) {
!         if ( !afssw_GetClientCellServDBDir(&p) ) {
!             strcompose(tbuffer, sizeof(tbuffer), p, "/",
!                         AFSDIR_CELLSERVDB_FILE_NTCLIENT, NULL);
!             free(p);
!         } else {
!             int len;
! 			strncpy(tbuffer, adir->name, sizeof(tbuffer));
! 			len = strlen(tbuffer);
!             if ( tbuffer[len-1] != '\\' && tbuffer[len-1] != '/' ) {
!                 strncat(tbuffer, "\\", sizeof(tbuffer));
!             }
!             strncat(tbuffer, AFSDIR_CELLSERVDB_FILE_NTCLIENT, sizeof(tbuffer));
!             tbuffer[sizeof(tbuffer)-1] = '\0';
!         }
      } else {
  	strcompose(tbuffer, 256, adir->name, "/", AFSDIR_CELLSERVDB_FILE,
  		   NULL);
***************
*** 237,243 ****
  static int
  afsconf_Touch(register struct afsconf_dir *adir)
  {
!     char tbuffer[256];
  #ifndef AFS_NT40_ENV
      struct timeval tvp[2];
  #endif
--- 249,255 ----
  static int
  afsconf_Touch(register struct afsconf_dir *adir)
  {
!     char tbuffer[256], *p;
  #ifndef AFS_NT40_ENV
      struct timeval tvp[2];
  #endif
***************
*** 248,255 ****
      /* NT client CellServDB has different file name than NT server or Unix */
  
      if (IsClientConfigDirectory(adir->name)) {
! 	strcompose(tbuffer, 256, adir->name, "/",
! 		   AFSDIR_CELLSERVDB_FILE_NTCLIENT, NULL);
      } else {
  	strcompose(tbuffer, 256, adir->name, "/", AFSDIR_CELLSERVDB_FILE,
  		   NULL);
--- 260,277 ----
      /* NT client CellServDB has different file name than NT server or Unix */
  
      if (IsClientConfigDirectory(adir->name)) {
!         if ( !afssw_GetClientCellServDBDir(&p) ) {
!             strcompose(tbuffer, sizeof(tbuffer), p, "/",
!                         AFSDIR_CELLSERVDB_FILE_NTCLIENT, NULL);
!             free(p);
!         } else {
!             int len = strlen(tbuffer);
!             if ( tbuffer[len-1] != '\\' && tbuffer[len-1] != '/' ) {
!                 strncat(tbuffer, "\\", sizeof(tbuffer));
!             }
!             strncat(tbuffer, AFSDIR_CELLSERVDB_FILE_NTCLIENT, sizeof(tbuffer));
!             tbuffer[sizeof(tbuffer)-1] = '\0';
!         }
      } else {
  	strcompose(tbuffer, 256, adir->name, "/", AFSDIR_CELLSERVDB_FILE,
  		   NULL);
***************
*** 412,419 ****
       */
      if (IsClientConfigDirectory(adir->name)) {
  	/* NT client config dir */
! 	strcompose(tbuffer, 256, adir->name, "/",
! 		   AFSDIR_CELLSERVDB_FILE_NTCLIENT, NULL);
      } else {
  	/* NT server config dir */
  	strcompose(tbuffer, 256, adir->name, "/", AFSDIR_CELLSERVDB_FILE,
--- 434,454 ----
       */
      if (IsClientConfigDirectory(adir->name)) {
  	/* NT client config dir */
!         char * p;
!         if ( !afssw_GetClientCellServDBDir(&p) ) {
!             strcompose(tbuffer, sizeof(tbuffer), p, "/",
!                         AFSDIR_CELLSERVDB_FILE_NTCLIENT, NULL);
!             free(p);
!         } else {
!             int len;
! 			strncpy(tbuffer, adir->name, sizeof(tbuffer));
! 			len = strlen(tbuffer);
!             if ( tbuffer[len-1] != '\\' && tbuffer[len-1] != '/' ) {
!                 strncat(tbuffer, "\\", sizeof(tbuffer));
!             }
!             strncat(tbuffer, AFSDIR_CELLSERVDB_FILE_NTCLIENT, sizeof(tbuffer));
!             tbuffer[sizeof(tbuffer)-1] = '\0';
!         }
      } else {
  	/* NT server config dir */
  	strcompose(tbuffer, 256, adir->name, "/", AFSDIR_CELLSERVDB_FILE,
Index: openafs/src/auth/ktc_nt.c
diff -c openafs/src/auth/ktc_nt.c:1.16 openafs/src/auth/ktc_nt.c:1.17
*** openafs/src/auth/ktc_nt.c:1.16	Sat Apr  3 21:35:47 2004
--- openafs/src/auth/ktc_nt.c	Thu Jul  8 09:24:00 2004
***************
*** 13,19 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/auth/ktc_nt.c,v 1.16 2004/04/04 02:35:47 jaltman Exp $");
  
  #include <afs/stds.h>
  #include <stdio.h>
--- 13,19 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/auth/ktc_nt.c,v 1.17 2004/07/08 13:24:00 jaltman Exp $");
  
  #include <afs/stds.h>
  #include <stdio.h>
***************
*** 116,124 ****
  	if (!strcmpi(encrypt, "OFF"))
  	    encryptionOff = TRUE;
  
!     /* Protocol sequence is named pipe by default */
      if (!GetEnvironmentVariable("AFS_RPC_PROTSEQ", protseq, sizeof(protseq)))
! 	strcpy(protseq, "ncacn_np");
  
      /* Server name */
      getservername(&serverNamep, sizeof(serverName));
--- 116,124 ----
  	if (!strcmpi(encrypt, "OFF"))
  	    encryptionOff = TRUE;
  
!     /* Protocol sequence is local by default */
      if (!GetEnvironmentVariable("AFS_RPC_PROTSEQ", protseq, sizeof(protseq)))
! 	strcpy(protseq, "ncalrpc");
  
      /* Server name */
      getservername(&serverNamep, sizeof(serverName));
***************
*** 189,197 ****
  	if (!strcmpi(encrypt, "OFF"))
  	    encryptionOff = TRUE;
  
!     /* Protocol sequence is named pipe by default */
      if (!GetEnvironmentVariable("AFS_RPC_PROTSEQ", protseq, sizeof(protseq)))
! 	strcpy(protseq, "ncacn_np");
  
      /* Server name */
      getservername(&serverNamep, sizeof(serverName));
--- 189,197 ----
  	if (!strcmpi(encrypt, "OFF"))
  	    encryptionOff = TRUE;
  
!     /* Protocol sequence is local by default */
      if (!GetEnvironmentVariable("AFS_RPC_PROTSEQ", protseq, sizeof(protseq)))
! 	strcpy(protseq, "ncalrpc");
  
      /* Server name */
      getservername(&serverNamep, sizeof(serverName));
Index: openafs/src/bucoord/NTMakefile
diff -c openafs/src/bucoord/NTMakefile:1.9 openafs/src/bucoord/NTMakefile:1.10
*** openafs/src/bucoord/NTMakefile:1.9	Sat May 29 19:48:07 2004
--- openafs/src/bucoord/NTMakefile	Thu Jul 15 23:56:51 2004
***************
*** 6,11 ****
--- 6,12 ----
  # directory or online at http://www.openafs.org/dl/license10.html
  
  RELDIR=bucoord
+ AFSDEV_AUXCDEFINES = $(AFSDEV_AUXCDEFINES) -DNOGDI -DWIN32_LEAN_AND_MEAN
  !INCLUDE ..\config\NTMakefile.$(SYS_NAME)
  !INCLUDE ..\config\NTMakefile.version
  
Index: openafs/src/budb/NTMakefile
diff -c openafs/src/budb/NTMakefile:1.7 openafs/src/budb/NTMakefile:1.8
*** openafs/src/budb/NTMakefile:1.7	Sat May 29 19:48:08 2004
--- openafs/src/budb/NTMakefile	Thu Jul 15 23:56:51 2004
***************
*** 6,11 ****
--- 6,12 ----
  # directory or online at http://www.openafs.org/dl/license10.html
  
  RELDIR=budb
+ AFSDEV_AUXCDEFINES = $(AFSDEV_AUXCDEFINES) -DNOGDI -DWIN32_LEAN_AND_MEAN
  !INCLUDE ..\config\NTMakefile.$(SYS_NAME)
  !INCLUDE ..\config\NTMakefile.version
  
Index: openafs/src/butc/Makefile.in
diff -c openafs/src/butc/Makefile.in:1.10 openafs/src/butc/Makefile.in:1.11
*** openafs/src/butc/Makefile.in:1.10	Fri Oct 24 02:26:07 2003
--- openafs/src/butc/Makefile.in	Tue Jul 13 01:52:46 2004
***************
*** 59,65 ****
  
  butc: ${SOBJS} ${LIBS} ${INCLS} ${HACKS}
  	@case ${SYS_NAME} in \
! 	  rs_aix4*) ${CC} ${CFLAGS} ${SOBJS} ${LIBS} ${XLIBS} /usr/lib/libc_r.a -o butc;; \
  	  *)        ${CC} ${CFLAGS} ${SOBJS} ${LIBS} ${XLIBS} -o butc;; \
  	esac
  
--- 59,65 ----
  
  butc: ${SOBJS} ${LIBS} ${INCLS} ${HACKS}
  	@case ${SYS_NAME} in \
! 	  rs_aix*) ${CC} ${CFLAGS} ${SOBJS} ${LIBS} ${XLIBS} /usr/lib/libc_r.a -o butc;; \
  	  *)        ${CC} ${CFLAGS} ${SOBJS} ${LIBS} ${XLIBS} -o butc;; \
  	esac
  
***************
*** 84,90 ****
  
  install:  
  	@case ${SYS_NAME} in \
! 	alpha_dux*|sgi_*|sun4x_*|sunx86_*|rs_aix4*|*linux*|hp_ux*) \
  		echo "Don't install butc for ${SYS_NAME} (will install from tbutc)" ;; \
  	*_darwin_[1-6][0-9]) \
  		echo ${INSTALL} butc ${DEST}/etc/butc ; \
--- 84,90 ----
  
  install:  
  	@case ${SYS_NAME} in \
! 	alpha_dux*|sgi_*|sun4x_*|sunx86_*|rs_aix*|*linux*|hp_ux*) \
  		echo "Don't install butc for ${SYS_NAME} (will install from tbutc)" ;; \
  	*_darwin_[1-6][0-9]) \
  		echo ${INSTALL} butc ${DEST}/etc/butc ; \
***************
*** 100,106 ****
  include ../config/Makefile.version
  dest:  
  	@case ${SYS_NAME} in \
! 	alpha_dux*|sgi_*|sun4x_*|sunx86_*|rs_aix4*|*linux*|hp_ux*) \
  		echo "Don't install butc for ${SYS_NAME} (will install from tbutc)" ;; \
  	*_darwin_[1-6][0-9]) \
  		echo ${INSTALL} butc ${DESTDIR}${sbindir}/butc ; \
--- 100,106 ----
  include ../config/Makefile.version
  dest:  
  	@case ${SYS_NAME} in \
! 	alpha_dux*|sgi_*|sun4x_*|sunx86_*|rs_aix*|*linux*|hp_ux*) \
  		echo "Don't install butc for ${SYS_NAME} (will install from tbutc)" ;; \
  	*_darwin_[1-6][0-9]) \
  		echo ${INSTALL} butc ${DESTDIR}${sbindir}/butc ; \
Index: openafs/src/butc/NTMakefile
diff -c openafs/src/butc/NTMakefile:1.6 openafs/src/butc/NTMakefile:1.7
*** openafs/src/butc/NTMakefile:1.6	Sat May 29 19:48:09 2004
--- openafs/src/butc/NTMakefile	Thu Jul 15 23:56:52 2004
***************
*** 6,11 ****
--- 6,12 ----
  # directory or online at http://www.openafs.org/dl/license10.html
  
  RELDIR=butc
+ AFSDEV_AUXCDEFINES = $(AFSDEV_AUXCDEFINES) -DNOGDI -DWIN32_LEAN_AND_MEAN
  !INCLUDE ..\config\NTMakefile.$(SYS_NAME)
  !INCLUDE ..\config\NTMakefile.version
  
Index: openafs/src/butc/butc_xbsa.c
diff -c openafs/src/butc/butc_xbsa.c:1.6 openafs/src/butc/butc_xbsa.c:1.8
*** openafs/src/butc/butc_xbsa.c:1.6	Sun Dec  7 17:49:21 2003
--- openafs/src/butc/butc_xbsa.c	Wed Jul 14 00:46:48 2004
***************
*** 13,19 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/butc/butc_xbsa.c,v 1.6 2003/12/07 22:49:21 jaltman Exp $");
  
  #include <sys/types.h>
  #include <afs/stds.h>
--- 13,19 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/butc/butc_xbsa.c,v 1.8 2004/07/14 04:46:48 shadow Exp $");
  
  #include <sys/types.h>
  #include <afs/stds.h>
***************
*** 24,29 ****
--- 24,30 ----
  #include <errno.h>
  #include "butc_xbsa.h"
  #include <afs/butx.h>
+ #include <afs/bubasics.h>
  
  #include "error_macros.h"
  
***************
*** 258,265 ****
  {
      char envStrs[XBSA_NUM_ENV_STRS][BSA_MAX_DESC];
      char *envP[XBSA_NUM_ENV_STRS + 1];
!     char *ADSMMaxObject = "MAXOBJ=";
!     char *ADSMServer = "DSMSRVR=";
      char *tempStrPtr;
      int i;
      int rc;
--- 259,266 ----
  {
      char envStrs[XBSA_NUM_ENV_STRS][BSA_MAX_DESC];
      char *envP[XBSA_NUM_ENV_STRS + 1];
!     char *ADSMMaxObject = "TSMMAXOBJ=";
!     char *ADSMServer = "TSMSRVR=";
      char *tempStrPtr;
      int i;
      int rc;
***************
*** 305,310 ****
--- 306,312 ----
  	    tempStrPtr = tempStrPtr + strlen(ADSMServer);
  	    strcat(tempStrPtr, serverName);
  	    envP[1] = NULL;
+ 	    envP[0] = NULL;     /* Hack for TSM V5 */
  	} else {
  	    envP[0] = NULL;
  	    ELog(0, "xbsa_Initialize: The serverName was not specified\n");
***************
*** 376,381 ****
--- 378,385 ----
  	return (BUTX_GETENVFAIL);
      }
  
+  info->maxObjects = 255; /* Hack for ADSM V5: unclear what this actually means... */
+ 
      switch (XBSA_GET_SERVER_TYPE(info->serverType)) {
      case XBSA_SERVER_TYPE_ADSM:
  	for (i = 0; i < XBSA_NUM_ENV_STRS; i++) {
Index: openafs/src/butc/tcprocs.c
diff -c openafs/src/butc/tcprocs.c:1.11 openafs/src/butc/tcprocs.c:1.12
*** openafs/src/butc/tcprocs.c:1.11	Sun Dec  7 17:49:23 2003
--- openafs/src/butc/tcprocs.c	Tue Jul 13 01:52:46 2004
***************
*** 13,19 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/butc/tcprocs.c,v 1.11 2003/12/07 22:49:23 jaltman Exp $");
  
  #include <sys/types.h>
  #include <errno.h>
--- 13,19 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/butc/tcprocs.c,v 1.12 2004/07/13 05:52:46 shadow Exp $");
  
  #include <sys/types.h>
  #include <errno.h>
***************
*** 51,56 ****
--- 51,70 ----
      return 1;
  }
  
+ /* XBSA Global Parameters */
+ afs_int32 xbsaType;
+ #ifdef xbsa
+ struct butx_transactionInfo butxInfo;
+ 
+ #define rpc_c_protect_level_default 0
+ afs_uint32 dumpRestAuthnLevel = rpc_c_protect_level_default;
+ char *xbsaObjectOwner;
+ char *appObjectOwner;
+ char *adsmServerName;
+ char *xbsaSecToken;
+ char *xbsalGName;
+ #endif
+ 
  /* -------------------------
   * butc - interface routines - alphabetic order
   * -------------------------
Index: openafs/src/config/NTMakefile.i386_nt40
diff -c openafs/src/config/NTMakefile.i386_nt40:1.42 openafs/src/config/NTMakefile.i386_nt40:1.44
*** openafs/src/config/NTMakefile.i386_nt40:1.42	Thu Jun 24 00:16:46 2004
--- openafs/src/config/NTMakefile.i386_nt40	Sun Jul 25 17:47:20 2004
***************
*** 79,85 ****
  #define used in WinNT/2000 installation and program version display
  AFSPRODUCT_VER_MAJOR=1
  AFSPRODUCT_VER_MINOR=3
! AFSPRODUCT_VER_PATCH=6500
  AFSPRODUCT_VER_BUILD=0
  AFSPRODUCT_VERSION=$(AFSPRODUCT_VER_MAJOR).$(AFSPRODUCT_VER_MINOR).$(AFSPRODUCT_VER_PATCH)
  AFSPRODUCT_FILE_VERSION=$(AFSPRODUCT_VER_MAJOR),$(AFSPRODUCT_VER_MINOR),$(AFSPRODUCT_VER_PATCH),$(AFSPRODUCT_VER_BUILD)
--- 79,85 ----
  #define used in WinNT/2000 installation and program version display
  AFSPRODUCT_VER_MAJOR=1
  AFSPRODUCT_VER_MINOR=3
! AFSPRODUCT_VER_PATCH=6600
  AFSPRODUCT_VER_BUILD=0
  AFSPRODUCT_VERSION=$(AFSPRODUCT_VER_MAJOR).$(AFSPRODUCT_VER_MINOR).$(AFSPRODUCT_VER_PATCH)
  AFSPRODUCT_FILE_VERSION=$(AFSPRODUCT_VER_MAJOR),$(AFSPRODUCT_VER_MINOR),$(AFSPRODUCT_VER_PATCH),$(AFSPRODUCT_VER_BUILD)
Index: openafs/src/config/afs_args.h
diff -c openafs/src/config/afs_args.h:1.12 openafs/src/config/afs_args.h:1.13
*** openafs/src/config/afs_args.h:1.12	Tue May 11 16:36:18 2004
--- openafs/src/config/afs_args.h	Thu Jul  8 01:35:27 2004
***************
*** 179,184 ****
--- 179,185 ----
  #define PROC_FSDIRNAME "openafs"
  #define PROC_SYSCALL_NAME "afs_ioctl"
  #define PROC_SYSCALL_FNAME "/proc/fs/openafs/afs_ioctl"
+ #define PROC_SYSCALL_ARLA_FNAME "/proc/fs/nnpfs/afs_ioctl"
  #define VIOC_SYSCALL_TYPE 'C' 
  #define VIOC_SYSCALL _IOW(VIOC_SYSCALL_TYPE,1,void *)
   
Index: openafs/src/libafsrpc/NTMakefile
diff -c openafs/src/libafsrpc/NTMakefile:1.8 openafs/src/libafsrpc/NTMakefile:1.9
*** openafs/src/libafsrpc/NTMakefile:1.8	Fri Apr  9 02:48:22 2004
--- openafs/src/libafsrpc/NTMakefile	Thu Jul 15 23:56:53 2004
***************
*** 6,11 ****
--- 6,12 ----
  # directory or online at http://www.openafs.org/dl/license10.html
  
  RELDIR=libafsrpc
+ AFSDEV_AUXCDEFINES = $(AFSDEV_AUXCDEFINES) -DNOGDI -DWIN32_LEAN_AND_MEAN
  !include ..\config\NTMakefile.$(SYS_NAME)
  !include ..\config\NTMakefile.version
  
Index: openafs/src/lwp/Makefile.in
diff -c openafs/src/lwp/Makefile.in:1.26 openafs/src/lwp/Makefile.in:1.27
*** openafs/src/lwp/Makefile.in:1.26	Thu Jun 24 13:38:32 2004
--- openafs/src/lwp/Makefile.in	Thu Jul  8 01:19:47 2004
***************
*** 35,41 ****
  	@case "$(SYS_NAME)" in \
  	pmax_he1) \
  		$(CCOBJ) ${LWP_DBG} ${LWP_OPTMZ} -c -I${TOP_INCDIR} process.s;; \
! 	sun4c_51 | sun4c_52 | sun4m_51 | sun4m_52 | sun4c_53 | sun4m_53  | sun4_53 | sun4_52 | sun4_54 | sun4c_54 | sun4m_54 | sun4x_5?) \
  		/usr/ccs/lib/cpp -P -I${TOP_INCDIR} ${srcdir}/process.s process.ss; \
  		${AS} process.ss -o process.o; \
  			$(RM) process.ss ;; \
--- 35,41 ----
  	@case "$(SYS_NAME)" in \
  	pmax_he1) \
  		$(CCOBJ) ${LWP_DBG} ${LWP_OPTMZ} -c -I${TOP_INCDIR} process.s;; \
! 	sun4c_51 | sun4c_52 | sun4m_51 | sun4m_52 | sun4c_53 | sun4m_53  | sun4_53 | sun4_52 | sun4_54 | sun4c_54 | sun4m_54 | sun4x_5* ) \
  		/usr/ccs/lib/cpp -P -I${TOP_INCDIR} ${srcdir}/process.s process.ss; \
  		${AS} process.ss -o process.o; \
  			$(RM) process.ss ;; \
Index: openafs/src/lwp/fasttime.c
diff -c openafs/src/lwp/fasttime.c:1.8 openafs/src/lwp/fasttime.c:1.9
*** openafs/src/lwp/fasttime.c:1.8	Sun Dec  7 17:49:33 2003
--- openafs/src/lwp/fasttime.c	Mon Jul 19 11:25:16 2004
***************
*** 27,33 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/lwp/fasttime.c,v 1.8 2003/12/07 22:49:33 jaltman Exp $");
  
  #include <stdio.h>
  #include <sys/types.h>
--- 27,33 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/lwp/fasttime.c,v 1.9 2004/07/19 15:25:16 shadow Exp $");
  
  #include <stdio.h>
  #include <sys/types.h>
***************
*** 118,123 ****
--- 118,129 ----
      return FT_GetTimeOfDay(tv, tz);
  }
  
+ #ifdef AFS_PTHREAD_ENV
+ unsigned int FT_ApproxTime(void)
+ {
+     return time(0);
+ }
+ #else
  unsigned int
  FT_ApproxTime(void)
  {
***************
*** 126,128 ****
--- 132,135 ----
      }
      return FT_LastTime.tv_sec;
  }
+ #endif
Index: openafs/src/lwp/iomgr.c
diff -c openafs/src/lwp/iomgr.c:1.12 openafs/src/lwp/iomgr.c:1.13
*** openafs/src/lwp/iomgr.c:1.12	Sat Nov 29 17:08:14 2003
--- openafs/src/lwp/iomgr.c	Thu Jul  8 01:16:57 2004
***************
*** 21,30 ****
  	IO Manager routines & server process for VICE server.
  */
  
  #include <afsconfig.h>
  #include <afs/param.h>
  
! RCSID("$Header: /cvs/openafs/src/lwp/iomgr.c,v 1.12 2003/11/29 22:08:14 jaltman Exp $");
  
  #include <stdio.h>
  #include <stdlib.h>
--- 21,42 ----
  	IO Manager routines & server process for VICE server.
  */
  
+ /* This controls the size of an fd_set; it must be defined early before
+  * the system headers define that type and the macros that operate on it.
+  * Its value should be as large as the maximum file descriptor limit we
+  * are likely to run into on any platform.  Right now, that is 65536
+  * which is the default hard fd limit on Solaris 9 */
+ /* We don't do this on Windows because on that platform there is code
+  * which allocates fd_set's on the stack (IOMGR_Sleep on Win9x, and
+  * FDSetAnd on WinNT) */
+ #ifndef _WIN32
+ #define FD_SETSIZE 65536
+ #endif
+ 
  #include <afsconfig.h>
  #include <afs/param.h>
  
! RCSID("$Header: /cvs/openafs/src/lwp/iomgr.c,v 1.13 2004/07/08 05:16:57 shadow Exp $");
  
  #include <stdio.h>
  #include <stdlib.h>
***************
*** 177,183 ****
  
  /* fd_set pool managment. 
   * Use the pool instead of creating fd_set's on the stack. fd_set's can be
!  * 2K in size, so making three could put 6K in the limited space of an LWP
   * stack.
   */
  struct IOMGR_fd_set {
--- 189,195 ----
  
  /* fd_set pool managment. 
   * Use the pool instead of creating fd_set's on the stack. fd_set's can be
!  * 8K in size, so making three could put 24K in the limited space of an LWP
   * stack.
   */
  struct IOMGR_fd_set {
Index: openafs/src/lwp/lwp.c
diff -c openafs/src/lwp/lwp.c:1.25 openafs/src/lwp/lwp.c:1.26
*** openafs/src/lwp/lwp.c:1.25	Wed Sep 24 15:02:05 2003
--- openafs/src/lwp/lwp.c	Thu Jul  8 01:11:34 2004
***************
*** 17,23 ****
  #include <afsconfig.h>
  #include <afs/param.h>
  
! RCSID("$Header: /cvs/openafs/src/lwp/lwp.c,v 1.25 2003/09/24 19:02:05 shadow Exp $");
  
  #include <stdlib.h>
  #include <stdio.h>
--- 17,23 ----
  #include <afsconfig.h>
  #include <afs/param.h>
  
! RCSID("$Header: /cvs/openafs/src/lwp/lwp.c,v 1.26 2004/07/08 05:11:34 shadow Exp $");
  
  #include <stdlib.h>
  #include <stdio.h>
***************
*** 116,122 ****
  struct QUEUE {
      PROCESS head;
      int count;
! } runnable[MAX_PRIORITIES], blocked;
  /* Invariant for runnable queues: The head of each queue points to the currently running process if it is in that queue, or it points to the next process in that queue that should run. */
  
  /* Offset of stack field within pcb -- used by stack checking stuff */
--- 116,122 ----
  struct QUEUE {
      PROCESS head;
      int count;
! } runnable[MAX_PRIORITIES], blocked, qwaiting;
  /* Invariant for runnable queues: The head of each queue points to the currently running process if it is in that queue, or it points to the next process in that queue that should run. */
  
  /* Offset of stack field within pcb -- used by stack checking stuff */
***************
*** 237,243 ****
  {
      register PROCESS tp;
      (tp = lwp_cpptr)->status = QWAITING;
!     lwp_remove(tp, &runnable[tp->priority]);
      Set_LWP_RC();
      return LWP_SUCCESS;
  }
--- 237,243 ----
  {
      register PROCESS tp;
      (tp = lwp_cpptr)->status = QWAITING;
!     move(tp, &runnable[tp->priority], qwaiting);
      Set_LWP_RC();
      return LWP_SUCCESS;
  }
***************
*** 248,254 ****
  {
      if (pid->status == QWAITING) {
  	pid->status = READY;
! 	insert(pid, &runnable[pid->priority]);
  	return LWP_SUCCESS;
      } else
  	return LWP_ENOWAIT;
--- 248,254 ----
  {
      if (pid->status == QWAITING) {
  	pid->status = READY;
! 	move(pid, qwaiting, &runnable[pid->priority]);
  	return LWP_SUCCESS;
      } else
  	return LWP_ENOWAIT;
***************
*** 556,561 ****
--- 556,564 ----
  	    for_all_elts(x, blocked, {
  			 Dump_One_Process(x);}
  	)
+ 	    for_all_elts(x, qwaiting, {
+ 			 Dump_One_Process(x);}
+ 	)
      } else
  	printf("***LWP: LWP support not initialized\n");
      return 0;
***************
*** 596,601 ****
--- 599,606 ----
      }
      blocked.head = NULL;
      blocked.count = 0;
+     qwaiting.head = NULL;
+     qwaiting.count = 0;
      lwp_init = (struct lwp_ctl *)malloc(sizeof(struct lwp_ctl));
      temp = (PROCESS) malloc(sizeof(struct lwp_pcb));
      if (lwp_init == NULL || temp == NULL)
***************
*** 655,660 ****
--- 660,668 ----
  	for_all_elts(cur, blocked, {
  		     Free_PCB(cur);}
      )
+ 	for_all_elts(cur, qwaiting, {
+ 		     Free_PCB(cur);}
+     )
  	free(lwp_init);
      lwp_init = NULL;
      return LWP_SUCCESS;
***************
*** 779,785 ****
      lwp_remove(pid,
  	       (pid->blockflag || pid->status == WAITING
  		|| pid->status ==
! 		DESTROYED ? &blocked : &runnable[pid->priority]));
      LWPANCHOR.processcnt--;
      return 0;
  }
--- 787,795 ----
      lwp_remove(pid,
  	       (pid->blockflag || pid->status == WAITING
  		|| pid->status ==
! 		DESTROYED ? &blocked : 
! 		(pid->status == QWAITING) ? &qwaiting :
! 		&runnable[pid->priority]));
      LWPANCHOR.processcnt--;
      return 0;
  }
***************
*** 806,811 ****
--- 816,824 ----
      case DESTROYED:
  	printf("DESTROYED");
  	break;
+     case QWAITING:
+ 	printf("QWAITING");
+ 	break;
      default:
  	printf("unknown");
      }
***************
*** 865,871 ****
  		     printf(" \"%s\"", p->name);
  		     }
  	)
! 	    puts("]");
      }
  #endif
  
--- 878,890 ----
  		     printf(" \"%s\"", p->name);
  		     }
  	)
! 	puts("]");
! 	printf("[Qwaiting (%d):", qwaiting.count);
! 	for_all_elts(p, qwaiting, {
! 		     printf(" \"%s\"", p->name);
! 		     }
! 	)
! 	puts("]");
      }
  #endif
  
Index: openafs/src/rx/rx_globals.c
diff -c openafs/src/rx/rx_globals.c:1.6 openafs/src/rx/rx_globals.c:1.8
*** openafs/src/rx/rx_globals.c:1.6	Tue Jul 15 19:16:09 2003
--- openafs/src/rx/rx_globals.c	Mon Jul 19 10:39:42 2004
***************
*** 9,14 ****
--- 9,23 ----
  
  /* RX:  Globals for internal use, basically */
  
+ /* This controls the size of an fd_set; it must be defined early before
+  * the system headers define that type and the macros that operate on it.
+  * Its value should be as large as the maximum file descriptor limit we
+  * are likely to run into on any platform.  Right now, that is 65536
+  * which is the default hard fd limit on Solaris 9 */
+ #ifndef _WIN32
+ #define FD_SETSIZE 65536
+ #endif
+ 
  #include <afsconfig.h>
  #ifdef KERNEL
  #include "afs/param.h"
***************
*** 17,23 ****
  #endif
  
  RCSID
!     ("$Header: /cvs/openafs/src/rx/rx_globals.c,v 1.6 2003/07/15 23:16:09 shadow Exp $");
  
  /* Enable data initialization when the header file is included */
  #define INIT(stuff) = stuff
--- 26,32 ----
  #endif
  
  RCSID
!     ("$Header: /cvs/openafs/src/rx/rx_globals.c,v 1.8 2004/07/19 14:39:42 jaltman Exp $");
  
  /* Enable data initialization when the header file is included */
  #define INIT(stuff) = stuff
Index: openafs/src/rx/rx_lwp.c
diff -c openafs/src/rx/rx_lwp.c:1.15 openafs/src/rx/rx_lwp.c:1.17
*** openafs/src/rx/rx_lwp.c:1.15	Sat Nov 29 17:08:16 2003
--- openafs/src/rx/rx_lwp.c	Mon Jul 19 10:39:42 2004
***************
*** 9,19 ****
  
  /* rx_user.c contains routines specific to the user space UNIX implementation of rx */
  
  #include <afsconfig.h>
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/rx/rx_lwp.c,v 1.15 2003/11/29 22:08:16 jaltman Exp $");
  
  # include <sys/types.h>		/* fd_set on older platforms */
  # include <errno.h>
--- 9,28 ----
  
  /* rx_user.c contains routines specific to the user space UNIX implementation of rx */
  
+ /* This controls the size of an fd_set; it must be defined early before
+  * the system headers define that type and the macros that operate on it.
+  * Its value should be as large as the maximum file descriptor limit we
+  * are likely to run into on any platform.  Right now, that is 65536
+  * which is the default hard fd limit on Solaris 9 */
+ #ifndef _WIN32
+ #define FD_SETSIZE 65536
+ #endif
+ 
  #include <afsconfig.h>
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/rx/rx_lwp.c,v 1.17 2004/07/19 14:39:42 jaltman Exp $");
  
  # include <sys/types.h>		/* fd_set on older platforms */
  # include <errno.h>
Index: openafs/src/rx/SOLARIS/rx_knet.c
diff -c openafs/src/rx/SOLARIS/rx_knet.c:1.17 openafs/src/rx/SOLARIS/rx_knet.c:1.18
*** openafs/src/rx/SOLARIS/rx_knet.c:1.17	Thu Jun 24 13:38:34 2004
--- openafs/src/rx/SOLARIS/rx_knet.c	Thu Jul  8 01:23:53 2004
***************
*** 11,17 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/rx/SOLARIS/rx_knet.c,v 1.17 2004/06/24 17:38:34 shadow Exp $");
  
  #ifdef AFS_SUN5_ENV
  #include "rx/rx_kcommon.h"
--- 11,17 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/rx/SOLARIS/rx_knet.c,v 1.18 2004/07/08 05:23:53 shadow Exp $");
  
  #ifdef AFS_SUN5_ENV
  #include "rx/rx_kcommon.h"
***************
*** 341,354 ****
  	afs_osi_Sleep(&rxk_ListenerPid);
      }
  
! #ifdef AFS_SUN510_ENV
      vp = SOTOV(so);
      VOP_CLOSE(vp, FREAD|FWRITE, 1, (offset_t)0, CRED());
      VN_RELE(vp);
! #else
!     sockfs_sounbind(so, 0);
!     sockfs_sockfree(so);
! #endif
      return 0;
  }
  
--- 341,351 ----
  	afs_osi_Sleep(&rxk_ListenerPid);
      }
  
!     /* Was sockfs_sounbind(so, 0); sockfs_sockfree(so); That's wrong */
      vp = SOTOV(so);
      VOP_CLOSE(vp, FREAD|FWRITE, 1, (offset_t)0, CRED());
      VN_RELE(vp);
! 
      return 0;
  }
  
Index: openafs/src/rx/test/NTMakefile
diff -c openafs/src/rx/test/NTMakefile:1.4 openafs/src/rx/test/NTMakefile:1.5
*** openafs/src/rx/test/NTMakefile:1.4	Fri Nov 21 03:01:17 2003
--- openafs/src/rx/test/NTMakefile	Thu Jul 15 23:56:54 2004
***************
*** 5,11 ****
  # License.  For details, see the LICENSE file in the top-level source
  # directory or online at http://www.openafs.org/dl/license10.html
  
! AFSDEV_AUXCDEFINES = -DRXDEBUG
  
  RELDIR=rx\test
  !INCLUDE ..\..\config\NTMakefile.$(SYS_NAME)
--- 5,11 ----
  # License.  For details, see the LICENSE file in the top-level source
  # directory or online at http://www.openafs.org/dl/license10.html
  
! AFSDEV_AUXCDEFINES = -DRXDEBUG -DAFS_PTHREAD_ENV
  
  RELDIR=rx\test
  !INCLUDE ..\..\config\NTMakefile.$(SYS_NAME)
***************
*** 20,35 ****
  
  RXTESTOBJS = $(OUT)\testclient.obj $(OUT)\testserver.obj
  
- 
  tests: $(OUT)\testclient.exe $(OUT)\testserver.exe $(OUT)\tableGen.exe $(OUT)\generator.exe
  
! testclient.exe: $(OUT)\testclient.obj $(LIBS)
  	$(EXECONLINK)
  
! testserver.exe: $(OUT)\testserver.obj $(LIBS)
  	$(EXECONLINK)
  
  $(RXTESTOBJS): ..\rx_clock.h ..\rx_queue.h ..\rx_event.h ..\rx.h
  
  mkdir:
  	
--- 20,46 ----
  
  RXTESTOBJS = $(OUT)\testclient.obj $(OUT)\testserver.obj
  
  tests: $(OUT)\testclient.exe $(OUT)\testserver.exe $(OUT)\tableGen.exe $(OUT)\generator.exe
  
! $(OUT)\testclient.exe: $(OUT)\testclient.obj $(LIBS)
! 	$(EXECONLINK)
! 
! $(OUT)\testserver.exe: $(OUT)\testserver.obj $(LIBS)
  	$(EXECONLINK)
  
! $(OUT)\tableGen.exe: $(OUT)\tableGen.obj $(LIBS)
! 	$(EXECONLINK)
! 
! $(OUT)\generator.exe: $(OUT)\generator.obj $(LIBS)
  	$(EXECONLINK)
  
  $(RXTESTOBJS): ..\rx_clock.h ..\rx_queue.h ..\rx_event.h ..\rx.h
  
  mkdir:
  	
+ install: tests
+ 
+ install9x: tests
+ 
+ clean::
+     $(DEL) $(TESTS)
Index: openafs/src/rxkad/rxkad.p.h
diff -c openafs/src/rxkad/rxkad.p.h:1.10 openafs/src/rxkad/rxkad.p.h:1.11
*** openafs/src/rxkad/rxkad.p.h:1.10	Sat Apr  3 02:59:53 2004
--- openafs/src/rxkad/rxkad.p.h	Sun Jul 11 17:23:09 2004
***************
*** 22,29 ****
  #define KTC_TIME_UNCERTAINTY (15*60)	/* max skew bet. machines' clocks */
  
  #define MAXRANDOMNAMELEN 16	/* length of random generated 
! 				 * usernames used by afslog for high 
! 				 * security must be < MAXKTCNAMELEN */
  #define LOGON_OPTION_INTEGRATED 1
  #define LOGON_OPTION_HIGHSECURITY 2
  
--- 22,31 ----
  #define KTC_TIME_UNCERTAINTY (15*60)	/* max skew bet. machines' clocks */
  
  #define MAXRANDOMNAMELEN 16	/* length of random generated 
!                              * usernames used by afslog for high 
!                              * security must be < MAXKTCNAMELEN && < MAXSMBNAMELEN */
! #define MAXSMBNAMELEN    256 /* max length of an SMB name */
! 
  #define LOGON_OPTION_INTEGRATED 1
  #define LOGON_OPTION_HIGHSECURITY 2
  
***************
*** 56,62 ****
      char instance[MAXKTCNAMELEN];
      char cell[MAXKTCREALMLEN];
  #ifdef AFS_NT40_ENV
!     char smbname[MAXRANDOMNAMELEN];
  #endif
  };
  
--- 58,64 ----
      char instance[MAXKTCNAMELEN];
      char cell[MAXKTCREALMLEN];
  #ifdef AFS_NT40_ENV
!     char smbname[MAXSMBNAMELEN];
  #endif
  };
  
Index: openafs/src/sys/afssyscalls.c
diff -c openafs/src/sys/afssyscalls.c:1.9 openafs/src/sys/afssyscalls.c:1.10
*** openafs/src/sys/afssyscalls.c:1.9	Tue May 11 16:36:27 2004
--- openafs/src/sys/afssyscalls.c	Thu Jul  8 01:35:26 2004
***************
*** 11,17 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/sys/afssyscalls.c,v 1.9 2004/05/11 20:36:27 shadow Exp $");
  
  #include <signal.h>
  #include <sys/errno.h>
--- 11,17 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/sys/afssyscalls.c,v 1.10 2004/07/08 05:35:26 shadow Exp $");
  
  #include <signal.h>
  #include <sys/errno.h>
***************
*** 319,325 ****
  		     long param4, int *rval) {
    struct afsprocdata syscall_data;
    int fd = open(PROC_SYSCALL_FNAME, O_RDWR);
! 
    if(fd < 0)
      return -1;
  
--- 319,326 ----
  		     long param4, int *rval) {
    struct afsprocdata syscall_data;
    int fd = open(PROC_SYSCALL_FNAME, O_RDWR);
!   if(fd < 0)
!       fd = open(PROC_SYSCALL_ARLA_FNAME, O_RDWR);
    if(fd < 0)
      return -1;
  
Index: openafs/src/sys/pioctl_nt.c
diff -c openafs/src/sys/pioctl_nt.c:1.14 openafs/src/sys/pioctl_nt.c:1.15
*** openafs/src/sys/pioctl_nt.c:1.14	Fri Jun  4 02:00:38 2004
--- openafs/src/sys/pioctl_nt.c	Mon Jul 26 16:40:23 2004
***************
*** 11,17 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/sys/pioctl_nt.c,v 1.14 2004/06/04 06:00:38 jaltman Exp $");
  
  #include <afs/stds.h>
  #include <windows.h>
--- 11,17 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/sys/pioctl_nt.c,v 1.15 2004/07/26 20:40:23 jaltman Exp $");
  
  #include <afs/stds.h>
  #include <windows.h>
***************
*** 122,128 ****
                  if ( tbuffer[i++] == '\\' )
                      count++;
              }
!             if (tbuffer[i] == 0)
                  tbuffer[i++] = '\\';
              tbuffer[i] = 0;
              strcat(tbuffer, SMB_IOCTL_FILENAME);
--- 122,128 ----
                  if ( tbuffer[i++] == '\\' )
                      count++;
              }
!             if (fileNamep[i] == 0)
                  tbuffer[i++] = '\\';
              tbuffer[i] = 0;
              strcat(tbuffer, SMB_IOCTL_FILENAME);
***************
*** 147,153 ****
                  if (tbuffer[i] == 0)
                      tbuffer[i++] = '\\';
                  tbuffer[i] = 0;
!                 strcat(tbuffer, SMB_IOCTL_FILENAME);
              }
          }
  	}
--- 147,153 ----
                  if (tbuffer[i] == 0)
                      tbuffer[i++] = '\\';
                  tbuffer[i] = 0;
!                 strcat(tbuffer, SMB_IOCTL_FILENAME_NOSLASH);
              }
          }
  	}
***************
*** 267,276 ****
  	pathHasDrive = 0;
      }
  
!     if (*firstp == '\\' || *firstp == '/') {
! 	/* already an absolute pathname, just copy it back */
! 	strcpy(outPathp, firstp);
! 	return 0;
      }
  
      GetCurrentDirectory(sizeof(origPath), origPath);
--- 267,290 ----
  	pathHasDrive = 0;
      }
  
!     if ( firstp[0] == '\\' && firstp[1] == '\\') {
!         /* UNC path - strip off the server and sharename */
!         int i, count;
!         for ( i=2,count=2; count < 4 && firstp[i]; i++ ) {
!             if ( firstp[i] == '\\' || firstp[i] == '/' ) {
!                 count++;
!             }
!         }
!         if ( firstp[i] == 0 ) {
!             strcpy(outPathp,"\\");
!         } else {
!             strcpy(outPathp,&firstp[--i]);
!         }
!         return 0;
!     } else if (firstp[0] == '\\' || firstp[0] == '/') {
!         /* already an absolute pathname, just copy it back */
!         strcpy(outPathp, firstp);
!         return 0;
      }
  
      GetCurrentDirectory(sizeof(origPath), origPath);
Index: openafs/src/tbutc/NTMakefile
diff -c openafs/src/tbutc/NTMakefile:1.13 openafs/src/tbutc/NTMakefile:1.14
*** openafs/src/tbutc/NTMakefile:1.13	Sat May 29 19:48:14 2004
--- openafs/src/tbutc/NTMakefile	Thu Jul 15 23:56:54 2004
***************
*** 5,11 ****
  # License.  For details, see the LICENSE file in the top-level source
  # directory or online at http://www.openafs.org/dl/license10.html
  
! AFSDEV_AUXCDEFINES = -DAFS_PTHREAD_ENV -DRXDEBUG
  
  RELDIR=tbutc
  !INCLUDE ..\config\NTMakefile.$(SYS_NAME)
--- 5,11 ----
  # License.  For details, see the LICENSE file in the top-level source
  # directory or online at http://www.openafs.org/dl/license10.html
  
! AFSDEV_AUXCDEFINES = -DAFS_PTHREAD_ENV -DRXDEBUG -DNOGDI -DWIN32_LEAN_AND_MEAN
  
  RELDIR=tbutc
  !INCLUDE ..\config\NTMakefile.$(SYS_NAME)
Index: openafs/src/util/dirpath.c
diff -c openafs/src/util/dirpath.c:1.14 openafs/src/util/dirpath.c:1.15
*** openafs/src/util/dirpath.c:1.14	Tue Jul 15 19:17:16 2003
--- openafs/src/util/dirpath.c	Tue Jul 13 23:28:45 2004
***************
*** 11,17 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/util/dirpath.c,v 1.14 2003/07/15 23:17:16 shadow Exp $");
  
  #include <stddef.h>
  #include <stdlib.h>
--- 11,17 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/util/dirpath.c,v 1.15 2004/07/14 03:28:45 jaltman Exp $");
  
  #include <stddef.h>
  #include <stdlib.h>
***************
*** 135,146 ****
      FilepathNormalize(ntServerInstallDirShort);
  
      /* get the afs client configuration directory (/usr/vice/etc equivalent) */
!     status = GetWindowsDirectory(ntClientConfigDirLong, AFSDIR_PATH_MAX);
!     if (status == 0 || status > AFSDIR_PATH_MAX) {
! 	/* failed to get canonical Windows directory; use temp directory */
! 	strcpy(ntClientConfigDirLong, gettmpdir());
      } else {
! 	initStatus |= AFSDIR_CLIENT_PATHS_OK;
      }
      FilepathNormalize(ntClientConfigDirLong);
  
--- 135,153 ----
      FilepathNormalize(ntServerInstallDirShort);
  
      /* get the afs client configuration directory (/usr/vice/etc equivalent) */
!     if (afssw_GetClientInstallDir(&buf)) {
!         /* failed */
!         status = GetWindowsDirectory(ntClientConfigDirLong, AFSDIR_PATH_MAX);
!         if (status == 0 || status > AFSDIR_PATH_MAX) {
!             /* failed to get canonical Windows directory; use temp directory */
!             strcpy(ntClientConfigDirLong, gettmpdir());
!         } else {
!             initStatus |= AFSDIR_CLIENT_PATHS_OK;
!         }
      } else {
!         strcpy(ntClientConfigDirLong, buf);
!         free(buf);
!         initStatus |= AFSDIR_CLIENT_PATHS_OK;
      }
      FilepathNormalize(ntClientConfigDirLong);
  
***************
*** 187,193 ****
      /* now initialize various dir and file paths exported by dirpath module */
  
      /* server dir paths */
- 
      strcpy(dirPathArray[AFSDIR_SERVER_AFS_DIRPATH_ID], afsSrvDirPath);
  
      pathp = dirPathArray[AFSDIR_SERVER_ETC_DIRPATH_ID];
--- 194,199 ----
***************
*** 218,224 ****
      AFSDIR_SERVER_DIRPATH(pathp, AFSDIR_BIN_FILE_DIR);
  
      /* client dir path */
- 
  #ifdef AFS_NT40_ENV
      strcpy(dirPathArray[AFSDIR_CLIENT_VICE_DIRPATH_ID],
  	   "/NoUsrViceDirectoryOnWindows");
--- 224,229 ----
***************
*** 237,243 ****
  #endif /* AFS_NT40_ENV */
  
      /* server file paths */
- 
      pathp = dirPathArray[AFSDIR_SERVER_THISCELL_FILEPATH_ID];
      AFSDIR_SERVER_FILEPATH(pathp, AFSDIR_SERVER_ETC_DIR,
  			   AFSDIR_THISCELL_FILE);
--- 242,247 ----
***************
*** 363,369 ****
  
  
      /* client file paths */
- 
  #ifdef AFS_NT40_ENV
      strcpy(dirPathArray[AFSDIR_CLIENT_THISCELL_FILEPATH_ID],
  	   "/NoUsrViceEtcThisCellFileOnWindows");
--- 367,372 ----
Index: openafs/src/util/dirpath_nt.h
diff -c openafs/src/util/dirpath_nt.h:1.5 openafs/src/util/dirpath_nt.h:1.6
*** openafs/src/util/dirpath_nt.h:1.5	Thu Dec 11 20:21:06 2003
--- openafs/src/util/dirpath_nt.h	Tue Jul 13 23:28:45 2004
***************
*** 145,151 ****
--- 145,155 ----
  #define AFSDIR_FILELOG_FILE     "FileLog"
  #define AFSDIR_MIGRATE_LOGNAME  "wtlog."
  
+ #ifdef COMMENT
  #define AFSDIR_CELLSERVDB_FILE_NTCLIENT  "afsdcell.ini"
+ #else
+ #define AFSDIR_CELLSERVDB_FILE_NTCLIENT  AFSDIR_CELLSERVDB_FILE
+ #endif
  
  #define AFSDIR_NETINFO_FILE     "NetInfo"
  #define AFSDIR_NETRESTRICT_FILE "NetRestrict"
Index: openafs/src/util/errmap_nt.h
diff -c openafs/src/util/errmap_nt.h:1.4 openafs/src/util/errmap_nt.h:1.5
*** openafs/src/util/errmap_nt.h:1.4	Tue Jul 15 19:17:16 2003
--- openafs/src/util/errmap_nt.h	Thu Jul 15 23:38:37 2004
***************
*** 21,27 ****
--- 21,29 ----
  #define AFS_NT_ERRNO_BASE  100
  
  /* Overloaded codes. */
+ #ifndef EWOULDBLOCK
  #define EWOULDBLOCK        EAGAIN
+ #endif
  
  /* New codes */
  #define ELOOP              (AFS_NT_ERRNO_BASE + 1)
Index: openafs/src/venus/kdump.c
diff -c openafs/src/venus/kdump.c:1.32 openafs/src/venus/kdump.c:1.33
*** openafs/src/venus/kdump.c:1.32	Tue May 11 15:52:28 2004
--- openafs/src/venus/kdump.c	Tue Jul 13 01:49:54 2004
***************
*** 11,17 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/venus/kdump.c,v 1.32 2004/05/11 19:52:28 shadow Exp $");
  
  #include <stdio.h>
  #include <errno.h>
--- 11,17 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/venus/kdump.c,v 1.33 2004/07/13 05:49:54 shadow Exp $");
  
  #include <stdio.h>
  #include <errno.h>
***************
*** 27,32 ****
--- 27,42 ----
  #undef USE_UCONTEXT
  #endif
  
+ #ifdef AFS_LINUX26_ENV
+ /* For some reason, this doesn't get defined in linux/types.h
+    if __KERNEL_STRICT_NAMES is defined. But the definition of
+    struct inode uses it.
+ */
+ #ifndef pgoff_t
+ #define pgoff_t unsigned long
+ #endif
+ #endif
+ 
  #include <string.h>
  
  #ifdef __linux__
***************
*** 625,631 ****
--- 635,645 ----
  #include <stdlib.h>
  #include <string.h>
  
+ #ifdef AFS_LINUX26_ENV
+ #define KSYMS "/proc/kallsyms"
+ #else
  #define KSYMS "/proc/ksyms"
+ #endif
  
  /* symlist_t contains all the kernel symbols. Forcing a 64 byte array is
   * a bit wasteful, but simple.
***************
*** 689,694 ****
--- 703,715 ----
  	}
  	ksyms[nksyms].s_value = (int)strtoul(line, &p, 16);
  	p++;
+ #ifdef AFS_LINUX26_ENV
+ 	/* Linux 2.6 /proc/kallsyms has a one-char symbol type
+ 	   between address and name, so step over it and the following
+ 	   blank.
+ 	*/
+ 	p += 2;
+ #endif
  	q = strchr(p, '\t');
  	if (q)
  	    *q = '\0';
***************
*** 2779,2786 ****
--- 2800,2812 ----
  	 vep->i_atime, vep->i_mtime, vep->i_ctime, vep->i_version,
  	 vep->i_nrpages);
  #endif
+ #ifdef AFS_LINUX26_ENV
+     printf("\ti_op=0x%x, i_rdev=0x%x, i_sb=0x%x\n", vep->i_op,
+ 	   vep->i_rdev, vep->i_sb);
+ #else /* AFS_LINUX26_ENV */
      printf("\ti_op=0x%x, i_dev=0x%x, i_rdev=0x%x, i_sb=0x%x\n", vep->i_op,
  	   vep->i_dev, vep->i_rdev, vep->i_sb);
+ #endif /* AFS_LINUX26_ENV */
  #ifdef AFS_LINUX24_ENV
  #ifdef AFS_PARISC_LINUX24_ENV
      printf("\ti_sem: count=%d, wait=0x%x\n", vep->i_sem.count,
***************
*** 2793,2801 ****
--- 2819,2833 ----
      printf("\ti_sem: count=%d, waking=%d, wait=0x%x\n", vep->i_sem.count,
  	   vep->i_sem.waking, vep->i_sem.wait);
  #endif
+ #ifdef AFS_LINUX26_ENV
+     printf("\ti_hash=0x%x:0x%x, i_list=0x%x:0x%x, i_dentry=0x%x:0x%x\n",
+ 	   vep->i_hash.pprev, vep->i_hash.next, vep->i_list.prev,
+ 	   vep->i_list.next, vep->i_dentry.prev, vep->i_dentry.next);
+ #else /* AFS_LINUX26_ENV */
      printf("\ti_hash=0x%x:0x%x, i_list=0x%x:0x%x, i_dentry=0x%x:0x%x\n",
  	   vep->i_hash.prev, vep->i_hash.next, vep->i_list.prev,
  	   vep->i_list.next, vep->i_dentry.prev, vep->i_dentry.next);
+ #endif /* AFS_LINUX26_ENV */
  #endif /* AFS_LINUX22_ENV */
  }
  
***************
*** 2830,2836 ****
  #ifdef AFS_64BIT_CLIENT
  	printf
  	    ("truncPos=(0x%x, 0x%x),\n\tcallb=x%lx, cbE=%d, opens=%d, XoW=%d, ",
! 	     (int)vep->truncPos >> 32, (int)vep->truncPos & 0xffffffff,
  	     vep->callback, vep->cbExpires, vep->opens, vep->execsOrWriters);
  #else /* AFS_64BIT_CLIENT */
  	printf("truncPos=%d,\n\tcallb=x%lx, cbE=%d, opens=%d, XoW=%d, ",
--- 2862,2868 ----
  #ifdef AFS_64BIT_CLIENT
  	printf
  	    ("truncPos=(0x%x, 0x%x),\n\tcallb=x%lx, cbE=%d, opens=%d, XoW=%d, ",
! 	     (int)(vep->truncPos >> 32), (int)(vep->truncPos & 0xffffffff),
  	     vep->callback, vep->cbExpires, vep->opens, vep->execsOrWriters);
  #else /* AFS_64BIT_CLIENT */
  	printf("truncPos=%d,\n\tcallb=x%lx, cbE=%d, opens=%d, XoW=%d, ",
***************
*** 2846,2856 ****
  #ifdef AFS_64BIT_CLIENT
  	printf("\tquick[dc=%x, stamp=%x, f=%x, min=%d, len=(0x%x, 0x%x)]\n",
  	       vep->quick.dc, vep->quick.stamp, vep->quick.f,
! 	       vep->quick.minLoc, (int)vep->quick.len >> 32,
! 	       (int)vep->quick.len & 0xffffffff);
  	printf
  	    ("\tmstat[len=(0x%x, 0x%x), DV=%d.%d, Date=%d, Owner=%d, Group=%d, Mode=0%o, linkc=%d]\n",
! 	     (int)vep->m.Length >> 32, (int)vep->m.Length & 0xffffffff,
  	     vep->m.DataVersion.high, vep->m.DataVersion.low, vep->m.Date,
  	     vep->m.Owner, vep->m.Group, vep->m.Mode, vep->m.LinkCount);
  #else /* AFS_64BIT_CLIENT */
--- 2878,2888 ----
  #ifdef AFS_64BIT_CLIENT
  	printf("\tquick[dc=%x, stamp=%x, f=%x, min=%d, len=(0x%x, 0x%x)]\n",
  	       vep->quick.dc, vep->quick.stamp, vep->quick.f,
! 	       vep->quick.minLoc, (int)(vep->quick.len >> 32),
! 	       (int)(vep->quick.len & 0xffffffff));
  	printf
  	    ("\tmstat[len=(0x%x, 0x%x), DV=%d.%d, Date=%d, Owner=%d, Group=%d, Mode=0%o, linkc=%d]\n",
! 	     (int)(vep->m.Length >> 32), (int)(vep->m.Length & 0xffffffff),
  	     vep->m.DataVersion.high, vep->m.DataVersion.low, vep->m.Date,
  	     vep->m.Owner, vep->m.Group, vep->m.Mode, vep->m.LinkCount);
  #else /* AFS_64BIT_CLIENT */
Index: openafs/src/vol/fssync.c
diff -c openafs/src/vol/fssync.c:1.23 openafs/src/vol/fssync.c:1.25
*** openafs/src/vol/fssync.c:1.23	Mon Dec  8 01:09:12 2003
--- openafs/src/vol/fssync.c	Mon Jul 19 10:39:38 2004
***************
*** 21,26 ****
--- 21,27 ----
  #endif
  static int newVLDB = 1;
  
+ 
  #ifndef AFS_PTHREAD_ENV
  #define USUAL_PRIORITY (LWP_MAX_PRIORITY - 2)
  
***************
*** 35,45 ****
     fsync.c
     File server synchronization with external volume utilities.
   */
  #include <afsconfig.h>
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/vol/fssync.c,v 1.23 2003/12/08 06:09:12 shadow Exp $");
  
  #include <sys/types.h>
  #include <stdio.h>
--- 36,56 ----
     fsync.c
     File server synchronization with external volume utilities.
   */
+ 
+ /* This controls the size of an fd_set; it must be defined early before
+  * the system headers define that type and the macros that operate on it.
+  * Its value should be as large as the maximum file descriptor limit we
+  * are likely to run into on any platform.  Right now, that is 65536
+  * which is the default hard fd limit on Solaris 9 */
+ #ifndef _WIN32
+ #define FD_SETSIZE 65536
+ #endif
+ 
  #include <afsconfig.h>
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/vol/fssync.c,v 1.25 2004/07/19 14:39:38 jaltman Exp $");
  
  #include <sys/types.h>
  #include <stdio.h>
***************
*** 276,281 ****
--- 287,294 ----
      return sd;
  }
  
+ static fd_set FSYNC_readfds;
+ 
  static void
  FSYNC_sync()
  {
***************
*** 331,348 ****
      InitHandler();
      AcceptOn();
      for (;;) {
- 	fd_set readfds;
  	int maxfd;
! 	GetHandler(&readfds, &maxfd);
  	/* Note: check for >= 1 below is essential since IOMGR_select
  	 * doesn't have exactly same semantics as select.
  	 */
  #ifdef AFS_PTHREAD_ENV
! 	if (select(maxfd + 1, &readfds, NULL, NULL, NULL) >= 1)
  #else /* AFS_PTHREAD_ENV */
! 	if (IOMGR_Select(maxfd + 1, &readfds, NULL, NULL, NULL) >= 1)
  #endif /* AFS_PTHREAD_ENV */
! 	    CallHandler(&readfds);
      }
  }
  
--- 344,360 ----
      InitHandler();
      AcceptOn();
      for (;;) {
  	int maxfd;
! 	GetHandler(&FSYNC_readfds, &maxfd);
  	/* Note: check for >= 1 below is essential since IOMGR_select
  	 * doesn't have exactly same semantics as select.
  	 */
  #ifdef AFS_PTHREAD_ENV
! 	if (select(maxfd + 1, &FSYNC_readfds, NULL, NULL, NULL) >= 1)
  #else /* AFS_PTHREAD_ENV */
! 	if (IOMGR_Select(maxfd + 1, &FSYNC_readfds, NULL, NULL, NULL) >= 1)
  #endif /* AFS_PTHREAD_ENV */
! 	    CallHandler(&FSYNC_readfds);
      }
  }
  
