root owned files/world writable

Greg Hunt hunt at dg-rtp.rtp.dg.com
Sat Nov 17 05:21:50 AEST 1990


In article <1990Nov14.224701.15657 at cs.odu.edu>, epperly at cs.odu.edu (William "Badger" Epperly) writes:
> 
> Hey, folks!  If this is the wrong place for this article
> you have my apologies, but where else would it go?
> 

This is the right place.  Ask away!

>
> Listen, I have a problem here.  I am trying to write 
> a small shell script that will search a network, made up of nine
> servers, for all files owned by root that have world writeable
> permissions.  I have tried working with the find command and its
> -perm option but it does not seem to take wild cards (although the
> man page shows an example using * and ?, but these only appear to
> be for filenames), so that is unusable by itself.

It isn't easy (unfortunately) to figure out how to do more complex
things like this with find.  My find allows me to do this:

    find / \( -user root -perm -2 \) -print

to find files owned by root that also have world write permission.

To get find to do the "and" of two conditions, you need to put them
next to each other and within a set of parentheses.  Since  ( and )
have special meaning to the shell, they have to be escaped, so you
put a \ in front of them.

Putting a - in front of the permission value says "only look at the
bits I specify instead of looking at the whole permission value".
So the '-2' makes it look for files with the world write bit turned
on, and makes it ignore all the other permission bits regardless of
whether they are on or off.

Give this a try on your system.  There's no guarantee, however, that
your version of find supports doing things this way.

Enjoy!

--
Greg Hunt                        Internet: hunt at dg-rtp.rtp.dg.com
DG/UX Kernel Development         UUCP:     {world}!mcnc!rti!dg-rtp!hunt
Data General Corporation
Research Triangle Park, NC       These opinions are mine, not DG's.



More information about the Comp.unix.questions mailing list