Grahame

Not the maintainer but another list denizen.

> We use intel and alpha machines on our network.  However we have
> found that chown on intel will change the ownership on symbolic
> links but not on the alpha.  [...]  I suspect that there is
> something deeper in the kernel that is causing this but this is the
> the best place to start.

This is probably a kernel difference.  AFAIK the GNU fileutils chown
uses lchown(2) if it is available on the machine.  lchown will work if
the kernel lets it work.  It would be interesting to see a targeted C
program to determine the lchown(2) behavior on the different machines.
I will include one at the end of this mail message.

Note that with traditional System V machines chown does not call
lchown on links and therefore /usr/bin/chown traditionally changes the
target of the link and not the symlink itself.  It is only the
additional niceness of the GNU fileutils that improves upon this
behavior.  So for general portability to other UNIX platforms I
suggest you not rely upon that behavior but only take additional
advantage of it if it exists.  Note also that a different policy of
Linux says that only the superuser can change the ownership of files.
On traditional UNIX machines any user can change ownership of files to
another user.  As a policy, by default, on Linux you need to be root
to change file ownership.

> The problem is that the symbolic link needs to be owned by admin.admin
> not by root.root.

Aside from the niceness of having directory listings report the owner
to be admin instead of root, for what other reason would you want
this?  The user, group, mode of a symlink is purely cosmetic.  The
attributes of the target of the symlink are the only significant
values.  I have long wished that UNIX would have only reported
non-information such as zero, zero, zero for those attributes if the
file is a symlink and then we could have avoided any confusion that
they might be significant in some way.  Ah, if only the Berkeley folks
had thought of that when they added symlinks to BSD UNIX.

Bob

#include <stdio.h>
#include <unistd.h>
#include <errno.h>

int main()
{
  if (geteuid() != 0)
    printf("warning, you are not root\n");
  if (lchown("upd2rdme.txt",0,0) < 0)
    {
      perror("lchown");
      return 1;
    }
  printf("It looks to have worked.\n");
  return 0;
}

Reply via email to