Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 26 Sep 2010 20:30:09 GMT
From:      Bruce Evans <brde@optusnet.com.au>
To:        freebsd-bugs@FreeBSD.org
Subject:   Re: misc/150972: symbolic link bug
Message-ID:  <201009262030.o8QKU9hM065296@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR misc/150972; it has been noted by GNATS.

From: Bruce Evans <brde@optusnet.com.au>
To: "Kevin K. Han" <ikevin.c11@revvo.org>
Cc: freebsd-gnats-submit@FreeBSD.org, freebsd-bugs@FreeBSD.org
Subject: Re: misc/150972: symbolic link bug
Date: Mon, 27 Sep 2010 06:25:42 +1000 (EST)

 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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201009262030.o8QKU9hM065296>