LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat
User Name
Password
Red Hat This forum is for the discussion of Red Hat Linux.

Notices



Reply
 
Search this Thread
Old 08-04-2004, 02:45 PM   #1
Mishley
LQ Newbie
 
Registered: Apr 2003
Distribution: Slackware
Posts: 10

Rep: Reputation: 0
cannot edit file as root with write permissions set?


NOTE: This is on a Redhat ES 2.1 Server

I am very, very confused. The file is a ColdFusion file in /home/httpd/www. I have permissions to edit the file.

[root@www www]# ls -lah Stuff.cfm
-rw-rw-r-- 1 mike mike 7.4k Jul 23 15:31 Stuff.cfm


The file system is also mounted as read-write.

[root@www www]# mount
/dev/cciss/c0d0p9 on / type ext3 (rw)
none on /proc type proc (rw)
usbdevfs on /proc/bus/usb type usbdevfs (rw)
/dev/cciss/c0d0p1 on /boot type ext3 (rw)
none on /dev/pts type devpts (rw,gid=5,mode=620)
/dev/cciss/c0d0p5 on /home type ext3 (rw)
/dev/cciss/c0d0p2 on /home/httpd type ext3 (rw)
/dev/cciss/c0d0p8 on /opt type ext3 (rw)
/dev/cciss/c0d0p10 on /tmp type ext3 (rw)
/dev/cciss/c0d0p3 on /usr type ext3 (rw)
/dev/cciss/c0d0p7 on /var type ext3 (rw)


But I can't edit the file, when I open and do an insert operation in vi I get:
-- INSERT -- W10: Warning: Changing a readonly file

And when I try to save the file anyways with wq! I get:
"Stuff.cfm" E212: Can't open file for writing
Hit ENTER or type command to continue


Any clue what in the hell is going on? I didn't set this system up, I've inherited it. After some testing I've found that /etc/passwd and /etc/shadow do the same exact thing, even though I can edit them with root on seperate installations. Can't edit with PICO either. Hell, I can't even chmod the file:
[root@www www]# chmod +w ProgViewFundingOps.cfm
chmod: changing permissions of `ProgViewFundingOps.cfm': Operation not permitted

Last edited by Mishley; 08-04-2004 at 02:47 PM.
 
Old 08-05-2004, 04:08 AM   #2
pingu
Senior Member
 
Registered: Jul 2004
Location: Skuttunge SWEDEN
Distribution: Debian preferably
Posts: 1,318

Rep: Reputation: 124Reputation: 124
Quote:
[root@www www]# ls -lah Stuff.cfm
-rw-rw-r-- 1 mike mike 7.4k Jul 23 15:31 Stuff.cfm
You are logged in as root, not as mike. That file is writeable only by user or group 'mike', not 'root.
-------------------------------------
Sorry, too hasty. root can edit any file, I then have no clue as to what is causing this.

Last edited by pingu; 08-05-2004 at 04:11 AM.
 
Old 08-05-2004, 10:48 AM   #3
Mishley
LQ Newbie
 
Registered: Apr 2003
Distribution: Slackware
Posts: 10

Original Poster
Rep: Reputation: 0
Yeah I know root can edit any file which is why I was really confused, but I found the problem. The file was using "chattr" as a secondary file system to place a lock on the file. The file was set to immutable.

[root@www www]# lsattr Stuff.cfm
---i---------- Stuff.cfm


So I tried to change it using chattr, but it didn't work.

[root@www www]# chattr -i Stuff.cfm
[root@www www]# lsattr Stuff.cfm
---i---------- Stuff.cfm


I then went and checked the history of the various accounts (I inherited this box so I was looking for a clue) and found the cr command, which may be a custom command for Redhat ES 2.1 or may be something that the administrator built in to prevent someone from knowing how to properly change the file attributes.

[root@www www]# cr -i Stuff.cfm
[root@www www]# lsattr Stuff.cfm
-------------- Stuff.cfm


The file was then editable. To put back the immutable status I used chattr, though cr also worked for some reason. Again, I suspect this was obfuscation on the part of the admin.

[root@www www]# cr +i Stuff.cfm
[root@www www]# lsattr Stuff.cfm
---i---------- Stuff.cfm
[root@www www]# cr -i Stuff.cfm
[root@www www]# chattr +i Stuff.cfm
[root@www www]# lsattr Stuff.cfm
---i---------- Stuff.cfm


So now everyone is happy. Once I removed immutable from the file I was able to edit it fine. Thanks for your help, and I hope this helps someone else.
 
Old 08-05-2004, 11:10 AM   #4
win32sux
Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 371Reputation: 371Reputation: 371Reputation: 371
Quote:
Originally posted by Mishley
I hope this helps someone else.
it already started helping people!!

thanks!!

=)


by the way, i'm a little curious about why you haven't made your own install, as every linux user i know would be way too paranoid as to actually trust someone else's install...

have you checked the install for rootkits??

http://www.rootkit.nl

=)
 
Old 08-05-2004, 01:23 PM   #5
Mishley
LQ Newbie
 
Registered: Apr 2003
Distribution: Slackware
Posts: 10

Original Poster
Rep: Reputation: 0
I'm just admin-ing this box for him while he's on vacation, but couldn't get in touch with him to find out what he had done.

Rest assured if it was MY box it would be running Debian .

I'm glad it helped. I couldn't find ANYTHING on this for like two days on Google, which is why I thought it would be a good idea to post a detailed account of what I had found.
 
  


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Not able to set write permissions on external hard drive. jpen8560 Linux - Hardware 19 03-22-2006 11:44 AM
Elementary Question - Can't Edit File - Need Root rrrssssss Linux - Newbie 2 04-12-2005 04:05 AM
smbmount write permissions - root zzyzx Linux - Networking 9 02-09-2005 11:25 PM
how to edit a file without logging in as root? osat3ch Fedora 3 08-22-2004 12:16 AM
How to set permissions to read, execute, write for users only chupacabra Linux - General 3 12-18-2002 04:54 PM


All times are GMT -5. The time now is 08:44 PM.

Main Menu
Advertisement
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