This is the mail archive of the
cygwin-patches
mailing list for the Cygwin project.
[PATCH] Cygwin: fhandler_socket::open: support the O_PATH flag
- From: Ken Brown <kbrown at cornell dot edu>
- To: "cygwin-patches at cygwin dot com" <cygwin-patches at cygwin dot com>
- Date: Thu, 26 Dec 2019 15:25:42 +0000
- Subject: [PATCH] Cygwin: fhandler_socket::open: support the O_PATH flag
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=cornell.edu; dmarc=pass action=none header.from=cornell.edu; dkim=pass header.d=cornell.edu; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=T57HMVZLkFp+Bn0MxjaoVQK+yOmSo3Wx1UmCyw2nnLY=; b=aJe+S0ita4gJhqo2OYWOBysHO7g06NNBMaifAQ4bHPHk95swrZ57of1SH3UeLF5WJJAuIW0GGYaHsJazl4S2z5cz5zvS/u1ZhhBas88dDVPeAgJk8feAYToDA1MeCUJbjobhdWfY5L5hLiPX0+UfroTL81pftlop5pQYV7RCLJiEqZRJZh695PEg+usBCxtFP1sZFPv59K5xpmQ6D+H4SNy1Deds3dO3/FKA81pvWWNWkklHCKtW+/kuiRbtApCnfLTgU4cIzk5CwyBTN0w9yVETvFz8PV6sYV6bwILOuuK9CcJuf8Xnd8I8v3OEw8/UCZzLBGXYcBFlGjj2J+psoA==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NtLY8PcJnieWma4wMAdVpTxjuSgzUEjdGTveNLqGkDRVQqX0XTWzpqbLwuIPO9A48LM20nhlkZjTCjtlv9UsJ4TTgfUhofd7aoougamyPyKusNV53XTS6tDy4tGEvG1XKujLOj47IxmCmyNJ9Kwp/WU/Zq7IgoNiPzu0iq8EX6BuVU1EoN5yobClb6XB5fcDy9bKeQE6eCTE8Gs1YA4IdpI0i+SLz67uCR5jSaYy+ihHEGsZPmjPooU8e/vU5HQped6ISO2XS1Zk68Jl/g8gQhdHiZYQ5y31v3s/H7zHvFSGKLoE6B5KpplWyitjDe7POUCOqu91v1iMg2iivFbdQw==
If that flag is not set, fail with EOPNOTSUPP instead of ENXIO. This
is consistent with POSIX, starting with the 2016 edition. Earlier
editions were silent on this issue.
---
winsup/cygwin/fhandler_socket.cc | 13 +++++++++++--
winsup/cygwin/release/3.1.3 | 5 +++++
winsup/doc/new-features.xml | 5 +++++
3 files changed, 21 insertions(+), 2 deletions(-)
create mode 100644 winsup/cygwin/release/3.1.3
diff --git a/winsup/cygwin/fhandler_socket.cc b/winsup/cygwin/fhandler_socket.cc
index 9f33d8087..4a46d5a64 100644
--- a/winsup/cygwin/fhandler_socket.cc
+++ b/winsup/cygwin/fhandler_socket.cc
@@ -269,8 +269,17 @@ fhandler_socket::fcntl (int cmd, intptr_t arg)
int
fhandler_socket::open (int flags, mode_t mode)
{
- set_errno (ENXIO);
- return 0;
+ /* We don't support opening sockets unless O_PATH is specified. */
+ if (!(flags & O_PATH))
+ {
+ set_errno (EOPNOTSUPP);
+ return 0;
+ }
+
+ query_open (query_read_attributes);
+ nohandle (true);
+ set_flags (flags);
+ return 1;
}
int __reg2
diff --git a/winsup/cygwin/release/3.1.3 b/winsup/cygwin/release/3.1.3
new file mode 100644
index 000000000..8755c93df
--- /dev/null
+++ b/winsup/cygwin/release/3.1.3
@@ -0,0 +1,5 @@
+What changed:
+-------------
+
+- Sockets can now be opened with the O_PATH flag. If that flag is not
+ specified, the errno is now EOPNOTSUPP instead of ENXIO.
diff --git a/winsup/doc/new-features.xml b/winsup/doc/new-features.xml
index 65bdc17ab..c8b48d1ca 100644
--- a/winsup/doc/new-features.xml
+++ b/winsup/doc/new-features.xml
@@ -54,6 +54,11 @@ Allow times(2) to have a NULL argument, as on Linux.
Improve /proc/cpuinfo output and align more closely with Linux.
</para></listitem>
+<listitem><para>
+Sockets can now be opened with the O_PATH flag. If that flag is not
+specified, the errno is now EOPNOTSUPP instead of ENXIO.
+</para></listitem>
+
</itemizedlist>
</sect2>
--
2.21.0