Date: Sun, 17 Jun 2001 23:02:50 +1000 (EST) From: Bruce Evans <bde@zeta.org.au> To: Warner Losh <imp@harmony.village.org> Cc: "Steve O'Hara-Smith" <steveo@eircom.net>, David Wolfskill <david@catwhisker.org>, current@FreeBSD.ORG Subject: Re: symlink(2) [Was: Re: tcsh.cat] Message-ID: <Pine.BSF.4.21.0106172154520.582-100000@besplex.bde.org> In-Reply-To: <200106170518.f5H5I6V44586@harmony.village.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, 16 Jun 2001, Warner Losh wrote:
> In message <20010615183515.36f81380.steveo@eircom.net> "Steve O'Hara-Smith" writes:
> : I would argue loud and long that changing that *would* be broken. There
> : is never a guarantee (or even an implication) that a symlink points to a
> : valid directory entry (think unmounted filesystems, NFS ...). I find it hard
> : to imagine why creation time should be special in that regard.
>
> And it would break /etc/malloc.conf! I'd have to agree 100% here.
No, it (disallowing null symlinks, not disallowing symlinks to nonexistent
files!!!) wouldn't break /etc/malloc.conf. "ln -fs '' /etc/malloc.conf"
would simply fail after unlinking /etc/malloc.conf. There would then
be no /etc/malloc.conf, which gives exactly the same behaviour as when
/etc/malloc.conf is a null symlink.
BTW, even ln(1) doesn't understand null symlinks:
root$ cd /tmp # a safe place to clobber
root$ ln -fs aj /etc/malloc.conf # my usual malloc.conf
root$ ln -fs a /etc/malloc.conf # normal changes to it work
root$ ln -fs '' /etc/malloc.conf # change it to null (works)
root$ ln -fs aj /etc/malloc.conf # attempt to change it back
root$ ls -l /etc/malloc.conf # change didn't work:
lrwxr-xr-x 1 root wheel 0 Jun 17 22:15 /etc/malloc.conf ->
root$ ls -l /aj # change clobbered root dir:
lrwxr-xr-x 1 root wheel 2 Jun 17 22:31 /aj@ -> aj
So disallowing null symlinks would actually unbreak /etc/malloc.conf.
Further debugging shows that the main bug is in the kernel.
stat(2) on a null symlink bogusly succeeds and classifies the symlink
as a directory. ln(1) just believes this so it rewrites
"ln -fs aj /etc/malloc.conf" to "ln -fs aj /etc/malloc.conf/aj".
The kernel then resolves /etc/malloc.conf/aj to /aj.
Bruce
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.21.0106172154520.582-100000>
