delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2020/09/25/14:51:09

X-Recipient: archive-cygwin AT delorie DOT com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 721F33972035
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
s=default; t=1601059818;
bh=qKoYWPwZ3P5o0hZIHuxFVGdksy9lrO2bvP2nXkr5cC0=;
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=yswERBOEgd7CueC0slSBqpV2UasWOCOlD/jG25y/S3kACyH7C1PKXPtKNAGiaOGA5
vE5yo/k/o3VX6QzyppfYmABA4oVD9ChAokddTZNDwz+10LN6l2Kl/7Ztjg05ICY0ns
yXXp1T8NYqaxG2a/d6LD4pmMeBI8fl74dgKNiT1k=
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 3E0F0385DC14
ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none;
b=M/tAFhPOQM1H6jw6pdhKNt9yzcm9l5YgbjACAl89oqTdjgMqLMybCO07A3Wfoi3Y5wN33nWt2TgfyaQGIkYeK10a+2p+BSU/wyV8zzhtLKwKhCIq6WVVxbpXogh7DIgXt//ux0SNInx6q2ptx+3P8ef88cBRN8Uk7ERSxtFnOfV6KkRakZ0I1U9QB7T5QnMpUIjBU3l/6zHlGxohj2UShGwAYyE2/5TOpnGI6VnTKw9Gbuc8tdI7R49UbuhVMZ8fw0nMKNh7l9xr2gqqMzyFjG5CuZQ1ucwhDQaT+RGby9m/qUL9CrFuSPw1moud+j8YQlFHWhyLx3nJn9Yd6VR7sA==
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=8rli9Erkcau2NDSa7HF81a5R/aMxxRoqupxjoi849d8=;
b=ktaNMv8X0CxnFQY5pza4CT2zezq9ObFrt6Y9J/ZpA+ptD2EdAO+O5U6gfr27MTI3PxowaV4xn9gM/k6IoQ2MYwEuhPVBKP+HELvyukVglx1QXfmVr9cNX1CHE6mOskbuaBoCb3qKwQ2OaGT/P4du5Bri8x2snCttGXJYCWNoMvX7bJCFcr/i4MXGX6pAN3UVRjQYbN9MH5gEUKQ3o4LW0ZJ8zGxIq4eUjbDsBxIYvUZ8FlNhX176Zrwgaznmr/yT5+65eQYMWkM8uAcVLpueXKnvN19/F/W6y1AUsWYY941IrtIRzFN2MbeXXwCqVCRgBwt7GXBW0EIfR4tYBglDHA==
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>
Message-ID: <3e3cfe17-7fda-b063-4885-9114db9e748d@cornell.edu>
Date: Fri, 25 Sep 2020 14:50:11 -0400
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101
Thunderbird/68.12.0
In-Reply-To: <d9a6467d-e797-8917-3240-e79d55dcfb38@oracle.com>
X-Originating-IP: [68.175.129.7]
X-ClientProxiedBy: BL1PR13CA0030.namprd13.prod.outlook.com
(2603:10b6:208:256::35) 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: 73a96a9f-e075-43b9-44f9-08d86183d661
X-MS-TrafficTypeDiagnostic: MN2PR04MB6207:
X-Microsoft-Antispam-PRVS: <MN2PR04MB6207EE99340852D91DDAE793D8360 AT MN2PR04MB6207 DOT namprd04 DOT prod DOT outlook DOT com>
X-MS-Oob-TLC-OOBClassifiers: OLM:8882;
X-MS-Exchange-SenderADCheck: 1
X-Microsoft-Antispam: BCL:0;
X-Microsoft-Antispam-Message-Info: qp09UZr0C6JZwwyhu6CC9A+wZLH0yYLn1DIsSzBaV/LIU6AxFjYLFBwYQqVZeFNayq8cj3TPccpCbdCakTO+dZzgCoZAqfOvSf7DeYzQePV84EFJafvq5rlvDw2ECegH6BEM7nHH2jjb/OdP8MYwPbW7wJqz3JKM34k9caJzglVwt9jDNKfwz0InCrAsHfeP8YXF67zuNjURjJhtvUNv8/sj81weYMVjC9Q9or76p3E0Pbo+5SLVu1es718UnakOmfi9koh6djN2eawweaDzp09hH0ULLqwUOsRi7owwOjA+arD7bW/RD86ESl97ypcMQezNTzsAav1yiPnQCKTXuu29YTo2p2r7OHGaa0NXE+STV2sT4sxLkk6gGL0IBSdDFXSXbxVny0dWBS8RY07n9DyAjhkoT3K4YP+iYt5EoEzCPtg28+riSBouSCGpS7uXsTytmZiUVp0FhF7b+DJ59EQXkGdPYka2tPQs1kmQCREzZcE+bC7+wrTo/Rd1J/aoEGLl3dYk/W5Et3O8E/SqUg==
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)(376002)(346002)(396003)(366004)(136003)(39860400002)(16526019)(66476007)(186003)(66946007)(66556008)(36756003)(26005)(31696002)(31686004)(86362001)(75432002)(53546011)(966005)(2906002)(5660300002)(6486002)(52116002)(16576012)(956004)(2616005)(786003)(316002)(8676002)(8936002)(83380400001)(478600001)(43740500002)(460985005)(2480315003);
DIR:OUT; SFP:1102;
X-MS-Exchange-AntiSpam-MessageData: yhj/0HRfXLm+zxZbUhLULr/IjAVkqSeVz8Nc6UqQxfwlHMUp63Lc16Jf9ni+pbsxXieU6DWQ0P7wTBA0PfHZpBw1ZDmCtqSuSseVL0wAm5ng/+7dhC5/qS9G+t7j4ihzD1ciRoXJ8Yaecy69GT+PioJQA4VW0C+SWnMiaobYsi3En4vRNjRLR+cBJgXST22slsKBQVvMxplvZDrXtV96GC4P1bey8a83+VBKwiBaK+9DqsTKwR9+VcN0wSBpEtUA1tr/gShmz2zOSbPRplSW7OF1tzNNW7OTVVTpQt4nYnbqTWMyv27S4FJ8p7+7R6sF5atz6sGPdQGMjuC2fIHGt+aWh6GRvRAOpwr1aJC4dHoKa1P8OJF6KZksF6FwZ5ycZyZxnXQEi6iOZpUj2/EW4VDHExiObc10I7xx4fH/tSe3fKx+WqNODB/C4ARJvDyPAiMNIxS3J0os3MQv8qzFVTuTffYqSdu9tzPvaS2MsPEbStwhu1vEvlPo6jO5WazRksm+PuhDiR1Wf+HFZDJ2rsGJRB2ACzYw9VnUb6ZKGyJhg9yTZA+imDEddqTrSuMdAocETEdGXWkgkF+hLMW4eRJD5zOlI7zoqHEEjqk6R6iInUIkGWQDmch5njwb8vhSK/gzY9j0ORNZxtpYz7S9KQ==
X-OriginatorOrg: cornell.edu
X-MS-Exchange-CrossTenant-Network-Message-Id: 73a96a9f-e075-43b9-44f9-08d86183d661
X-MS-Exchange-CrossTenant-AuthSource: MN2PR04MB6176.namprd04.prod.outlook.com
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Sep 2020 18:50:13.9733 (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: GNzFRFertpu8ZnBiCddqsjvbXbaUAnmW+7ZeIUOXM8Bn8VUSBU4Zy6yAT5BsrMvdAen49pMvYfmfq1E8QepQDA==
X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR04MB6207
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 08PIohJI022644

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.

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