Author steve.dower
Recipients eryksun, paul.moore, steve.dower, tim.golden, zach.ware
Date 2019-08-15.21:28:19
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1565904500.2.0.000384809608634.issue37834@roundup.psfhosted.org>
In-reply-to
Content
> So we _do_ want to "upgrade" lstat() to stat() when it's not a symlink.

Except this bug came about because we want to _downgrade_ stat() to lstat() when it's an appexeclink, because the whole point of those is to use them without following them (and yeah, most operations are going to fail, but they'd fail against the target file too).

So we have this logic:

def xstat(path, traverse):
    f = open(path, flags | (0 if traverse else OPEN_REPARSE_POINT))
    if !f:
        # Special case for appexeclink
        if traverse and ERROR_CANT_OPEN_FILE:
            st = xstat(path, !traverse)
            if st.reparse_tag == APPEXECLINC:
                return st
            raise ERROR_CANT_OPEN_FILE
        # Handle "likely" errors
        if ERROR_ACCESS_DENIED or SHARING_VIOLATION:
            st = read_from_dir(os.path.split(path))
    else:
        st = read_from_file(f)

    # Always make the OS resolve "unknown" reparse points
    ALLOWED_TO_TRAVERSE = {SYMLINK, MOUNT_POINT}
    if !traverse and st.reparse_tag not in ALLOWED_TO_TRAVERSE:
        return xstat(path, !traverse)

    return st

And the open question is just whether MOUNT_POINT should be in that set near the end. I believe it should, since the alternative is to force all Python developers to write special Windows-only code to handle directory junctions.
History
Date User Action Args
2019-08-15 21:28:20steve.dowersetrecipients: + steve.dower, paul.moore, tim.golden, zach.ware, eryksun
2019-08-15 21:28:20steve.dowersetmessageid: <1565904500.2.0.000384809608634.issue37834@roundup.psfhosted.org>
2019-08-15 21:28:20steve.dowerlinkissue37834 messages
2019-08-15 21:28:19steve.dowercreate