Re: How does chown(2) works with symlinks?

Thomas Koenig (ig25@fg70.rz.uni-karlsruhe.de)
8 Jul 1996 11:36:43 +0200


In linux.dev.kernel, Linus Torvalds <torvalds@cs.helsinki.fi> wrote:

>which should always work the way you expect. If you use "chown()" on the
>pathname it will change the synlink itself (if you think about it, that is
>actually the reasonable behaviour: otherwise you could never change the owner
>of the symlink).

This also protects against all sorts of nasty games with symlinks,
for example the well - known xterm bug, where the program did, as root,

open("somefile");
<=== user could do a "rm somefile; ln -s /etc/profile somefile"
chown(user,group,"somefile");