VirtualBox

Changeset 91620 in vbox for trunk/src/VBox/Runtime/r3/posix


Ignore:
Timestamp:
Oct 7, 2021 8:11:46 PM (3 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
147343
Message:

IPRT/RTDirRemove/posix: Do not rely on EEXIST taking priority over EACCES, because it isn't reliable, even in the "no danger of exposing contents of directories which can't be listed" case. Some Linux kernels reportedly also have odd behavior with NFS, but so far this isn't verified.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r3/posix/dir-posix.cpp

    r90781 r91620  
    107107            {
    108108                rc = errno;
    109                 /*bool fVerifyIsDir = true; - Windows returns VERR_ALREADY_EXISTS, so why bother with this. */
    110 #ifdef RT_OS_SOLARIS
    111109                /*
    112                  * mkdir on nfs mount points has been/is busted in various
    113                  * during the Nevada development cycle. We've observed:
    114                  *  - Build 111b (2009.06) returns EACCES.
    115                  *  - Build ca. 70-80 returns ENOSYS.
     110                 * Solaris mkdir returns ENOSYS on autofs directories, and also
     111                 * did this apparently for NFS mount points in some Nevada
     112                 * development builds. It also returned EACCES when it should
     113                 * have returned EEXIST, which actually is within the POSIX
     114                 * spec (not that I like this interpretation, but it seems
     115                 * valid). Check ourselves.
    116116                 */
    117117                if (    rc == ENOSYS
     
    119119                {
    120120                    rc = RTErrConvertFromErrno(rc);
    121                     /*fVerifyIsDir = false;   We'll check if it's a dir ourselves since we're going to stat() anyway. */
    122121                    if (!stat(pszNativePath, &st))
    123                     {
    124122                        rc = VERR_ALREADY_EXISTS;
    125                         /* Windows returns VERR_ALREADY_EXISTS, so why bother with this:
    126                         if (!S_ISDIR(st.st_mode))
    127                             rc = VERR_IS_A_FILE; */
    128                     }
    129123                }
    130124                else
    131125                    rc = RTErrConvertFromErrno(rc);
    132 #else
    133                 rc = RTErrConvertFromErrno(rc);
    134 #endif
    135 #if 0 /* Windows returns VERR_ALREADY_EXISTS, so why bother with this. */
    136                 if (   rc == VERR_ALREADY_EXISTS
    137                     /*&& fVerifyIsDir == true*/)
    138                 {
    139                     /*
    140                      * Verify that it really exists as a directory.
    141                      */
    142                     struct stat st;
    143                     if (!stat(pszNativePath, &st) && !S_ISDIR(st.st_mode))
    144                         rc = VERR_IS_A_FILE;
    145                 }
    146 #endif
    147126            }
    148127        }
Note: See TracChangeset for help on using the changeset viewer.

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