Eryk Sun <eryk...@gmail.com> added the comment:

Symlinks are specially interpreted by the file API, I/O manager, and network 
redirector. So I think they should remain a separate category. readlink() and 
is_link() should be reserved for POSIX symlinks, i.e. only 
IO_REPARSE_TAG_SYMLINK. 

These app-exec reparse points are not name surrogates (i.e. 0x2000_0000 set in 
the tag), and they lack an associated filter driver that handles them in normal 
file operations. I/O syscalls that try to reparse the path fail with 
STATUS_IO_REPARSE_TAG_NOT_HANDLED.

It's also messy to conflate different things in general for the sake of a 
particular case. For example, if code sees the app-exec link as a symlink 
because ntpath.is_link() is true, it may try to copy it via os.readlink() and 
os.symlink(). This creates a different type of reparse point, if the user even 
has the symlink privilege, which may not behave the same as the original 
app-exec link in a CreateProcessW call. (I don't know what the end goal is for 
the Windows team in terms of allowing app executables under 
"%ProgramFiles%\WindowsApps" to be executed directly.) 

How about adding a separate function such as nt.read_reparse_point() that's 
able to read reparse points that are documented (most types are opaque) and can 
be interpreted as a string, or a tuple of strings? The internal implementation 
could be shared with os.readlink.

The current behavior of follow_symlinks in stat() is problematic. It should be 
limited to symlinks. So another idea that I think could prove generally useful 
is to extend stat() and lstat() with a follow_reparse_points=True parameter. If 
false, it would imply follow_symlinks is false. Explicitly passing 
follow_symlinks=True with follow_reparse_points=False would be an error. With 
follow_symlinks=False and follow_reparse_points=True, it would only open a 
symlink and follow all other types of reparse points. The stat result would 
gain an st_reparse_tag field (already added by your PR), which would be 
non-zero whenever a reparse point is opened.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue37834>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to