delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2020/09/25/16:31:46

X-Recipient: archive-cygwin AT delorie DOT com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 40C1F385702F
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
s=default; t=1601065855;
bh=wzpuJmrfIrhFsIIlo7YiE9FkzLa+0xpadQHh0kMEKKw=;
h=Subject:To:References:Date:In-Reply-To:List-Id:List-Unsubscribe:
List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:
From;
b=HqlAxnjjyAYukGchbi3wsGaFMjLdM3K0E4C9kJ0wvqr0bnKHYOrn9woNG7RDyJFQO
nwjJeqbaQ7ZcIMoZIDDtaSRnBJGMqrHA/ctAf7jhvRFiaqrr0knXjGBdFj/vpbJdJv
JU5/5Eq39nuzktnQbH//CZE6pjMeB33nwKziy3HE=
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org DA212385702F
ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none;
b=UeLNHg7ULwlXoRq/p3Dp6GCRtT5l3GM2UWx/HA1KkrWWcDupwl2WA+SVQOGdlTsZb3h+IK0UVifWFYUvC2E4iXXgXRbPnpfYng/hbfSCWtPpcXS7GgL/8W8Y24LZiOYdyH3X5Pd+FMz/fNPZxARGgW8nXmVOTq1wXoJlXa3Qcn+FvxkHYzZFVi7PcX4M//T9fGyu/rdjulkj73O00UsK3VpbH/7O16hjAFZ7Ja2rcukwLUtVPHPd3zGlJlWFt5+uArK/G20iTnHvpZgXpFM7hlPIISWO621X9UaRBvVn2gjG9u2A3PZQ9kQZ5z9S8U6e7HkGce/nC21rZLZSYoQtxA==
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=78YT57GySg8K1GCYth5PK31au0ayYnGtq63p+Mxz3r0=;
b=CRUxW24y9Y92n0oJJuPHHcgeNVqKQeVxTrxnnHAftpZWVSqaQiEq79W48BrDCMp5eWjnTDadpZshQ26wYZd02k5/5EpRewU2QotoeQU9ml7Eg/vYy3OJhoVkYN9yU5SYf63GSsQRfBBkDjGwu/MrFcIkWra4olJJQyJEN2an2N+dBzOO+cwri721CycO/RfhBiTs3dgsjwhCaQA9ZE+Sxq9kPvV+R2BVCDorG/GcXSKQE345hmWud0ZJYdMDDbjwjtSFBSJouxlwPlfxGTTF3MlOVkqp8tXA2jO7Y9t4a/e4HvlTBQ0/EDizs0WIUb+4Gs9tObr7Q4wznkbMqc6zGQ==
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
Subject: Re: Problems with native Unix domain sockets on Win 10/2019
To: Michael McMahon <michael DOT x DOT mcmahon AT oracle DOT com>, cygwin AT cygwin DOT com
References: <2b0aeab4-983d-e1d7-301f-edfeeb38cc85 AT oracle DOT com>
<db0f2634-328c-baaa-1cdb-5bd3c145c9e0 AT cornell DOT edu>
<bb34a767-0cb5-1d48-7f9b-ad914762f9f7 AT oracle DOT com>
<97d2b3af-224a-6873-fb4a-55a0ae9cd379 AT cornell DOT edu>
<d9a6467d-e797-8917-3240-e79d55dcfb38 AT oracle DOT com>
<3e3cfe17-7fda-b063-4885-9114db9e748d AT cornell DOT edu>
Message-ID: <70b5577f-2cf1-0110-5d3b-cb2bd8ee6df2@cornell.edu>
Date: Fri, 25 Sep 2020 16:30:45 -0400
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101
Thunderbird/68.12.0
In-Reply-To: <3e3cfe17-7fda-b063-4885-9114db9e748d@cornell.edu>
X-Originating-IP: [68.175.129.7]
X-ClientProxiedBy: CH2PR05CA0056.namprd05.prod.outlook.com
(2603:10b6:610:38::33) To MN2PR04MB6176.namprd04.prod.outlook.com
(2603:10b6:208:e3::13)
MIME-Version: 1.0
X-MS-Exchange-MessageSentRepresentingType: 1
X-MS-PublicTrafficType: Email
X-MS-Office365-Filtering-Correlation-Id: 3fb89bc6-56f9-4281-6c85-08d86191e2f5
X-MS-TrafficTypeDiagnostic: MN2PR04MB5616:
X-Microsoft-Antispam-PRVS: <MN2PR04MB5616E47259D7474E98AC2240D8360 AT MN2PR04MB5616 DOT namprd04 DOT prod DOT outlook DOT com>
X-MS-Oob-TLC-OOBClassifiers: OLM:9508;
X-MS-Exchange-SenderADCheck: 1
X-Microsoft-Antispam: BCL:0;
X-Microsoft-Antispam-Message-Info: 3MS2JEgxVRLCaCInDBlAi/Zpk6BvT8j+BlJMJ6O8YFNrDIPGbFWD2FAA3RUZKYMJWeQkSiRgfiva+1pwekt1dLrfq4/9c+LXNQ28KY/E6hX8zpaum1vnh+Gt2Jaus8/2Rv4S74ft12Y+mS0MvWjKwh4PvJ38fPVsm1/3SUbk7FCHBlbsU6rBINlkwNKq4sSfc0fsqEpotnvrtP9+5yMnTRn2GruxXNQItjCfsI0HBDDBTl7OcKdXnL662xxCNqpz4jaX0wfZ6zM8yW7Rl5FsbcNRJhjHnvUY2XRwwLWSDs58V3DNLRhFFs/1/xs8NwM/i0QN3OxvxV7eJbAuH2LogwDx+x4elBZKjBfoSAWnnQfLPmOdBwLoBVlGhlnGFW06iLmZmZFbg9VMvk/PXY4HSNVc0/+EubJ5YwHshHqzKTSRR60GE25VUUMMhMf8EdxvonOI1g/7rprZb7T1wBR4BUgLjlIOEbn29Z3yA0RwPPMY3cvA/+inZ+Rqg5LOdF0il7Bz5u/LMZ7Bb/q2ZV1B+A==
X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:;
IPV:NLI; SFV:NSPM; H:MN2PR04MB6176.namprd04.prod.outlook.com; PTR:; CAT:NONE;
SFS:(4636009)(396003)(376002)(346002)(39860400002)(366004)(136003)(66556008)(66476007)(8936002)(6486002)(66946007)(2906002)(31696002)(75432002)(31686004)(36756003)(966005)(5660300002)(83380400001)(52116002)(478600001)(26005)(186003)(956004)(16526019)(16576012)(2616005)(786003)(316002)(53546011)(86362001)(8676002)(43740500002)(460985005);
DIR:OUT; SFP:1102;
X-MS-Exchange-AntiSpam-MessageData: QPWm3jKN7j7UG0lNyGtVcq7Fm+vBqxhS3NvTfUMtXNWwija18Ln8H4RskWrBIKwIv1qjxtiYi2hPbDu/tINOIW4PRBsuWqY/exHnCmzZSGUK1KP5htrRbwZIVMD2utVaJ+gFHXFaLf8oqEzBYa/+oHgEBdBTCDPTkodsrK5n+vt46ABL57NuNGC4t6rFJzndrtRAxOH7Fz/ih3eaengePapq0v+/JSyt4UCXSVRlJbQsOns3MVwKBz+0AwByzEotxlrTbArlHk+DrF8gSP+3PFAkdN/UViV1Zh8ZATeT5pIuncnRUhCL2zSLSjYCTqZUHgK5FSGHNpHRoUP3BHe+EnE/3kasrYwWDaLrqcLI30OkgYABP5M+k2VTPEp8JHV23ifJZ6CgbRl9B8JbXexRoNJ12XLpZZ6f8ggTzyvVH1kOtUgbLY7udFSLSk7HgXPhs4FukBVHdExgVziGYIqsD8RrQXlcU1Ish0ufTZZI2mtlYFB2JIT48A7kbSpE6m0ZrJG8SV9DhoFKjjF19Hozxe49ITA+aTlv9jmzvkFKyfBI2wxkdrqBebtYkgedD+9j1U1KIykgvKpYJ0SksdeFH52b3bzAOfQXvZLdZPjFpD38eUDHaz3sYlY0ZdPh9vsM3meedwE1muAlzinD9FVHZQ==
X-OriginatorOrg: cornell.edu
X-MS-Exchange-CrossTenant-Network-Message-Id: 3fb89bc6-56f9-4281-6c85-08d86191e2f5
X-MS-Exchange-CrossTenant-AuthSource: MN2PR04MB6176.namprd04.prod.outlook.com
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Sep 2020 20:30:48.2959 (UTC)
X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted
X-MS-Exchange-CrossTenant-Id: 5d7e4366-1b9b-45cf-8e79-b14b27df46e1
X-MS-Exchange-CrossTenant-MailboxType: HOSTED
X-MS-Exchange-CrossTenant-UserPrincipalName: LQvr6wrskaCaX4Bo/VslwTfpAomq7sCPWBy4LEMbdEihDcQ0HMJXLbQYeNwEv5qALtdln6JnoieDVwSpLmnktA==
X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR04MB5616
X-Spam-Status: No, score=-0.5 required=5.0 tests=BAYES_00, BODY_8BITS,
DKIM_INVALID, DKIM_SIGNED, KAM_DMARC_STATUS, MSGID_FROM_MTA_HEADER,
NICE_REPLY_A, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS,
TXREP autolearn=no autolearn_force=no version=3.4.2
X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on
server2.sourceware.org
X-BeenThere: cygwin AT cygwin DOT com
X-Mailman-Version: 2.1.29
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Unsubscribe: <https://cygwin.com/mailman/options/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=unsubscribe>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-request AT cygwin DOT com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=subscribe>
From: Ken Brown via Cygwin <cygwin AT cygwin DOT com>
Reply-To: Ken Brown <kbrown AT cornell DOT edu>
Errors-To: cygwin-bounces AT cygwin DOT com
Sender: "Cygwin" <cygwin-bounces AT cygwin DOT com>
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id 08PKVLoT032546

On 9/25/2020 2:50 PM, Ken Brown via Cygwin wrote:
> On 9/25/2020 10:29 AM, Michael McMahon wrote:
>>
>>
>> On 25/09/2020 14:19, Ken Brown wrote:
>>> On 9/24/2020 8:01 AM, Michael McMahon wrote:
>>>>
>>>>
>>>> On 24/09/2020 12:26, Ken Brown wrote:
>>>>> On 9/23/2020 7:25 AM, Michael McMahon via Cygwin wrote:
>>>>>> Hi,
>>>>>>
>>>>>> I searched for related issues but haven't found anything.
>>>>>>
>>>>>> I am having some trouble with Windows native Unix domain sockets
>>>>>> (a recent feature in Windows 10 and 2019 server) and Cygwin.
>>>>>> I think I possibly know the cause since I had to investigate a similar
>>>>>> looking issue on another platform built on Windows.
>>>>>>
>>>>>> The problem is that cygwin commands don't seem to recognise native Unix
>>>>>> domain sockets correctly. For example, the socket "foo.sock" should
>>>>>> have the same ownership and similar permissions to other files
>>>>>> in the example below:
>>>>>>
>>>>>> $ ls -lrt
>>>>>> total 2181303
>>>>>>
>>>>>> -rw-r--r--  1 mimcmah      None             1259   Sep 23 10:22 test.c
>>>>>> -rwxr-xr-x  1 mimcmah      None             3680   Sep 23 10:22 test.obj
>>>>>> -rwxr-xr-x  1 mimcmah      None             121344 Sep 23 10:22 test.exe
>>>>>> -rw-r-----  1 Unknown+User Unknown+Group         0 Sep 23 10:23 foo.sock
>>>>>> -rw-r--r--  1 mimcmah      None             144356 Sep 23 10:27 check.ot
>>>>>>
>>>>>> A bigger problem is that foo.sock can't be deleted with the cygwin "rm"
>>>>>> command.
>>>>>>
>>>>>> $ rm -f foo.sock
>>>>>> rm: cannot remove 'foo.sock': Permission denied
>>>>>>
>>>>>> $ chmod 777 foo.sock
>>>>>> chmod: changing permissions of 'foo.sock': Permission denied
>>>>>>
>>>>>> $ cmd /c del foo.sock
>>>>>>
>>>>>> But, native Windows commands are okay, as the third example shows.
>>>>>>
>>>>>> I think the problem may relate to the way native Unix domain sockets are
>>>>>> implemented in Windows and the resulting special handling required.
>>>>>> They are implemented as NTFS reparse points and when opening them
>>>>>> with CreateFile, you need to specify the FILE_FLAG_OPEN_REPARSE_POINT
>>>>>> flag. Otherwise, you get an ERROR_CANT_ACCESS_FILE. There are other
>>>>>> complications unfortunately, which I'd be happy to discuss further.
>>>>>>
>>>>>> But, to reproduce it, you can compile the attached code snippet
>>>>>> which creates foo.sock in the current directory. Obviously, this
>>>>>> only works on recent versions of Windows 10 and 2019 server.
>>>>>
>>>>> Cygwin doesn't currently support native Windows AF_UNIX sockets, as you've 
>>>>> discovered.  See
>>>>>
>>>>> https://urldefense.com/v3/__https://cygwin.com/pipermail/cygwin/2020-June/245088.html__;!!GqivPVa7Brio!P7lIFI4rYAtWh8_DtCbRCxT-M_E4vwQ0qwzQ0p656T73BpJ0jbUkLI_bXdA6mmSL9lJcSQ$ 
>>>>>
>>>>> for the current state of AF_UNIX sockets on Cygwin, including the 
>>>>> possibility of using native Windows AF_UNIX sockets on systems that support 
>>>>> them.
>>>>>
>>>>> If all you want is for Cygwin to recognize such sockets and allow you to 
>>>>> apply rm, chmod, etc., I don't think it would be hard to add that 
>>>>> capability.  But I doubt if that's all you want.
>>>>>
>>>>> Further discussion of this will have to wait until Corinna is available.
>>>>>
>>>>
>>>> Thanks for the info. It's mainly about recognition of sockets for
>>>> regular commands. Since these objects can exist on Windows filesystems
>>>> now, potentially created by any kind of Windows application,
>>>> it would be great if Cygwin could handle them, irrespective of whether
>>>> the Cygwin development environment does. Though that sounds like a
>>>> good idea too.
>>>
>>> I think this has a simple fix (attached), but I can't easily test it because 
>>> your test program doesn't compile for me.  First, I got
>>>
>>> $ gcc -o native_unix_socket native_unix_socket.c
>>> native_unix_socket.c:5:10: fatal error: WS2tcpip.h: No such file or directory
>>>      5 | #include <WS2tcpip.h>
>>>        |          ^~~~~~~~~~~~
>>> compilation terminated.
>>>
>>> I fixed this by making the include file name lower case.  (My system is case 
>>> sensitive, so it matters.)
>>>
>>> Next:
>>>
>>> $ gcc -o native_unix_socket native_unix_socket.c
>>> native_unix_socket.c:8:10: fatal error: afunix.h: No such file or directory
>>>      8 | #include <afunix.h>
>>>        |          ^~~~~~~~~~
>>> compilation terminated.
>>>
>>> There's no file afunix.h in the Cygwin distribution, but I located it online 
>>> and pasted in the contents.  The program now compiles but fails to link:
>>>
>>> $ gcc -o native_unix_socket native_unix_socket.c
>>> /usr/lib/gcc/x86_64-pc-cygwin/10/../../../../x86_64-pc-cygwin/bin/ld: 
>>> /tmp/cc74urPr.o:native_unix_socket.c:(.text+0x3b): undefined reference to 
>>> `__imp_WSAStartup'
>>> /tmp/cc74urPr.o:native_unix_socket.c:(.text+0x3b): relocation truncated to 
>>> fit: R_X86_64_PC32 against undefined symbol `__imp_WSAStartup'
>>> /usr/lib/gcc/x86_64-pc-cygwin/10/../../../../x86_64-pc-cygwin/bin/ld: 
>>> /tmp/cc74urPr.o:native_unix_socket.c:(.text+0xf2): undefined reference to 
>>> `__imp_WSAGetLastError'
>>> /tmp/cc74urPr.o:native_unix_socket.c:(.text+0xf2): relocation truncated to 
>>> fit: R_X86_64_PC32 against undefined symbol `__imp_WSAGetLastError'
>>> /usr/lib/gcc/x86_64-pc-cygwin/10/../../../../x86_64-pc-cygwin/bin/ld: 
>>> /tmp/cc74urPr.o:native_unix_socket.c:(.text+0x13d): undefined reference to 
>>> `__imp_WSAGetLastError'
>>> /tmp/cc74urPr.o:native_unix_socket.c:(.text+0x13d): relocation truncated to 
>>> fit: R_X86_64_PC32 against undefined symbol `__imp_WSAGetLastError'
>>> collect2: error: ld returned 1 exit status
>>>
>>> This is probably easy to fix too, but I don't feel like tracking it down. 
>>> Please send compilation instructions (that use Cygwin tools).
>>>
>>> Ken
>>
>> Hi
>>
>> Sorry, I had compiled it in a native Visual C environment.
>>
>> Assuming you have afunix.h in the current directory.
>>
>> gcc -o native_unix_socket -I. native_unix_socket.c -lws2_32
>>
>> should do it.
> 
> Thanks, that works.  But now I can't reproduce your problem.  Here's what I see, 
> using Cygwin 3.1.7 without applying my patch:
> 
> $ ./native_unix_socket.exe
> getsockname works
> fam = 1, len = 11
> offsetof clen = 9
> strlen = 8
> name = foo.sock
> 
> $ ls -l foo.sock
> -rwxr-xr-x 1 kbrown None 0 2020-09-25 14:39 foo.sock*
> 
> $ chmod 644 foo.sock
> 
> $ ls -l foo.sock
> -rw-r--r-- 1 kbrown None 0 2020-09-25 14:39 foo.sock
> 
> $ rm foo.sock
> 
> $ ls -l foo.sock
> ls: cannot access 'foo.sock': No such file or directory
> 
> I'm running 64-bit Cygwin on Windows 10 1909.

I just ran the 'rm' command under gdb to see what's going on, and it seems that 
foo.sock is not being recognized as a reparse point.  So maybe your test 
program, when compiled and run under Cygwin, doesn't actually produce a native 
Windows AF_UNIX socket.  And when I try to run it in a Windows Command Prompt, I get

bind failed 10050
getsockname failed 10022

Can you make your version of the test executable available for me to try?  Or 
tell me some other way to create a native Windows AF_UNIX socket?

Ken
--
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019