From: Jeffrey Altman Date: Thu, 31 Jul 2008 18:02:49 +0000 (+0000) Subject: DEVEL15-windows-ioctl-create-mount-point-validate-volume-20080731 X-Git-Tag: openafs-devel-1_5_52~50 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=e409c7d8b040f5e70479187818a60ac7080b2ee2;p=packages%2Fo%2Fopenafs.git DEVEL15-windows-ioctl-create-mount-point-validate-volume-20080731 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) --- diff --git a/src/WINNT/afsd/cm_ioctl.c b/src/WINNT/afsd/cm_ioctl.c index 63cd4f218..789a1dca7 100644 --- a/src/WINNT/afsd/cm_ioctl.c +++ b/src/WINNT/afsd/cm_ioctl.c @@ -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)