From fd8e75df5ef3dd503a31c75c952655ecd50213c4 Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Tue, 20 Jul 2004 16:48:18 +0000 Subject: [PATCH] submounts-20040720 Fix afsshare.c to strip the MountRoot off the afs-path before inserting into the registry Fix smb.c to read the submounts out of the registry. ==================== This delta was composed from multiple commits as part of the CVS->Git migration. The checkin message with each commit was inconsistent. The following are the additional commit messages. ==================== fix submount extraction from registry --- src/WINNT/afsd/afsd.h | 1 + src/WINNT/afsd/afsshare.c | 30 ++++++++++++++++++++++++++++-- src/WINNT/afsd/smb.c | 18 +++++++++++++++--- 3 files changed, 44 insertions(+), 5 deletions(-) diff --git a/src/WINNT/afsd/afsd.h b/src/WINNT/afsd/afsd.h index 6456c7139..1e3a7571e 100644 --- a/src/WINNT/afsd/afsd.h +++ b/src/WINNT/afsd/afsd.h @@ -61,6 +61,7 @@ BOOL APIENTRY About(HWND, unsigned int, unsigned int, long); #include "cm_dnlc.h" #include "cm_buf.h" #include "cm_freelance.h" +#include "smb_ioctl.h" #ifdef DJGPP #include "afs/afsmsg95.h" #endif diff --git a/src/WINNT/afsd/afsshare.c b/src/WINNT/afsd/afsshare.c index 4586dfff0..eb0f83a52 100644 --- a/src/WINNT/afsd/afsshare.c +++ b/src/WINNT/afsd/afsshare.c @@ -17,9 +17,12 @@ int main(int argc, char **argv) { BOOL res; HKEY hkSubmounts; + HKEY hkParameters; + char mountRoot[64]="/afs"; + char * mountstring; if (argc < 2 || argc > 3) { - fprintf(stderr, "Incorrect arguments\n"); + fprintf(stderr, "afsshare.exe []\n"); exit(1); } @@ -37,12 +40,35 @@ main(int argc, char **argv) { if (RegDeleteValue(hkSubmounts, argv[1])) { fprintf(stderr,"Submount Deletion failure for [%s]: %lX", argv[1], GetLastError()); + RegCloseKey(hkSubmounts); return 1; } } else { - if (RegSetValueEx(hkSubmounts, argv[1], 0, REG_SZ, argv[2], strlen(argv[2])+1)) { + if (RegCreateKeyEx( HKEY_LOCAL_MACHINE, + "SYSTEM\\CurrentControlSet\\Services\\TransarcAFSDaemon\\Parameters", + 0, + NULL, + REG_OPTION_NON_VOLATILE, + KEY_READ, + NULL, + &hkParameters, + NULL) == ERROR_SUCCESS) + { + DWORD dwSize = sizeof(mountRoot); + RegQueryValueEx (hkParameters, "MountRoot", NULL, NULL, (PBYTE)mountRoot, &dwSize); + RegCloseKey(hkParameters); + } + + + if ( !strncmp(mountRoot, argv[2], strlen(mountRoot)) ) + mountstring = argv[2] + strlen(mountRoot); + else + mountstring = argv[2]; + + if (RegSetValueEx(hkSubmounts, argv[1], 0, REG_SZ, mountstring, strlen(mountstring)+1)) { fprintf(stderr,"Submount Set failure for [%s]: %lX", argv[1], GetLastError()); + RegCloseKey(hkSubmounts); return 2; } } diff --git a/src/WINNT/afsd/smb.c b/src/WINNT/afsd/smb.c index 6b04d44e0..19a919fde 100644 --- a/src/WINNT/afsd/smb.c +++ b/src/WINNT/afsd/smb.c @@ -1178,6 +1178,7 @@ char VNLCUserName[] = "%LCUSERNAME%"; char VNComputerName[] = "%COMPUTERNAME%"; char VNLCComputerName[] = "%LCCOMPUTERNAME%"; +#ifdef DJGPP /* List available shares */ int smb_ListShares() { @@ -1241,7 +1242,7 @@ int smb_ListShares() return num_shares; } - +#endif /* DJGPP */ /* find a shareName in the table of submounts */ int smb_FindShare(smb_vc_t *vcp, smb_user_t *uidp, char *shareName, char **pathNamep) @@ -1293,13 +1294,24 @@ int smb_FindShare(smb_vc_t *vcp, smb_user_t *uidp, char *shareName, } #ifndef DJGPP - strcpy(sbmtpath, "afsdsbmt.ini"); + code = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\OpenAFS\\Client\\Submounts", + 0, KEY_QUERY_VALUE, &parmKey); + if (code == ERROR_SUCCESS) { + len = sizeof(pathName); + code = RegQueryValueEx(parmKey, shareName, NULL, NULL, + (BYTE *) pathName, &len); + if (code != ERROR_SUCCESS) + len = 0; + RegCloseKey (parmKey); + } else { + len = 0; + } #else /* DJGPP */ strcpy(sbmtpath, cm_confDir); strcat(sbmtpath, "/afsdsbmt.ini"); -#endif /* !DJGPP */ len = GetPrivateProfileString("AFS Submounts", shareName, "", pathName, sizeof(pathName), sbmtpath); +#endif /* !DJGPP */ if (len != 0 && len != sizeof(pathName) - 1) { /* We can accept either unix or PC style AFS pathnames. Convert * Unix-style to PC style here for internal use. -- 2.39.5