[newlib-cygwin] Cygwin: allow opening a symlink with O_PATH | O_NOFOLLOW

Ken Brown kbrown@sourceware.org
Mon Jan 20 14:48:00 GMT 2020


https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=35a1a6dbdf03df1e33bae51f679820a3a868d0c0

commit 35a1a6dbdf03df1e33bae51f679820a3a868d0c0
Author: Ken Brown <kbrown@cornell.edu>
Date:   Fri Dec 27 11:43:58 2019 -0500

    Cygwin: allow opening a symlink with O_PATH | O_NOFOLLOW
    
    Up to now, opening a symlink with O_NOFOLLOW fails with ELOOP.
    Following Linux, allow this to succeed if O_PATH is also specified.

Diff:
---
 winsup/cygwin/syscalls.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
index 20126ce..038a316 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -1470,7 +1470,7 @@ open (const char *unix_path, int flags, ...)
 
       if (!(fh = build_fh_name (unix_path, opt, stat_suffixes)))
 	__leave;		/* errno already set */
-      if ((flags & O_NOFOLLOW) && fh->issymlink ())
+      if ((flags & O_NOFOLLOW) && fh->issymlink () && !(flags & O_PATH))
 	{
 	  set_errno (ELOOP);
 	  __leave;



More information about the Cygwin-cvs mailing list