in reply to Re: maintaining owner id
in thread maintaining owner id

Most systems will not let you change the owner of a file unless you are a SuperUser.

This at least used to be true of one major branch of the Unix family tree (I think the SysV side) but not true of the other (I think Berkeley).

In any case, on several Unix systems, it at least used to be possible to give your own files away. That is, you could chown files that you owned such that they would then belong to someone else.

To prevent this from being a huge problem, there were (of course) several restrictions. You couldn't chown files in partitions with quotas active. chowning a file removes the set-UID and set-GID bits (true even if you a root, no?). etc.

                - tye

Replies are listed 'Best First'.
Re: Re^2: maintaining owner id (depends)
by Limbic~Region (Chancellor) on Aug 08, 2003 at 22:11 UTC
    tye,
    Since we have had a related discussion previously, I have looked at various man pages. I guess I should have indicated to check the local man pages on chown but keep in mind that in doing so it might not make it portable. Here are some of the variations I have seen:
  • Allowed only if UID = 0
  • Allowed if no quota restrictions
  • Allowed, but strip any setuid/setgid bits
  • Allowed only if UID = 0 unless "set rstchown = 1" appears in /etc/system

    The most systems won't allow it unless superuser bit actually came from perldoc -f chown. It goes on to say how you can detect on a POSIX system if you have the right or not.

    Cheers - L~R