From 06634de3494db97c182b3452e1f7a9b70e608606 Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Tue, 27 Jul 2004 00:01:31 +0000 Subject: [PATCH] afsconfig-dns-cells-20040726 Another annoying bug. afs_config.exe now validates cell names against DNS in addition to the CellServDB file. --- src/WINNT/client_config/tab_general.cpp | 27 ++++++++++++++++++------- src/WINNT/client_config/tab_hosts.cpp | 18 +++++++++++++++-- 2 files changed, 36 insertions(+), 9 deletions(-) diff --git a/src/WINNT/client_config/tab_general.cpp b/src/WINNT/client_config/tab_general.cpp index 8ec755eb2..450ad7d70 100644 --- a/src/WINNT/client_config/tab_general.cpp +++ b/src/WINNT/client_config/tab_general.cpp @@ -11,6 +11,7 @@ extern "C" { #include #include #include +#include } #include "afs_config.h" @@ -657,15 +658,27 @@ BOOL GeneralTab_AskIfStopped (HWND hDlg) BOOL fIsCellInCellServDB (LPCTSTR pszCell) { BOOL fFound = FALSE; - CELLSERVDB CellServDB; - if (CSDB_ReadFile (&CellServDB, NULL)) - { - if (CSDB_FindCell (&CellServDB, pszCell)) - fFound = TRUE; - CSDB_FreeFile (&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; } diff --git a/src/WINNT/client_config/tab_hosts.cpp b/src/WINNT/client_config/tab_hosts.cpp index 3b2600e18..4f270535d 100644 --- a/src/WINNT/client_config/tab_hosts.cpp +++ b/src/WINNT/client_config/tab_hosts.cpp @@ -10,6 +10,7 @@ extern "C" { #include #include +#include } #include "afs_config.h" @@ -181,8 +182,21 @@ BOOL HostsTab_OnApply (HWND hDlg) if (!CSDB_FindCell (&g.Configuration.CellServDB, szCell)) { - Message (MB_ICONASTERISK | MB_OK, GetErrorTitle(), IDS_BADCELL_DESC_CC); - return FALSE; +#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)) -- 2.39.5