VirtualBox

Changeset 6402 in vbox


Ignore:
Timestamp:
Jan 21, 2008 11:09:00 AM (17 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
27354
Message:

more places to check if writing is allowed

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostServices/SharedFolders/vbsf.cpp

    r6384 r6402  
    10191019            }
    10201020
     1021            rc = VINF_SUCCESS;
     1022
    10211023            /* write access requested? */
    10221024            if (pParms->CreateFlags & (  SHFL_CF_ACT_REPLACE_IF_EXISTS
     
    10291031                rc = vbsfMappingsQueryWritable (pClient, root, &fWritable);
    10301032                if (RT_FAILURE(rc) || !fWritable)
    1031                     return VERR_WRITE_PROTECT;
    1032             }
    1033 
    1034             if (BIT_FLAG(pParms->CreateFlags, SHFL_CF_DIRECTORY))
    1035             {
    1036                 rc = vbsfOpenDir (pszFullPath, pParms);
    1037             }
    1038             else
    1039             {
    1040                 rc = vbsfOpenFile (pszFullPath, pParms);
     1033                    rc = VERR_WRITE_PROTECT;
     1034            }
     1035
     1036            if (RT_SUCCESS(rc))
     1037            {
     1038                if (BIT_FLAG(pParms->CreateFlags, SHFL_CF_DIRECTORY))
     1039                    rc = vbsfOpenDir (pszFullPath, pParms);
     1040                else
     1041                    rc = vbsfOpenFile (pszFullPath, pParms);
    10411042            }
    10421043        }
     
    13881389    }
    13891390
     1391    /* is the guest allowed to write to this share? */
     1392    bool fWritable;
     1393    rc = vbsfMappingsQueryWritable (pClient, root, &fWritable);
     1394    if (RT_FAILURE(rc) || !fWritable)
     1395        return VERR_WRITE_PROTECT;
     1396
    13901397    *pcbBuffer  = 0;
    13911398    pSFDEntry   = (RTFSOBJINFO *)pBuffer;
     
    16871694
    16881695    rc = vbsfBuildFullPath (pClient, root, pPath, cbPath, &pszFullPath, NULL);
    1689 
    16901696    if (VBOX_SUCCESS (rc))
    16911697    {
    1692         if (flags & SHFL_REMOVE_FILE)
    1693             rc = RTFileDelete(pszFullPath);
    1694         else
    1695             rc = RTDirRemove(pszFullPath);
     1698        /* is the guest allowed to write to this share? */
     1699        bool fWritable;
     1700        rc = vbsfMappingsQueryWritable (pClient, root, &fWritable);
     1701        if (RT_FAILURE(rc) || !fWritable)
     1702            rc = VERR_WRITE_PROTECT;
     1703
     1704        if (VBOX_SUCCESS (rc))
     1705        {
     1706            if (flags & SHFL_REMOVE_FILE)
     1707                rc = RTFileDelete(pszFullPath);
     1708            else
     1709                rc = RTDirRemove(pszFullPath);
     1710        }
    16961711
    16971712#ifndef DEBUG_dmik
     
    17331748    {
    17341749        Log(("Rename %s to %s\n", pszFullPathSrc, pszFullPathDest));
    1735         if (flags & SHFL_RENAME_FILE)
    1736         {
    1737             rc = RTFileMove(pszFullPathSrc, pszFullPathDest, (flags & SHFL_RENAME_REPLACE_IF_EXISTS) ? RTFILEMOVE_FLAGS_REPLACE : 0);
    1738         }
    1739         else
    1740         {
    1741             /* NT ignores the REPLACE flag and simply return and already exists error. */
    1742             rc = RTDirRename(pszFullPathSrc, pszFullPathDest, (flags & SHFL_RENAME_REPLACE_IF_EXISTS) ? RTPATHRENAME_FLAGS_REPLACE : 0);
     1750
     1751        /* is the guest allowed to write to this share? */
     1752        bool fWritable;
     1753        rc = vbsfMappingsQueryWritable (pClient, root, &fWritable);
     1754        if (RT_FAILURE(rc) || !fWritable)
     1755            rc = VERR_WRITE_PROTECT;
     1756
     1757        if (VBOX_SUCCESS (rc))
     1758        {
     1759            if (flags & SHFL_RENAME_FILE)
     1760            {
     1761                rc = RTFileMove(pszFullPathSrc, pszFullPathDest, (flags & SHFL_RENAME_REPLACE_IF_EXISTS) ? RTFILEMOVE_FLAGS_REPLACE : 0);
     1762            }
     1763            else
     1764            {
     1765                /* NT ignores the REPLACE flag and simply return and already exists error. */
     1766                rc = RTDirRename(pszFullPathSrc, pszFullPathDest, (flags & SHFL_RENAME_REPLACE_IF_EXISTS) ? RTPATHRENAME_FLAGS_REPLACE : 0);
     1767            }
    17431768        }
    17441769
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette