Operating System - Linux
1752798 Members
5550 Online
108789 Solutions
New Discussion юеВ

Re: Command for checking world-writable access

 
SOLVED
Go to solution
Dewa Negara_4
Regular Advisor

Command for checking world-writable access

Hi All,

I have a script to check world-writable access using the following command:

grep -v "#" /etc/fstab| awk '{print $2}'|grep -E -v "^/tmp$|^/var/tmp$|\.\.$"|xargs -n1 ls -ld|grep "wx "

However, this command is giving me a bug when the ownership of the mount point with "wx" chars as below:

[root@PROD:/opt/soeg/validation/scripts]
# grep -v "#" /etc/fstab| awk '{print $2}'|grep -E -v "^/tmp$|^/var/tmp$|\.\.$"|xargs -n1 ls -ld|grep "wx "
drwxrwxrwx 6 p50adm sapsys 96 Jun 30 2005 /usr/sap/P50
drwxrwxrwx 19 oratwx dba 2048 Oct 21 21:37 /oracle/TWX
drwxrwxr-x 56 oratwx dba 2048 Oct 14 16:59 /oracle/TWX/920_64
drwxr-xr-x 3 oratwx dba 24576 Feb 13 14:00 /oracle/TWX/saparch
drwxr-xr-x 5 oratwx dba 1024 Oct 27 11:21 /oracle/TWX/sapreorg

How can I do a little bit modification on the command, so it only checks for the world-writable permission?

Pls help.

Thanks and Best Regards,
Dewa
Santos
5 REPLIES 5
James R. Ferguson
Acclaimed Contributor

Re: Command for checking world-writable access

Hi Dewa:

If you want to find files with world-writable permissions do:

# find /path -xdev -type f -perm -o+w

The '-xdev' argument prevents crossing mountpoints. If you want you want to brutally search every filesystem, do:

# find / -type f -perm -o+w

Regards!

...JRF...
harry d brown jr
Honored Contributor
Solution

Re: Command for checking world-writable access

Change your ending grep with:

grep "^d.......wx "

live free or die
harry d brown jr
Live Free or Die
James R. Ferguson
Acclaimed Contributor

Re: Command for checking world-writable access

Hi (again) Dewa:

OK, you want mountpoints. How about this:

while read DEV MPT NULL
do
find ${MPT} -xdev -type d -perm -o+w
done < /etc/fstab

Regards!

...JRF...
James R. Ferguson
Acclaimed Contributor

Re: Command for checking world-writable access

Hi Dewa:

Oops, that should be:

while read DEV MPT NULL
do
find ${MPT} -xdev -type d -prune -perm -o+w
done < /etc/fstab

Regards!

...JRF...
Dewa Negara_4
Regular Advisor

Re: Command for checking world-writable access

Hi Harry / James,

Thanks a lot. It looks ok for me now. Thanks again for your great help.

Best Regards,
Dewa
Santos