From 35a1a6dbdf03df1e33bae51f679820a3a868d0c0 Mon Sep 17 00:00:00 2001 From: Ken Brown Date: Fri, 27 Dec 2019 11:43:58 -0500 Subject: [PATCH] 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. --- 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 20126ce10..038a316db 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;