From 8449967538a6a5b4f1eb9dee4f46dd34e62716ae Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Sat, 2 Feb 2008 02:48:12 +0000 Subject: [PATCH] DEVEL15-windows-more-cellservdb-consolidation-20080201 LICENSE MIT Merge cellconfig.c and the afsreg library. Redefine the location of the client cellservdb directory in dirpath in terms of the cellservdb direction and not the install directory. (although they point at the same thing now by default.) Future changes to the location of the cellservdb directory should be made in afsreg. (cherry picked from commit 753ba70cf257aded0fae158c556a25ca72243214) --- src/NTMakefile | 66 ++++++++++++++++++------------------- src/WINNT/afsd/cm_config.c | 53 ++++++----------------------- src/WINNT/afsreg/afssw.c | 36 ++++++++++++++++++-- src/WINNT/afsreg/afssw.h | 3 -- src/libadmin/cfg/NTMakefile | 3 +- src/util/dirpath.c | 2 +- 6 files changed, 80 insertions(+), 83 deletions(-) diff --git a/src/NTMakefile b/src/NTMakefile index 265e6a232..0b8d325e3 100644 --- a/src/NTMakefile +++ b/src/NTMakefile @@ -409,82 +409,82 @@ tbutc: tviced $(NTMAKE) $(CD) ..\.. -adminutil: tbutc +talocale: tbutc echo ***** $@ - $(DOCD) $(SRC)\libadmin\$@ - $(CD) $(SRC)\libadmin\$@ + $(DOCD) $(SRC)\WINNT\$@ + $(CD) $(SRC)\WINNT\$@ $(NTMAKE) $(CD) ..\..\.. -vos: adminutil +license: talocale echo ***** $@ - $(DOCD) $(SRC)\libadmin\$@ - $(CD) $(SRC)\libadmin\$@ + $(DOCD) $(SRC)\WINNT\$@ + $(CD) $(SRC)\WINNT\$@ $(NTMAKE) $(CD) ..\..\.. -client: vos +client_osi: license echo ***** $@ - $(DOCD) $(SRC)\libadmin\$@ - $(CD) $(SRC)\libadmin\$@ + $(DOCD) $(SRC)\WINNT\$@ + $(CD) $(SRC)\WINNT\$@ $(NTMAKE) $(CD) ..\..\.. -kas: client +afsd: client_osi echo ***** $@ - $(DOCD) $(SRC)\libadmin\$@ - $(CD) $(SRC)\libadmin\$@ + $(DOCD) $(SRC)\WINNT\$@ + $(CD) $(SRC)\WINNT\$@ $(NTMAKE) $(CD) ..\..\.. -pts: kas +libadmin: afsd echo ***** $@ - $(DOCD) $(SRC)\libadmin\$@ - $(CD) $(SRC)\libadmin\$@ + $(DOCD) $(SRC)\$@ + $(CD) $(SRC)\$@ $(NTMAKE) - $(CD) ..\..\.. + $(CD) ..\.. -bos: pts +adminutil: libadmin echo ***** $@ $(DOCD) $(SRC)\libadmin\$@ $(CD) $(SRC)\libadmin\$@ $(NTMAKE) $(CD) ..\..\.. -talocale: bos +vos: adminutil echo ***** $@ - $(DOCD) $(SRC)\WINNT\$@ - $(CD) $(SRC)\WINNT\$@ + $(DOCD) $(SRC)\libadmin\$@ + $(CD) $(SRC)\libadmin\$@ $(NTMAKE) $(CD) ..\..\.. -license: talocale +client: vos echo ***** $@ - $(DOCD) $(SRC)\WINNT\$@ - $(CD) $(SRC)\WINNT\$@ + $(DOCD) $(SRC)\libadmin\$@ + $(CD) $(SRC)\libadmin\$@ $(NTMAKE) $(CD) ..\..\.. -client_osi: license +kas: client echo ***** $@ - $(DOCD) $(SRC)\WINNT\$@ - $(CD) $(SRC)\WINNT\$@ + $(DOCD) $(SRC)\libadmin\$@ + $(CD) $(SRC)\libadmin\$@ $(NTMAKE) $(CD) ..\..\.. -afsd: client_osi +pts: kas echo ***** $@ - $(DOCD) $(SRC)\WINNT\$@ - $(CD) $(SRC)\WINNT\$@ + $(DOCD) $(SRC)\libadmin\$@ + $(CD) $(SRC)\libadmin\$@ $(NTMAKE) $(CD) ..\..\.. -libadmin: afsd +bos: pts echo ***** $@ - $(DOCD) $(SRC)\$@ - $(CD) $(SRC)\$@ + $(DOCD) $(SRC)\libadmin\$@ + $(CD) $(SRC)\libadmin\$@ $(NTMAKE) - $(CD) ..\.. + $(CD) ..\..\.. cfg: bos echo ***** $@ diff --git a/src/WINNT/afsd/cm_config.c b/src/WINNT/afsd/cm_config.c index de7de240b..ddf221919 100644 --- a/src/WINNT/afsd/cm_config.c +++ b/src/WINNT/afsd/cm_config.c @@ -318,9 +318,9 @@ long cm_SearchCellByDNS(char *cellNamep, char *newCellNamep, int *ttl, #endif /* AFS_AFSDB_ENV */ } -/* look up the CellServDBDir's name in the Registry - * or use the Client Dirpath value to produce a CellServDB - * filename +/* use cm_GetConfigDir() plus AFS_CELLSERVDB to + * generate the fully qualified name of the CellServDB + * file. */ long cm_GetCellServDB(char *cellNamep, afs_uint32 len) { @@ -541,46 +541,13 @@ long cm_CloseCellFile(cm_configFile_t *filep) void cm_GetConfigDir(char *dir, afs_uint32 len) { - char wdir[512]; - int tlen; - char *afsconf_path; - DWORD dwSize; - - dwSize = GetEnvironmentVariable("AFSCONF", NULL, 0); - afsconf_path = malloc(dwSize); - dwSize = GetEnvironmentVariable("AFSCONF", afsconf_path, dwSize); - if (!afsconf_path) { - DWORD code, dummyLen; - HKEY parmKey; - - code = RegOpenKeyEx(HKEY_LOCAL_MACHINE, AFSREG_CLT_OPENAFS_SUBKEY, - 0, KEY_QUERY_VALUE, &parmKey); - if (code != ERROR_SUCCESS) - goto dirpath; - - dummyLen = sizeof(wdir); - code = RegQueryValueEx(parmKey, "CellServDBDir", NULL, NULL, - wdir, &dummyLen); - RegCloseKey (parmKey); - - dirpath: - if (code != ERROR_SUCCESS || wdir[0] == 0) { - strncpy(wdir, AFSDIR_CLIENT_ETC_DIRPATH, sizeof(wdir)); - wdir[sizeof(wdir)-1] = '\0'; - } - } else { - strncpy(wdir, afsconf_path, sizeof(wdir)); - wdir[sizeof(wdir)-1] = '\0'; - free(afsconf_path); - } + char * dirp = NULL; - /* add trailing backslash, if required */ - tlen = (int)strlen(wdir); - if (wdir[tlen-1] != '\\') { - strncat(wdir, "\\", sizeof(wdir)); - wdir[sizeof(wdir)-1] = '\0'; + if (!afssw_GetClientCellServDBDir(&dirp)) { + strncpy(dir, dirp, len); + dir[len-1] = '\0'; + free(dirp); + } else { + dir[0] = '\0'; } - - strncpy(dir, wdir, len); - dir[len-1] ='\0'; } diff --git a/src/WINNT/afsreg/afssw.c b/src/WINNT/afsreg/afssw.c index c6aa2fe37..9c23ba3f0 100644 --- a/src/WINNT/afsreg/afssw.c +++ b/src/WINNT/afsreg/afssw.c @@ -77,9 +77,41 @@ afssw_GetClientInstallDir(char **bufPP) /* [out] data buffer */ int afssw_GetClientCellServDBDir(char **bufPP) /* [out] data buffer */ { - return StringDataRead(AFSREG_CLT_OPENAFS_KEY, + char wdir[512]; + int tlen; + char *path = NULL; + int rc; + DWORD cbPath; + + cbPath = GetEnvironmentVariable("AFSCONF", NULL, 0); + if (cbPath) { + cbPath += 2; + path = malloc(cbPath); + } + if (path) { + GetEnvironmentVariable("AFSCONF", path, cbPath); + tlen = (int)strlen(path); + if (path[tlen-1] != '\\') { + strncat(path, "\\", cbPath); + path[cbPath-1] = '\0'; + } + *bufPP = path; + return 0; + } + + if (!StringDataRead(AFSREG_CLT_OPENAFS_KEY, AFSREG_CLT_OPENAFS_CELLSERVDB_DIR_VALUE, - bufPP); + &path)) { + tlen = (int)strlen(path); + if (path[tlen-1] != '\\') { + strncat(path, "\\", cbPath); + path[cbPath-1] = '\0'; + } + *bufPP = path; + return 0; + } + + return afssw_GetClientInstallDir(bufPP); } diff --git a/src/WINNT/afsreg/afssw.h b/src/WINNT/afsreg/afssw.h index 5eaecbe73..4d8326ea3 100644 --- a/src/WINNT/afsreg/afssw.h +++ b/src/WINNT/afsreg/afssw.h @@ -22,9 +22,6 @@ afssw_GetServerInstallDir(char **bufPP); extern int afssw_GetClientCellServDBDir(char **bufPP); -extern int -afssw_GetClientCellDir(char **bufPP); - extern int afssw_GetClientCellName(char **bufPP); diff --git a/src/libadmin/cfg/NTMakefile b/src/libadmin/cfg/NTMakefile index 3f11f0cd2..b8c3c76c5 100644 --- a/src/libadmin/cfg/NTMakefile +++ b/src/libadmin/cfg/NTMakefile @@ -55,7 +55,8 @@ DLLLIBS =\ $(DESTDIR)\lib\afs\afsvosadmin.lib \ $(DESTDIR)\lib\afsrpc.lib \ $(DESTDIR)\lib\afsauthent.lib \ - $(DESTDIR)\lib\afs\afsreg.lib + $(DESTDIR)\lib\afs\afsreg.lib \ + $(DESTDIR)\lib\libafsconf.lib $(DLLFILE): $(DLLOBJS) $(DLLLIBS) $(DLLCONLINK) /DEF:afscfgadmin.def diff --git a/src/util/dirpath.c b/src/util/dirpath.c index ee245cfd4..2648fd10e 100644 --- a/src/util/dirpath.c +++ b/src/util/dirpath.c @@ -135,7 +135,7 @@ initDirPathArray(void) FilepathNormalize(ntServerInstallDirShort); /* get the afs client configuration directory (/usr/vice/etc equivalent) */ - if (afssw_GetClientInstallDir(&buf)) { + if (afssw_GetClientCellServDBDir(&buf)) { /* failed */ status = GetWindowsDirectory(ntClientConfigDirLong, AFSDIR_PATH_MAX); if (status == 0 || status > AFSDIR_PATH_MAX) { -- 2.39.5