Index: openafs/src/WINNT/install/loopback/wmi.cpp
diff -c openafs/src/WINNT/install/loopback/wmi.cpp:1.3.2.1 openafs/src/WINNT/install/loopback/wmi.cpp:1.3.2.2
*** openafs/src/WINNT/install/loopback/wmi.cpp:1.3.2.1	Wed Aug 31 21:56:07 2005
--- openafs/src/WINNT/install/loopback/wmi.cpp	Tue Sep 19 01:50:01 2006
***************
*** 1,6 ****
--- 1,7 ----
  /*
  
  Copyright 2004 by the Massachusetts Institute of Technology
+ Copyright 2006 by Secure Endpoints Inc.
  
  All rights reserved.
  
***************
*** 32,38 ****
  //
  // Note:
  //
! //	The EnableStatic method is notsupported on Win9x platforms.
  //
  //**************************************************************************
  
--- 33,39 ----
  //
  // Note:
  //
! //	The EnableStatic method is not supported on Win9x platforms.
  //
  //**************************************************************************
  
***************
*** 214,219 ****
--- 215,258 ----
      return hr;
  }
  
+ static BOOL
+ IsXP(void)
+ {
+     OSVERSIONINFOEX osInfoEx;
+     memset(&osInfoEx, 0, sizeof(osInfoEx));
+     osInfoEx.dwOSVersionInfoSize = sizeof(osInfoEx);
+ 
+     GetVersionEx((POSVERSIONINFO)&osInfoEx);
+ 
+     return(osInfoEx.dwMajorVersion == 5 && osInfoEx.dwMinorVersion == 1 && osInfoEx.wServicePackMajor < 2);
+ }
+ 
+ static VOID
+ FixupXPDNSRegistrations(LPCWSTR pCfgGuidString)
+ {
+     // As per http://support.microsoft.com/default.aspx?scid=kb%3Ben-us%3B834440
+     // HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\<NetworkAdapterGUID>
+     HKEY hkInterfaces=NULL, hkAdapter=NULL;
+     DWORD dw = 0;
+ 
+     if (!IsXP())
+ 	return;		// Nothing to do
+ 
+     RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT("SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters\\Interfaces"),
+ 		 0, KEY_READ, &hkInterfaces);
+ 
+     RegOpenKeyEx(hkInterfaces, pCfgGuidString, 0, KEY_READ|KEY_WRITE, &hkAdapter);
+ 
+     RegDeleteValue(hkAdapter, TEXT("DisableDynamicUpdate"));
+     RegDeleteValue(hkAdapter, TEXT("EnableAdapterDomainNameRegistration"));
+     RegSetValueEx(hkAdapter, TEXT("RegistrationEnabled"), 0, REG_DWORD, (BYTE *)&dw, sizeof(DWORD));
+     RegSetValueEx(hkAdapter, TEXT("RegisterAdapterName"), 0, REG_DWORD, (BYTE *)&dw, sizeof(DWORD));
+ 
+     if (hkInterfaces)
+ 	RegCloseKey(hkInterfaces);
+     if (hkAdapter)
+ 	RegCloseKey(hkAdapter);
+ }
  
  HRESULT
  WMIEnableStatic(
***************
*** 223,241 ****
      LPCWSTR mask
      )
  {
!     HRESULT hr = 0;
  
!     IWbemLocator* pLocator = 0;
!     IWbemServices* pNamespace = 0;
!     IWbemClassObject* pClass = 0;
!     IWbemClassObject* pOutInst = 0;
!     IWbemClassObject* pInClass = 0;
!     IWbemClassObject* pInInst = 0;
! 
!     BSTR NamespacePath = 0;
!     BSTR ClassPath = 0;
!     BSTR InstancePath = 0;
!     BSTR MethodName = 0; // needs to be BSTR for ExecMethod()
  
      BOOL comInitialized = FALSE;
  
--- 262,280 ----
      LPCWSTR mask
      )
  {
!     HRESULT hr = 0, hr2 = 0;
  
!     IWbemLocator* pLocator = NULL;
!     IWbemServices* pNamespace = NULL;
!     IWbemClassObject* pClass = NULL;
!     IWbemClassObject* pOutInst = NULL;
!     IWbemClassObject* pInClass = NULL;
!     IWbemClassObject* pInInst = NULL;
! 
!     BSTR NamespacePath = NULL;
!     BSTR ClassPath = NULL;
!     BSTR InstancePath = NULL;
!     BSTR MethodName = NULL; // needs to be BSTR for ExecMethod()
  
      BOOL comInitialized = FALSE;
  
***************
*** 248,253 ****
--- 287,298 ----
      VARIANT v_ret_value;
      VariantInit(&v_ret_value);
  
+     VARIANT v_reg_enabled;
+     VariantInit(&v_reg_enabled);
+ 
+     VARIANT v_netbios;
+     VariantInit(&v_netbios);
+ 
      int count;
  
      // end of declarations & NULL initialization
***************
*** 258,266 ****
      ClassPath = SysAllocString(L"Win32_NetWorkAdapterConfiguration");
      CLEANUP_ON_AND_SET(!ClassPath, hr, E_OUTOFMEMORY);
  
-     MethodName = SysAllocString(L"EnableStatic");
-     CLEANUP_ON_AND_SET(!MethodName, hr, E_OUTOFMEMORY);
- 
      // Initialize COM and connect up to CIMOM
  
      ReportMessage(0, "Intializing COM", NULL, NULL, 0);
--- 303,308 ----
***************
*** 328,333 ****
--- 370,378 ----
      }
  #endif
  
+     MethodName = SysAllocString(L"EnableStatic");
+     CLEANUP_ON_AND_SET(!MethodName, hr, E_OUTOFMEMORY);
+ 
      // Get the input argument and set the property
      hr = pClass->GetMethod(MethodName, 0, &pInClass, NULL);
      CLEANUP_ON_FAILURE(hr);
***************
*** 348,361 ****
      hr = pInInst->Put(L"SubNetMask", 0, &v_mask_list, 0);
      CLEANUP_ON_FAILURE(hr);
  
-     // Sleep for a twenty seconds
-     ReportMessage(0,"Calling ExecMethod in 20 seconds...",NULL,NULL,0);
-     Sleep(10000);
-     ReportMessage(0,"Calling ExecMethod in 10 seconds...",NULL,NULL,0);
-     Sleep(5000);  
-     ReportMessage(0,"Calling ExecMethod in  5 seconds...",NULL,NULL,0);
-     Sleep(2000);
- 
  //    printf("Skipping ExecMethod\n");
  //    hr = 0;
  //    goto cleanup;
--- 393,398 ----
***************
*** 363,388 ****
      // Try up to five times, sleeping 3 seconds between tries
      for (count=0; count<5; count++)
      {
!         if (count>0) ReportMessage(0,"Trying again in 3 seconds...",NULL,NULL,0);
! 
! 	Sleep(3000);
    
!         ReportMessage(0,"Calling ExecMethod NOW...          ",NULL,NULL,0);     
! 
!         // Call the method
! 
          hr = pNamespace->ExecMethod(InstancePath, MethodName, 0, NULL, pInInst,
                                    &pOutInst, NULL);   
- 
          if (!SUCCEEDED(hr))
          {
!            ReportMessage(0,"ExecMethod failed",NULL,NULL, hr);
             continue;
          }
  
          // Get the EnableStatic method return value
          hr = pOutInst->Get(L"ReturnValue", 0, &v_ret_value, 0, 0);
- 
          if (!SUCCEEDED(hr))
          {
            ReportMessage(0,"WARNING: Could not determine return value for EnableStatic ",NULL,NULL, hr);
--- 400,429 ----
      // Try up to five times, sleeping 3 seconds between tries
      for (count=0; count<5; count++)
      {
! 	if (count>1) {
! 	    ReportMessage(0,"Trying again in 3 seconds...",NULL,NULL,0);
! 	    Sleep(3000);
! 	} else if (count>0) {
! 	    ReportMessage(0,"Trying again in 20 seconds...",NULL,NULL,0);
! 	    Sleep(10000);
! 	    ReportMessage(0,"Trying again in 10 seconds...",NULL,NULL,0);
! 	    Sleep(5000);  
! 	    ReportMessage(0,"Trying again in  5 seconds...",NULL,NULL,0);
! 	    Sleep(2000);
! 	}
    
!         ReportMessage(0,"Calling ExecMethod EnableStatic NOW...          ",NULL,NULL,0);     
! 	// Call the method
          hr = pNamespace->ExecMethod(InstancePath, MethodName, 0, NULL, pInInst,
                                    &pOutInst, NULL);   
          if (!SUCCEEDED(hr))
          {
!            ReportMessage(0,"ExecMethod EnableStatic failed",NULL,NULL, hr);
             continue;
          }
  
          // Get the EnableStatic method return value
          hr = pOutInst->Get(L"ReturnValue", 0, &v_ret_value, 0, 0);
          if (!SUCCEEDED(hr))
          {
            ReportMessage(0,"WARNING: Could not determine return value for EnableStatic ",NULL,NULL, hr);
***************
*** 390,397 ****
          }
  
          hr = V_I4(&v_ret_value);                
- 
- 
          if(hr != 0)
              ReportMessage(0,"EnableStatic failed ", NULL,NULL,hr);
          else
--- 431,436 ----
***************
*** 399,414 ****
--- 438,563 ----
              ReportMessage(0,"EnableStatic succeeded",NULL,NULL,0);
              break;
          }
+     }
+ 
+     /* if failure, skip SetDynamicDNSRegistration */
+     if (hr)
+ 	goto cleanup;
+ 
+     /* Cleanup and Prepare for SetDynamicDNSRegistration */
+     if (pInClass) {
+ 	pInClass->Release();
+ 	pInClass = NULL;
+     }
+     if (pInInst) {
+ 	pInInst->Release();
+ 	pInInst = NULL;
+     }
+     SysFreeString(MethodName);
+     VariantClear(&v_ret_value);
+ 
+     MethodName = SysAllocString(L"SetDynamicDNSRegistration");
+     CLEANUP_ON_AND_SET(!MethodName, hr2, E_OUTOFMEMORY);
+ 
+     // Get the input argument and set the property
+     hr2 = pClass->GetMethod(MethodName, 0, &pInClass, NULL);
+     CLEANUP_ON_FAILURE(hr2);
+ 
+     hr2 = pInClass->SpawnInstance(0, &pInInst);
+     CLEANUP_ON_FAILURE(hr2);
  
+     // Set up parameters
+     V_VT(&v_reg_enabled) = VT_BOOL;
+     V_BOOL(&v_reg_enabled) = VARIANT_FALSE;
+ 
+     hr2 = pInInst->Put(L"FullDNSRegistrationEnabled", 0, &v_reg_enabled, 0);
+     CLEANUP_ON_FAILURE(hr2);
+ 
+     hr2 = pInInst->Put(L"DomainDNSRegistrationEnabled", 0, &v_reg_enabled, 0);
+     CLEANUP_ON_FAILURE(hr2);
+ 
+     // Call the method
+     hr2 = pNamespace->ExecMethod(InstancePath, MethodName, 0, NULL, pInInst,
+ 				 &pOutInst, NULL);   
+     if (!SUCCEEDED(hr2))	{
+ 	ReportMessage(0,"ExecMethod SetDynamicDNSRegistration failed",NULL,NULL, hr2);
+ 	goto cleanup;
+     }
+ 
+     // Get the EnableStatic method return value
+     hr2 = pOutInst->Get(L"ReturnValue", 0, &v_ret_value, 0, 0);
+     if (!SUCCEEDED(hr2)) {
+ 	ReportMessage(0,"WARNING: Could not determine return value for SetDynamicDNSRegistration ",NULL,NULL, hr2);
+     } else {
+ 	hr2 = V_I4(&v_ret_value);                
+ 	if(hr2 != 0)
+ 	    ReportMessage(0,"SetDynamicDNSRegistration failed ", NULL,NULL,hr2);
+ 	else
+ 	    ReportMessage(0,"SetDynamicDNSRegistration succeeded",NULL,NULL,0);
+     }
+ 
+     /* if failure, skip SetTcpipNetbios */
+     if (hr)
+ 	goto cleanup;
+ 
+     /* Cleanup and Prepare for SetTcpipNetbios */
+     if (pInClass) {
+ 	pInClass->Release();
+ 	pInClass = NULL;
+     }
+     if (pInInst) {
+ 	pInInst->Release();
+ 	pInInst = NULL;
      }
+     SysFreeString(MethodName);
+     VariantClear(&v_ret_value);
  
+     ReportMessage(0,"Preparing for SetTcpipNetbios",NULL,NULL,0);
  
+     MethodName = SysAllocString(L"SetTcpipNetbios");
+     CLEANUP_ON_AND_SET(!MethodName, hr2, E_OUTOFMEMORY);
+ 
+     // Get the input argument and set the property
+     hr2 = pClass->GetMethod(MethodName, 0, &pInClass, NULL);
+     CLEANUP_ON_FAILURE(hr2);
+ 
+     hr2 = pInClass->SpawnInstance(0, &pInInst);
+     CLEANUP_ON_FAILURE(hr2);
+ 
+     // Set up parameters
+     V_VT(&v_netbios) = VT_BSTR;
+     V_BSTR(&v_netbios) = SysAllocString(L"1");	/* Use Netbios */
+ 
+     hr2 = pInInst->Put(L"TcpipNetbiosOptions", 0, &v_netbios, 0);
+     CLEANUP_ON_FAILURE(hr2);
+ 
+     // Call the method
+     hr2 = pNamespace->ExecMethod(InstancePath, MethodName, 0, NULL, pInInst,
+ 				 &pOutInst, NULL);   
+     if (!SUCCEEDED(hr2)) {
+ 	ReportMessage(0,"ExecMethod SetTcpipNetbios failed",NULL,NULL, hr2);
+ 	goto cleanup;
+     }
+ 
+     // Get the EnableStatic method return value
+     hr2 = pOutInst->Get(L"ReturnValue", 0, &v_ret_value, 0, 0);
+     if (!SUCCEEDED(hr2)) {
+ 	ReportMessage(0,"WARNING: Could not determine return value for SetTcpipNetbios ",NULL,NULL, hr2);
+     } else {
+ 	hr2 = V_I4(&v_ret_value);                
+ 	if(hr2 != 0)
+ 	    ReportMessage(0,"SetTcpipNetbios failed ", NULL,NULL,hr2);
+ 	else
+ 	    ReportMessage(0,"SetTcpipNetbios succeeded",NULL,NULL,0);
+     }
  
   cleanup:
      // Free up resources
      VariantClear(&v_ret_value);
      VariantClear(&v_ip_list);
      VariantClear(&v_mask_list);
+     VariantClear(&v_reg_enabled);
+     VariantClear(&v_netbios);
  
      // SysFreeString is NULL safe
      SysFreeString(NamespacePath);
***************
*** 447,453 ****
      LPWSTR			swName = NULL;
      GUID            g;
      wchar_t         device_guid[100];
-     DWORD			lenDeviceId;    
      
      ReportMessage(0,"Running LoopbackBindings()...",NULL,NULL,0);
      
--- 596,601 ----
***************
*** 471,477 ****
      hr = pCfg->EnumComponents( &GUID_DEVCLASS_NET, &pEnumComponent );
      CLEANUP_ON_FAILURE(hr);
      
-     
      while( pEnumComponent->Next( 1, &pAdapter, NULL ) == S_OK )
      {
          pAdapter->GetDisplayName( &swName );
--- 619,624 ----
***************
*** 581,599 ****
  }
  
          
!         extern "C"
!             DWORD
! SetIpAddress(
!     LPCWSTR guid,
!     LPCWSTR ip,
!     LPCWSTR mask
!     )
  {
      ReportMessage(0,"Running SetIpAddress()...",0,0,0);
      HRESULT hr = 0;
  
      hr = WMIEnableStatic(FindNetworkAdapterConfigurationInstanceByGUID,
                          (PVOID)guid, ip, mask);
      return hr;
  }
  
--- 728,742 ----
  }
  
          
! extern "C" DWORD SetIpAddress(LPCWSTR guid, LPCWSTR ip, LPCWSTR mask)
  {
      ReportMessage(0,"Running SetIpAddress()...",0,0,0);
      HRESULT hr = 0;
  
      hr = WMIEnableStatic(FindNetworkAdapterConfigurationInstanceByGUID,
                          (PVOID)guid, ip, mask);
+     if (hr == 0)
+ 	FixupXPDNSRegistrations(guid);
      return hr;
  }
  
Index: openafs/src/afs/LINUX/osi_machdep.h
diff -c openafs/src/afs/LINUX/osi_machdep.h:1.22.2.13 openafs/src/afs/LINUX/osi_machdep.h:1.22.2.14
*** openafs/src/afs/LINUX/osi_machdep.h:1.22.2.13	Fri Aug 11 17:43:38 2006
--- openafs/src/afs/LINUX/osi_machdep.h	Sat Sep 16 15:12:15 2006
***************
*** 227,230 ****
--- 227,292 ----
  #define AFS_ASSERT_GLOCK()
  #endif
  
+ #ifdef AFS_AMD64_LINUX20_ENV
+ /* RHEL5 beta's kernel doesn't define these. They aren't gonna change, so... */
+ 
+ #ifndef __NR_ia32_afs_syscall
+ #define __NR_ia32_afs_syscall 137
+ #endif
+ #ifndef __NR_ia32_setgroups
+ #define __NR_ia32_setgroups 81
+ #endif
+ #ifndef __NR_ia32_setgroups32
+ #define __NR_ia32_setgroups32 206
+ #endif
+ #ifndef __NR_ia32_close
+ #define __NR_ia32_close 6
+ #endif
+ #ifndef __NR_ia32_chdir
+ #define __NR_ia32_chdir 12
+ #endif
+ #ifndef __NR_ia32_break
+ #define __NR_ia32_break 17
+ #endif
+ #ifndef __NR_ia32_stty
+ #define __NR_ia32_stty 31
+ #endif
+ #ifndef __NR_ia32_gtty
+ #define __NR_ia32_gtty 32
+ #endif
+ #ifndef __NR_ia32_ftime
+ #define __NR_ia32_ftime 35
+ #endif
+ #ifndef __NR_ia32_prof
+ #define __NR_ia32_prof 44
+ #endif
+ #ifndef __NR_ia32_lock
+ #define __NR_ia32_lock 53
+ #endif
+ #ifndef __NR_ia32_mpx
+ #define __NR_ia32_mpx 56
+ #endif
+ #ifndef __NR_ia32_exit
+ #define __NR_ia32_exit 1
+ #endif
+ #ifndef __NR_ia32_mount
+ #define __NR_ia32_mount 21
+ #endif
+ #ifndef __NR_ia32_read
+ #define __NR_ia32_read 3
+ #endif
+ #ifndef __NR_ia32_write
+ #define __NR_ia32_write 4
+ #endif
+ #ifndef __NR_ia32_open
+ #define __NR_ia32_open 5
+ #endif
+ #ifndef __NR_ia32_close
+ #define __NR_ia32_close 6
+ #endif
+ #ifndef __NR_ia32_unlink
+ #define __NR_ia32_unlink 10
+ #endif
+ #endif
+ 
  #endif /* OSI_MACHDEP_H_ */
Index: openafs/src/afs/LINUX/osi_module.c
diff -c openafs/src/afs/LINUX/osi_module.c:1.52.2.24 openafs/src/afs/LINUX/osi_module.c:1.52.2.25
*** openafs/src/afs/LINUX/osi_module.c:1.52.2.24	Mon Aug 14 18:09:33 2006
--- openafs/src/afs/LINUX/osi_module.c	Sat Sep 16 15:19:36 2006
***************
*** 15,21 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/LINUX/osi_module.c,v 1.52.2.24 2006/08/14 22:09:33 shadow Exp $");
  
  #include <linux/module.h> /* early to avoid printf->printk mapping */
  #include "afs/sysincludes.h"
--- 15,21 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/LINUX/osi_module.c,v 1.52.2.25 2006/09/16 19:19:36 shadow Exp $");
  
  #include <linux/module.h> /* early to avoid printf->printk mapping */
  #include "afs/sysincludes.h"
***************
*** 366,376 ****
  
      osi_Init();
  
- #ifndef LINUX_KEYRING_SUPPORT
      err = osi_syscall_init();
      if (err)
  	return err;
- #endif
      err = afs_init_inodecache();
      if (err)
  	return err;
--- 366,374 ----
Index: openafs/src/auth/cellconfig.c
diff -c openafs/src/auth/cellconfig.c:1.40.2.6 openafs/src/auth/cellconfig.c:1.40.2.8
*** openafs/src/auth/cellconfig.c:1.40.2.6	Tue Mar 28 13:42:57 2006
--- openafs/src/auth/cellconfig.c	Sun Sep 17 01:01:56 2006
***************
*** 11,17 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/auth/cellconfig.c,v 1.40.2.6 2006/03/28 18:42:57 shadow 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.2.8 2006/09/17 05:01:56 shadow Exp $");
  
  #include <afs/stds.h>
  #include <afs/pthread_glock.h>
***************
*** 114,119 ****
--- 114,226 ----
   * CellServDB changes.
   */
  
+ #if defined(AFS_SUN5_ENV) && !defined(__sparcv9)
+ /* Solaris through 10 in 32 bit mode will return EMFILE if fopen can't
+    get an fd <= 255. We allow the fileserver to claim more fds than that.
+    This has always been a problem since pr_Initialize would have the same
+    issue, but hpr_Initialize makes it more likely that we would see this. 
+    Work around it. This is not generic. It's coded with the needs of
+    afsconf_* in mind only.
+ 
+    http://www.opensolaris.org/os/community/onnv/flag-days/pages/2006042001/
+ */
+ 
+ #define BUFFER 4096
+ 
+ struct afsconf_iobuffer {
+     int _file;
+     char *buffer;
+     char *ptr;
+     char *endptr;
+ };
+ 
+ typedef struct afsconf_iobuffer afsconf_FILE;
+ 
+ static afsconf_FILE *
+ afsconf_fopen(const char *fname, const char *fmode)
+ {
+     int fd;
+     afsconf_FILE *iop;
+     
+     if ((fd = open(fname, O_RDONLY)) == -1) {
+ 	return NULL;
+     }
+     
+     iop = malloc(sizeof(struct afsconf_iobuffer));
+     if (iop == NULL) {
+ 	(void) close(fd);
+ 	errno = ENOMEM;
+ 	return NULL;
+     }
+     iop->_file = fd;
+     iop->buffer = malloc(BUFFER);
+     if (iop->buffer == NULL) {
+ 	(void) close(fd);
+ 	free((void *) iop);
+ 	errno = ENOMEM;
+ 	return NULL;
+     }
+     iop->ptr = iop->buffer;
+     iop->endptr = iop->buffer;
+     return iop;
+ }
+ 
+ static int
+ afsconf_fclose(afsconf_FILE *iop)
+ {
+     if (iop == NULL) {
+ 	return 0;
+     }
+     close(iop->_file);
+     free((void *)iop->buffer);
+     free((void *)iop);
+     return 0;
+ }
+ 
+ static char *
+ afsconf_fgets(char *s, int n, afsconf_FILE *iop)
+ {
+     char *p;
+     
+     p = s;
+     for (;;) {
+ 	char c;
+ 	
+ 	if (iop->ptr == iop->endptr) {
+ 	    ssize_t len;
+ 	    
+ 	    if ((len = read(iop->_file, (void *)iop->buffer, BUFFER)) == -1) {
+ 		return NULL;
+ 	    }
+ 	    if (len == 0) {
+ 		*p = 0;
+ 		if (s == p) {
+ 		    return NULL;
+ 		}
+ 		return s;
+ 	    }
+ 	    iop->ptr = iop->buffer;
+ 	    iop->endptr = iop->buffer + len;
+ 	}
+ 	c = *iop->ptr++;
+ 	*p++ = c;
+ 	if ((p - s) == (n - 1)) {
+ 	    *p = 0;
+ 	    return s;
+ 	}
+ 	if (c == '\n') {
+ 	    *p = 0;
+ 	    return s;
+ 	}
+     }
+ }
+ #define fopen afsconf_fopen
+ #define fclose afsconf_fclose
+ #define fgets afsconf_fgets
+ #else
+ #define afsconf_FILE FILE
+ #endif /* AFS_SUN5_ENV && ! __sparcv9 */
+ 
  /* return port number in network byte order in the low 16 bits of a long; return -1 if not found */
  static afs_int32
  afsconf_FindService(register const char *aname)
***************
*** 311,317 ****
  	if (!(afsconf_path = getenv("AFSCONF"))) {
  	    /* The "AFSCONF" environment (or contents of "/.AFSCONF") will be typically set to something like "/afs/<cell>/common/etc" where, by convention, the default files for "ThisCell" and "CellServDB" will reside; note that a major drawback is that a given afs client on that cell may NOT contain the same contents... */
  	    char *home_dir;
! 	    FILE *fp;
  	    size_t len;
  
  	    if (!(home_dir = getenv("HOME"))) {
--- 418,424 ----
  	if (!(afsconf_path = getenv("AFSCONF"))) {
  	    /* The "AFSCONF" environment (or contents of "/.AFSCONF") will be typically set to something like "/afs/<cell>/common/etc" where, by convention, the default files for "ThisCell" and "CellServDB" will reside; note that a major drawback is that a given afs client on that cell may NOT contain the same contents... */
  	    char *home_dir;
! 	    afsconf_FILE *fp;
  	    size_t len;
  
  	    if (!(home_dir = getenv("HOME"))) {
***************
*** 366,391 ****
      return tdir;
  }
  
- 
  static int
  GetCellUnix(struct afsconf_dir *adir)
  {
      int rc;
      char tbuffer[256];
!     FILE *tf;
! 
      strcompose(tbuffer, 256, adir->name, "/", AFSDIR_THISCELL_FILE, NULL);
!     tf = fopen(tbuffer, "r");
!     if (tf) {
! 	/* FIXME: buffer overflow waiting to happen */
! 	rc = fscanf(tf, "%s", tbuffer);
! 	if (rc == 1) {
! 	    adir->cellName = (char *)malloc(strlen(tbuffer) + 1);
! 	    strcpy(adir->cellName, tbuffer);
! 	}
! 	fclose(tf);
      } else {
! 	return -1;
      }
      return 0;
  }
--- 473,503 ----
      return tdir;
  }
  
  static int
  GetCellUnix(struct afsconf_dir *adir)
  {
      int rc;
      char tbuffer[256];
!     int fd;
!     
      strcompose(tbuffer, 256, adir->name, "/", AFSDIR_THISCELL_FILE, NULL);
!     fd = open(tbuffer, O_RDONLY, 0);
!     if (fd < 0) {
!         return -1;
      } else {
! 	int sz;
! 
! 	memset(tbuffer, 0, 256);
!         sz = read(fd, tbuffer, 255);
!         close(fd);
!         if (sz > 0) {
! 	    char *p = strchr(tbuffer, '\n');
! 	    if (p)
! 		*p = '\0';
! 
!             adir->cellName = (char *)malloc(sz + 1);
!             strncpy(adir->cellName, tbuffer, sz);
!         }
      }
      return 0;
  }
***************
*** 410,416 ****
  afsconf_OpenInternal(register struct afsconf_dir *adir, char *cell,
  		     char clones[])
  {
!     FILE *tf;
      register char *tp, *bp;
      register struct afsconf_entry *curEntry;
      struct afsconf_aliasentry *curAlias;
--- 522,528 ----
  afsconf_OpenInternal(register struct afsconf_dir *adir, char *cell,
  		     char clones[])
  {
!     afsconf_FILE *tf;
      register char *tp, *bp;
      register struct afsconf_entry *curEntry;
      struct afsconf_aliasentry *curAlias;
Index: openafs/src/config/NTMakefile.amd64_w2k
diff -c openafs/src/config/NTMakefile.amd64_w2k:1.1.2.41 openafs/src/config/NTMakefile.amd64_w2k:1.1.2.42
*** openafs/src/config/NTMakefile.amd64_w2k:1.1.2.41	Wed Sep  6 13:22:09 2006
--- openafs/src/config/NTMakefile.amd64_w2k	Sat Sep 16 19:47:43 2006
***************
*** 80,86 ****
  #define used in WinNT/2000 installation and program version display
  AFSPRODUCT_VER_MAJOR=1
  AFSPRODUCT_VER_MINOR=4
! AFSPRODUCT_VER_PATCH=0202
  AFSPRODUCT_VER_BUILD=0
  
  AFSPRODUCT_VERSION=$(AFSPRODUCT_VER_MAJOR).$(AFSPRODUCT_VER_MINOR).$(AFSPRODUCT_VER_PATCH)
--- 80,86 ----
  #define used in WinNT/2000 installation and program version display
  AFSPRODUCT_VER_MAJOR=1
  AFSPRODUCT_VER_MINOR=4
! AFSPRODUCT_VER_PATCH=0203
  AFSPRODUCT_VER_BUILD=0
  
  AFSPRODUCT_VERSION=$(AFSPRODUCT_VER_MAJOR).$(AFSPRODUCT_VER_MINOR).$(AFSPRODUCT_VER_PATCH)
Index: openafs/src/config/NTMakefile.i386_nt40
diff -c openafs/src/config/NTMakefile.i386_nt40:1.46.2.56 openafs/src/config/NTMakefile.i386_nt40:1.46.2.57
*** openafs/src/config/NTMakefile.i386_nt40:1.46.2.56	Wed Sep  6 13:22:09 2006
--- openafs/src/config/NTMakefile.i386_nt40	Sat Sep 16 19:47:43 2006
***************
*** 80,86 ****
  #define used in WinNT/2000 installation and program version display
  AFSPRODUCT_VER_MAJOR=1
  AFSPRODUCT_VER_MINOR=4
! AFSPRODUCT_VER_PATCH=0202
  AFSPRODUCT_VER_BUILD=0
  
  AFSPRODUCT_VERSION=$(AFSPRODUCT_VER_MAJOR).$(AFSPRODUCT_VER_MINOR).$(AFSPRODUCT_VER_PATCH)
--- 80,86 ----
  #define used in WinNT/2000 installation and program version display
  AFSPRODUCT_VER_MAJOR=1
  AFSPRODUCT_VER_MINOR=4
! AFSPRODUCT_VER_PATCH=0203
  AFSPRODUCT_VER_BUILD=0
  
  AFSPRODUCT_VERSION=$(AFSPRODUCT_VER_MAJOR).$(AFSPRODUCT_VER_MINOR).$(AFSPRODUCT_VER_PATCH)
Index: openafs/src/config/NTMakefile.i386_w2k
diff -c openafs/src/config/NTMakefile.i386_w2k:1.1.2.43 openafs/src/config/NTMakefile.i386_w2k:1.1.2.44
*** openafs/src/config/NTMakefile.i386_w2k:1.1.2.43	Wed Sep  6 13:22:10 2006
--- openafs/src/config/NTMakefile.i386_w2k	Sat Sep 16 19:47:43 2006
***************
*** 80,86 ****
  #define used in WinNT/2000 installation and program version display
  AFSPRODUCT_VER_MAJOR=1
  AFSPRODUCT_VER_MINOR=4
! AFSPRODUCT_VER_PATCH=0202
  AFSPRODUCT_VER_BUILD=0
  
  AFSPRODUCT_VERSION=$(AFSPRODUCT_VER_MAJOR).$(AFSPRODUCT_VER_MINOR).$(AFSPRODUCT_VER_PATCH)
--- 80,86 ----
  #define used in WinNT/2000 installation and program version display
  AFSPRODUCT_VER_MAJOR=1
  AFSPRODUCT_VER_MINOR=4
! AFSPRODUCT_VER_PATCH=0203
  AFSPRODUCT_VER_BUILD=0
  
  AFSPRODUCT_VERSION=$(AFSPRODUCT_VER_MAJOR).$(AFSPRODUCT_VER_MINOR).$(AFSPRODUCT_VER_PATCH)
Index: openafs/src/kauth/authclient.c
diff -c openafs/src/kauth/authclient.c:1.14.2.4 openafs/src/kauth/authclient.c:1.14.2.5
*** openafs/src/kauth/authclient.c:1.14.2.4	Mon Dec 13 14:38:51 2004
--- openafs/src/kauth/authclient.c	Fri Sep 15 19:19:27 2006
***************
*** 17,23 ****
  #endif
  
  RCSID
!     ("$Header: /cvs/openafs/src/kauth/authclient.c,v 1.14.2.4 2004/12/13 19:38:51 shadow Exp $");
  
  #if defined(UKERNEL)
  #include "afs/sysincludes.h"
--- 17,23 ----
  #endif
  
  RCSID
!     ("$Header: /cvs/openafs/src/kauth/authclient.c,v 1.14.2.5 2006/09/15 23:19:27 jaltman Exp $");
  
  #if defined(UKERNEL)
  #include "afs/sysincludes.h"
***************
*** 145,150 ****
--- 145,151 ----
  	}
      }
      code = myCellLookup(conf, cell, AFSCONF_KAUTHSERVICE, cellinfo);
+     afsconf_Close(conf);
      UNLOCK_GLOBAL_MUTEX;
      return code;
  }
Index: openafs/src/libafs/afs.ppc_darwin_70.plist.in
diff -c openafs/src/libafs/afs.ppc_darwin_70.plist.in:1.2.2.14 openafs/src/libafs/afs.ppc_darwin_70.plist.in:1.2.2.15
*** openafs/src/libafs/afs.ppc_darwin_70.plist.in:1.2.2.14	Wed Sep  6 17:13:52 2006
--- openafs/src/libafs/afs.ppc_darwin_70.plist.in	Sat Sep 16 15:50:23 2006
***************
*** 15,25 ****
  	<key>CFBundlePackageType</key>
  	<string>KEXT</string>
  	<key>CFBundleShortVersionString</key>
! 	<string>1.4.2fc3</string>
  	<key>CFBundleSignature</key>
  	<string>????</string>
  	<key>CFBundleVersion</key>
! 	<string>1.4.2fc3</string>
  	<key>OSBundleLibraries</key>
  	<dict>
  		<key>com.apple.kernel.bsd</key>
--- 15,25 ----
  	<key>CFBundlePackageType</key>
  	<string>KEXT</string>
  	<key>CFBundleShortVersionString</key>
! 	<string>1.4.2fc4</string>
  	<key>CFBundleSignature</key>
  	<string>????</string>
  	<key>CFBundleVersion</key>
! 	<string>1.4.2fc4</string>
  	<key>OSBundleLibraries</key>
  	<dict>
  		<key>com.apple.kernel.bsd</key>
Index: openafs/src/libafs/afs.ppc_darwin_80.plist.in
diff -c openafs/src/libafs/afs.ppc_darwin_80.plist.in:1.1.2.9 openafs/src/libafs/afs.ppc_darwin_80.plist.in:1.1.2.10
*** openafs/src/libafs/afs.ppc_darwin_80.plist.in:1.1.2.9	Wed Sep  6 17:13:52 2006
--- openafs/src/libafs/afs.ppc_darwin_80.plist.in	Sat Sep 16 15:50:23 2006
***************
*** 15,25 ****
  	<key>CFBundlePackageType</key>
  	<string>KEXT</string>
  	<key>CFBundleShortVersionString</key>
! 	<string>1.4.2fc3</string>
  	<key>CFBundleSignature</key>
  	<string>????</string>
  	<key>CFBundleVersion</key>
! 	<string>1.4.2fc3</string>
  	<key>OSBundleLibraries</key>
  	<dict>
  		<key>com.apple.kpi.bsd</key>
--- 15,25 ----
  	<key>CFBundlePackageType</key>
  	<string>KEXT</string>
  	<key>CFBundleShortVersionString</key>
! 	<string>1.4.2fc4</string>
  	<key>CFBundleSignature</key>
  	<string>????</string>
  	<key>CFBundleVersion</key>
! 	<string>1.4.2fc4</string>
  	<key>OSBundleLibraries</key>
  	<dict>
  		<key>com.apple.kpi.bsd</key>
Index: openafs/src/libafs/afs.ppc_darwin_90.plist.in
diff -c openafs/src/libafs/afs.ppc_darwin_90.plist.in:1.1.2.8 openafs/src/libafs/afs.ppc_darwin_90.plist.in:1.1.2.9
*** openafs/src/libafs/afs.ppc_darwin_90.plist.in:1.1.2.8	Wed Sep  6 17:13:52 2006
--- openafs/src/libafs/afs.ppc_darwin_90.plist.in	Sat Sep 16 15:50:23 2006
***************
*** 15,25 ****
  	<key>CFBundlePackageType</key>
  	<string>KEXT</string>
  	<key>CFBundleShortVersionString</key>
! 	<string>1.4.2fc3</string>
  	<key>CFBundleSignature</key>
  	<string>????</string>
  	<key>CFBundleVersion</key>
! 	<string>1.4.2fc3</string>
  	<key>OSBundleLibraries</key>
  	<dict>
  		<key>com.apple.kpi.bsd</key>
--- 15,25 ----
  	<key>CFBundlePackageType</key>
  	<string>KEXT</string>
  	<key>CFBundleShortVersionString</key>
! 	<string>1.4.2fc4</string>
  	<key>CFBundleSignature</key>
  	<string>????</string>
  	<key>CFBundleVersion</key>
! 	<string>1.4.2fc4</string>
  	<key>OSBundleLibraries</key>
  	<dict>
  		<key>com.apple.kpi.bsd</key>
Index: openafs/src/libafs/afs.x86_darwin_80.plist.in
diff -c openafs/src/libafs/afs.x86_darwin_80.plist.in:1.1.2.8 openafs/src/libafs/afs.x86_darwin_80.plist.in:1.1.2.9
*** openafs/src/libafs/afs.x86_darwin_80.plist.in:1.1.2.8	Wed Sep  6 17:13:52 2006
--- openafs/src/libafs/afs.x86_darwin_80.plist.in	Sat Sep 16 15:50:23 2006
***************
*** 15,25 ****
  	<key>CFBundlePackageType</key>
  	<string>KEXT</string>
  	<key>CFBundleShortVersionString</key>
! 	<string>1.4.2fc3</string>
  	<key>CFBundleSignature</key>
  	<string>????</string>
  	<key>CFBundleVersion</key>
! 	<string>1.4.2fc3</string>
  	<key>OSBundleLibraries</key>
  	<dict>
  		<key>com.apple.kpi.bsd</key>
--- 15,25 ----
  	<key>CFBundlePackageType</key>
  	<string>KEXT</string>
  	<key>CFBundleShortVersionString</key>
! 	<string>1.4.2fc4</string>
  	<key>CFBundleSignature</key>
  	<string>????</string>
  	<key>CFBundleVersion</key>
! 	<string>1.4.2fc4</string>
  	<key>OSBundleLibraries</key>
  	<dict>
  		<key>com.apple.kpi.bsd</key>
Index: openafs/src/libafs/afs.x86_darwin_90.plist.in
diff -c openafs/src/libafs/afs.x86_darwin_90.plist.in:1.1.2.8 openafs/src/libafs/afs.x86_darwin_90.plist.in:1.1.2.9
*** openafs/src/libafs/afs.x86_darwin_90.plist.in:1.1.2.8	Wed Sep  6 17:13:52 2006
--- openafs/src/libafs/afs.x86_darwin_90.plist.in	Sat Sep 16 15:50:23 2006
***************
*** 15,25 ****
  	<key>CFBundlePackageType</key>
  	<string>KEXT</string>
  	<key>CFBundleShortVersionString</key>
! 	<string>1.4.2fc3</string>
  	<key>CFBundleSignature</key>
  	<string>????</string>
  	<key>CFBundleVersion</key>
! 	<string>1.4.2fc3</string>
  	<key>OSBundleLibraries</key>
  	<dict>
  		<key>com.apple.kpi.bsd</key>
--- 15,25 ----
  	<key>CFBundlePackageType</key>
  	<string>KEXT</string>
  	<key>CFBundleShortVersionString</key>
! 	<string>1.4.2fc4</string>
  	<key>CFBundleSignature</key>
  	<string>????</string>
  	<key>CFBundleVersion</key>
! 	<string>1.4.2fc4</string>
  	<key>OSBundleLibraries</key>
  	<dict>
  		<key>com.apple.kpi.bsd</key>
Index: openafs/src/packaging/MacOS/OpenAFS.Info.plist
diff -c openafs/src/packaging/MacOS/OpenAFS.Info.plist:1.2.2.24 openafs/src/packaging/MacOS/OpenAFS.Info.plist:1.2.2.25
*** openafs/src/packaging/MacOS/OpenAFS.Info.plist:1.2.2.24	Wed Sep  6 17:13:53 2006
--- openafs/src/packaging/MacOS/OpenAFS.Info.plist	Sat Sep 16 15:50:24 2006
***************
*** 3,15 ****
  <plist version="1.0">
  <dict>
  	<key>CFBundleGetInfoString</key>
! 	<string>OpenAFS 1.4.2fc3</string>
  	<key>CFBundleIdentifier</key>
  	<string>org.openafs.OpenAFS.pkg</string>
  	<key>CFBundleName</key>
  	<string>OpenAFS</string>
  	<key>CFBundleShortVersionString</key>
! 	<string>1.4.2fc3</string>
  	<key>IFMajorVersion</key>
  	<integer>1</integer>
  	<key>IFMinorVersion</key>
--- 3,15 ----
  <plist version="1.0">
  <dict>
  	<key>CFBundleGetInfoString</key>
! 	<string>OpenAFS 1.4.2fc4</string>
  	<key>CFBundleIdentifier</key>
  	<string>org.openafs.OpenAFS.pkg</string>
  	<key>CFBundleName</key>
  	<string>OpenAFS</string>
  	<key>CFBundleShortVersionString</key>
! 	<string>1.4.2fc4</string>
  	<key>IFMajorVersion</key>
  	<integer>1</integer>
  	<key>IFMinorVersion</key>
Index: openafs/src/packaging/MacOS/OpenAFS.info
diff -c openafs/src/packaging/MacOS/OpenAFS.info:1.1.4.37 openafs/src/packaging/MacOS/OpenAFS.info:1.1.4.38
*** openafs/src/packaging/MacOS/OpenAFS.info:1.1.4.37	Wed Sep  6 17:13:53 2006
--- openafs/src/packaging/MacOS/OpenAFS.info	Sat Sep 16 15:50:24 2006
***************
*** 1,5 ****
  Title OpenAFS
! Version 1.4.2fc3
  Description The OpenAFS distributed filesystem. This package installs an almost-ready-to-run client for OpenAFS. see http://www.openafs.org for more information.
  DefaultLocation /
  Diskname (null)
--- 1,5 ----
  Title OpenAFS
! Version 1.4.2fc4
  Description The OpenAFS distributed filesystem. This package installs an almost-ready-to-run client for OpenAFS. see http://www.openafs.org for more information.
  DefaultLocation /
  Diskname (null)
Index: openafs/src/ptserver/ptuser.c
diff -c openafs/src/ptserver/ptuser.c:1.16.2.8 openafs/src/ptserver/ptuser.c:1.16.2.10
*** openafs/src/ptserver/ptuser.c:1.16.2.8	Mon Jul 31 13:15:48 2006
--- openafs/src/ptserver/ptuser.c	Sat Sep 16 15:40:52 2006
***************
*** 15,21 ****
  #endif
  
  RCSID
!     ("$Header: /cvs/openafs/src/ptserver/ptuser.c,v 1.16.2.8 2006/07/31 17:15:48 shadow Exp $");
  
  #if defined(UKERNEL)
  #include "afs/sysincludes.h"
--- 15,21 ----
  #endif
  
  RCSID
!     ("$Header: /cvs/openafs/src/ptserver/ptuser.c,v 1.16.2.10 2006/09/16 19:40:52 shadow Exp $");
  
  #if defined(UKERNEL)
  #include "afs/sysincludes.h"
***************
*** 71,77 ****
      afs_int32 code;
      struct rx_connection *serverconns[MAXSERVERS];
      struct rx_securityClass *sc[3];
!     static struct afsconf_dir *tdir = (struct afsconf_dir *)0;	/* only do this once */
      static char tconfDir[100] = "";
      static char tcell[64] = "";
      struct ktc_token ttoken;
--- 71,77 ----
      afs_int32 code;
      struct rx_connection *serverconns[MAXSERVERS];
      struct rx_securityClass *sc[3];
!     static struct afsconf_dir *tdir = (struct afsconf_dir *)NULL;	/* only do this once */
      static char tconfDir[100] = "";
      static char tcell[64] = "";
      struct ktc_token ttoken;
***************
*** 117,132 ****
      }
  #endif /* defined(UKERNEL) */
  
!     if (tdir == 0 || strcmp(confDir, tconfDir) || strcmp(cell, tcell)) {
  	/*
  	 * force re-evaluation.  we either don't have an afsconf_dir,
           * the directory has changed or the cell has changed.
  	 */
  	if (tdir && !gottdir) {
  	    afsconf_Close(tdir);
!             tdir = (struct afsconf_dir *)0;
          }
! 	pruclient = (struct ubik_client *)0;
          refresh = 1;
      }
  
--- 117,132 ----
      }
  #endif /* defined(UKERNEL) */
  
!     if (tdir == NULL || strcmp(confDir, tconfDir) || strcmp(cell, tcell)) {
  	/*
  	 * force re-evaluation.  we either don't have an afsconf_dir,
           * the directory has changed or the cell has changed.
  	 */
  	if (tdir && !gottdir) {
  	    afsconf_Close(tdir);
!             tdir = (struct afsconf_dir *)NULL;
          }
! 	pruclient = (struct ubik_client *)NULL;
          refresh = 1;
      }
  
***************
*** 163,170 ****
       * want, don't get a new one. Unless the security level is 2 in
       * which case we will get one (and re-read the key file).
       */
!     if (pruclient && (lastLevel == secLevel) && (secLevel != 2))
  	return 0;
  
      code = rx_Init(0);
      if (code) {
--- 163,171 ----
       * want, don't get a new one. Unless the security level is 2 in
       * which case we will get one (and re-read the key file).
       */
!     if (pruclient && (lastLevel == secLevel) && (secLevel != 2)) {
  	return 0;
+     }
  
      code = rx_Init(0);
      if (code) {
***************
*** 216,221 ****
--- 217,223 ----
  					      ttoken.ticket);
  	}
      }
+ 
      if (scIndex == 1)
  	return PRBADARG;
      if ((scIndex == 0) && (sc[0] == 0))
Index: openafs/src/rx/DARWIN/rx_knet.c
diff -c openafs/src/rx/DARWIN/rx_knet.c:1.10.2.2 openafs/src/rx/DARWIN/rx_knet.c:1.10.2.3
*** openafs/src/rx/DARWIN/rx_knet.c:1.10.2.2	Tue Jan 17 12:09:48 2006
--- openafs/src/rx/DARWIN/rx_knet.c	Fri Sep 15 20:11:24 2006
***************
*** 11,17 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/rx/DARWIN/rx_knet.c,v 1.10.2.2 2006/01/17 17:09:48 shadow Exp $");
  
  #include "rx/rx_kcommon.h"
  
--- 11,17 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/rx/DARWIN/rx_knet.c,v 1.10.2.3 2006/09/16 00:11:24 shadow Exp $");
  
  #include "rx/rx_kcommon.h"
  
***************
*** 127,133 ****
--- 127,135 ----
  		*addr = *(struct sockaddr_in *)sa;
  	} else
  	    printf("Unknown socket family %d in NetReceive\n", sa->sa_family);
+ #ifndef AFS_DARWIN80_ENV
  	FREE(sa, M_SONAME);
+ #endif
      }
      return code;
  }
Index: openafs/src/ubik/uinit.c
diff -c openafs/src/ubik/uinit.c:1.6.2.2 openafs/src/ubik/uinit.c:1.6.2.3
*** openafs/src/ubik/uinit.c:1.6.2.2	Tue Nov  9 12:09:41 2004
--- openafs/src/ubik/uinit.c	Fri Sep 15 19:19:28 2006
***************
*** 11,17 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/ubik/uinit.c,v 1.6.2.2 2004/11/09 17:09:41 shadow Exp $");
  
  #include <afs/stds.h>
  #ifdef AFS_NT40_ENV
--- 11,17 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/ubik/uinit.c,v 1.6.2.3 2006/09/15 23:19:28 jaltman Exp $");
  
  #include <afs/stds.h>
  #ifdef AFS_NT40_ENV
***************
*** 87,92 ****
--- 87,93 ----
  	}
  	code = afsconf_ClientAuth(tdir, &sc, &scIndex);	/* sets sc,scIndex */
  	if (code) {
+ 	    afsconf_Close(tdir);
  	    fprintf(stderr,
  		    "%s: Could not get security object for -localAuth\n",
  		    funcName);
***************
*** 96,101 ****
--- 97,103 ----
  	    afsconf_GetCellInfo(tdir, tdir->cellName, serviceid,
  				&info);
  	if (code) {
+ 	    afsconf_Close(tdir);
  	    fprintf(stderr,
  		    "%s: can't find cell %s's hosts in %s/%s\n",
  		    funcName, cellName, AFSDIR_SERVER_ETC_DIRPATH,
Index: openafs/src/viced/afsfileprocs.c
diff -c openafs/src/viced/afsfileprocs.c:1.81.2.35 openafs/src/viced/afsfileprocs.c:1.81.2.36
*** openafs/src/viced/afsfileprocs.c:1.81.2.35	Tue Sep  5 12:31:58 2006
--- openafs/src/viced/afsfileprocs.c	Thu Sep 14 19:59:36 2006
***************
*** 29,35 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/viced/afsfileprocs.c,v 1.81.2.35 2006/09/05 16:31:58 shadow Exp $");
  
  #include <stdio.h>
  #include <stdlib.h>
--- 29,35 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/viced/afsfileprocs.c,v 1.81.2.36 2006/09/14 23:59:36 shadow Exp $");
  
  #include <stdio.h>
  #include <stdlib.h>
***************
*** 7395,7403 ****
--- 7395,7407 ----
      sys2et[ENAMETOOLONG] = UAENAMETOOLONG;
      sys2et[ENOLCK] = UAENOLCK;
      sys2et[ENOSYS] = UAENOSYS;
+ #if (ENOTEMPTY != EEXIST)
      sys2et[ENOTEMPTY] = UAENOTEMPTY;
+ #endif
      sys2et[ELOOP] = UAELOOP;
+ #if (EWOULDBLOCK != EAGAIN)
      sys2et[EWOULDBLOCK] = UAEWOULDBLOCK;
+ #endif
      sys2et[ENOMSG] = UAENOMSG;
      sys2et[EIDRM] = UAEIDRM;
      sys2et[ECHRNG] = UAECHRNG;
Index: openafs/src/viced/viced.c
diff -c openafs/src/viced/viced.c:1.58.2.17 openafs/src/viced/viced.c:1.58.2.18
*** openafs/src/viced/viced.c:1.58.2.17	Sun Sep  3 01:51:41 2006
--- openafs/src/viced/viced.c	Fri Sep 15 19:19:28 2006
***************
*** 20,26 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/viced/viced.c,v 1.58.2.17 2006/09/03 05:51:41 shadow Exp $");
  
  #include <stdio.h>
  #include <stdlib.h>
--- 20,26 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/viced/viced.c,v 1.58.2.18 2006/09/15 23:19:28 jaltman Exp $");
  
  #include <stdio.h>
  #include <stdlib.h>
***************
*** 1372,1377 ****
--- 1372,1378 ----
  			     info.hostAddr[i].sin_port, USER_SERVICE_ID, sc,
  			     scIndex);
      code = ubik_ClientInit(serverconns, &cstruct);
+     afsconf_Close(tdir);
      if (code) {
  	ViceLog(0, ("vl_Initialize: ubik client init failed.\n"));
  	return code;
Index: openafs/src/vol/namei_ops.c
diff -c openafs/src/vol/namei_ops.c:1.21.2.8 openafs/src/vol/namei_ops.c:1.21.2.10
*** openafs/src/vol/namei_ops.c:1.21.2.8	Tue Sep  5 11:01:09 2006
--- openafs/src/vol/namei_ops.c	Wed Sep 20 01:52:35 2006
***************
*** 13,19 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/vol/namei_ops.c,v 1.21.2.8 2006/09/05 15:01:09 shadow Exp $");
  
  #ifdef AFS_NAMEI_ENV
  #include <stdio.h>
--- 13,19 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/vol/namei_ops.c,v 1.21.2.10 2006/09/20 05:52:35 shadow Exp $");
  
  #ifdef AFS_NAMEI_ENV
  #include <stdio.h>
***************
*** 27,35 ****
  #include <sys/file.h>
  #include <sys/param.h>
  #include <lock.h>
- #ifdef AFS_AIX_ENV
- #include <sys/lockf.h>
- #endif
  #if defined(AFS_SUN5_ENV) || defined(AFS_HPUX_ENV)
  #include <unistd.h>
  #endif
--- 27,32 ----
***************
*** 69,74 ****
--- 66,103 ----
  
  /*@printflike@*/ extern void Log(const char *format, ...);
  
+ #ifndef LOCK_SH
+ #define   LOCK_SH   1    /* shared lock */
+ #define   LOCK_EX   2    /* exclusive lock */
+ #define   LOCK_NB   4    /* don't block when locking */
+ #define   LOCK_UN   8    /* unlock */
+ #endif
+ 
+ #ifndef HAVE_FLOCK
+ #include <fcntl.h>
+ 
+ /*
+  * This function emulates a subset of flock()
+  */
+ int 
+ emul_flock(int fd, int cmd)
+ {    struct flock f;
+ 
+     memset(&f, 0, sizeof (f));
+ 
+     if (cmd & LOCK_UN)
+         f.l_type = F_UNLCK;
+     if (cmd & LOCK_SH)
+         f.l_type = F_RDLCK;
+     if (cmd & LOCK_EX)
+         f.l_type = F_WRLCK;
+ 
+     return fcntl(fd, (cmd & LOCK_NB) ? F_SETLK : F_SETLKW, &f);
+ }
+ 
+ #define flock(f,c)      emul_flock(f,c)
+ #endif
+ 
  extern char *volutil_PartitionName_r(int volid, char *buf, int buflen);
  int Testing=0;
  
***************
*** 869,886 ****
      ssize_t rc;
      int index;
  
-     if (!VALID_INO(ino)) return 0;
      /* there's no linktable yet. the salvager will create one later */
      if (h->fd_fd == -1 && fixup)
         return 1;
      namei_GetLCOffsetAndIndexFromIno(ino, &offset, &index);
  
      if (lockit) {
- #if defined(AFS_AIX_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_HPUX_ENV)
- 	if (lockf(h->fd_fd, F_LOCK, 0) < 0)
- #else
  	if (flock(h->fd_fd, LOCK_EX) < 0)
- #endif
  	    return -1;
      }
  
--- 898,910 ----
***************
*** 915,925 ****
  
    bad_getLinkByte:
      if (lockit)
- #if defined(AFS_AIX_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_HPUX_ENV)
- 	lockf(h->fd_fd, F_ULOCK, 0);
- #else
  	flock(h->fd_fd, LOCK_UN);
- #endif
      return -1;
  }
  
--- 939,945 ----
***************
*** 946,956 ****
  	return -1;
  
      /* Only one manipulates at a time. */
- #if defined(AFS_AIX_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_HPUX_ENV)
-     if (lockf(fdP->fd_fd, F_LOCK, 0) < 0) {
- #else
      if (flock(fdP->fd_fd, LOCK_EX) < 0) {
- #endif
  	FDH_REALLYCLOSE(fdP);
  	return -1;
      }
--- 966,972 ----
***************
*** 986,1005 ****
  	goto badGetFreeTag;
      }
      FDH_SYNC(fdP);
- #if defined(AFS_AIX_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_HPUX_ENV)
-     lockf(fdP->fd_fd, F_ULOCK, 0);
- #else
      flock(fdP->fd_fd, LOCK_UN);
- #endif
      FDH_REALLYCLOSE(fdP);
      return col;;
  
    badGetFreeTag:
- #if defined(AFS_AIX_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_HPUX_ENV)
-     lockf(fdP->fd_fd, F_ULOCK, 0);
- #else
      flock(fdP->fd_fd, LOCK_UN);
- #endif
      FDH_REALLYCLOSE(fdP);
      return -1;
  }
--- 1002,1013 ----
***************
*** 1022,1032 ****
      namei_GetLCOffsetAndIndexFromIno(ino, &offset, &index);
  
      if (!locked) {
- #if defined(AFS_AIX_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_HPUX_ENV)
- 	if (lockf(fdP->fd_fd, F_LOCK, 0) < 0) {
- #else
  	if (flock(fdP->fd_fd, LOCK_EX) < 0) {
- #endif
  	    return -1;
  	}
      }
--- 1030,1036 ----
***************
*** 1065,1075 ****
  
  
    bad_SetLinkCount:
- #if defined(AFS_AIX_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_HPUX_ENV)
-     lockf(fdP->fd_fd, F_ULOCK, 0);
- #else
      flock(fdP->fd_fd, LOCK_UN);
- #endif
  
      return code;
  }
--- 1069,1075 ----
