Date: Tue, 30 Jan 1996 01:27:47 +0200 From: Dmitry Kohmanyuk <dk@dog.farm.org> To: jmacd@CS.Berkeley.EDU (Josh MacDonald) Cc: freebsd-hackers@freebsd.org Subject: Re: sticky directory symlinks Message-ID: <199601292327.BAA12731@dog.farm.org>
next in thread | raw e-mail | index | archive | help
In article <inj.2-31075bb0-8a1@bee.cs.kiev.ua> you wrote: > I apologize if this has been discussed before, though I couldn't > find anything on the subject. I asked a NetBSD user and he said > he recalled some discussion on this topic but didn't recall the > results. I just encountered the following problem: > axis-/tmp % ls -ld . > drwxrwsrwt 4 root wheel 512 Jan 25 00:46 ./ > axis-/tmp % ln -s this sucks > axis-/tmp % ls -l sucks > lrwxrwsrwt 1 root wheel 4 Jan 25 00:46 sucks@ -> this > axis-/tmp % rm sucks > rm: sucks: Operation not permitted > /tmp is mode 1777 and when I create a symlink I can't remove it. > I notice that the link shares the sticky dirs inode. I think from my understanding, 4.4BSD doesn't have any inode info for symlink, but rather inherits the information from directory containing the symlink. >From the symlink(7) manual page: Unlike other filesystem objects, symbolic links do not have an owner, group, permissions, access and modification times, etc. The only at- tributes returned from an lstat(2) that refer to the symbolic link itself are the file type (S_IFLNK), size, blocks, and link count (always 1). The other attributes are filled in from the directory that contains the link. For portability reasons, you should be aware that other implemen- tations (including historic implementations of 4BSD), implement symbolic links such that they have the same attributes as any other file. see /sys/kern/vfs_syscalls.c:lstat() for the actual code. > this is very very bad. I guess that an optimization is made > where the linkname is kept in the directory file instead of > on disk but if its a sticky directory, then I can't remove > something I create. That sucks a lot. Has this been brought > up before? another 4.4BSD optimization is that for short symlinks, the name of the link is stored in the inode instead of inside of separate disk block if it is sufficiently short to fit there (struct mount->mnt_maxsymlinklen). (the code is in /sys/ufs/ufs/ufs_vnops.c). But this is irrelevant here. -- No matter how subtle the wizard, a knife in the shoulder blades will seriously cramp his style.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199601292327.BAA12731>