Changeset 39627 in vbox
- Timestamp:
- Dec 15, 2011 11:44:19 AM (13 years ago)
- svn:sync-xref-src-repo-rev:
- 75421
- Location:
- trunk
- Files:
-
- 1 deleted
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/dir.h
r39626 r39627 305 305 * @{ */ 306 306 /** Don't allow symbolic links as part of the path. */ 307 #define RTDIROPEN _FLAGS_NO_SYMLINKS RT_BIT(0)307 #define RTDIROPENFILTERED_FLAGS_NO_SYMLINKS RT_BIT(0) 308 308 /** @} */ 309 309 -
trunk/include/iprt/path.h
r39626 r39627 127 127 /** Last component: Follow if link. */ 128 128 #define RTPATH_F_FOLLOW_LINK RT_BIT_32(1) 129 /** Don't allow symbolic links as part of the path. */130 #define RTPATH_F_NO_SYMLINKS RT_BIT_32(2)131 129 /** @} */ 132 130 … … 135 133 * @remarks The parameters will be referenced multiple times. */ 136 134 #define RTPATH_F_IS_VALID(fFlags, fIgnore) \ 137 ( ((fFlags) & ~(uint32_t)(fIgnore | RTPATH_F_NO_SYMLINKS)) == RTPATH_F_ON_LINK \138 || ((fFlags) & ~(uint32_t)(fIgnore | RTPATH_F_NO_SYMLINKS)) == RTPATH_F_FOLLOW_LINK )135 ( ((fFlags) & ~(uint32_t)(fIgnore)) == RTPATH_F_ON_LINK \ 136 || ((fFlags) & ~(uint32_t)(fIgnore)) == RTPATH_F_FOLLOW_LINK ) 139 137 140 138 -
trunk/src/VBox/HostServices/SharedFolders/service.cpp
r39626 r39627 244 244 else 245 245 { 246 pszFolderName = (char*)RTStrAlloc(cbFolderName + 1);246 pszFolderName = (char*)RTStrAlloc(cbFolderName); 247 247 AssertReturn(pszFolderName, VERR_NO_MEMORY); 248 248 249 rc = SSMR3GetStrZ(pSSM, pszFolderName, cbFolderName + 1);249 rc = SSMR3GetStrZ(pSSM, mapping.pszFolderName, cbFolderName); 250 250 AssertRCReturn(rc, rc); 251 251 mapping.pszFolderName = pszFolderName; -
trunk/src/VBox/HostServices/SharedFolders/vbsf.cpp
r39626 r39627 42 42 #endif 43 43 44 // never follow symbolic links */ 45 //#define SHFL_RT_LINK(pClient) ((pClient)->fu32Flags & SHFL_CF_SYMLINKS ? RTPATH_F_ON_LINK : RTPATH_F_FOLLOW_LINK) 46 #define SHFL_RT_LINK(pClient) (RTPATH_F_ON_LINK) 47 44 48 /** 45 49 * @todo find a better solution for supporting the execute bit for non-windows … … 135 139 strcat(pDirEntry->szName, szWildCard); 136 140 137 rc = RTDirOpenFiltered(&hSearch, pDirEntry->szName, RTDIRFILTER_WINNT, RTDIROPEN _FLAGS_NO_SYMLINKS);141 rc = RTDirOpenFiltered(&hSearch, pDirEntry->szName, RTDIRFILTER_WINNT, RTDIROPENFILTERED_FLAGS_NO_SYMLINKS); 138 142 *(pszStartComponent-1) = RTPATH_DELIMITER; 139 143 if (RT_FAILURE(rc)) … … 144 148 size_t cbDirEntrySize = cbDirEntry; 145 149 146 rc = RTDirReadEx(hSearch, pDirEntry, &cbDirEntrySize, RTFSOBJATTRADD_NOTHING, 147 RTPATH_F_ON_LINK | RTPATH_F_NO_SYMLINKS); 150 rc = RTDirReadEx(hSearch, pDirEntry, &cbDirEntrySize, RTFSOBJATTRADD_NOTHING, SHFL_RT_LINK(pClient)); 148 151 if (rc == VERR_NO_MORE_FILES) 149 152 break; … … 423 426 if (RT_SUCCESS(rc)) 424 427 { 425 /* When the host file system is case sensitive and the guest expects 426 * a case insensitive fs, then problems can occur */ 428 /* When the host file system is case sensitive and the guest expects a case insensitive fs, then problems can occur */ 427 429 if ( vbsfIsHostMappingCaseSensitive(root) 428 430 && !vbsfIsGuestMappingCaseSensitive(root)) … … 433 435 if (fWildCard || fPreserveLastComponent) 434 436 { 435 /* strip off the last path component, that has to be preserved: 436 * contains the wildcard(s) or a 'rename' target. */ 437 /* strip off the last path component, that has to be preserved: contains the wildcard(s) or a 'rename' target. */ 437 438 size_t cb = strlen(pszFullPath); 438 439 char *pszSrc = pszFullPath + cb - 1; … … 469 470 470 471 /** @todo don't check when creating files or directories; waste of time */ 471 rc = RTPathQueryInfoEx(pszFullPath, &info, RTFSOBJATTRADD_NOTHING, 472 RTPATH_F_ON_LINK | RTPATH_F_NO_SYMLINKS); 472 rc = RTPathQueryInfoEx(pszFullPath, &info, RTFSOBJATTRADD_NOTHING, SHFL_RT_LINK(pClient)); 473 473 if (rc == VERR_FILE_NOT_FOUND || rc == VERR_PATH_NOT_FOUND) 474 474 { … … 484 484 { 485 485 *pszSrc = 0; 486 rc = RTPathQueryInfoEx(pszFullPath, &info, RTFSOBJATTRADD_NOTHING, 487 RTPATH_F_ON_LINK | RTPATH_F_NO_SYMLINKS); 486 rc = RTPathQueryInfoEx(pszFullPath, &info, RTFSOBJATTRADD_NOTHING, SHFL_RT_LINK(pClient)); 488 487 *pszSrc = RTPATH_DELIMITER; 489 488 if (rc == VINF_SUCCESS) … … 521 520 fEndOfString = false; 522 521 *pszEnd = 0; 523 rc = RTPathQueryInfoEx(pszSrc, &info, RTFSOBJATTRADD_NOTHING, 524 RTPATH_F_ON_LINK | RTPATH_F_NO_SYMLINKS); 522 rc = RTPathQueryInfoEx(pszSrc, &info, RTFSOBJATTRADD_NOTHING, SHFL_RT_LINK(pClient)); 525 523 Assert(rc == VINF_SUCCESS || rc == VERR_FILE_NOT_FOUND || rc == VERR_PATH_NOT_FOUND); 526 524 } … … 862 860 863 861 /** @todo Possible race left here. */ 864 if (RT_SUCCESS(RTPathQueryInfoEx(pszPath, &info, RTFSOBJATTRADD_NOTHING, 865 RTPATH_F_ON_LINK | RTPATH_F_NO_SYMLINKS))) 862 if (RT_SUCCESS(RTPathQueryInfoEx(pszPath, &info, RTFSOBJATTRADD_NOTHING, SHFL_RT_LINK(pClient)))) 866 863 { 867 864 #ifdef RT_OS_WINDOWS … … 1035 1032 /* Open the directory now */ 1036 1033 rc = RTDirOpenFiltered(&pHandle->dir.Handle, pszPath, 1037 RTDIRFILTER_NONE, RTDIROPEN _FLAGS_NO_SYMLINKS);1034 RTDIRFILTER_NONE, RTDIROPENFILTERED_FLAGS_NO_SYMLINKS); 1038 1035 if (RT_SUCCESS(rc)) 1039 1036 { … … 1133 1130 * @retval pParms->Info On success, information returned about the file 1134 1131 */ 1135 static int vbsfLookupFile(SHFLCLIENTDATA *pClient, SHFLROOT root,char *pszPath, SHFLCREATEPARMS *pParms)1132 static int vbsfLookupFile(SHFLCLIENTDATA *pClient, char *pszPath, SHFLCREATEPARMS *pParms) 1136 1133 { 1137 1134 RTFSOBJINFO info; 1138 1135 int rc; 1139 1136 1140 char szRealPath[RTPATH_MAX + 1]; 1141 const char *pszRoot = vbsfMappingsQueryHostRoot(root); 1142 AssertReturn(pszRoot, VERR_INVALID_PARAMETER); 1143 rc = RTPathReal(pszPath, szRealPath, sizeof(szRealPath)); 1144 AssertRCReturn(rc, rc); 1145 if (!RTPathStartsWith(szRealPath, pszRoot)) 1146 return VERR_TOO_MANY_SYMLINKS; 1147 1148 rc = RTPathQueryInfoEx(pszPath, &info, RTFSOBJATTRADD_NOTHING, 1149 RTPATH_F_ON_LINK | RTPATH_F_NO_SYMLINKS); 1137 rc = RTPathQueryInfoEx(pszPath, &info, RTFSOBJATTRADD_NOTHING, SHFL_RT_LINK(pClient)); 1150 1138 LogFlow(("SHFL_CF_LOOKUP\n")); 1151 1139 /* Client just wants to know if the object exists. */ … … 1246 1234 if (BIT_FLAG(pParms->CreateFlags, SHFL_CF_LOOKUP)) 1247 1235 { 1248 rc = vbsfLookupFile(pClient, root,pszFullPath, pParms);1236 rc = vbsfLookupFile(pClient, pszFullPath, pParms); 1249 1237 } 1250 1238 else … … 1253 1241 RTFSOBJINFO info; 1254 1242 1255 rc = RTPathQueryInfoEx(pszFullPath, &info, RTFSOBJATTRADD_NOTHING, 1256 RTPATH_F_ON_LINK | RTPATH_F_NO_SYMLINKS); 1243 rc = RTPathQueryInfoEx(pszFullPath, &info, RTFSOBJATTRADD_NOTHING, SHFL_RT_LINK(pClient)); 1257 1244 LogFlow(("RTPathQueryInfoEx returned %Rrc\n", rc)); 1258 1245 … … 1308 1295 { 1309 1296 if (BIT_FLAG(pParms->CreateFlags, SHFL_CF_DIRECTORY)) 1297 { 1310 1298 rc = vbsfOpenDir(pClient, pszFullPath, pParms); 1299 } 1311 1300 else 1301 { 1312 1302 rc = vbsfOpenFile(pClient, pszFullPath, pParms); 1303 } 1313 1304 } 1314 1305 else … … 1514 1505 PRTDIR DirHandle; 1515 1506 bool fUtf8; 1516 1507 1517 1508 fUtf8 = BIT_FLAG(pClient->fu32Flags, SHFL_CF_UTF8) != 0; 1518 1509 … … 1555 1546 if (RT_SUCCESS(rc)) 1556 1547 { 1557 #if 0 1558 const char *pszRoot = vbsfMappingsQueryHostRoot(root); 1559 if (!pszRoot) 1560 { 1561 rc = VERR_INVALID_PARAMETER; 1562 goto end; 1563 } 1564 char szRealPath[RTPATH_MAX + 1]; 1565 rc = RTPathReal(pszFullPath, szRealPath, sizeof(szRealPath)); 1548 rc = RTDirOpenFiltered(&pHandle->dir.SearchHandle, pszFullPath, 1549 RTDIRFILTER_WINNT, RTDIROPENFILTERED_FLAGS_NO_SYMLINKS); 1550 1551 /* free the path string */ 1552 vbsfFreeFullPath(pszFullPath); 1553 1566 1554 if (RT_FAILURE(rc)) 1567 1555 goto end; 1568 if (!RTPathStartsWith(szRealPath, pszRoot))1569 {1570 rc = VERR_TOO_MANY_SYMLINKS;1571 goto end;1572 }1573 #endif1574 rc = RTDirOpenFiltered(&pHandle->dir.SearchHandle, pszFullPath,1575 RTDIRFILTER_WINNT, RTDIROPEN_FLAGS_NO_SYMLINKS);1576 1577 /* free the path string */1578 vbsfFreeFullPath(pszFullPath);1579 1580 if (RT_FAILURE(rc))1581 goto end;1582 1556 } 1583 1557 else … … 1602 1576 pDirEntry = pDirEntryOrg; 1603 1577 1604 rc = RTDirReadEx(DirHandle, pDirEntry, &cbDirEntrySize, RTFSOBJATTRADD_NOTHING, 1605 RTPATH_F_ON_LINK | RTPATH_F_NO_SYMLINKS); 1578 rc = RTDirReadEx(DirHandle, pDirEntry, &cbDirEntrySize, RTFSOBJATTRADD_NOTHING, SHFL_RT_LINK(pClient)); 1606 1579 if (rc == VERR_NO_MORE_FILES) 1607 1580 { … … 2322 2295 { 2323 2296 RTFSOBJINFO info; 2324 rc = RTPathQueryInfoEx(pszFullNewPath, &info, RTFSOBJATTRADD_NOTHING, 2325 RTPATH_F_ON_LINK | RTPATH_F_NO_SYMLINKS); 2297 rc = RTPathQueryInfoEx(pszFullNewPath, &info, RTFSOBJATTRADD_NOTHING, SHFL_RT_LINK(pClient)); 2326 2298 if (RT_SUCCESS(rc)) 2327 2299 vbfsCopyFsObjInfoFromIprt(pInfo, &info); -
trunk/src/VBox/Runtime/Makefile.kmk
r39626 r39627 615 615 r3/posix/RTTimeSet-posix.cpp \ 616 616 r3/posix/rtmempage-exec-mmap-heap-posix.cpp \ 617 r3/posix/rtPathOpenPathFh.cpp \618 617 r3/posix/dir-posix.cpp \ 619 618 r3/posix/env-posix.cpp \ … … 1174 1173 r3/posix/env-posix.cpp \ 1175 1174 r3/posix/fileio-posix.cpp \ 1176 r3/posix/rtPathOpenPathFh.cpp \1177 1175 r3/posix/fileio2-posix.cpp \ 1178 1176 r3/posix/path-posix.cpp \ -
trunk/src/VBox/Runtime/include/internal/dir.h
r39626 r39627 129 129 * wildcard expression. 130 130 */ 131 int rtDirNativeOpen(PRTDIR pDir, char *pszPathBuf , uint32_t fOpen);131 int rtDirNativeOpen(PRTDIR pDir, char *pszPathBuf); 132 132 133 133 #endif -
trunk/src/VBox/Runtime/include/internal/path.h
r39626 r39627 48 48 DECLHIDDEN(int) rtPathPosixRename(const char *pszSrc, const char *pszDst, unsigned fRename, RTFMODE fFileType); 49 49 DECLHIDDEN(int) rtPathWin32MoveRename(const char *pszSrc, const char *pszDst, uint32_t fFlags, RTFMODE fFileType); 50 DECLHIDDEN(int) rtPathOpenPathNoFollowFh(const char *pszPath, int *fh, const char **ppszName); 50 51 51 52 52 /** -
trunk/src/VBox/Runtime/r3/dir.cpp
r39626 r39627 517 517 * @param pszFilter Pointer to where the filter start in the path. NULL if no filter. 518 518 * @param enmFilter The type of filter to apply. 519 * @param fOpen Open flags, RTDIROPENFILTERED_FLAGS_*. 520 */ 521 static int rtDirOpenCommon(PRTDIR *ppDir, const char *pszPath, const char *pszFilter, RTDIRFILTER enmFilter, uint32_t fOpen) 519 */ 520 static int rtDirOpenCommon(PRTDIR *ppDir, const char *pszPath, const char *pszFilter, RTDIRFILTER enmFilter) 522 521 { 523 522 /* … … 647 646 * Hand it over to the native part. 648 647 */ 649 rc = rtDirNativeOpen(pDir, szRealPath , fOpen);648 rc = rtDirNativeOpen(pDir, szRealPath); 650 649 if (RT_SUCCESS(rc)) 651 650 *ppDir = pDir; … … 669 668 * Take common cause with RTDirOpenFiltered(). 670 669 */ 671 int rc = rtDirOpenCommon(ppDir, pszPath, NULL, RTDIRFILTER_NONE , 0);670 int rc = rtDirOpenCommon(ppDir, pszPath, NULL, RTDIRFILTER_NONE); 672 671 LogFlow(("RTDirOpen(%p:{%p}, %p:{%s}): return %Rrc\n", ppDir, *ppDir, pszPath, pszPath, rc)); 673 672 return rc; … … 712 711 * and initialize the handle, and finally call the backend. 713 712 */ 714 int rc = rtDirOpenCommon(ppDir, pszPath, pszFilter, enmFilter , fOpen);713 int rc = rtDirOpenCommon(ppDir, pszPath, pszFilter, enmFilter); 715 714 716 715 LogFlow(("RTDirOpenFiltered(%p:{%p}, %p:{%s}, %d): return %Rrc\n", -
trunk/src/VBox/Runtime/r3/posix/dir-posix.cpp
r39626 r39627 194 194 195 195 196 int rtDirNativeOpen(PRTDIR pDir, char *pszPathBuf , uint32_t fOpen)196 int rtDirNativeOpen(PRTDIR pDir, char *pszPathBuf) 197 197 { 198 198 NOREF(pszPathBuf); /* only used on windows */ … … 205 205 if (RT_SUCCESS(rc)) 206 206 { 207 #if defined(RT_OS_LINUX) || defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD) 208 /* XXX Darwin? */ 209 if (fOpen & RTDIROPEN_FLAGS_NO_SYMLINKS) 210 { 211 const char *pszName; 212 int fhDir; 213 rc = rtPathOpenPathNoFollowFh(pszNativePath, &fhDir, &pszName); 214 printf("rtPathOpenPathNoFollowFh '%s' => %d\n", pszNativePath, rc); 215 AssertRCReturn(rc, rc); 216 if (pszName != NULL) 217 { 218 AssertMsgFailed(("Path name '%s' contains filename\n", pszNativePath)); 219 return VERR_INVALID_PARAMETER; 220 } 221 pDir->pDir = fdopendir(fhDir); 222 /* 223 * do NOT close fhDir, it will be closed implicitely when closing pDir! 224 */ 225 } 226 else 227 #endif 228 { 229 pDir->pDir = opendir(pszNativePath); 230 } 207 pDir->pDir = opendir(pszNativePath); 231 208 if (pDir->pDir) 232 209 { -
trunk/src/VBox/Runtime/r3/posix/fileio-posix.cpp
r39626 r39627 204 204 return (rc); 205 205 206 int fh; 207 #if defined(RT_OS_LINUX) || defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD) 208 /* XXX Darwin? */ 209 if (fOpen & RTFILE_O_NO_SYMLINKS) 210 { 211 const char *pszName; 212 int fhDir; 213 rc = rtPathOpenPathNoFollowFh(pszNativeFilename, &fhDir, &pszName); 214 if (RT_FAILURE(rc)) 215 { 216 rtPathFreeNative(pszNativeFilename, pszFilename); 217 return rc; 218 } 219 fh = openat(fhDir, pszName, fOpenMode, fMode | O_NOFOLLOW); 220 close(fhDir); 221 } 222 else 223 #endif 224 { 225 fh = open(pszNativeFilename, fOpenMode, fMode); 226 } 206 int fh = open(pszNativeFilename, fOpenMode, fMode); 227 207 int iErr = errno; 228 208 -
trunk/src/VBox/Runtime/r3/win/dir-win.cpp
r39626 r39627 130 130 131 131 132 int rtDirNativeOpen(PRTDIR pDir, char *pszPathBuf , uint32_t fOpen)132 int rtDirNativeOpen(PRTDIR pDir, char *pszPathBuf) 133 133 { 134 134 /*
Note:
See TracChangeset
for help on using the changeset viewer.