change of owner and group owner of a file belongs to diff user ?
Can anyone explain ?
Hi, (Red Hat Linux 7) #mkdir /doc #chmod 777 /doc user1$ cd /doc user1$ touch file1 {here the owner and group owner of the file is user1} user2$ cd /doc user2$ vim file1 {user2 is able to add content and save the file.} 1. After user2 edited the file1 with "vim" the owner of the file get changed why? 2. file1 was created my user1 and having 664 perm by default and user1 is the owner and groupowner of the file. How user2 was able to edit it with the file having only read perm for others ? |
give us the output of
Code:
ls -al /doc |
This is because the directory permissions allowed user2 to overwrite the file. Although user2 only had read permisson on the file, when saving it could not be saved in-place, so it used the write permission on the directory to overwrite the file, thats why the owner changes. Write permission on a directory allows creation and deletion of files in that directory regardless of the file permission itself.
|
Quote:
Quote:
b. user2 was allowed to read the file, and create a new file. From item "a", that user is also allowed to delete/rename the file before creating a new file there. You should look into what the "sticky" bit is for (for example, how it is used for /tmp). BTW, you might also look into using "git" for documentation version control... That would allow you to determine who can make changes, as well as resolve collision when two or more make edits to the same file without loosing edits. It also allows you a "undo" to make it simple to revert changes. There is also a "gitfs" that can be used to provide a filesystem access to the data (https://github.com/PressLabs/gitfs and scroll down to see what it is). |
All times are GMT -5. The time now is 06:06 PM. |