From 91d1501be5e8ca0f957de2897c4c4ea0782dfbc3 Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Thu, 31 Jul 2008 18:01:12 +0000 Subject: [PATCH] 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". --- src/WINNT/afsd/cm_ioctl.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/src/WINNT/afsd/cm_ioctl.c b/src/WINNT/afsd/cm_ioctl.c index ec347f782..13abf4116 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) -- 2.39.5