LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices

Reply
 
LinkBack Search this Thread
Old 02-09-2010, 02:27 PM   #1
RattleSn@ke
Member
 
Registered: Oct 2007
Location: Netherlands, ZH
Posts: 32

Rep: Reputation: 15
Unable to delete file as root


Hi All,

I search these forums and the internet, but all results are about regular users wanting to delete files owned by root.
I have a slightly different problem.

I have files which are owned by root, but user root is unable to delete them?

Code:
[root@ .montepio]# ls -lash
total 24K
8.0K drwxr-xr-x 2 root        root        4.0K Feb  1 05:19 .
8.0K drwxr-xr-x 3 userA       groupA       4.0K Feb  1 22:04 ..
8.0K -rwxrwxrwx 1 root        groupA       90 Feb  2 12:58 Actualizacao-Montepio.php

[root@ .montepio]# lsattr Actualizacao-Montepio.php
------------- Actualizacao-Montepio.php

[root@ .montepio]# rm -rf Actualizacao-Montepio.php
rm: cannot remove `Actualizacao-Montepio.php': Permission denied
Ow by the way, I am able to 'empty' the file or write other things in it.
So how the **** do I delete these things??
I don't know how the files are created.

I also reinstalled coreutils just to make sure a 'clean' version of rm is installed.

Anyone an idea?

Thanks!
Onno.
 
Old 02-09-2010, 02:35 PM   #2
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Debian, FreeBSD
Posts: 3,739
Blog Entries: 5

Rep: Reputation: Disabled
Try lsattr on its parent directory.
 
Old 02-09-2010, 03:41 PM   #3
unSpawn
Moderator
 
Registered: May 2001
Posts: 21,576
Blog Entries: 47

Rep: Reputation: 1402Reputation: 1402Reputation: 1402Reputation: 1402Reputation: 1402Reputation: 1402Reputation: 1402Reputation: 1402Reputation: 1402Reputation: 1402
Quote:
Originally Posted by RattleSn@ke View Post
I don't know how the files are created.
Might be a Remote File Inclusion, might be lax FTPd settings, I don't know either w/o details, but since it's got root ownership I'd comb the server over thoroughly. Start with the logs and auth data as recon will show up. That it's bad goes without saying, accessing an URI with the PHP file leads to D/L of a mcrsft executable, as in hosting malware. Who has access to the fs as userA and as groupA?
 
Old 02-09-2010, 03:47 PM   #4
PTrenholme
Senior Member
 
Registered: Dec 2004
Location: Olympia, WA, USA
Distribution: Fedora, (K)Ubuntu
Posts: 3,664

Rep: Reputation: 204Reputation: 204Reputation: 204
To expand on anomie's comment, in order to delete a file, you need permission to change the contents of the directory in which the file is listed. (After all, you're removing data from that file. [Note that a "directory" is just another file in *nix systems.])

And also note that the "directory" file coud be in a read only file system on some other physical device, so having w access on the "directory" does not necessarily mean that you can actually change the "directory's" contents. (This is an unlikely scenario, since lot's of other things would "go wrong" if the "directory" was on a r/o fs.")
 
Old 02-12-2010, 04:44 AM   #5
RattleSn@ke
Member
 
Registered: Oct 2007
Location: Netherlands, ZH
Posts: 32

Original Poster
Rep: Reputation: 15
Solved

Hi All,

First of all, thanks for all the replies.
After the hint of 'anomie', I looked further on how to view the permissions of a directory. lsattr normally only shows attributes of files. So I rechecked the man page and found that I need to use the '-d' option. So I did:

Code:
[root@ .montepio]# lsattr -d
su--ia-A----- .
Tata .. there's the bastard. After removing the attributes I was able to remove the complete directory:

Code:
[root@ images]# chattr -d -suSiadAc .montepio
[root@ images]# cd .montepio/
[root@ .montepio]# lsattr -d
------------- .
[root@ images]# rm -rf .montepio
[root@ images]#
Thank you all again!

Kind regards,
Onno.
 
Old 02-12-2010, 10:43 AM   #6
unSpawn
Moderator
 
Registered: May 2001
Posts: 21,576
Blog Entries: 47

Rep: Reputation: 1402Reputation: 1402Reputation: 1402Reputation: 1402Reputation: 1402Reputation: 1402Reputation: 1402Reputation: 1402Reputation: 1402Reputation: 1402
You haven't followed up on post #3. If that's intentional at least let me know, OK?
 
  


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
Strange file type - Unable to delete the file kk2202 Linux - General 6 08-10-2009 12:00 PM
Strange file type - Unable to delete the file kk2202 Red Hat 1 08-10-2009 08:22 AM
Root Unable to delete files of unknown type Slowfamily Linux - General 1 06-20-2008 06:10 PM
Tried to delete file as root but it says I don't have permission to delete it! beejayzed Mandriva 23 03-12-2004 02:46 AM


All times are GMT -5. The time now is 02:07 AM.

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
Open Source Consulting | Domain Registration