LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   chown cannot change owner (https://www.linuxquestions.org/questions/linux-newbie-8/chown-cannot-change-owner-738254/)

PMP 07-07-2009 04:14 AM

chown cannot change owner
 
I have a scenarion where I am user "A" on a Linux machine. There is another user "B" on this machine. I created a file in my home directory and tried to change the ownership to "B".

In this case I get the Operation not permitted error.

Up to my understanding this seems to me as a security issues that linux is not allowing the file to owned by user B.

Am I correct ? Is there anyway to achieve it except becoming a super user or suoders.

vharishankar 07-07-2009 04:23 AM

You need to be root to change ownership of files. :) Unfortunately there's no solution other than to log in as root or using sudo (if it is configured correctly).

jschiwal 07-07-2009 04:27 AM

You need root permissions to change a file's owner. You can change the group ownership if you are a member.

If you copy a file from another directory, to your own, it will inherit your ownership. (If you have read rights)

PMP 07-07-2009 04:35 AM

Harishankar in my scenario user A is the owner of the file and user A want to change the owner to user B.

vharishankar 07-07-2009 04:37 AM

Quote:

Originally Posted by PMP (Post 3599476)
Harishankar in my scenario user A is the owner of the file and user A want to change the owner to user B.

That's still not possible except as root. chown requires root permissions except to change group.

The reason for not allowing changing your own file ownership is because you could easily write a malicious script (just an example, nothing personal) and use it to access another user's files. Since that script is "owned" by the other user, it would have the permissions to scan the other user's home directories and access personal information etc.

Tinkster 07-07-2009 04:49 AM

Quote:

Originally Posted by harishankar (Post 3599479)
That's still not possible except as root. chown requires root permissions except to change group.

That's corrrrect, and your first post is still wrong.
Quote:

You need to be root to change ownership of files you don't own.
He owns the file (before a chown, anyway), and can't change its
ownership. The rationale (to the best of my knowledge) behind
this (the fact that one can't "disown" oneself of a file) is
stemmed from systems with multiple users and user quotas; one
could (if disowning was possible) if one was about to run out
of space just make some files in an arbitrary place in the
file-system where one happens to have write access files and
make someone else the owner (who probably will never stumble
across those, so the ownership doesn't matter too much as
long as the group permissions are still fine).



Cheers,
Tink

vharishankar 07-07-2009 04:56 AM

Sorry I made a mistake. Grossly misleading. A quick look at google confirms that most *nix implements chown that way. But there seem to be ways to bypass this behaviour on some distributions/OSes(use google, I won't help :))


All times are GMT -5. The time now is 11:48 PM.