X-Recipient: archive-cygwin AT delorie DOT com DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:reply-to:to:subject:message-id :in-reply-to:references:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=ACiVM3Ido0mszzHr z12963QICJzEdIwH0wU6uDMXou8DXsVo5EzgxgTWHuIxiKJ7sIsio4zacm1h0CXm B9PjoYwUGJnYagG1YGixo7XFX6rhC5aBzTfzY8xZgM7tO9w2ksYZK3ecDyNRrNcH cR138w+SsuO+ZvPclQx/onkrR3w= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:reply-to:to:subject:message-id :in-reply-to:references:mime-version:content-type :content-transfer-encoding; s=default; bh=3/6YVlWklOBLmm0V56UCJB rLyKk=; b=sffeD6jC4qAyfY92KfN+hKw5kN0lVgwB+uXvTbT6+6GDYy0z6NuGhh 9g9P8uw3CD8XiWptObstxEcsUIinlbN5SgCphBofYW9V1/CWYV9UwqIJsAsYgVfP iE6r3YxnvUNuqTo6ljow+KhgiIEHcnOBSgtMb7HENEa9QO+tXVSPA= Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.8 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 spammy=ground, UD:ru, claims, H*r:esmtpa X-HELO: smtp32.i.mail.ru Date: Wed, 14 Mar 2018 13:58:45 +0300 From: "Mikhail Usenko via cygwin" Reply-To: Mikhail Usenko To: cygwin AT cygwin DOT com Subject: Re: [bug] coreutils: potentially dangerous: $(realpath //) != / Message-Id: <20180314135845.caeb571cdd5a54fc5b3fd4aa@inbox.ru> In-Reply-To: <0277f5b4-35e4-4da0-2bea-b73c4fdcfa89@redhat.com> References: <20180312232815 DOT 692b5da79fc18abf86d42ba1 AT inbox DOT ru> <20180313023854 DOT 2e07e4396f934961935e4435 AT inbox DOT ru> <0277f5b4-35e4-4da0-2bea-b73c4fdcfa89 AT redhat DOT com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Authentication-Results: smtp32.i.mail.ru; auth=pass smtp.auth=cygwin AT inbox DOT ru smtp.mailfrom=cygwin AT inbox DOT ru X-7FA49CB5: 0D63561A33F958A5AE6DF61D6D18C2AF6A82CD453AE9C1BF90B17CB10010B774725E5C173C3A84C3DCCD623F9E1C9531D6ECA3D9ACDA77A2A3CCBC2573AEBDE1C4224003CC836476C0CAF46E325F83A50BF2EBBBDD9D6B0F2AF38021CC9F462D574AF45C6390F7469DAA53EE0834AAEE X-Mailru-Sender: 6EC2BC89932334D1F7B5BD7C7EAE77D3BBF757CFA1E49C86C693B14912A7E6FE6747B68F6006C5D3660F59C8B746F306C436427D37DF329266E4D333E66FA46EE08AD13A84CB3945E26AC9D112D2F5D8C42AFB4B603C56BB0DA7A0AF5A3A8387 X-IsSubscribed: yes On Mon, 12 Mar 2018 20:43:13 -0500 Eric Blake <...> wrote: > Furthermore, you need to realize that GNU coreutils 'rm' already has > special logic (permitted by POSIX) such that 'rm -rf /' fails unless you > use --no-preserve-root ('rm -rf /*' unfortunately does not trigger the > special logic, only an attempt to directly remove the root directory is > flagged - but you're also forgetting that /* does not necessarily list > all files under /, thanks to hidden files, and that 'rm -rf "$dir"' is > always better than 'rm -rf "$dir"/*' if you are worried about hidden > files in $dir and/or command-line length limits due to the glob > expansion of *). > I don't know what this is for, but nevertheless, thank you for your efforts to eliminate of illiteracy among readers... > Just because Linux has taken the stance that their documented definition > of // is "synonym for /" does NOT mean that ALL POSIX systems have taken > the same approach; Cygwin has taken the approach that "// is documented > to be the root of network access points, distinct from /". > > POSIX allows leeway between implementations; this is one of those > documented places where they differ, yet are still both POSIX compliant > with their different choices. If your script is not robust to what > POSIX has already warned you about, fix your script. > > > and, as a consequence, I should avoid the case where > > somewhere in a bash script evaluating of some variable would lead to one of > > the following command to execute: > > rm -rf /* > > rm -rf //* > > rm -rf ///* > > rm -rf ////* > > that all do the very same thing in Linux. > > 3 of the 4 do the same thing on ALL POSIX platforms. The only one that > has implementation-defined behavior is 'rm -rf //*', which is different > on systems where // is distinct (such as Cygwin). All the other > spellings (attempt) to remove all non-hidden files from the root directory. > If you really claims that Cygwin may and should be different and distinct from all other existing POSIX systems (the more so that it is allowed by POSIX), then it would probably be more obvious and clear to say this at the very begining, e.g. "Get that Linux feeling (with all those differents and distinctions) - on Windows" > Use of // in Linux is already on shaky ground, given that POSIX has > already declared it to be implementation-defined. Shaky ground? There must be some good reasons (beyond the declaration of such an abstarct possibility) that it should to be done differently than it has been so far. -- -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple