How to find root owned world writable files?
Being a system administrator i came across a statement as " Excluding temporary directories /tmp and /var/tmp, no root owned files should be in world writable directories"
While the above statement may look straight forward but how would i check if there are any such directories in the distribution? |
Code:
find / -owner root -perm /o=w |
Quote:
Correct me if i m wrong. Code:
# find / -type d -user root -perm /o=w |
~~mistake~~
|
certainly it's -user, not -owner. doh.
|
So, I'm still missing something here. Won't the solution(s) offered, identify root-owned other-writeable directories, but not check whether there's any root-owned files in there (and if there aren't, then the directory should be filtered out of the results, no?)?
|
Quote:
|
Well your query says root owned 'files' not directories so '-type d' would be incorrect.
I believe you would need to pipe food into a while loop and check if directory had the correct perms. Something like: Code:
while read -r test_file |
Quote:
|
Thanks grail & Chris - that clears things up!
grail, I had been working on something similar to what you've got there, but yours looks better. :) |
thanks :)
|
Quote:
Not sure about whatever i did is correct.Here listing the things i did. I have created a bash script named tempprogram.sh place it under / directory. executed. content: Code:
# cat testprogram.sh Code:
./proc/5834/task/5834/attr |
Just noticed that we are also stating the file and not the directory ... my bad.
Change the following: Code:
$(stat -c%A "$test_file") |
@pinga123: /proc is a window into the kernel; ignore that dir
|
Please find the modified code but even this seems to generate lot of output entries i guess they and in lacks.
Please help. Quote:
|
All times are GMT -5. The time now is 05:46 PM. |