in reply to maintaining owner id

Anonymous Monk,
Most systems will not let you change the owner of a file unless you are a SuperUser. This, I believe, is for two reasons:
  • Disk quotas
  • Security (change SetUID bit and chown root)

    I can think of a few ways to get around this, but they all involve using su/sudo/etc as well as entering a password.

    If you are interested in one with the knowledge that it is a security concern, let me know.

    Cheers - L~R

  • Replies are listed 'Best First'.
    Re^2: maintaining owner id (depends)
    by tye (Sage) on Aug 08, 2003 at 21:53 UTC
      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
        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