From unknown Sun Aug 17 22:05:33 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#36416 <36416@debbugs.gnu.org> To: bug#36416 <36416@debbugs.gnu.org> Subject: Status: realpath doesn't preserve '//' in -m mode Reply-To: bug#36416 <36416@debbugs.gnu.org> Date: Mon, 18 Aug 2025 05:05:33 +0000 retitle 36416 realpath doesn't preserve '//' in -m mode reassign 36416 coreutils submitter 36416 L A Walsh severity 36416 normal tag 36416 notabug thanks From debbugs-submit-bounces@debbugs.gnu.org Fri Jun 28 08:53:06 2019 Received: (at submit) by debbugs.gnu.org; 28 Jun 2019 12:53:06 +0000 Received: from localhost ([127.0.0.1]:40525 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hgqNG-0001yT-Iz for submit@debbugs.gnu.org; Fri, 28 Jun 2019 08:53:06 -0400 Received: from lists.gnu.org ([209.51.188.17]:40139) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hgqNC-0001yJ-Pl for submit@debbugs.gnu.org; Fri, 28 Jun 2019 08:53:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44668) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hgqNA-00044Z-AC for bug-coreutils@gnu.org; Fri, 28 Jun 2019 08:53:02 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50 autolearn=disabled version=3.3.2 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hgqN5-0005tF-EW for bug-coreutils@gnu.org; Fri, 28 Jun 2019 08:53:00 -0400 Received: from ishtar.tlinx.org ([173.164.175.65]:43726 helo=Ishtar.sc.tlinx.org) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hgqN1-0005oB-IH for bug-coreutils@gnu.org; Fri, 28 Jun 2019 08:52:53 -0400 Received: from [192.168.3.12] (Athenae [192.168.3.12]) by Ishtar.sc.tlinx.org (8.14.7/8.14.4/SuSE Linux 0.8) with ESMTP id x5SBBTjr051349 for ; Fri, 28 Jun 2019 04:11:33 -0700 Message-ID: <5D15F5E1.6090905@tlinx.org> Date: Fri, 28 Jun 2019 04:11:29 -0700 From: L A Walsh User-Agent: Thunderbird MIME-Version: 1.0 To: Coreutils Subject: realpath doesn't preserve '//' in -m mode Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] X-Received-From: 173.164.175.65 X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) realpath -m //sysname/rootdir/. returns "/sysname/rootdir" This is incorrect, according to POSIX. and #3-4 have specific meanings in various applications that in usage. 1) leading double slashes are to be preserved My Notes: in combining paths like pathcat(//, sys, /a) => should get //sys/a in combining paths like pathcat(//, /sys, /a) => /sys sys specifies it wants to be directory, not a system., so at root, '//' refer to no system, and we just get: '/sys/a' 2) final slash indicates end node is a directory 3) a final . in a source specifies something under the directory name. ~4?) I don't think /.. at end of a pathname can be safely deleted and have same meaning as without it, but brain is too tired to detail right now. From debbugs-submit-bounces@debbugs.gnu.org Fri Jun 28 13:48:25 2019 Received: (at submit) by debbugs.gnu.org; 28 Jun 2019 17:48:25 +0000 Received: from localhost ([127.0.0.1]:42926 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hguz3-0008KR-4i for submit@debbugs.gnu.org; Fri, 28 Jun 2019 13:48:25 -0400 Received: from lists.gnu.org ([209.51.188.17]:37492) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hguz1-0008KK-SV for submit@debbugs.gnu.org; Fri, 28 Jun 2019 13:48:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57884) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hguyr-0000rC-Qy for bug-coreutils@gnu.org; Fri, 28 Jun 2019 13:48:22 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50 autolearn=disabled version=3.3.2 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hguyl-0004Lt-Tf for bug-coreutils@gnu.org; Fri, 28 Jun 2019 13:48:13 -0400 Received: from ishtar.tlinx.org ([173.164.175.65]:55280 helo=Ishtar.sc.tlinx.org) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hguyc-0004Fc-O2 for bug-coreutils@gnu.org; Fri, 28 Jun 2019 13:48:00 -0400 Received: from [192.168.3.12] (Athenae [192.168.3.12]) by Ishtar.sc.tlinx.org (8.14.7/8.14.4/SuSE Linux 0.8) with ESMTP id x5SHlrex095574; Fri, 28 Jun 2019 10:47:56 -0700 Message-ID: <5D1652C9.1090106@tlinx.org> Date: Fri, 28 Jun 2019 10:47:53 -0700 From: L A Walsh User-Agent: Thunderbird MIME-Version: 1.0 To: Coreutils Subject: Re: realpath doesn't preserve '..' consistently as per POSIX, nor '/.' References: <5D15F5E1.6090905@tlinx.org> In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] X-Received-From: 173.164.175.65 X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: submit Cc: Eric Blake X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) I don't recall reading anything about posix allowing the elimination of such paths. If I have an application layer on top of linux that processes those double slashes, it may or may not work depending on the underlying OS? That wouldn't be very portable w/r/t a Portable OS Information eXchange standard. I also specified the elimination of the single dots after a slash which in reality don't have the same meaning as the slash. It would useful if bugs were not closed before asking for more information. I've seen many bugs over the years that were closed when they were real bugs that came back and bit the project hard, including bugs that were closed out because I hadn't sent them through cygwin's list first when I knew they were not bugs in cygwin. On 2019/06/28 08:38, Eric Blake wrote: > tag ### notabug > thanks > > On 6/28/19 6:11 AM, L A Walsh wrote: >> realpath -m //sysname/rootdir/. >> returns "/sysname/rootdir" This is incorrect, according to POSIX. > > No, it is implementation-defined if it is correct. You failed to say > what platform you are on. If you are on Cygwin, where // is distinct > from /, then it is incorrect - but that's not the behavior of realpath > on Cygwin. If you are Linux, where // is an alias for /, then the > behavior is correct. > > Unless you can provide more details about which system you saw this > behavior on, and which version of realpath you tested, I'm marking this > as not a bug. > From debbugs-submit-bounces@debbugs.gnu.org Fri Jun 28 15:03:14 2019 Received: (at submit) by debbugs.gnu.org; 28 Jun 2019 19:03:14 +0000 Received: from localhost ([127.0.0.1]:43001 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hgw9R-0004Qv-Mh for submit@debbugs.gnu.org; Fri, 28 Jun 2019 15:03:14 -0400 Received: from lists.gnu.org ([209.51.188.17]:46547) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hgw9P-0004QW-3Q for submit@debbugs.gnu.org; Fri, 28 Jun 2019 15:03:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43696) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hgw9L-0005KR-05 for bug-coreutils@gnu.org; Fri, 28 Jun 2019 15:03:10 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_50,RCVD_IN_DNSWL_HI, URIBL_BLOCKED autolearn=disabled version=3.3.2 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hgw9H-0004FJ-67 for bug-coreutils@gnu.org; Fri, 28 Jun 2019 15:03:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44284) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hgw9G-00044K-Su for bug-coreutils@gnu.org; Fri, 28 Jun 2019 15:03:03 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6E6413DDB6; Fri, 28 Jun 2019 19:02:42 +0000 (UTC) Received: from [10.3.116.142] (ovpn-116-142.phx2.redhat.com [10.3.116.142]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F3F24608CA; Fri, 28 Jun 2019 19:02:40 +0000 (UTC) Subject: Re: realpath doesn't preserve '..' consistently as per POSIX, nor '/.' To: L A Walsh , Coreutils References: <5D15F5E1.6090905@tlinx.org> <5D1652C9.1090106@tlinx.org> From: Eric Blake Openpgp: preference=signencrypt Autocrypt: addr=eblake@redhat.com; keydata= xsBNBEvHyWwBCACw7DwsQIh0kAbUXyqhfiKAKOTVu6OiMGffw2w90Ggrp4bdVKmCaEXlrVLU xphBM8mb+wsFkU+pq9YR621WXo9REYVIl0FxKeQo9dyQBZ/XvmUMka4NOmHtFg74nvkpJFCD TUNzmqfcjdKhfFV0d7P/ixKQeZr2WP1xMcjmAQY5YvQ2lUoHP43m8TtpB1LkjyYBCodd+LkV GmCx2Bop1LSblbvbrOm2bKpZdBPjncRNob73eTpIXEutvEaHH72LzpzksfcKM+M18cyRH+nP sAd98xIbVjm3Jm4k4d5oQyE2HwOur+trk2EcxTgdp17QapuWPwMfhaNq3runaX7x34zhABEB AAHNHkVyaWMgQmxha2UgPGVibGFrZUByZWRoYXQuY29tPsLAegQTAQgAJAIbAwULCQgHAwUV CgkICwUWAgMBAAIeAQIXgAUCS8fL9QIZAQAKCRCnoWtKJSdDahBHCACbl/5FGkUqJ89GAjeX RjpAeJtdKhujir0iS4CMSIng7fCiGZ0fNJCpL5RpViSo03Q7l37ss+No+dJI8KtAp6ID+PMz wTJe5Egtv/KGUKSDvOLYJ9WIIbftEObekP+GBpWP2+KbpADsc7EsNd70sYxExD3liwVJYqLc Rw7so1PEIFp+Ni9A1DrBR5NaJBnno2PHzHPTS9nmZVYm/4I32qkLXOcdX0XElO8VPDoVobG6 gELf4v/vIImdmxLh/w5WctUpBhWWIfQDvSOW2VZDOihm7pzhQodr3QP/GDLfpK6wI7exeu3P pfPtqwa06s1pae3ad13mZGzkBdNKs1HEm8x6zsBNBEvHyWwBCADGkMFzFjmmyqAEn5D+Mt4P zPdO8NatsDw8Qit3Rmzu+kUygxyYbz52ZO40WUu7EgQ5kDTOeRPnTOd7awWDQcl1gGBXgrkR pAlQ0l0ReO57Q0eglFydLMi5bkwYhfY+TwDPMh3aOP5qBXkm4qIYSsxb8A+i00P72AqFb9Q7 3weG/flxSPApLYQE5qWGSXjOkXJv42NGS6o6gd4RmD6Ap5e8ACo1lSMPfTpGzXlt4aRkBfvb NCfNsQikLZzFYDLbQgKBA33BDeV6vNJ9Cj0SgEGOkYyed4I6AbU0kIy1hHAm1r6+sAnEdIKj cHi3xWH/UPrZW5flM8Kqo14OTDkI9EtlABEBAAHCwF8EGAEIAAkFAkvHyWwCGwwACgkQp6Fr SiUnQ2q03wgAmRFGDeXzc58NX0NrDijUu0zx3Lns/qZ9VrkSWbNZBFjpWKaeL1fdVeE4TDGm I5mRRIsStjQzc2R9b+2VBUhlAqY1nAiBDv0Qnt+9cLiuEICeUwlyl42YdwpmY0ELcy5+u6wz mK/jxrYOpzXKDwLq5k4X+hmGuSNWWAN3gHiJqmJZPkhFPUIozZUCeEc76pS/IUN72NfprZmF Dp6/QDjDFtfS39bHSWXKVZUbqaMPqlj/z6Ugk027/3GUjHHr8WkeL1ezWepYDY7WSoXwfoAL 2UXYsMAr/uUncSKlfjvArhsej0S4zbqim2ZY6S8aRWw94J3bSvJR+Nwbs34GPTD4Pg== Organization: Red Hat, Inc. Message-ID: Date: Fri, 28 Jun 2019 14:02:39 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 In-Reply-To: <5D1652C9.1090106@tlinx.org> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="Eee2V2iyPToNmcxQcnt5WJSoahGwD4tOC" X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Fri, 28 Jun 2019 19:02:47 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 X-Spam-Score: -1.4 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.4 (--) This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --Eee2V2iyPToNmcxQcnt5WJSoahGwD4tOC Content-Type: multipart/mixed; boundary="Y7G337thv0W8uOXIaqKyRbHlYNMakqBdz"; protected-headers="v1" From: Eric Blake To: L A Walsh , Coreutils Message-ID: Subject: Re: realpath doesn't preserve '..' consistently as per POSIX, nor '/.' References: <5D15F5E1.6090905@tlinx.org> <5D1652C9.1090106@tlinx.org> In-Reply-To: <5D1652C9.1090106@tlinx.org> --Y7G337thv0W8uOXIaqKyRbHlYNMakqBdz Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable On 6/28/19 12:47 PM, L A Walsh wrote: > I don't recall reading anything about posix allowing the elimination > of such paths. https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html 4.13: "If a pathname begins with two successive characters, the first component following the leading characters may be interpreted in an implementation-defined manner, " Linux has an implementation-defined manner: "// is an alias for /, and therefore may be shortened" Cygwin has an implementation-defined manner: "// is distinct from /, and therefore must be preserved" Note that "may be shortened" is not synonymous with "must be shortened" nor with "must be preserved". So on Linux, preserving "//" is POSIX-compliant, AND shortening "//" to "/" is POSIX-compliant (since both choices comply with the implementation definition). >=20 > If I have an application layer on top of linux that processes those > double slashes, it may or may not work depending on the underlying OS? If your application layer is on top of Linux, then yes, the underlying OS guarantees that your application processing a path beginning with "//" is correct whether it preserves or shortens that path to "/". If you port the source code of an application originally built on Linux to then operate on some other operating system, then the source code is buggy if it shortens the path to "/". But you have to actually check the source code to see if it has that bug - just because 'realpath' in coreutils shortens '//' to '/' on Linux does NOT mean that it is buggy, because the code for realpath has an explicit check (run at configure-time) for whether "//" is distinct from "/" - and on platforms where that check is answered differently than on Linux, the code behaves differently. That is, the coreutils code is self-adapting to the implementation definition of the implementation it is compiled on. > It would useful if bugs were not closed before asking for more > information.=20 They can always be reopened if you provide enough relevant information to show it was closed prematurely. But so far in this case, you have not done so, but merely confirmed my suspicions - you noticed a difference in behavior between Linux and Cygwin, but both behaviors were POSIX-compliant when factoring in the implementation-defined nature of the underlying implementation. --=20 Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org --Y7G337thv0W8uOXIaqKyRbHlYNMakqBdz-- --Eee2V2iyPToNmcxQcnt5WJSoahGwD4tOC Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEccLMIrHEYCkn0vOqp6FrSiUnQ2oFAl0WZE8ACgkQp6FrSiUn Q2oUgwf/WP8+DoKQe854dUz0aALARemn0HeMM7Xvw0hteb55eN1XzEwxdtP+IDcv Rz8lwI6MYXUUmrVb/1wZ5jvz5LroBjUs4dZXW6umm0fHd2V8m6NkOrnw4OoniWpu A211ppGHN3EidxSEIFx1zPMQl/rrcQNgyuThFGCmfjwHXn8USiGT6OOzotzW0+DU 9XbYRujkcE2JS4Wuz/s0fzHrWYlc72FhejgRvxLZOFrrSDvZu+Lgcd+Yz0sR+QPF G82qC9FGnPW59iijQoYYKSDnbwMmAtEeT+kf+ZbOsnIjNHfK9KWW/8ZFWbu1+CR/ F0gsnTL+iXifGWjjGwjnoIVAl02tqQ== =PRIp -----END PGP SIGNATURE----- --Eee2V2iyPToNmcxQcnt5WJSoahGwD4tOC-- From debbugs-submit-bounces@debbugs.gnu.org Fri Jun 28 15:03:22 2019 Received: (at control) by debbugs.gnu.org; 28 Jun 2019 19:03:22 +0000 Received: from localhost ([127.0.0.1]:43004 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hgw9Z-0004Rz-EL for submit@debbugs.gnu.org; Fri, 28 Jun 2019 15:03:22 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59910) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hgw9T-0004QQ-2C for control@debbugs.gnu.org; Fri, 28 Jun 2019 15:03:16 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B92F230860AA for ; Fri, 28 Jun 2019 19:03:06 +0000 (UTC) Received: from [10.3.116.142] (ovpn-116-142.phx2.redhat.com [10.3.116.142]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8002B19C59 for ; Fri, 28 Jun 2019 19:03:06 +0000 (UTC) Subject: Re: bug#36416: realpath doesn't preserve '//' in -m mode To: control@debbugs.gnu.org References: <5D15F5E1.6090905@tlinx.org> From: Eric Blake Openpgp: preference=signencrypt Autocrypt: addr=eblake@redhat.com; keydata= xsBNBEvHyWwBCACw7DwsQIh0kAbUXyqhfiKAKOTVu6OiMGffw2w90Ggrp4bdVKmCaEXlrVLU xphBM8mb+wsFkU+pq9YR621WXo9REYVIl0FxKeQo9dyQBZ/XvmUMka4NOmHtFg74nvkpJFCD TUNzmqfcjdKhfFV0d7P/ixKQeZr2WP1xMcjmAQY5YvQ2lUoHP43m8TtpB1LkjyYBCodd+LkV GmCx2Bop1LSblbvbrOm2bKpZdBPjncRNob73eTpIXEutvEaHH72LzpzksfcKM+M18cyRH+nP sAd98xIbVjm3Jm4k4d5oQyE2HwOur+trk2EcxTgdp17QapuWPwMfhaNq3runaX7x34zhABEB AAHNHkVyaWMgQmxha2UgPGVibGFrZUByZWRoYXQuY29tPsLAegQTAQgAJAIbAwULCQgHAwUV CgkICwUWAgMBAAIeAQIXgAUCS8fL9QIZAQAKCRCnoWtKJSdDahBHCACbl/5FGkUqJ89GAjeX RjpAeJtdKhujir0iS4CMSIng7fCiGZ0fNJCpL5RpViSo03Q7l37ss+No+dJI8KtAp6ID+PMz wTJe5Egtv/KGUKSDvOLYJ9WIIbftEObekP+GBpWP2+KbpADsc7EsNd70sYxExD3liwVJYqLc Rw7so1PEIFp+Ni9A1DrBR5NaJBnno2PHzHPTS9nmZVYm/4I32qkLXOcdX0XElO8VPDoVobG6 gELf4v/vIImdmxLh/w5WctUpBhWWIfQDvSOW2VZDOihm7pzhQodr3QP/GDLfpK6wI7exeu3P pfPtqwa06s1pae3ad13mZGzkBdNKs1HEm8x6zsBNBEvHyWwBCADGkMFzFjmmyqAEn5D+Mt4P zPdO8NatsDw8Qit3Rmzu+kUygxyYbz52ZO40WUu7EgQ5kDTOeRPnTOd7awWDQcl1gGBXgrkR pAlQ0l0ReO57Q0eglFydLMi5bkwYhfY+TwDPMh3aOP5qBXkm4qIYSsxb8A+i00P72AqFb9Q7 3weG/flxSPApLYQE5qWGSXjOkXJv42NGS6o6gd4RmD6Ap5e8ACo1lSMPfTpGzXlt4aRkBfvb NCfNsQikLZzFYDLbQgKBA33BDeV6vNJ9Cj0SgEGOkYyed4I6AbU0kIy1hHAm1r6+sAnEdIKj cHi3xWH/UPrZW5flM8Kqo14OTDkI9EtlABEBAAHCwF8EGAEIAAkFAkvHyWwCGwwACgkQp6Fr SiUnQ2q03wgAmRFGDeXzc58NX0NrDijUu0zx3Lns/qZ9VrkSWbNZBFjpWKaeL1fdVeE4TDGm I5mRRIsStjQzc2R9b+2VBUhlAqY1nAiBDv0Qnt+9cLiuEICeUwlyl42YdwpmY0ELcy5+u6wz mK/jxrYOpzXKDwLq5k4X+hmGuSNWWAN3gHiJqmJZPkhFPUIozZUCeEc76pS/IUN72NfprZmF Dp6/QDjDFtfS39bHSWXKVZUbqaMPqlj/z6Ugk027/3GUjHHr8WkeL1ezWepYDY7WSoXwfoAL 2UXYsMAr/uUncSKlfjvArhsej0S4zbqim2ZY6S8aRWw94J3bSvJR+Nwbs34GPTD4Pg== Organization: Red Hat, Inc. Message-ID: <23174286-0971-a424-b313-2811d0ae8566@redhat.com> Date: Fri, 28 Jun 2019 14:03:05 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 In-Reply-To: <5D15F5E1.6090905@tlinx.org> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="MIdiM5EI4lKalW3baIFb7Mor9tf2ExvI4" X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Fri, 28 Jun 2019 19:03:06 +0000 (UTC) X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -6.0 (------) This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --MIdiM5EI4lKalW3baIFb7Mor9tf2ExvI4 Content-Type: multipart/mixed; boundary="xsEAIQMTMm8A92Y5Stiagzjxnb5ijGGAG"; protected-headers="v1" From: Eric Blake To: control@debbugs.gnu.org Message-ID: <23174286-0971-a424-b313-2811d0ae8566@redhat.com> Subject: Re: bug#36416: realpath doesn't preserve '//' in -m mode References: <5D15F5E1.6090905@tlinx.org> In-Reply-To: <5D15F5E1.6090905@tlinx.org> --xsEAIQMTMm8A92Y5Stiagzjxnb5ijGGAG Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable tag 36416 notabug close 36416 thanks On 6/28/19 6:11 AM, L A Walsh wrote: > realpath -m //sysname/rootdir/. > returns "/sysname/rootdir" This is incorrect, according to POSIX. >=20 > and #3-4 have specific meanings in various applications that in usage.= >=20 > 1) leading double slashes are to be preserved > My Notes: in combining paths like pathcat(//, sys, /a) =3D> > should get //sys/a > in combining paths like pathcat(//, /sys, /a) =3D> /sys s= ys > specifies it wants to be directory, not a system., so at root, '//' ref= er to > no system, and we just get: '/sys/a' >=20 > 2) final slash indicates end node is a directory >=20 > 3) a final . in a source specifies something under the directory name. >=20 > ~4?) I don't think /.. at end of a pathname can be safely deleted > and have same meaning as without it, but brain is too tired to detail > right now. >=20 >=20 >=20 >=20 >=20 >=20 --=20 Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org --xsEAIQMTMm8A92Y5Stiagzjxnb5ijGGAG-- --MIdiM5EI4lKalW3baIFb7Mor9tf2ExvI4 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEccLMIrHEYCkn0vOqp6FrSiUnQ2oFAl0WZGkACgkQp6FrSiUn Q2olIgf/RA+rVNFv7R/NC4ZEsmgvpiw8s8XJ7WkebdUDaAo6J82RFKPP7eMovMiA bR+mSpo7zQUaDRMIusqSkl6yRumb/yoUbM8hZSPWoPGuTMWs68CEUDrGycTkE0OT Yp6PUvtZOoAjypBewpak/KvBfPAhRnRylBXxonzU0rcQt/I1RTQ9c86D/+QdNvId xPkeD+VAwTmmy3bHzwOBu2A5NTrUfo+1JHnQwgSYAHvOHAWDx6mdRds5JqmxAUuQ kJpuPjb/JX9Q2Ynv4ML2fIcM3kbggUxTSOOzxHdT8mIVDf89mBpiVUBEEx0tZlfu S7hpZM4MIZdjuK5cowYD2JfVPy40Ig== =I31S -----END PGP SIGNATURE----- --MIdiM5EI4lKalW3baIFb7Mor9tf2ExvI4-- From debbugs-submit-bounces@debbugs.gnu.org Sat Jun 29 15:21:35 2019 Received: (at submit) by debbugs.gnu.org; 29 Jun 2019 19:21:35 +0000 Received: from localhost ([127.0.0.1]:44921 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hhIuk-0008MJ-UE for submit@debbugs.gnu.org; Sat, 29 Jun 2019 15:21:35 -0400 Received: from lists.gnu.org ([209.51.188.17]:48413) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hhIuj-0008MC-1T for submit@debbugs.gnu.org; Sat, 29 Jun 2019 15:21:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52719) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hhIuh-0004fj-Qe for bug-coreutils@gnu.org; Sat, 29 Jun 2019 15:21:32 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50 autolearn=disabled version=3.3.2 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hhIug-0004m7-KN for bug-coreutils@gnu.org; Sat, 29 Jun 2019 15:21:31 -0400 Received: from ishtar.tlinx.org ([173.164.175.65]:57436 helo=Ishtar.sc.tlinx.org) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hhIug-0004jU-B2 for bug-coreutils@gnu.org; Sat, 29 Jun 2019 15:21:30 -0400 Received: from [192.168.3.12] (Athenae [192.168.3.12]) by Ishtar.sc.tlinx.org (8.14.7/8.14.4/SuSE Linux 0.8) with ESMTP id x5TJLNhL007090; Sat, 29 Jun 2019 12:21:25 -0700 Message-ID: <5D17BA33.9070905@tlinx.org> Date: Sat, 29 Jun 2019 12:21:23 -0700 From: L A Walsh User-Agent: Thunderbird MIME-Version: 1.0 To: Eric Blake Subject: Re: realpath doesn't preserve '..' consistently as per POSIX, nor '/.' References: <5D15F5E1.6090905@tlinx.org> <5D1652C9.1090106@tlinx.org> In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] X-Received-From: 173.164.175.65 X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: submit Cc: Coreutils X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) On 2019/06/28 12:02, Eric Blake wrote: > If your application layer is on top of Linux, then yes, the underlying > OS guarantees that your application processing a path beginning with > "//" is correct whether it preserves or shortens that path to "/". ---- Linux doesn't forever guarantee that it will or won't use '//'. > If you port the source code of an application originally built on Linux > to then operate on some other operating system, then the source code is > buggy if it shortens the path to "/". But you have to actually check the > source code to see if it has that bug - just because 'realpath' in > coreutils shortens '//' to '/' on Linux does NOT mean that it is buggy, > because the code for realpath has an explicit check (run at > configure-time) for whether "//" is distinct from "/" - and on platforms > where that check is answered differently than on Linux, the code behaves > differently. That is, the coreutils code is self-adapting to the > implementation definition of the implementation it is compiled on. --- As long as realpath guarantees that the generated binary won't work on any other version of linux, that would be true. However the run-time binary isn't recompiled with each version of linux. > > >> It would useful if bugs were not closed before asking for more >> information. > > They can always be reopened if you provide enough relevant information > to show it was closed prematurely. But so far in this case, you have > not done so, but merely confirmed my suspicions - you noticed a > difference in behavior between Linux and Cygwin, but both behaviors were > POSIX-compliant when factoring in the implementation-defined nature of > the underlying implementation. ---- And you confirm that there there is a design flaw in realpath. Realpath is not part of the OS and is not regenerated as part of the kernel build process. If a patch is applied to specifically to enable or assign meaning to '//' separately that to '/', 'realpath' will continue to run as it was configured to run on the earlier version. Realpath can't assume either that it was configured properly for the current linux binary -- neither that the user knows which is correct, nor that some behavior that was true at compile time is still true at run time. Realpath also trims '.' off of "[dir]/." when these do not have identical meaning within the linux or cygwin ecospheres. If I process source and destination paths through realpath before passing them to another user app, like 'cp', realpath will alter the behavior. If you look at the historic behavior of cp w/relation to to *nix, it behaves differently if the source comes from '' than if it comes from '/.'. Similarly if you look at the historic behavior of *nix, you can't claim '//' and '/' are identical. Realpath fixes it's path-modifying behaviors at compile time but doesn't disallow its binary being run on differently compiled copies of linux. FWIW, for device paths in /etc/fstab, the notation for CIFS remote mounts is '//', as in: mount -t cifs //Win_Desktop/C/ /Athenae -o rw,cifsacl,nocase,serverino,vers=2.1 It seems useful for '//' to made available on linux as an automounter path, though with nothing mounted, refering to the local system. I could see concatenating paths '//' & '/usr' being reduced to '/usr', but concatenating '//' & svrname reducing to '//svrname'. Other realpath problem: ----- -------- ------- But for a real case now where processing path-args with realpath resulting in different and unwanted behavior: using a function for shorthand: rp() { declare p=(); for e in "$@"; do p+=($(realpath -m "$e")); done ; set "${p[@]}"; printf "%s\n" "$@"; }; export rp # && sample files && cd to /tmp: mkdir /tmp/{a,b}; touch /tmp/a{1,2}; cd /tmp; cp -a $(rp a/.) $(rp b/.) #versus cp -a a/. b/. produce very different results. I would assert that reducing 'dir/.' to simply 'dir/' is also incorrect. From unknown Sun Aug 17 22:05:33 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sun, 28 Jul 2019 11:24:05 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator