Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

4
  • 1
    @Robert, on what system would those rules apply? On the systems I know, either you're root and you can do whatever you like or your not user1 and you can't do anything. If you're user1, depending on the system, either you can't change the owner anyway, or, when you can, then you can change the group to whatever you like, and then the user to whatever you like. Commented Jun 14, 2014 at 15:27
  • If I have in a directory that I own, a file owned by someone else, and group I am not member of, but I can read because of other permissions. Then I it is possible for me to copy it to make me the owner, and it have a new group (for which I am member). Therefore it must be as save for the OS to allow me as non-root to chown me:my-group file if file is in a location where I have read/write access (no sticky). I could not chgrp first as not owner. I could not chown first as this would result in file I could not create: me owning a file with group I am not member of. Commented Jun 16, 2014 at 12:59
  • @richard, no it wouldn't be as safe. That file could be hardlinked to another directory you don't have access to. On systems where you can link files you don't own (like Linux by default), that would mean you could claim ownership to any file by linking it to a directory you have write access to. Commented Jun 16, 2014 at 13:15
  • I found this text, it also explains why I am wrong (it is not as safe): “If you were allowed to appropriate the file, this would be a security hole. For example, the user someone could open the file, then verify its ownership and permissions (by calling fstat on the open file handle), and conclude that only a program running as someone could have produced this data. If you were able to appropriate the file, you could then change its content against someone's wishes.” — unix.stackexchange.com/questions/68439/… Commented Jun 16, 2014 at 13:20