lkml.org 
[lkml]   [1996]   [Jul]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: How does chown(2) works with symlinks?
> Which file gets changed when a call to chown(2) is done on a symlink?
> The man page gives the impression that it would follow the symlink and
> change the owner of the file pointed by the symlink. Still, if a used
> chown on a symlink now, it will only change the symlink. Was there a
> change to the way it works?

If you want to change the owner of the file it points to, use:

fd = open(...);
fchown(fd,..);

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).

I think some older versions of linux actually changed the file that the symlink
pointed to, and it got changed at one point. I could be mistaken, though,

Linus


\
 
 \ /
  Last update: 2005-03-22 13:38    [from the cache]
©2003-2011 Jasper Spaans