From owner-freebsd-stable@FreeBSD.ORG Tue Sep 25 15:25:37 2007 Return-Path: Delivered-To: freebsd-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1E99516A417 for ; Tue, 25 Sep 2007 15:25:37 +0000 (UTC) (envelope-from mkhitrov@gmail.com) Received: from wr-out-0506.google.com (wr-out-0506.google.com [64.233.184.236]) by mx1.freebsd.org (Postfix) with ESMTP id A765513C467 for ; Tue, 25 Sep 2007 15:25:36 +0000 (UTC) (envelope-from mkhitrov@gmail.com) Received: by wr-out-0506.google.com with SMTP id 70so647296wra for ; Tue, 25 Sep 2007 08:25:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=EIVXTHIQN3Z9pEzpiMkvVZu7+KqhTHmRhg9ichLHGQ4=; b=IXk6nbsio6YtLRs6xgox6DZ0bOSYiubUmVlGuf2V6/QEE9FsERwDyZjldkpL4kjtYhcYU8Rgv2pdP9HIRKxPtNUUTEsOzXBYjLi5fSxB/zVsCkr09FEaU9Bfit0WQpsl/r/ndu5uNyHbkH4P5fKegs5UoM0xMof9T1y9XCzmQO0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=nxyXIaIQizh8tC06D4jxbSZiEjzMJm8X3pAChkd7P2Nd/5K61n0nuMflgcxtWzpQ2S5U77mpqNfMwBfyMG0FVt0LLOxC5uKSD3xFqNY6z+PZQ2KKdiYzP7Cz9/tX4fxnm2QYD+3jDW4i/IYu4u1kfhud9k0SHxzL9Uz5phGMovE= Received: by 10.142.141.5 with SMTP id o5mr2282653wfd.1190733934853; Tue, 25 Sep 2007 08:25:34 -0700 (PDT) Received: by 10.142.211.11 with HTTP; Tue, 25 Sep 2007 08:25:34 -0700 (PDT) Message-ID: <26ddd1750709250825j2d70798awa96cd0d2d305e0a9@mail.gmail.com> Date: Tue, 25 Sep 2007 11:25:34 -0400 From: "Maxim Khitrov" To: freebsd-stable@freebsd.org In-Reply-To: <200709251512.l8PFCoPe006574@lurza.secnetix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <200709251512.l8PFCoPe006574@lurza.secnetix.de> Subject: Re: rm(1) bug, possibly serious X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 25 Sep 2007 15:25:37 -0000 On 9/25/07, Oliver Fromme wrote: > Hi, > > Today I noticed the following behaviour on a 6-stable > machine: > > $ cd /tmp > $ mkdir -p foo/var > $ cd foo/bar > $ rm -rf ../ > rm: ../: Invalid argument > $ rm -rf ../ > $ > > Note that the command "rm -rf ../" was entered twice. > The first time I got an error message (and exit code 1), > the second time it apparently succeeded. The very same > command. > > Further investigation: > > $ cd /tmp > $ mkdir -p foo/var > $ cd foo/bar > $ rm -rf ../ > rm: ../: Invalid argument > $ ls -al .. > ls: ..: No such file or directory > $ ls /tmp/foo/bar > ls: /tmp/foo/bar: No such file or directory > > That means: Even though "rm -rf ../" prints an error > message, indicating that the argument is invalid, it > *DOES* remove the contents of the parent directory! > > To add further confusion, another "rm -rf ../" does > not print an error message and seemingly succeeds, > even though ".." does not exist anymore in the current > directory (which has been removed). > > Shall I file a PR? Or is rm working correctly, and > my assumptions are wrong? > > Best regards > Oliver Confirmed on CURRENT as well. Note that if you run rf -rf .. as the first command, the command does fail with 'rm: "." and ".." may not be removed'. Adding a / at the end does seem to get around this check. - Max