From owner-freebsd-bugs@FreeBSD.ORG Wed Sep 19 22:00:06 2007 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E05DF16A41A for ; Wed, 19 Sep 2007 22:00:06 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id ABDE213C428 for ; Wed, 19 Sep 2007 22:00:06 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.1/8.14.1) with ESMTP id l8JM06n1064473 for ; Wed, 19 Sep 2007 22:00:06 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.1/8.14.1/Submit) id l8JM06Bt064472; Wed, 19 Sep 2007 22:00:06 GMT (envelope-from gnats) Resent-Date: Wed, 19 Sep 2007 22:00:06 GMT Resent-Message-Id: <200709192200.l8JM06Bt064472@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Justin Mitchell Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D828716A417 for ; Wed, 19 Sep 2007 21:53:37 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21]) by mx1.freebsd.org (Postfix) with ESMTP id BC2D013C46C for ; Wed, 19 Sep 2007 21:53:37 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.14.1/8.14.1) with ESMTP id l8JLrbX2040793 for ; Wed, 19 Sep 2007 21:53:37 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.14.1/8.14.1/Submit) id l8JLrbXo040792; Wed, 19 Sep 2007 21:53:37 GMT (envelope-from nobody) Message-Id: <200709192153.l8JLrbXo040792@www.freebsd.org> Date: Wed, 19 Sep 2007 21:53:37 GMT From: Justin Mitchell To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: bin/116477: rm behaves unexpectedly when using -r and relative paths X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 Sep 2007 22:00:07 -0000 >Number: 116477 >Category: bin >Synopsis: rm behaves unexpectedly when using -r and relative paths >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Wed Sep 19 22:00:05 GMT 2007 >Closed-Date: >Last-Modified: >Originator: Justin Mitchell >Release: Mac OS X 10.4 >Organization: >Environment: Darwin justin-mitchells-mac-mini.local 8.10.0 Darwin Kernel Version 8.10.0: Wed May 23 16:50:59 PDT 2007; root:xnu-792.21.3~1/RELEASE_PPC Power Macintosh powerpc >Description: This is a bug with the 'rm' commandline utility that can cause data loss. When using 'rm -r' with relative paths and a trailing slash rm can delete the wrong item, or no item at all. Here is an example of rm deleting the wrong file. mac:~ $ mkdir tmp mac:~ $ cd tmp mac:~/tmp $ mkdir test mac:~/tmp $ ln -s test test2 mac:~/tmp $ ls -l total 8 drwxr-xr-x 2 justin justin 68 Aug 10 01:41 test lrwxr-xr-x 1 justin justin 4 Aug 10 01:42 test2 -> test mac:~/tmp $ cd .. mac:~ $ rm -r tmp/test2/ mac:~ $ ls -l tmp total 8 lrwxr-xr-x 1 justin justin 4 Aug 10 01:42 test2 -> test Note that if you do you not use the trailing slash in 'rm -f tmp/ test2/' that it will behave normally. It will also behave normally if you do not 'cd' to another directory. I confirmed this with another individual running OS X, but I do not know the version. For comparison, I tested this with an older version of Redhat, and it worked fine. I submitted this bug report to Apple, but they said "This is how FreeBSD operates and rm is based on their sources." >How-To-Repeat: mac:~ $ mkdir tmp mac:~ $ cd tmp mac:~/tmp $ mkdir test mac:~/tmp $ ln -s test test2 mac:~/tmp $ ls -l total 8 drwxr-xr-x 2 justin justin 68 Aug 10 01:41 test lrwxr-xr-x 1 justin justin 4 Aug 10 01:42 test2 -> test mac:~/tmp $ cd .. mac:~ $ rm -r tmp/test2/ mac:~ $ ls -l tmp total 8 lrwxr-xr-x 1 justin justin 4 Aug 10 01:42 test2 -> test >Fix: >Release-Note: >Audit-Trail: >Unformatted: