LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
LinkBack Search this Thread
Old 05-11-2009, 09:27 AM   #1
Laserjock
LQ Newbie
 
Registered: Dec 2004
Location: Raleigh, NC USA
Distribution: CentOS 5, RHEL 5, Ubuntu
Posts: 19

Rep: Reputation: 0
Understanding file permissions issue


I'm a newb and am trying to understand the following scenario, where I create a file as root and take over ownership as a regular user, which I wouldn't think I should be able to do. Recreation:
  1. [root@mybox test]#touch root.txt
  2. [root@mybox test]#chmod 700 root.txt
  3. Log in on another tty as regular user "reguser".
  4. [reguser@mybox test]#vi root.txt
  5. I can edit the file, then try to save with :wq and get warned that file is read-only.
  6. I am prompted to overwrite with !, so I enter :wq!
  7. [reguser@mybox test]$ ls -l shows that reguser now owns root.txt

What gives? I can take over any root-owned file with a regular user? Yes, the directory /test that I am in is public.
 
Old 05-11-2009, 09:35 AM   #2
Laserjock
LQ Newbie
 
Registered: Dec 2004
Location: Raleigh, NC USA
Distribution: CentOS 5, RHEL 5, Ubuntu
Posts: 19

Original Poster
Rep: Reputation: 0
I guess it's in the owning directory permissions. After taking off the write bit for world in the owning directory I can no longer change the file. I had not realized that it doesn't make any difference how restrictive the file permission is if the owning directory's permissions were completely permissive.
 
Old 05-11-2009, 11:03 AM   #3
jschiwal
Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654
Vim deleted the old file and created a new one. Deleting a file is an operation on the directory. So if you can write to the directory, you can delete a file, even one owned by root. The sticky bit on a directory is used to prevent one user from deleting another users files.

However, vim should not have been able to read the contents of the file if it was owned & group owned by root and had only root read rights.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Understanding Linux File Permissions LXer Syndicated Linux News 0 04-05-2006 07:21 PM
Understanding File Permissions username132 Linux - Software 13 04-03-2006 04:42 AM
FTP File Permissions Issue KrGAce Linux - Newbie 6 01-12-2006 07:22 AM
FTP File Permissions Issue KrGAce Linux - Networking 1 01-11-2006 06:33 PM
Weird File Permissions Issue SiLiCoN *BSD 1 04-08-2005 04:41 AM


All times are GMT -5. The time now is 07:14 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration