}
p = strrchr(name, '.');
if (p) {
+ /* as of 2009-09-04 these are not valid ICANN ccTLDs */
if (i == 1 &&
(!cm_stricmp_utf8N(p,".dll") ||
!cm_stricmp_utf8N(p,".exe") ||
valuep[strlen(valuep) - 1] = '\0';
if (inRightCell) {
+ char hostname[256];
+ int i, isClone = 0;
+
+ isClone = (lineBuffer[0] == '[');
+
+ /* copy just the first word and ignore trailing white space */
+ for ( i=0; valuep[i] && !isspace(valuep[i]) && i<sizeof(hostname); i++)
+ hostname[i] = valuep[i];
+ hostname[i] = '\0';
+
/* add the server to the VLDB list */
WSASetLastError(0);
- thp = gethostbyname(valuep);
+ thp = gethostbyname(hostname);
#ifdef CELLSERV_DEBUG
osi_Log3(afsd_logp,"cm_searchfile inRightCell thp[%p], valuep[%s], WSAGetLastError[%d]",
- thp, osi_LogSaveString(afsd_logp,valuep), WSAGetLastError());
+ thp, osi_LogSaveString(afsd_logp,hostname), WSAGetLastError());
#endif
if (thp) {
- memcpy(&vlSockAddr.sin_addr.s_addr, thp->h_addr,
- sizeof(long));
- vlSockAddr.sin_family = AF_INET;
- /* sin_port supplied by connection code */
- if (procp)
- (*procp)(rockp, &vlSockAddr, valuep, 0);
- foundCell = 1;
+ int foundAddr = 0;
+ for (i=0 ; thp->h_addr_list[i]; i++) {
+ if (thp->h_addrtype != AF_INET)
+ continue;
+ memcpy(&vlSockAddr.sin_addr.s_addr, thp->h_addr_list[i],
+ sizeof(long));
+ vlSockAddr.sin_family = AF_INET;
+ /* sin_port supplied by connection code */
+ if (procp)
+ (*procp)(rockp, &vlSockAddr, hostname, 0);
+ foundAddr = 1;
+ }
+ /* if we didn't find a valid address, force the use of the specified one */
+ if (!foundAddr)
+ thp = NULL;
}
if (!thp) {
afs_uint32 ip_addr;
* available we will read the IP address
* stored in the CellServDB file
*/
- code = sscanf(lineBuffer, " %u.%u.%u.%u",
- &c1, &c2, &c3, &c4);
+ if (isClone)
+ code = sscanf(lineBuffer, "[%u.%u.%u.%u]",
+ &c1, &c2, &c3, &c4);
+ else
+ code = sscanf(lineBuffer, " %u.%u.%u.%u",
+ &c1, &c2, &c3, &c4);
if (code == 4 && c1<256 && c2<256 && c3<256 && c4<256) {
tp = (unsigned char *) &ip_addr;
*tp++ = c1;
vlSockAddr.sin_family = AF_INET;
/* sin_port supplied by connection code */
if (procp)
- (*procp)(rockp, &vlSockAddr, valuep, 0);
- foundCell = 1;
+ (*procp)(rockp, &vlSockAddr, hostname, 0);
}
}
+ foundCell = 1;
}
} /* a vldb line */
} /* while loop processing all lines */
}
if ( !bFound ) {
- if (newCellNamep)
- newCellNamep[0] = '\0';
RegCloseKey(hkCellServDB);
return CM_ERROR_NOSUCHCELL;
}
#ifdef CELLSERV_DEBUG
osi_Log1(afsd_logp,"SearchCellDNS-Doing search for [%s]", osi_LogSaveString(afsd_logp,cellNamep));
#endif
- if ( IsWindowsModule(cellNamep) )
+ /*
+ * Do not perform a DNS lookup if the name is
+ * either a well-known Windows DLL or directory,
+ * or if the name does not contain a top-level
+ * domain, or if the file prefix is the afs pioctl
+ * file name.
+ */
+ if ( IsWindowsModule(cellNamep) ||
+ cm_FsStrChr(cellNamep, '.') == NULL ||
+ strncasecmp(cellNamep, CM_IOCTL_FILENAME_NOSLASH, strlen(CM_IOCTL_FILENAME_NOSLASH)) == 0)
return -1;
+
rc = getAFSServer(cellNamep, cellHostAddrs, cellHostNames, ipRanks, &numServers, ttl);
if (rc == 0 && numServers > 0) { /* found the cell */
for (i = 0; i < numServers; i++) {