[lkml]   [1996]   [Jul]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    SubjectRe: How does chown(2) works with symlinks?

    Linus wrote:
    > 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,

    This behaviour is incompatible with most (all?) other versions of
    UNIX I've used - SVR4 derived, and Solaris.

    The chown(2) syscall should follow the link(s). The OS provides another
    call, lchown(2), for operating directly on a symlink (some also
    provide a lchmod(2), such as SCO's OpenServer). There is also a

    For me, a chown(2) makes more sense if it follows the link - I want
    to change the ownership of the file that would be open(2)ed or
    stat(2)ed, not something inbetween.

    I believe the latest POSIX drafts have tackled symbolic links (they
    worked around the issue before). It would be nice to known what
    they say...


     \ /
      Last update: 2005-03-22 13:38    [W:0.030 / U:77.496 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site