Changeset 39643 in vbox for trunk/src/VBox/HostServices/SharedFolders
- Timestamp:
- Dec 16, 2011 10:54:38 AM (13 years ago)
- svn:sync-xref-src-repo-rev:
- 75443
- Location:
- trunk/src/VBox/HostServices/SharedFolders
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostServices/SharedFolders/mappings.cpp
r39607 r39643 192 192 */ 193 193 int vbsfMappingsAdd(PSHFLSTRING pFolderName, PSHFLSTRING pMapName, 194 uint32_t fWritable, uint32_t fAutoMount)194 bool fWritable, bool fAutoMount, bool fSymlinksCreate) 195 195 { 196 196 unsigned i; … … 232 232 memcpy(FolderMapping[i].pMapName->String.ucs2, pMapName->String.ucs2, pMapName->u16Size); 233 233 234 FolderMapping[i].fValid = true; 235 FolderMapping[i].cMappings = 0; 236 FolderMapping[i].fWritable = !!fWritable; 237 FolderMapping[i].fAutoMount = !!fAutoMount; 234 FolderMapping[i].fValid = true; 235 FolderMapping[i].cMappings = 0; 236 FolderMapping[i].fWritable = fWritable; 237 FolderMapping[i].fAutoMount = fAutoMount; 238 FolderMapping[i].fSymlinksCreate = fSymlinksCreate; 238 239 239 240 /* Check if the host file system is case sensitive */ … … 444 445 int rc = VINF_SUCCESS; 445 446 446 LogFlow(("vbsfMappingsQueryWritable: pClient = %p, root = %d\n", 447 pClient, root)); 448 449 MAPPING *pFolderMapping = vbsfMappingGetByRoot(root); 450 if (pFolderMapping == NULL) 451 { 452 return VERR_INVALID_PARAMETER; 453 } 447 LogFlow(("vbsfMappingsQueryWritable: pClient = %p, root = %d\n", pClient, root)); 448 449 MAPPING *pFolderMapping = vbsfMappingGetByRoot(root); 450 AssertReturn(pFolderMapping, VERR_INVALID_PARAMETER); 454 451 455 452 if (pFolderMapping->fValid == true) … … 467 464 int rc = VINF_SUCCESS; 468 465 469 LogFlow(("vbsfMappingsQueryAutoMount: pClient = %p, root = %d\n", 470 pClient, root)); 471 472 MAPPING *pFolderMapping = vbsfMappingGetByRoot(root); 473 if (pFolderMapping == NULL) 474 { 475 return VERR_INVALID_PARAMETER; 476 } 466 LogFlow(("vbsfMappingsQueryAutoMount: pClient = %p, root = %d\n", pClient, root)); 467 468 MAPPING *pFolderMapping = vbsfMappingGetByRoot(root); 469 AssertReturn(pFolderMapping, VERR_INVALID_PARAMETER); 477 470 478 471 if (pFolderMapping->fValid == true) … … 482 475 483 476 LogFlow(("vbsfMappingsQueryAutoMount:Writable return rc = %Rrc\n", rc)); 477 478 return rc; 479 } 480 481 int vbsfMappingsQuerySymlinksCreate(PSHFLCLIENTDATA pClient, SHFLROOT root, bool *fSymlinksCreate) 482 { 483 int rc = VINF_SUCCESS; 484 485 LogFlow(("vbsfMappingsQueryAutoMount: pClient = %p, root = %d\n", pClient, root)); 486 487 MAPPING *pFolderMapping = vbsfMappingGetByRoot(root); 488 AssertReturn(pFolderMapping, VERR_INVALID_PARAMETER); 489 490 if (pFolderMapping->fValid == true) 491 *fSymlinksCreate = pFolderMapping->fSymlinksCreate; 492 else 493 rc = VERR_FILE_NOT_FOUND; 494 495 LogFlow(("vbsfMappingsQueryAutoMount:SymlinksCreate return rc = %Rrc\n", rc)); 484 496 485 497 return rc; -
trunk/src/VBox/HostServices/SharedFolders/mappings.h
r39607 r39643 23 23 typedef struct 24 24 { 25 char *pszFolderName; 26 PSHFLSTRING pMapName; 27 uint32_t cMappings; 28 bool fValid; 29 bool fHostCaseSensitive; 30 bool fGuestCaseSensitive; 31 bool fWritable; 32 bool fAutoMount; 25 char *pszFolderName; /**< directory at the host to share with the guest */ 26 PSHFLSTRING pMapName; /**< share name for the guest */ 27 uint32_t cMappings; /**< number of mappings */ 28 bool fValid; /**< mapping entry is used/valid */ 29 bool fHostCaseSensitive; /**< host file name space is case-sensitive */ 30 bool fGuestCaseSensitive; /**< guest file name space is case-sensitive */ 31 bool fWritable; /**< folder is writable for the guest */ 32 bool fAutoMount; /**< folder will be auto-mounted by the guest */ 33 bool fSymlinksCreate; /**< guest is able to create symlinks */ 33 34 } MAPPING; 34 35 /** Pointer to a MAPPING structure. */ … … 39 40 bool vbsfMappingQuery(uint32_t iMapping, PMAPPING *pMapping); 40 41 41 int vbsfMappingsAdd(PSHFLSTRING pFolderName, PSHFLSTRING pMapName, uint32_t fWritable, uint32_t fAutoMount); 42 int vbsfMappingsAdd(PSHFLSTRING pFolderName, PSHFLSTRING pMapName, 43 bool fWritable, bool fAutoMount, bool fCreateSymlinks); 42 44 int vbsfMappingsRemove(PSHFLSTRING pMapName); 43 45 … … 45 47 int vbsfMappingsQueryName(PSHFLCLIENTDATA pClient, SHFLROOT root, SHFLSTRING *pString); 46 48 int vbsfMappingsQueryWritable(PSHFLCLIENTDATA pClient, SHFLROOT root, bool *fWritable); 49 int vbsfMappingsQueryAutoMount(PSHFLCLIENTDATA pClient, SHFLROOT root, bool *fAutoMount); 50 int vbsfMappingsQuerySymlinksCreate(PSHFLCLIENTDATA pClient, SHFLROOT root, bool *fSymlinksCreate); 47 51 48 int vbsfMapFolder(PSHFLCLIENTDATA pClient, PSHFLSTRING pszMapName, RTUTF16 delimiter, bool fCaseSensitive, SHFLROOT *pRoot); 52 int vbsfMapFolder(PSHFLCLIENTDATA pClient, PSHFLSTRING pszMapName, RTUTF16 delimiter, 53 bool fCaseSensitive, SHFLROOT *pRoot); 49 54 int vbsfUnmapFolder(PSHFLCLIENTDATA pClient, SHFLROOT root); 50 55 -
trunk/src/VBox/HostServices/SharedFolders/service.cpp
r39628 r39643 1259 1259 1260 1260 /* 1261 * We differentiate between a function handler for the guest and one for the host. The guest is not allowed to add or remove mappings for obvious security reasons. 1261 * We differentiate between a function handler for the guest (svcCall) and one 1262 * for the host. The guest is not allowed to add or remove mappings for obvious 1263 * security reasons. 1262 1264 */ 1263 1265 static DECLCALLBACK(int) svcHostCall (void *, uint32_t u32Function, uint32_t cParms, VBOXHGCMSVCPARM paParms[]) … … 1283 1285 Log(("SharedFolders host service: svcCall: SHFL_FN_ADD_MAPPING\n")); 1284 1286 LogRel(("SharedFolders host service: adding host mapping\n")); 1285 LogRel((" Host path '%ls', map name '%ls', %s\n",1286 ((SHFLSTRING *)paParms[0].u.pointer.addr)->String.ucs2,1287 ((SHFLSTRING *)paParms[1].u.pointer.addr)->String.ucs2,1288 paParms[2].u.uint32 ? "writable" : "read-only"));1289 1290 1287 /* Verify parameter count and types. */ 1291 1288 if ( (cParms != SHFL_CPARMS_ADD_MAPPING) 1292 && (cParms != SHFL_CPARMS_ADD_MAPPING2) /* With auto-mount flag. */1293 1289 ) 1294 1290 { … … 1297 1293 else if ( paParms[0].type != VBOX_HGCM_SVC_PARM_PTR /* host folder name */ 1298 1294 || paParms[1].type != VBOX_HGCM_SVC_PARM_PTR /* guest map name */ 1299 || paParms[2].type != VBOX_HGCM_SVC_PARM_32BIT /* fWritable */ 1300 /* With auto-mount flag? */ 1301 || ( cParms == SHFL_CPARMS_ADD_MAPPING2 1302 && paParms[3].type != VBOX_HGCM_SVC_PARM_32BIT)) 1295 || paParms[2].type != VBOX_HGCM_SVC_PARM_32BIT /* fFlags */ 1296 ) 1303 1297 { 1304 1298 rc = VERR_INVALID_PARAMETER; … … 1309 1303 SHFLSTRING *pFolderName = (SHFLSTRING *)paParms[0].u.pointer.addr; 1310 1304 SHFLSTRING *pMapName = (SHFLSTRING *)paParms[1].u.pointer.addr; 1311 uint32_t fWritable = paParms[2].u.uint32; 1312 uint32_t fAutoMount = 0; /* Disabled by default. */ 1313 1314 /* Handle auto-mount flag if present. */ 1315 if (cParms == SHFL_CPARMS_ADD_MAPPING2) 1316 fAutoMount = paParms[3].u.uint32; 1305 uint32_t fFlags = paParms[2].u.uint32; 1317 1306 1318 1307 /* Verify parameters values. */ … … 1325 1314 else 1326 1315 { 1316 LogRel((" Host path '%ls', map name '%ls', %s, automount=%s, create_symlinks=%s\n", 1317 ((SHFLSTRING *)paParms[0].u.pointer.addr)->String.ucs2, 1318 ((SHFLSTRING *)paParms[1].u.pointer.addr)->String.ucs2, 1319 RT_BOOL(fFlags & SHFL_ADD_MAPPING_F_WRITABLE) ? "writable" : "read-only", 1320 RT_BOOL(fFlags & SHFL_ADD_MAPPING_F_AUTOMOUNT) ? "true" : "false", 1321 RT_BOOL(fFlags & SHFL_ADD_MAPPING_F_CREATE_SYMLINKS) ? "true" : "false")); 1322 1327 1323 /* Execute the function. */ 1328 rc = vbsfMappingsAdd(pFolderName, pMapName, fWritable, fAutoMount); 1324 rc = vbsfMappingsAdd(pFolderName, pMapName, 1325 RT_BOOL(fFlags & SHFL_ADD_MAPPING_F_WRITABLE), 1326 RT_BOOL(fFlags & SHFL_ADD_MAPPING_F_AUTOMOUNT), 1327 RT_BOOL(fFlags & SHFL_ADD_MAPPING_F_CREATE_SYMLINKS)); 1329 1328 if (RT_SUCCESS(rc)) 1330 1329 { -
trunk/src/VBox/HostServices/SharedFolders/vbsf.cpp
r39630 r39643 42 42 #endif 43 43 44 #define SHFL_RT_LINK(pClient) ((pClient)->fu32Flags & SHFL_CF_SYMLINKS ? RTPATH_F_ON_LINK : RTPATH_F_FOLLOW_LINK) 44 45 45 46 /** … … 136 137 strcat(pDirEntry->szName, szWildCard); 137 138 138 rc = RTDirOpenFiltered(&hSearch, pDirEntry->szName, RTDIRFILTER_WINNT, RTDIROPEN_FLAGS_NO_SYMLINKS);139 rc = RTDirOpenFiltered(&hSearch, pDirEntry->szName, RTDIRFILTER_WINNT, 0); 139 140 *(pszStartComponent-1) = RTPATH_DELIMITER; 140 141 if (RT_FAILURE(rc)) … … 145 146 size_t cbDirEntrySize = cbDirEntry; 146 147 147 rc = RTDirReadEx(hSearch, pDirEntry, &cbDirEntrySize, RTFSOBJATTRADD_NOTHING, RTPATH_F_ON_LINK);148 rc = RTDirReadEx(hSearch, pDirEntry, &cbDirEntrySize, RTFSOBJATTRADD_NOTHING, SHFL_RT_LINK(pClient)); 148 149 if (rc == VERR_NO_MORE_FILES) 149 150 break; … … 473 474 474 475 /** @todo don't check when creating files or directories; waste of time */ 475 rc = RTPathQueryInfoEx(pszFullPath, &info, RTFSOBJATTRADD_NOTHING, RTPATH_F_ON_LINK);476 rc = RTPathQueryInfoEx(pszFullPath, &info, RTFSOBJATTRADD_NOTHING, SHFL_RT_LINK(pClient)); 476 477 if (rc == VERR_FILE_NOT_FOUND || rc == VERR_PATH_NOT_FOUND) 477 478 { … … 487 488 { 488 489 *pszSrc = 0; 489 rc = RTPathQueryInfoEx(pszFullPath, &info, RTFSOBJATTRADD_NOTHING, RTPATH_F_ON_LINK);490 rc = RTPathQueryInfoEx(pszFullPath, &info, RTFSOBJATTRADD_NOTHING, SHFL_RT_LINK(pClient)); 490 491 *pszSrc = RTPATH_DELIMITER; 491 492 if (RT_SUCCESS(rc)) … … 523 524 fEndOfString = false; 524 525 *pszEnd = 0; 525 rc = RTPathQueryInfoEx(pszSrc, &info, RTFSOBJATTRADD_NOTHING, RTPATH_F_ON_LINK);526 rc = RTPathQueryInfoEx(pszSrc, &info, RTFSOBJATTRADD_NOTHING, SHFL_RT_LINK(pClient)); 526 527 Assert(rc == VINF_SUCCESS || rc == VERR_FILE_NOT_FOUND || rc == VERR_PATH_NOT_FOUND); 527 528 } … … 585 586 static int vbsfConvertFileOpenFlags(unsigned fShflFlags, RTFMODE fMode, SHFLHANDLE handleInitial, uint32_t *pfOpen) 586 587 { 587 uint32_t fOpen = RTFILE_O_NO_SYMLINKS;588 uint32_t fOpen = 0; 588 589 int rc = VINF_SUCCESS; 589 590 … … 863 864 864 865 /** @todo Possible race left here. */ 865 if (RT_SUCCESS(RTPathQueryInfoEx(pszPath, &info, RTFSOBJATTRADD_NOTHING, RTPATH_F_ON_LINK)))866 if (RT_SUCCESS(RTPathQueryInfoEx(pszPath, &info, RTFSOBJATTRADD_NOTHING, SHFL_RT_LINK(pClient)))) 866 867 { 867 868 #ifdef RT_OS_WINDOWS … … 1014 1015 1015 1016 pParms->Result = SHFL_FILE_CREATED; 1016 rc = RTDirCreate(pszPath, fMode, RTDIRCREATE_FLAGS_NO_SYMLINKS);1017 rc = RTDirCreate(pszPath, fMode, 0); 1017 1018 if (RT_FAILURE(rc)) 1018 1019 { … … 1034 1035 { 1035 1036 /* Open the directory now */ 1036 rc = RTDirOpenFiltered(&pHandle->dir.Handle, pszPath, 1037 RTDIRFILTER_NONE, RTDIROPEN_FLAGS_NO_SYMLINKS); 1037 rc = RTDirOpenFiltered(&pHandle->dir.Handle, pszPath, RTDIRFILTER_NONE, 0); 1038 1038 if (RT_SUCCESS(rc)) 1039 1039 { … … 1138 1138 int rc; 1139 1139 1140 rc = RTPathQueryInfoEx(pszPath, &info, RTFSOBJATTRADD_NOTHING, RTPATH_F_ON_LINK);1140 rc = RTPathQueryInfoEx(pszPath, &info, RTFSOBJATTRADD_NOTHING, SHFL_RT_LINK(pClient)); 1141 1141 LogFlow(("SHFL_CF_LOOKUP\n")); 1142 1142 /* Client just wants to know if the object exists. */ … … 1243 1243 RTFSOBJINFO info; 1244 1244 1245 rc = RTPathQueryInfoEx(pszFullPath, &info, RTFSOBJATTRADD_NOTHING, RTPATH_F_ON_LINK);1245 rc = RTPathQueryInfoEx(pszFullPath, &info, RTFSOBJATTRADD_NOTHING, SHFL_RT_LINK(pClient)); 1246 1246 LogFlow(("RTPathQueryInfoEx returned %Rrc\n", rc)); 1247 1247 … … 1548 1548 if (RT_SUCCESS(rc)) 1549 1549 { 1550 rc = RTDirOpenFiltered(&pHandle->dir.SearchHandle, pszFullPath, 1551 RTDIRFILTER_WINNT, RTDIROPEN_FLAGS_NO_SYMLINKS); 1550 rc = RTDirOpenFiltered(&pHandle->dir.SearchHandle, pszFullPath, RTDIRFILTER_WINNT, 0); 1552 1551 1553 1552 /* free the path string */ … … 1578 1577 pDirEntry = pDirEntryOrg; 1579 1578 1580 rc = RTDirReadEx(DirHandle, pDirEntry, &cbDirEntrySize, RTFSOBJATTRADD_NOTHING, RTPATH_F_ON_LINK);1579 rc = RTDirReadEx(DirHandle, pDirEntry, &cbDirEntrySize, RTFSOBJATTRADD_NOTHING, SHFL_RT_LINK(pClient)); 1581 1580 if (rc == VERR_NO_MORE_FILES) 1582 1581 { … … 1732 1731 if (RT_SUCCESS(rc)) 1733 1732 { 1734 rc = RTSymlinkRead(pszFullPath, (char *) pBuffer, cbBuffer, RTSYMLINKREAD_FLAGS_NO_SYMLINKS);1733 rc = RTSymlinkRead(pszFullPath, (char *) pBuffer, cbBuffer, 0); 1735 1734 1736 1735 /* free the path string */ … … 2179 2178 { 2180 2179 if (flags & SHFL_REMOVE_SYMLINK) 2181 rc = RTSymlinkDelete(pszFullPath, RTSYMLINKDELETE_FLAGS_NO_SYMLINKS);2180 rc = RTSymlinkDelete(pszFullPath, 0); 2182 2181 else if (flags & SHFL_REMOVE_FILE) 2183 2182 rc = RTFileDelete(pszFullPath); … … 2246 2245 { 2247 2246 rc = RTFileMove(pszFullPathSrc, pszFullPathDest, 2248 ((flags & SHFL_RENAME_REPLACE_IF_EXISTS) ? RTFILEMOVE_FLAGS_REPLACE : 0) 2249 | RTFILEMOVE_FLAGS_NO_SYMLINKS); 2247 ((flags & SHFL_RENAME_REPLACE_IF_EXISTS) ? RTFILEMOVE_FLAGS_REPLACE : 0)); 2250 2248 } 2251 2249 else … … 2253 2251 /* NT ignores the REPLACE flag and simply return and already exists error. */ 2254 2252 rc = RTDirRename(pszFullPathSrc, pszFullPathDest, 2255 ((flags & SHFL_RENAME_REPLACE_IF_EXISTS) ? RTPATHRENAME_FLAGS_REPLACE : 0) 2256 | RTPATHRENAME_FLAGS_NO_SYMLINKS); 2253 ((flags & SHFL_RENAME_REPLACE_IF_EXISTS) ? RTPATHRENAME_FLAGS_REPLACE : 0)); 2257 2254 } 2258 2255 } … … 2293 2290 if (RTPathStartsWithRoot(pszOldPath)) 2294 2291 return VERR_INVALID_NAME; 2295 2296 /* Force relative pathes to be inside the shared folder. Don't allow the target to go up */2297 rc = vbsf PathCheck(pszOldPath, pOldPath->u16Length);2292 2293 bool fSymlinksCreate; 2294 rc = vbsfMappingsQuerySymlinksCreate(pClient, root, &fSymlinksCreate); 2298 2295 AssertRCReturn(rc, rc); 2296 if (!fSymlinksCreate) 2297 return VERR_WRITE_PROTECT; /* XXX or VERR_TOO_MANY_SYMLINKS? */ 2299 2298 2300 2299 rc = vbsfBuildFullPath(pClient, root, pNewPath, pNewPath->u16Size, &pszFullNewPath, NULL); … … 2302 2301 2303 2302 rc = RTSymlinkCreate(pszFullNewPath, (const char *)pOldPath->String.utf8, 2304 RTSYMLINKTYPE_UNKNOWN, RTSYMLINKCREATE_FLAGS_NO_SYMLINKS);2303 RTSYMLINKTYPE_UNKNOWN, 0); 2305 2304 if (RT_SUCCESS(rc)) 2306 2305 { 2307 2306 RTFSOBJINFO info; 2308 rc = RTPathQueryInfoEx(pszFullNewPath, &info, RTFSOBJATTRADD_NOTHING, RTPATH_F_ON_LINK);2307 rc = RTPathQueryInfoEx(pszFullNewPath, &info, RTFSOBJATTRADD_NOTHING, SHFL_RT_LINK(pClient)); 2309 2308 if (RT_SUCCESS(rc)) 2310 2309 vbfsCopyFsObjInfoFromIprt(pInfo, &info);
Note:
See TracChangeset
for help on using the changeset viewer.