From owner-freebsd-bugs@FreeBSD.ORG Sun Sep 26 20:25:47 2010 Return-Path: Delivered-To: freebsd-bugs@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 36C0C106566B; Sun, 26 Sep 2010 20:25:47 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail03.syd.optusnet.com.au (mail03.syd.optusnet.com.au [211.29.132.184]) by mx1.freebsd.org (Postfix) with ESMTP id AD9E48FC12; Sun, 26 Sep 2010 20:25:46 +0000 (UTC) Received: from besplex.bde.org (c122-107-116-249.carlnfd1.nsw.optusnet.com.au [122.107.116.249]) by mail03.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id o8QKPge9024605 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 27 Sep 2010 06:25:44 +1000 Date: Mon, 27 Sep 2010 06:25:42 +1000 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: "Kevin K. Han" In-Reply-To: <201009261824.o8QIORiF092345@www.freebsd.org> Message-ID: <20100927060130.E5896@besplex.bde.org> References: <201009261824.o8QIORiF092345@www.freebsd.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: freebsd-bugs@FreeBSD.org, freebsd-gnats-submit@FreeBSD.org Subject: Re: misc/150972: symbolic link bug 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: Sun, 26 Sep 2010 20:25:47 -0000 On Sun, 26 Sep 2010, Kevin K. Han wrote: >> Description: > Create a directory on the root folder, for example ("/whatever"). > Switch to user's home directory ("cd /usr/home/username") ... from now onwards, work in this directory: > Create a symbolic link from inside a user's home ("ln -s /whatever .") > Execute this: ("chown -R username:username whatever") Apparently you are still running as root after creating /whatever. This chown -R has no effect even as root. (A plain chown would change /whatever and chown -h would change the symlink.) > Try to delete it using ("rm whatever")... it will say it is a directory. It is still not deleted! I don't see this. It would be a bad bug. rm is required to not follow symlinks. A broken version of rm might stat() the symlink and decide that it is a directory, and then rewrite its name to "whatever/" for maximal brokenness (other utilities do need to append a slash sometimes, and this is not easy to get right); then unlink("whatever/") would say it is a directory. > Then, try to delete using ("rm -r -f whatever/"), no errormessage, BUT It is still there! This is how symlinks work. "whatever/" is whatever the symlink points to. It is "/whatever" here. So this commands removes "/whatever" and leaves the symlink untouched. > Then, again, try the same thing ("rm whatever")... It is GONE, INCLUDING the original at "/whatever" !!! Consistent with a broken rm stat()ing the symlink. The previous command removed "/whatever", so "whatever" is a dangling symlink and stat()ing it wouldn't see it as a directory. Bruce