From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from conssluserg-02.nifty.com (conssluserg-02.nifty.com [210.131.2.81]) by sourceware.org (Postfix) with ESMTPS id BE2DA395B45E for ; Fri, 27 May 2022 10:51:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org BE2DA395B45E Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=nifty.ne.jp Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=nifty.ne.jp Received: from HP-Z230 (ak044095.dynamic.ppp.asahi-net.or.jp [119.150.44.95]) (authenticated) by conssluserg-02.nifty.com with ESMTP id 24RApMCV014048 for ; Fri, 27 May 2022 19:51:22 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-02.nifty.com 24RApMCV014048 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.ne.jp; s=dec2015msa; t=1653648682; bh=kd0cI1GrTWFE9D76KF5JRNA2bdkmOPDK3U7D3yODYXg=; h=Date:From:To:Subject:In-Reply-To:References:From; b=WGZwGR8YcCpwLwnh+9gzfIOr2ZS6f6QMoyQFxlPhcFOv8dspYTDu/fkXrZtM/PshX us4dRuyzigO9poxL6U/yLjgFk4ux6krBd4oTtLPzDYB/onLFZ8QvGsgvMsil9ArENQ Mkh5TyQs6VJiBvAaNFj5pHuUB759xXx28BdD6h9kxmvg744y/NnP+4TnbZkS9lSbYn FH0ASzWlIx2lwakEf2XD2k/v87l/coKFrCIGUCSJMFIYjViBY4UL7OUpFiB+lBTsaJ 0ImI1S4ECdJVupW7bdHX/qKi5z2ayOfQOo+yHSu7oJpaghl6dfuooWvwl6HzFgKPtE Q8xmSNWL2aMgQ== X-Nifty-SrcIP: [119.150.44.95] Date: Fri, 27 May 2022 19:51:23 +0900 From: Takashi Yano To: cygwin@cygwin.com Subject: Re: Unable to execute Cygwin application within UDF format Message-Id: <20220527195123.abd2d66a17e28b51f1a745a3@nifty.ne.jp> In-Reply-To: <20220527181849.6baaa5d9e8446f3e7d23cbee@nifty.ne.jp> References: <20220527133120.58530edd99f4a87c605b8a04@nifty.ne.jp> <20220527181849.6baaa5d9e8446f3e7d23cbee@nifty.ne.jp> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.30; i686-pc-mingw32) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: cygwin@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: General Cygwin discussions and problem reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 May 2022 10:51:43 -0000 On Fri, 27 May 2022 18:18:49 +0900 Takashi Yano wrote: > On Fri, 27 May 2022 16:47:09 +0800 > Sam Lin wrote: > > I have also successfully executed that is to move cygwin1.dll to the root > > directory to execute. > > > > Will cygwin1.dll be supported to execute in UDF format in the future? > > As I wrote earlier, it doesn't matter that the file system > is UDF. cygwin1.dll 3.2.0 and later seems to cause problems > if it is placed in the root directory. > > Even with UDF format, the problem does not occur if hello.exe > and cygwin1.dll are placed in any directory other than root > directory. I looked into this problem and found the problem occurs after the commit: commit 6d898f43fc87a7bf3ab100d75538e381bd86f657 Author: Corinna Vinschen Date: Fri Feb 19 18:15:58 2021 +0100 Cygwin: realpath: fix cygwin installation dir being access via junction Consider this case: - Cygwin installed in C:\cygwin64 - mklink /j D:\cygwin64 C:\cygwin64 - create testcase calling realpath("/", result); printf ("%s\n", result); - start cmd >C:\cygwin64\bin\bash -lc / >D\cygwin64\bin\bash -lc /cygdrive/c/cygwin64 This scenario circumventing the mount point handling which is automated in terms of /, depending on the path returned from GetModuleFileNameW for the Cygwin DLL. When calling D:\cygwin64\bin\bash the dir returned from GetModuleFileNameW is D:\cygwin64\bin, thus root is D:\cygwin64. However, junctions are treated as symlinks in Cygwin which explains why the path gets converted to a cygdrive path. Fix this by calling GetFinalPathNameByHandleW on the result from GetModuleFileNameW to get the correct root path, even if accessed via a junction point. Signed-off-by: Corinna Vinschen And also found the following patch fixes the issue. diff --git a/winsup/cygwin/cygheap.cc b/winsup/cygwin/cygheap.cc index 01b49468e..c4031b919 100644 --- a/winsup/cygwin/cygheap.cc +++ b/winsup/cygwin/cygheap.cc @@ -183,6 +183,8 @@ init_cygheap::init_installation_root () if (p) p = wcschr (p + 1, L'\\'); /* Skip share name */ } + else + p = installation_root_buf + 4; /* 4 is the length of "\\\\?\\" */ } installation_root_buf[1] = L'?'; RtlInitEmptyUnicodeString (&installation_key, installation_key_buf, -- Takashi Yano