]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
DEVEL15-windows-ioctl-create-mount-point-validate-volume-20080731
authorJeffrey Altman <jaltman@secure-endpoints.com>
Thu, 31 Jul 2008 18:02:49 +0000 (18:02 +0000)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Thu, 31 Jul 2008 18:02:49 +0000 (18:02 +0000)
LICENSE MIT

validate the specified volume to make sure it exists before permitting
the mount point to be created.   This will catch many instances in which
the user swaps the parameters to "fs mkmount".

(cherry picked from commit 91d1501be5e8ca0f957de2897c4c4ea0782dfbc3)

src/WINNT/afsd/cm_ioctl.c

index 63cd4f218f98fa99f5642b657fd079b705ad64e4..789a1dca74d1cd44883156ad5166ef80dd4e33b7 100644 (file)
@@ -1733,7 +1733,8 @@ cm_IoctlCreateMountPoint(struct cm_ioctl *ioctlp, struct cm_user *userp, cm_scac
     clientchar_t volume[VL_MAXNAMELEN];
     clientchar_t *mpp = NULL;
     clientchar_t *cell = NULL;
-    int ttl;
+    cm_volume_t *volp = NULL;
+    cm_cell_t *cellp = NULL;
 
    /* 
      * The fs command allows the user to specify partial cell names on NT.  These must
@@ -1754,12 +1755,8 @@ cm_IoctlCreateMountPoint(struct cm_ioctl *ioctlp, struct cm_user *userp, cm_scac
         fsvolume = cm_ClientStringToFsStringAlloc(volume, -1, NULL);
 
         /* Get the full name for this cell */
-        code = cm_SearchCellFile(fscell, fullCell, 0, 0);
-#ifdef AFS_AFSDB_ENV
-        if (code && cm_dnsEnabled)
-            code = cm_SearchCellByDNS(fscell, fullCell, &ttl, 0, 0);
-#endif
-        if (code) {
+        cellp = cm_GetCell_Gen(fscell, fullCell, CM_FLAG_NOPROBE);
+        if (!cellp) {
             code = CM_ERROR_NOSUCHCELL;
             goto done;
         }
@@ -1771,8 +1768,20 @@ cm_IoctlCreateMountPoint(struct cm_ioctl *ioctlp, struct cm_user *userp, cm_scac
         /* No cell name specified, so cell points at the volume instead. */
         fsvolume = cm_ClientStringToFsStringAlloc(cell, -1, NULL);
         cm_ClientStringToFsString(mpp, -1, mpInfo, lengthof(mpInfo));
+        cellp = cm_FindCellByID(dscp->fid.cell, CM_FLAG_NOPROBE);
     }
 
+    /* validate the target info */
+    if (cm_VolNameIsID(fsvolume)) {
+        code = cm_FindVolumeByID(cellp, atoi(fsvolume), userp, reqp, 
+                                CM_GETVOL_FLAG_CREATE, &volp);
+    } else {
+        code = cm_FindVolumeByName(cellp, fsvolume, userp, reqp, 
+                                  CM_GETVOL_FLAG_CREATE, &volp);
+    }
+    if (code)
+        goto done;
+
 #ifdef AFS_FREELANCE_CLIENT
     if (cm_freelanceEnabled && dscp == cm_data.rootSCachep) {
         /* we are adding the mount point to the root dir, so call
@@ -1800,6 +1809,8 @@ cm_IoctlCreateMountPoint(struct cm_ioctl *ioctlp, struct cm_user *userp, cm_scac
                          dscp, leaf, NULL, TRUE);
 
   done:
+    if (volp)
+        cm_PutVolume(volp);
     if (mpp)
         free(mpp);
     if (fscell)