submounts-20040720
authorJeffrey Altman <jaltman@mit.edu>
Tue, 20 Jul 2004 16:48:18 +0000 (16:48 +0000)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Tue, 20 Jul 2004 16:48:18 +0000 (16:48 +0000)
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
src/WINNT/afsd/afsshare.c
src/WINNT/afsd/smb.c

index 6456c71..1e3a757 100644 (file)
@@ -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
index 4586dff..eb0f83a 100644 (file)
@@ -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 <submount> [<afs mount path>]\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;
             }
         }
index 6b04d44..19a919f 100644 (file)
@@ -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.