This is the mail archive of the
cygwin-patches
mailing list for the Cygwin project.
Re: [PATCH] Cygwin: allow opening an AF_LOCAL/AF_UNIX socket with O_PATH
- From: Ken Brown <kbrown at cornell dot edu>
- To: "cygwin-patches at cygwin dot com" <cygwin-patches at cygwin dot com>
- Date: Wed, 22 Jan 2020 21:37:22 +0000
- Subject: Re: [PATCH] Cygwin: allow opening an AF_LOCAL/AF_UNIX socket with O_PATH
- 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=MeBcoA03a1d/0vtMPp7vGkXLYbxXKYZxHswJEnKZLBQ=; b=HW75hHq9XrfQ3wE3lWKp4ReQW/iHwDyf996f4lNViwYb48wtTkj6yhBxbIw/WefZultN3C2REUeJj/sFSzwSYWtUOTABs6eI63PuO0BjEdvwOImDTyzAy6f1nfaUbzPpOFQ9s1WfK33eysTXHsukxpj+8Y4+eQpTlCDvbBKgiAhITBDQOGwCRQYlGQJntsj0tR7zkJTRGzhFEGo9yl1WS7QfhQGalh4hEYNzMapjyZQQyGDoOn8zFYvrOt2UtYet/Rp2fev3RXQd+PbH9yMAOa5QX0pnZ7HF5ty0ywZAm61d+cmXxkmUX3uX44Gb6AhabYf1xSNWA31CyNd+Gj5PXQ==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jNH8bD362Pr8DwLbu5S5NcX0jZWDaVXNUz3uKt3S/2YIkv3KPX9up4QFTydxUvOF6ptJrZxD/+IWJkFuVk2fful+httgPDfDeO8vEj4Fc0yMH5nEWfi3UqGy3Yk9xi6Wl7kUlEY3oi3n2YDEUcVthYkie7j0m/DV6pfgdkxXfwnCiZi65SFz6tksRgpi1WxY2J0SZMETgUT1ccoNhZP/swSHK01rzo/rYS7FQJ0XGMKhOf0m+WRlSL3DBXathZwA9Umy4u5peGck5r934EQ3xY2q9TMjvxv1F0BB+I7/iZEXQ+sTbAdT8sJOTmj1N1uq09L0IEdsV7mR3chWfEp75A==
- References: <20200116183355.1177-1-kbrown@cornell.edu> <20200117094826.GC5858@calimero.vinschen.de> <20200117095104.GD5858@calimero.vinschen.de> <f94efc8e-28d3-fd68-d6e4-a092637cf6e8@cornell.edu> <20200120093541.GC20672@calimero.vinschen.de>
On 1/20/2020 4:35 AM, Corinna Vinschen wrote:
> On Jan 19 20:25, Ken Brown wrote:
>> On 1/17/2020 4:51 AM, Corinna Vinschen wrote:
>>> On Jan 17 10:48, Corinna Vinschen wrote:
>>>> On Jan 16 18:34, Ken Brown wrote:
>>>>> If that flag is not set, or if an attempt is made to open a different
>>>>> type of socket, the errno is now EOPNOTSUPP instead of ENXIO. This is
>>>>> consistent with POSIX, starting with the 2016 edition. Earlier
>>>>> editions were silent on this issue.
>>>>> ---
>>>>> winsup/cygwin/fhandler.h | 2 ++
>>>>> winsup/cygwin/fhandler_socket.cc | 2 +-
>>>>> winsup/cygwin/fhandler_socket_local.cc | 16 ++++++++++++++++
>>>>> winsup/cygwin/fhandler_socket_unix.cc | 16 ++++++++++++++++
>>>>> winsup/cygwin/release/3.1.3 | 7 +++++++
>>>>> winsup/doc/new-features.xml | 6 ++++++
>>>>> 6 files changed, 48 insertions(+), 1 deletion(-)
>>>>
>>>> I'm a bit concerned here that some function calls might succeed
>>>> accidentally or even crash, given that the original socket code doesn't
>>>> cope with the nohandle flag. Did you perform some basic testing?
>>>
>>> Iow, do the usual socket calls on a fhandler_socket_local return EBADF
>>> now? Ignoring fhandler_socket_unix for now.
>>
>> I really hadn't thought this through very well. I think the following
>> additional patch should do the job:
>>
>> --- a/winsup/cygwin/net.cc
>> +++ b/winsup/cygwin/net.cc
>> @@ -67,6 +67,11 @@ get (const int fd)
>>
>> if (!fh)
>> set_errno (ENOTSOCK);
>> + else if (fh->get_flags () & O_PATH)
>> + {
>> + set_errno (EBADF);
>> + fh = NULL;
>> + }
>>
>> return fh;
>> }
>
> Looks like the easiest solution indeed.
It turns out that some further tweaks are needed, so it may be a while before a
finish this. And in the course of working on it, I discovered that I was
careless when I attempted to support O_PATH for FIFOs in commit aa55d22c. So
I'll be sending a fix for that shortly, along with a test program, and then I'll
return to the socket case.
I *think* what I did for symlinks is OK as it stands, but I'll recheck that too
with a suitable test program.
Ken