batch-commits-windows-20040529
authorJeffrey Altman <jaltman@mit.edu>
Sun, 30 May 2004 00:47:59 +0000 (00:47 +0000)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Sun, 30 May 2004 00:47:59 +0000 (00:47 +0000)
   * Fixed DNS lookups to work consistently throughout the OpenAFS
     product instead of just from within the afsd_service.exe

   * Added a runtime check to ensure that AFS Client Service SMB
     Server is accepting connections before attempting to mount
     global drives.

   * Read IP addresses for volume servers out of the CellServDB
     file if gethostbyname() on the hostname fails.

   * Fix getcellconfig() to populate both the Hostnames as well
     as IP addresses when loading cell data via DNS

   * Increase the Connection Dead Time to 50 from 20 seconds
     Increase the Hard Dead Time to 120 from 40 seconds
     (matches the Unix values)

   * Fixed an assertion validating the number of allocated NCBs

   * Fixed the build environment to consistently build for
     Windows 2000 and above.  (APPVER = 5.0)

   * Fixed rx_debug to properly validate the receipt in incoming
     data with select() and recvfrom().  Do not copy data out of
     the socket buffer unless success is indicated.

22 files changed:
src/WINNT/afsd/afsd_init.c
src/WINNT/afsd/afsd_service.c
src/WINNT/afsd/cm_config.c
src/WINNT/afsd/cm_conn.c
src/WINNT/afsd/cm_conn.h
src/WINNT/afsd/cm_dns.c
src/WINNT/afsd/cm_dns.h
src/WINNT/afsd/cm_scache.c
src/WINNT/afsd/smb.c
src/auth/NTMakefile
src/auth/cellconfig.c
src/bozo/NTMakefile
src/bucoord/NTMakefile
src/budb/NTMakefile
src/butc/NTMakefile
src/config/NTMakefile.i386_nt40
src/kauth/NTMakefile
src/ptserver/NTMakefile
src/tbutc/NTMakefile
src/update/NTMakefile
src/vlserver/NTMakefile
src/volser/NTMakefile

index 8f428fe..431f9be 100644 (file)
@@ -669,7 +669,7 @@ int afsd_InitCM(char **reasonP)
        }
 
 #ifdef AFS_AFSDB_ENV
-#if !defined(_WIN32_WINNT) || _WIN32_WINNT < 0x500
+#if !defined(_WIN32_WINNT) || (_WIN32_WINNT < 0x0500)
        if (cm_InitDNS(cm_dnsEnabled) == -1)
          cm_dnsEnabled = 0;  /* init failed, so deactivate */
        afsi_log("cm_InitDNS %d", cm_dnsEnabled);
index 4291b1c..09719c8 100644 (file)
@@ -307,6 +307,7 @@ afsd_ServiceControlHandlerEx(
  * Mount a drive into AFS if there global mapping
  */
 /* DEE Could check first if we are run as SYSTEM */
+#define MAX_RETRIES 30
 static void MountGlobalDrives()
 {
     char szAfsPath[_MAX_PATH];
@@ -314,7 +315,7 @@ static void MountGlobalDrives()
     DWORD dwResult;
     char szKeyName[256];
     HKEY hKey;
-    DWORD dwIndex = 0;
+    DWORD dwIndex = 0, dwRetry = 0;
     DWORD dwDriveSize;
     DWORD dwSubMountSize;
     char szSubMount[256];
@@ -326,7 +327,7 @@ static void MountGlobalDrives()
        if (dwResult != ERROR_SUCCESS)
         return;
 
-    while (1) {
+    while (dwRetry < MAX_RETRIES) {
         dwDriveSize = sizeof(szDriveToMapTo);
         dwSubMountSize = sizeof(szSubMount);
         dwResult = RegEnumValue(hKey, dwIndex++, szDriveToMapTo, &dwDriveSize, 0, &dwType, szSubMount, &dwSubMountSize);
@@ -338,6 +339,7 @@ static void MountGlobalDrives()
             }
         }
 
+        for ( ; dwRetry < MAX_RETRIES; dwRetry++)
                {
                    NETRESOURCE nr;
                    memset (&nr, 0x00, sizeof(NETRESOURCE));
@@ -352,8 +354,14 @@ static void MountGlobalDrives()
                    nr.dwUsage = RESOURCEUSAGE_CONNECTABLE;
 
                    dwResult = WNetAddConnection2(&nr,NULL,NULL,FALSE);
-               }
-        afsi_log("GlobalAutoMap of %s to %s %s", szDriveToMapTo, szSubMount, dwResult ? "succeeded" : "failed");
+            afsi_log("GlobalAutoMap of %s to %s %s (%d)", szDriveToMapTo, szSubMount, 
+                     (dwResult == NO_ERROR) ? "succeeded" : "failed", dwResult);
+            if (dwResult == NO_ERROR) {
+                break;
+            }
+            /* wait for smb server to come up */
+            Sleep((DWORD)1000 /* miliseconds */);              
+        }
     }        
 
     RegCloseKey(hKey);
index af94ede..ce6f925 100644 (file)
@@ -9,6 +9,7 @@
 
 #include <afs/param.h>
 #include <afs/stds.h>
+#include <afs/cellconfig.h>
 
 #ifndef DJGPP
 #include <windows.h>
 
 #include "cm_config.h"
 #ifdef AFS_AFSDB_ENV
-#if !defined(DJGPP) && defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x500
-#include <windns.h>
-#define DNSAPI_ENV
-#else
 #include "cm_dns.h"
-#endif
 #include <afs/afsint.h>
 #endif
 
@@ -165,9 +161,6 @@ long cm_SearchCellFile(char *cellNamep, char *newCellNamep,
     long code;
        int tracking = 1, partial = 0;
 #if defined(DJGPP) || defined(AFS_WIN95_ENV)
-       long ip_addr;
-    int c1, c2, c3, c4;
-    char aname[241];
     char *afsconf_path;
 #endif
 
@@ -334,23 +327,32 @@ long cm_SearchCellFile(char *cellNamep, char *newCellNamep,
                     foundCell = 1;
                                }
 #else
-                /* For DJGPP, we will read IP address instead
-                of name/comment field */
-                code = sscanf(lineBuffer, "%d.%d.%d.%d #%s",
-                               &c1, &c2, &c3, &c4, aname);
-                tp = (char *) &ip_addr;
-                *tp++ = c1;
-                *tp++ = c2;
-                *tp++ = c3;
-                *tp++ = c4;
-                memcpy(&vlSockAddr.sin_addr.s_addr, &ip_addr,
-                        sizeof(long));
-                vlSockAddr.sin_family = AF_INET;
-                /* sin_port supplied by connection code */
-                if (procp)
-                    (*procp)(rockp, &vlSockAddr, valuep);
-                foundCell = 1;
+                thp = 0;
 #endif /* !DJGPP */
+                if (!thp) {
+                    long ip_addr;
+                                       int c1, c2, c3, c4;
+                                       char aname[241] = "";                    
+                    
+                    /* Since there is no gethostbyname() data 
+                     * available we will read the IP address
+                     * stored in the CellServDB file
+                     */
+                    code = sscanf(lineBuffer, "%d.%d.%d.%d #%s",
+                                   &c1, &c2, &c3, &c4, aname);
+                    tp = (char *) &ip_addr;
+                    *tp++ = c1;
+                    *tp++ = c2;
+                    *tp++ = c3;
+                    *tp++ = c4;
+                    memcpy(&vlSockAddr.sin_addr.s_addr, &ip_addr,
+                            sizeof(long));
+                    vlSockAddr.sin_family = AF_INET;
+                    /* sin_port supplied by connection code */
+                    if (procp)
+                        (*procp)(rockp, &vlSockAddr, valuep);
+                    foundCell = 1;
+                }
             }
         }      /* a vldb line */
     }          /* while loop processing all lines */
@@ -363,9 +365,9 @@ long cm_SearchCellByDNS(char *cellNamep, char *newCellNamep, int *ttl,
                cm_configProc_t *procp, void *rockp)
 {
 #ifdef AFS_AFSDB_ENV
-#ifndef DNSAPI_ENV
     int rc;
-    int cellHosts[AFSMAXCELLHOSTS];
+    int  cellHostAddrs[AFSMAXCELLHOSTS];
+    char cellHostNames[AFSMAXCELLHOSTS][MAXHOSTCHARS];
     int numServers;
     int i;
     struct sockaddr_in vlSockAddr;
@@ -373,15 +375,15 @@ long cm_SearchCellByDNS(char *cellNamep, char *newCellNamep, int *ttl,
 #ifdef DEBUG
     DebugEvent_local("AFS SearchCellDNS-","Doing search for [%s]", cellNamep);
 #endif
-    rc = getAFSServer(cellNamep, cellHosts, &numServers, ttl);
+    rc = getAFSServer(cellNamep, cellHostAddrs, cellHostNames, &numServers, ttl);
     if (rc == 0 && numServers > 0) {     /* found the cell */
         for (i = 0; i < numServers; i++) {
-            memcpy(&vlSockAddr.sin_addr.s_addr, &cellHosts[i],
+            memcpy(&vlSockAddr.sin_addr.s_addr, &cellHostAddrs[i],
                    sizeof(long));
            vlSockAddr.sin_family = AF_INET;
            /* sin_port supplied by connection code */
            if (procp)
-          (*procp)(rockp, &vlSockAddr, NULL);
+          (*procp)(rockp, &vlSockAddr, cellHostNames[i]);
            if(newCellNamep)
           strcpy(newCellNamep,cellNamep);
         }
@@ -389,98 +391,6 @@ long cm_SearchCellByDNS(char *cellNamep, char *newCellNamep, int *ttl,
     }
     else
        return -1;  /* not found */
-#else /* DNSAPI_ENV */
-       PDNS_RECORD pDnsCell, pDnsIter, pDnsVol,pDnsVolIter, pDnsCIter;
-       LPSTR vlServers[AFSMAXCELLHOSTS];
-       IP4_ADDRESS vlAddrs[AFSMAXCELLHOSTS];
-       WORD nvlServers;
-       DWORD wttl, i;
-       BOOL success;
-    struct sockaddr_in vlSockAddr;
-
-       success = FALSE;
-
-#ifdef DEBUG
-    DebugEvent_local("AFS SearchCellDNS-","Doing search for [%s]", cellNamep);
-#endif 
-
-    /* query the AFSDB records of cell */
-       if(DnsQuery_A(cellNamep, DNS_TYPE_AFSDB, DNS_QUERY_STANDARD, NULL, &pDnsCell, NULL) == ERROR_SUCCESS) {
-
-               memset((void*) &vlSockAddr, 0, sizeof(vlSockAddr));
-               
-               nvlServers = 0; wttl = 0;
-
-               /* go through the returned records */
-               for(pDnsIter = pDnsCell;pDnsIter; pDnsIter = pDnsIter->pNext) {
-                       /* if we find an AFSDB record with Preference set to 1, we found a volserver */
-                       if(pDnsIter->wType == DNS_TYPE_AFSDB && pDnsIter->Data.Afsdb.wPreference == 1) {
-                               vlServers[nvlServers++] = pDnsIter->Data.Afsdb.pNameExchange;
-                               if(!wttl) wttl = pDnsIter->dwTtl;
-                               if(nvlServers == AFSMAXCELLHOSTS) break;
-                       }
-               }
-
-               for(i=0;i<nvlServers;i++) vlAddrs[i] = 0;
-
-               /* now check if there are any A records in the results */
-               for(pDnsIter = pDnsCell; pDnsIter; pDnsIter = pDnsIter->pNext) {
-                       if(pDnsIter->wType == DNS_TYPE_A)
-                               /* check if its for one of the volservers */
-                               for(i=0;i<nvlServers;i++)
-                                       if(stricmp(pDnsIter->pName, vlServers[i]) == 0)
-                                               vlAddrs[i] = pDnsIter->Data.A.IpAddress;
-               }
-
-               for(i=0;i<nvlServers;i++) {
-                       /* if we don't have an IP yet, then we should try resolving the volserver hostname
-                          in a separate query. */
-                       if(!vlAddrs[i]) {
-                               if(DnsQuery_A(vlServers[i], DNS_TYPE_A, DNS_QUERY_STANDARD, NULL, &pDnsVol, NULL) == ERROR_SUCCESS) {
-                                       for(pDnsVolIter = pDnsVol; pDnsVolIter; pDnsVolIter=pDnsVolIter->pNext) {
-                                               /* if we get an A record, keep it */
-                                               if(pDnsVolIter->wType == DNS_TYPE_A && stricmp(vlServers[i], pDnsVolIter->pName)==0) {
-                                                       vlAddrs[i] = pDnsVolIter->Data.A.IpAddress;
-                                                       break;
-                                               }
-                                               /* if we get a CNAME, look for a corresponding A record */
-                                               if(pDnsVolIter->wType == DNS_TYPE_CNAME && stricmp(vlServers[i], pDnsVolIter->pName)==0) {
-                                                       for(pDnsCIter=pDnsVolIter; pDnsCIter; pDnsCIter=pDnsCIter->pNext) {
-                                                               if(pDnsCIter->wType == DNS_TYPE_A && stricmp(pDnsVolIter->Data.CNAME.pNameHost, pDnsCIter->pName)==0) {
-                                                                       vlAddrs[i] = pDnsCIter->Data.A.IpAddress;
-                                                                       break;
-                                                               }
-                                                       }
-                                                       if(vlAddrs[i]) break;
-                                                       /* TODO: if the additional section is missing, then do another lookup for the CNAME */
-                                               }
-                                       }
-                                       /* we are done with the volserver lookup */
-                                       DnsRecordListFree(pDnsVol, DnsFreeRecordListDeep);
-                               }
-                       }
-
-                       /* if we found a volserver, then add it */
-                       if(vlAddrs[i]) {
-                               vlSockAddr.sin_family = AF_INET;
-                               vlSockAddr.sin_addr.s_addr = vlAddrs[i];
-                               if(procp)
-                                       (*procp)(rockp, &vlSockAddr, vlServers[i]);
-                               success = TRUE;
-                       }
-               }
-
-               DnsRecordListFree(pDnsCell, DnsFreeRecordListDeep);
-       }
-
-       if(!success) return -1;
-       else {
-               strcpy(newCellNamep, cellNamep);
-               if(ttl) *ttl = (int) wttl;
-               return 0;
-       }
-
-#endif /* DNSAPI_ENV */
 #else
        return -1;  /* not found */
 #endif /* AFS_AFSDB_ENV */
index 06aceb1..29d23b6 100644 (file)
@@ -164,7 +164,7 @@ cm_Analyze(cm_conn_t *connp, cm_user_t *userp, cm_req_t *reqp,
        if (reqp->flags & CM_REQ_NORETRY)
                goto out;
 
-       /* if timeout - check that is did not exceed the SMB timeout
+       /* if timeout - check that it did not exceed the SMB timeout
           and retry */
        if (errorCode == CM_ERROR_TIMEDOUT)
     {
@@ -389,12 +389,16 @@ long cm_ConnByMServers(cm_serverRef_t *serversp, cm_user_t *usersp,
                        firstError = CM_ERROR_ALLBUSY;
                else if (someOffline) 
                        firstError = CM_ERROR_ALLOFFLINE;
+#ifndef COMMENT
                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;
+#else
+        firstError = CM_ERROR_TIMEDOUT;
+#endif /* COMMENT */
        }
        osi_Log1(afsd_logp, "cm_ConnByMServers returning %x", firstError);
     return firstError;
index 4c9a42f..7c22ec4 100644 (file)
@@ -11,8 +11,8 @@
 #define __CM_CONN_H_ENV__ 1
 
 #define        CM_CONN_DEFAULTRDRTIMEOUT       45
-#define CM_CONN_CONNDEADTIME           20
-#define CM_CONN_HARDDEADTIME            40
+#define CM_CONN_CONNDEADTIME           50
+#define CM_CONN_HARDDEADTIME        120
 
 typedef struct cm_conn {
        struct cm_conn *nextp;          /* locked by cm_connLock */
index e817fc2..14fa426 100644 (file)
@@ -10,6 +10,7 @@
 
 #include <afs/param.h>
 #include <afs/stds.h>
+#include <afs/cellconfig.h>
 #ifndef DJGPP
 #include <windows.h>
 #include <winsock2.h>
 #include "cm_dns.h"
 #include <lwp.h>
 #include <afs/afsint.h>
+#if defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0500)
+#include <windns.h>
+#define DNSAPI_ENV
+#endif
 
 /*extern void afsi_log(char *pattern, ...);*/
 
@@ -40,6 +45,7 @@ void DNSlowerCase(char *str)
 
 int cm_InitDNS(int enabled)
 {
+#ifndef DNSAPI_ENV
   char configpath[100];
   int len;
   int code;
@@ -79,11 +85,12 @@ int cm_InitDNS(int enabled)
     }
     else fprintf(stderr, "Found DNS server %s\n", dns_addr);
   }
-
+#endif /* DNSAPI_ENV */
   cm_dnsEnabled = 1;
   return 0;
 }
 
+#ifndef DNSAPI_ENV
 SOCKADDR_IN setSockAddr(char *server, int port)
 {
   SOCKADDR_IN sockAddr;                     
@@ -481,7 +488,7 @@ void printReplyBuffer_AFSDB(PDNS_HDR replyBuff)
 
 };
 
-void processReplyBuffer_AFSDB(SOCKET commSock, PDNS_HDR replyBuff, int *cellHosts, int *numServers, int *ttl)
+void processReplyBuffer_AFSDB(SOCKET commSock, PDNS_HDR replyBuff, int *cellHostAddrs, char cellHostNames[][MAXHOSTCHARS], int *numServers, int *ttl)
   /*PAFS_SRV_LIST (srvList)*/
 {
   u_char *ptr = (u_char *) replyBuff;
@@ -531,7 +538,9 @@ void processReplyBuffer_AFSDB(SOCKET commSock, PDNS_HDR replyBuff, int *cellHost
 #ifdef DEBUG
       fprintf(stderr, "processRep_AFSDB: resolved name %s to addr %x\n", hostName, addr);
 #endif /* DEBUG */
-      memcpy(&cellHosts[srvCount], &addr.s_addr, sizeof(addr.s_addr));
+      memcpy(&cellHostAddrs[srvCount], &addr.s_addr, sizeof(addr.s_addr));
+         strncpy(cellHostNames[srvCount], hostName, MAXCELLCHARS);
+         cellHostNames[srvCount][MAXCELLCHARS-1] = '\0';
       srvCount++;
     }
     else {
@@ -582,9 +591,46 @@ u_char * processReplyBuffer_Addr(PDNS_HDR replyBuff)
 
 };
 
-int getAFSServer(char *cellName, int *cellHosts, int *numServers, int *ttl)
+int DNSgetAddr(SOCKET commSock, char *hostName, struct in_addr *iNet)
+{
+  /* Variables for DNS message parsing and creation */
+  PDNS_HDR  pDNShdr;
+
+  SOCKADDR_IN sockAddr;
+  char buffer[BUFSIZE];
+  u_char *addr;
+  u_long *aPtr;
+  int rc;
+
+  /**********************
+   * Get a DGRAM socket *
+   **********************/
+  
+  sockAddr = setSockAddr(dns_addr, DNS_PORT);
+  
+  rc = send_DNS_Addr_Query(hostName,commSock,sockAddr, buffer);
+  if (rc < 0) return rc;
+  pDNShdr = get_DNS_Response(commSock,sockAddr, buffer);
+  if (pDNShdr == NULL)
+    return -1;
+  
+  addr = processReplyBuffer_Addr(pDNShdr);
+  if (addr == 0)
+    return -1;
+
+  aPtr = (u_long *) addr;
+
+  iNet->s_addr = *aPtr;
+
+  return(0);
+}
+#endif /* DNSAPI_ENV */
+
+int getAFSServer(char *cellName, int *cellHostAddrs, char cellHostNames[][MAXHOSTCHARS], 
+                 int *numServers, int *ttl)
 {
-  /*static AFS_SRV_LIST srvList;  
+#ifndef DNSAPI_ENV
+   /*static AFS_SRV_LIST srvList;
     static int ans = 0;*/
   SOCKET commSock;
   SOCKADDR_IN sockAddr;
@@ -596,7 +642,7 @@ int getAFSServer(char *cellName, int *cellHosts, int *numServers, int *ttl)
   fprintf(stderr, "getAFSServer: cell %s, cm_dnsEnabled=%d\n", cellName, cm_dnsEnabled);
 #endif
 
-#if !defined(_WIN32_WINNT) || _WIN32_WINNT < 0x500
+#if !defined(_WIN32_WINNT) || (_WIN32_WINNT < 0x0500)
   if (cm_dnsEnabled == -1) { /* not yet initialized, eg when called by klog */
     cm_InitDNS(1);    /* assume enabled */
   }
@@ -637,7 +683,7 @@ int getAFSServer(char *cellName, int *cellHosts, int *numServers, int *ttl)
   
   /*printReplyBuffer_AFSDB(pDNShdr);*/
   if (pDNShdr)
-    processReplyBuffer_AFSDB(commSock, pDNShdr, cellHosts, numServers, ttl);
+    processReplyBuffer_AFSDB(commSock, pDNShdr, cellHostAddrs, cellHostNames, numServers, ttl);
   else
     *numServers = 0;
   
@@ -647,40 +693,83 @@ int getAFSServer(char *cellName, int *cellHosts, int *numServers, int *ttl)
 
   else
     return 0;
-}
-
-int DNSgetAddr(SOCKET commSock, char *hostName, struct in_addr *iNet)
-{
-  /* Variables for DNS message parsing and creation */
-  PDNS_HDR  pDNShdr;
-
-  SOCKADDR_IN sockAddr;
-  char buffer[BUFSIZE];
-  u_char *addr;
-  u_long *aPtr;
-  int rc;
-
-  /**********************
-   * Get a DGRAM socket *
-   **********************/
-  
-  sockAddr = setSockAddr(dns_addr, DNS_PORT);
-  
-  rc = send_DNS_Addr_Query(hostName,commSock,sockAddr, buffer);
-  if (rc < 0) return rc;
-  pDNShdr = get_DNS_Response(commSock,sockAddr, buffer);
-  if (pDNShdr == NULL)
-    return -1;
-  
-  addr = processReplyBuffer_Addr(pDNShdr);
-  if (addr == 0)
-    return -1;
-
-  aPtr = (u_long *) addr;
-
-  iNet->s_addr = *aPtr;
+#else /* DNSAPI_ENV */
+       PDNS_RECORD pDnsCell, pDnsIter, pDnsVol,pDnsVolIter, pDnsCIter;
+       DWORD i;
+    struct sockaddr_in vlSockAddr;
+
+    /* query the AFSDB records of cell */
+       if (DnsQuery_A(cellName, DNS_TYPE_AFSDB, DNS_QUERY_STANDARD, NULL, &pDnsCell, NULL) == ERROR_SUCCESS) {
+
+               memset((void*) &vlSockAddr, 0, sizeof(vlSockAddr));
+               
+               *numServers = 0; 
+        *ttl = 0;
+
+               /* go through the returned records */
+               for (pDnsIter = pDnsCell;pDnsIter; pDnsIter = pDnsIter->pNext) {
+                       /* if we find an AFSDB record with Preference set to 1, we found a volserver */
+                       if (pDnsIter->wType == DNS_TYPE_AFSDB && pDnsIter->Data.Afsdb.wPreference == 1) {
+                               strncpy(cellHostNames[*numServers], pDnsIter->Data.Afsdb.pNameExchange, MAXHOSTCHARS);
+                cellHostNames[*numServers][MAXHOSTCHARS-1]='\0';
+                               (*numServers)++;
+                
+                               if (!*ttl) 
+                    *ttl = pDnsIter->dwTtl;
+                               if (*numServers == AFSMAXCELLHOSTS) 
+                    break;
+                       }
+               }
+
+               for (i=0;i<*numServers;i++) 
+            cellHostAddrs[i] = 0;
+
+               /* now check if there are any A records in the results */
+               for (pDnsIter = pDnsCell; pDnsIter; pDnsIter = pDnsIter->pNext) {
+                       if(pDnsIter->wType == DNS_TYPE_A)
+                               /* check if its for one of the volservers */
+                               for (i=0;i<*numServers;i++)
+                                       if(stricmp(pDnsIter->pName, cellHostNames[i]) == 0)
+                                               cellHostAddrs[i] = pDnsIter->Data.A.IpAddress;
+               }
+
+               for (i=0;i<*numServers;i++) {
+                       /* if we don't have an IP yet, then we should try resolving the volserver hostname
+                          in a separate query. */
+                       if (!cellHostAddrs[i]) {
+                               if (DnsQuery_A(cellHostNames[i], DNS_TYPE_A, DNS_QUERY_STANDARD, NULL, &pDnsVol, NULL) == ERROR_SUCCESS) {
+                                       for (pDnsVolIter = pDnsVol; pDnsVolIter; pDnsVolIter=pDnsVolIter->pNext) {
+                                               /* if we get an A record, keep it */
+                                               if (pDnsVolIter->wType == DNS_TYPE_A && stricmp(cellHostNames[i], pDnsVolIter->pName)==0) {
+                                                       cellHostAddrs[i] = pDnsVolIter->Data.A.IpAddress;
+                                                       break;
+                                               }
+                                               /* if we get a CNAME, look for a corresponding A record */
+                                               if (pDnsVolIter->wType == DNS_TYPE_CNAME && stricmp(cellHostNames[i], pDnsVolIter->pName)==0) {
+                                                       for (pDnsCIter=pDnsVolIter; pDnsCIter; pDnsCIter=pDnsCIter->pNext) {
+                                                               if (pDnsCIter->wType == DNS_TYPE_A && stricmp(pDnsVolIter->Data.CNAME.pNameHost, pDnsCIter->pName)==0) {
+                                                                       cellHostAddrs[i] = pDnsCIter->Data.A.IpAddress;
+                                                                       break;
+                                                               }
+                                                       }
+                                                       if (cellHostAddrs[i]) 
+                                break;
+                                                       /* TODO: if the additional section is missing, then do another lookup for the CNAME */
+                                               }
+                                       }
+                                       /* we are done with the volserver lookup */
+                                       DnsRecordListFree(pDnsVol, DnsFreeRecordListDeep);
+                               }
+                       }
+               }
+               DnsRecordListFree(pDnsCell, DnsFreeRecordListDeep);
+       }
 
-  return(0);
+    if ( *numServers > 0 )
+        return 0;
+    else
+        return -1;
+#endif /* DNSAPI_ENV */
 }
 
 #endif /* AFS_AFSDB_ENV */
index 1e5d28c..6bfa381 100644 (file)
@@ -13,7 +13,7 @@
 
 /* this function will continue to return cell server
    names for the given cell, ending in null */
-int getAFSServer(char *cellname, int *cellHosts, int *numServers, int *ttl);
+int getAFSServer(char *cellname, int *cellHostAddrs, char cellHostNames[][MAXHOSTCHARS], int *numServers, int *ttl);
 
 /* a supplement for the DJGPP gethostbyname ... which 
    never bothers calling a DNS server ... so this function
index ced5db1..587e381 100644 (file)
@@ -646,10 +646,10 @@ sleep:
                osi_Log1(afsd_logp, "CM SyncOp sleeping scp %x", (long) scp);
                scp->flags |= CM_SCACHEFLAG_WAITING;
                if (bufLocked) lock_ReleaseMutex(&bufp->mx);
-                osi_SleepM((long) &scp->flags, &scp->mx);
-                osi_Log0(afsd_logp, "CM SyncOp woke!");
-               if (bufLocked) lock_ObtainMutex(&bufp->mx);
-                lock_ObtainMutex(&scp->mx);
+        osi_SleepM((long) &scp->flags, &scp->mx);
+        osi_Log0(afsd_logp, "CM SyncOp woke!");
+        if (bufLocked) lock_ObtainMutex(&bufp->mx);
+        lock_ObtainMutex(&scp->mx);
         } /* big while loop */
         
         /* now, update the recorded state for RPC-type calls */
index 48d4074..c6b2d6e 100644 (file)
@@ -2005,6 +2005,7 @@ void smb_MapNTError(long code, unsigned long *NTStatusp)
        unsigned long NTStatus;
 
        /* map CM_ERROR_* errors to NT 32-bit status codes */
+    /* NT Status codes are listed in ntstatus.h not winerror.h */
        if (code == CM_ERROR_NOSUCHCELL) {
                NTStatus = 0xC000000FL; /* No such file */
        }
@@ -2100,11 +2101,7 @@ void smb_MapNTError(long code, unsigned long *NTStatusp)
                NTStatus = 0xC0000023L; /* Buffer too small */
        }
     else if (code == CM_ERROR_AMBIGUOUS_FILENAME) {
-#ifdef COMMENT
-               NTStatus = 0xC000049CL; /* Potential file found */
-#else
                NTStatus = 0xC0000035L; /* Object name collision */
-#endif
     }
        else {
                NTStatus = 0xC0982001L; /* SMB non-specific error */
@@ -6693,7 +6690,8 @@ void smb_Listener(void *parmp)
          * we run out.
          */
 
-        osi_assert(i < Sessionmax && numNCBs < NCBmax - 1);
+        osi_assert(i < Sessionmax);
+        osi_assert(numNCBs < NCBmax);
 
                LSNs[i] = ncbp->ncb_lsn;
                lanas[i] = ncbp->ncb_lana_num;
index 0a3d3a0..87bd403 100644 (file)
@@ -84,7 +84,7 @@ EXELIBS =\
 
 
 $(SETKEY_EXEFILE): $(SETKEY_EXEOBJS) $(EXELIBS)
-       $(EXECONLINK)
+       $(EXECONLINK) dnsapi.lib
        $(EXEPREP) 
 
 # build copyauth
index e4978d1..aad9bbd 100644 (file)
@@ -25,9 +25,6 @@ RCSID
 #include <sys/utime.h>
 #include <io.h>
 #include <WINNT/afssw.h>
-#ifdef AFS_AFSDB_ENV
-#include <cm_dns.h>
-#endif /* AFS_AFSDB_ENV */
 #else
 #include <sys/socket.h>
 #include <netinet/in.h>
@@ -64,7 +61,12 @@ RCSID
 #include <afs/afsutil.h>
 #include "cellconfig.h"
 #include "keys.h"
-
+#ifdef AFS_NT40_ENV
+#ifdef AFS_AFSDB_ENV
+/* cm_dns.h depends on cellconfig.h */
+#include <cm_dns.h>
+#endif /* AFS_AFSDB_ENV */
+#endif
 static struct afsconf_servPair serviceTable[] = {
     {"afs", 7000,},
     {"afscb", 7001,},
@@ -792,14 +794,15 @@ afsconf_GetAfsdbInfo(char *acellName, char *aservice,
     register afs_int32 i;
     int tservice;
     struct afsconf_entry DNSce;
-    afs_int32 cellHosts[AFSMAXCELLHOSTS];
+    afs_int32 cellHostAddrs[AFSMAXCELLHOSTS];
+       char      cellHostNames[AFSMAXCELLHOSTS][MAXHOSTCHARS];
     int numServers;
     int rc;
     int ttl;
 
     DNSce.cellInfo.numServers = 0;
     DNSce.next = NULL;
-    rc = getAFSServer(acellName, cellHosts, &numServers, &ttl);
+    rc = getAFSServer(acellName, cellHostAddrs, cellHostNames, &numServers, &ttl);
     /* ignore the ttl here since this code is only called by transitory programs
      * like klog, etc. */
     if (rc < 0)
@@ -808,8 +811,9 @@ afsconf_GetAfsdbInfo(char *acellName, char *aservice,
        return -1;
 
     for (i = 0; i < numServers; i++) {
-       memcpy(&acellInfo->hostAddr[i].sin_addr.s_addr, &cellHosts[i],
+       memcpy(&acellInfo->hostAddr[i].sin_addr.s_addr, &cellHostAddrs[i],
               sizeof(long));
+       memcpy(acellInfo->hostName[i], cellHostNames[i], MAXHOSTCHARS);
        acellInfo->hostAddr[i].sin_family = AF_INET;
 
        /* sin_port supplied by connection code */
index e59bcd2..8d7b8a7 100644 (file)
@@ -70,7 +70,7 @@ BOSSERVER_EXELIBS =\
        $(DESTDIR)\lib\cm_dns.obj
 
 $(BOSSERVER_EXEFILE): $(BOSSERVER_EXEOBJS) $(BOSSERVER_EXELIBS)
-       $(EXECONLINK)
+       $(EXECONLINK) dnsapi.lib
        $(EXEPREP)
 
 
@@ -106,7 +106,7 @@ BOS_EXELIBS =\
 
 
 $(RS_BOS_EXEFILE): $(BOS_EXEOBJS) $(BOS_EXELIBS)
-       $(EXECONLINK)
+       $(EXECONLINK) dnsapi.lib
        $(EXEPREP)
 
 $(CL_BOS_EXEFILE): $(RS_BOS_EXEFILE)
index a055a7c..71bf0ce 100644 (file)
@@ -90,7 +90,7 @@ EXELIBS =\
        
 
 $(EXEFILE): $(EXEOBJS) $(EXELIBS)
-       $(EXECONLINK)
+       $(EXECONLINK) dnsapi.lib
        $(EXEPREP)
 
 
index 96a3c4f..e9b7160 100644 (file)
@@ -80,7 +80,7 @@ EXELIBS =\
 
 
 $(EXEFILE): $(EXEOBJS)  $(EXELIBS)
-       $(EXECONLINK)
+       $(EXECONLINK) dnsapi.lib
        $(EXEPREP) 
 
 ############################################################################
index 5f466a2..a644f9c 100644 (file)
@@ -53,7 +53,7 @@ EXELIBS =\
        $(DESTDIR)\lib\cm_dns.obj
 
 $(EXEFILE): $(EXEOBJS) $(EXELIBS)
-       $(EXECONLINK)
+       $(EXECONLINK) dnsapi.lib
        $(EXEPREP)
 
 ############################################################################
index b820297..51f953a 100644 (file)
@@ -79,7 +79,7 @@ LIB = $(AFSDEV_LIB)
 #define used in WinNT/2000 installation and program version display
 AFSPRODUCT_VER_MAJOR=1
 AFSPRODUCT_VER_MINOR=3
-AFSPRODUCT_VER_PATCH=6400
+AFSPRODUCT_VER_PATCH=6410
 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)
@@ -166,7 +166,7 @@ OUT=$(OJT)\$(RELDIR)
 # !ENDIF
 
 !IF ("$(APPVER)" == "")
-APPVER=4.0
+APPVER=5.0
 !ENDIF
 
 
@@ -215,6 +215,10 @@ afscdefs =\
     -DAFS_FREELANCE_CLIENT \
     -DAFS_64BIT_ENV \
        -DAFS_64BIT_CLIENT \
+#    We would like to be able to define these but currently cannot
+#    -DRX_ENABLE_LOCKS \
+#    -DUSE_PTHREADS \
+#    -DAFS_PTHREAD_ENV \
         $(AFSDEV_AUXCDEFINES)
 
 # Compiler switches (except include paths and preprocessor defines)
index 447bf4d..d89b5a8 100644 (file)
@@ -125,7 +125,7 @@ KASERVER_EXELIBS =\
        $(DESTDIR)\lib\afs\afsprocmgmt.lib
 
 $(KASERVER): $(KASERVER_OBJS) $(AFSLIBS) $(KASERVER_EXELIBS)
-       $(EXECONLINK)
+       $(EXECONLINK) dnsapi.lib
        $(EXEPREP) 
 
 #build $(OUT)\kadatabase.obj
@@ -149,7 +149,7 @@ KAS_OBJS =\
        $(OUT)\kas.res
        
 $(KAS): $(KAS_OBJS) $(AFSLIBS) $(KAUTH_LIBFILE) $(TOKENLIB)
-       $(EXECONLINK)
+       $(EXECONLINK) dnsapi.lib
        $(EXEPREP) 
 
 ########### Misc Exes #######################################################
@@ -162,20 +162,20 @@ KPASSWD_OBJS =\
        $(OUT)\kpasswd.res
 
 $(KPASSWD_EXEFILE): $(KPASSWD_OBJS) $(AFSLIBS) $(KAUTH_LIBFILE) $(TOKENLIB)
-       $(EXECONLINK)
+       $(EXECONLINK) dnsapi.lib
        $(EXEPREP)
 
 #kpwvalid.exe
 $(OUT)\kpwvalid.exe: $(OUT)\kpwvalid.obj $(AFSLIBS) $(KAUTH_LIBFILE)
-       $(EXECONLINK)
+       $(EXECONLINK) dnsapi.lib
 
 #kdb.exe - Not implemented for NT - because dbm not available on NT
 #kdb.exe: $(OUT)\kdb.obj $(AFSLIBS) $(KAUTH_LIBFILE) 
-#      $(EXECONLINK)
+#      $(EXECONLINK) dnsapi.lib
 
 #rebuild.exe 
 $(OUT)\rebuild.exe: $(OUT)\rebuild.obj $(OUT)\kautils.obj $(AFSLIBS) 
-       $(EXECONLINK)
+       $(EXECONLINK) dnsapi.lib
 
 ############################################################################
 # Definitions for generating versioninfo resources
index 28f42bc..ae2c058 100644 (file)
@@ -73,7 +73,7 @@ PTSERVER_EXELIBS =$(PTSERVER_EXELIBS) $(DESTDIR)\lib\afs\afsprocmgmt.lib
 !ENDIF
 
 $(PTSERVER): $(PTSERVER_EXEOBJS) $(RXKADOBJS) $(PTSERVER_EXELIBS)
-       $(EXECONLINK)
+       $(EXECONLINK) dnsapi.lib
        $(EXEPREP) 
 
 
@@ -104,7 +104,7 @@ PTS_EXELIBS =\
        $(DESTDIR)\lib\cm_dns.obj
 
 $(PTS): $(PTS_EXEOBJS) $(PTS_EXELIBS) 
-       $(EXECONLINK)
+       $(EXECONLINK) dnsapi.lib
        $(EXEPREP) 
 
 
@@ -180,16 +180,16 @@ clean::
 TEST_LIBS = $(PTS_EXELIBS)
 
 $(OUT)\readgroup.exe: $(OUT)\readgroup.obj $(LIBFILE) $(TEST_LIBS)
-       $(EXECONLINK)
+       $(EXECONLINK) dnsapi.lib
 
 $(OUT)\readpwd.exe: $(OUT)\readpwd.obj $(LIBFILE) $(TEST_LIBS)
-       $(EXECONLINK)
+       $(EXECONLINK) dnsapi.lib
 
 $(OUT)\testpt.exe: $(OUT)\testpt.obj $(LIBFILE) $(TEST_LIBS)
-       $(EXECONLINK)
+       $(EXECONLINK) dnsapi.lib
 
 $(OUT)\db_verify.exe: $(OUT)\db_verify.obj $(OUT)\pterror.obj $(OUT)\display.obj $(LIBFILE) $(TEST_LIBS)
-       $(EXECONLINK)
+       $(EXECONLINK) dnsapi.lib
 
 mkdir:
        
index f8bd979..7790594 100644 (file)
@@ -111,7 +111,7 @@ BUTCLIBS=$(DESTDIR)\lib\afs\afsbudb.lib  \
 #----------------------------------------------- BUTC
 
 $(BUTCEXE): $(BUTCOBJS) $(BUTCLIBS)
-       $(EXECONLINK)
+       $(EXECONLINK) dnsapi.lib
        $(EXEPREP)
 
 .c.$(OUT)\obj:
index 9d92ca2..5571383 100644 (file)
@@ -42,7 +42,7 @@ USVR_OBJS = \
        $(OUT)\upserver.res
 
 $(UPSERVER):  $(USVR_OBJS) $(LIBS)
-       $(EXECONLINK)
+       $(EXECONLINK) dnsapi.lib
        $(EXEPREP) 
 
 ############################################################################
@@ -57,7 +57,7 @@ UCLNT_OBJS = \
        $(OUT)\upclient.res
 
 $(UPCLIENT):  $(UCLNT_OBJS)  $(LIBS)
-       $(EXECONLINK)
+       $(EXECONLINK) dnsapi.lib
        $(EXEPREP) 
 
 ############################################################################
index b0dfcb1..86f6a3e 100644 (file)
@@ -89,7 +89,7 @@ VLSERVER_EXECLIBS = \
 
        
 $(VLSERVER): $(VLSERVER_EXEOBJS) $(LIBFILE) $(VLSERVER_EXECLIBS)
-       $(EXECONLINK)
+       $(EXECONLINK) dnsapi.lib
        $(EXEPREP) 
 
 ############################################################################
@@ -135,7 +135,7 @@ VLCLIENT_LIBS = \
        $(DESTDIR)\lib\afs\afspioctl.lib
 
 $(OUT)\vlclient.exe: $(OUT)\vlclient.obj  $(LIBFILE) $(VLSERVER_EXECLIBS) $(VLCLIENT_LIBS)
-       $(EXECONLINK)
+       $(EXECONLINK) dnsapi.lib
 
 
 ############################################################################
index ff0e914..e86eb8d 100644 (file)
@@ -93,7 +93,7 @@ VOLSERVER_EXELIBS = \
        $(DESTDIR)\lib\afs\afsprocmgmt.lib
 
 $(VOLSERVER_EXEFILE): $(VOLSERVER_EXEOBJS) $(VOLSERVER_EXELIBS) $(EXEC_LIBS)
-       $(EXECONLINK)
+       $(EXECONLINK) dnsapi.lib
        $(EXEPREP) 
 
 ############################################################################
@@ -118,7 +118,7 @@ VOS_EXELIBS = \
        $(DESTDIR)\lib\afs\afspioctl.lib
 
 $(RS_VOS_EXEFILE): $(VOS_EXEOBJS) $(VOS_EXELIBS) $(EXEC_LIBS)
-       $(EXECONLINK)
+       $(EXECONLINK) dnsapi.lib
        $(EXEPREP) 
 
 $(CL_VOS_EXEFILE): $(RS_VOS_EXEFILE)