Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 19 Aug 1996 09:00:21 -0500 (CDT)
From:      Joe Greco <jgreco@brasil.moneng.mei.com>
To:        rif@ns.kconline.com (Jim Riffle)
Cc:        hackers@FreeBSD.org
Subject:   Re: how /etc/security works
Message-ID:  <199608191400.JAA19138@brasil.moneng.mei.com>
In-Reply-To: <Pine.BSI.3.95.960819075145.20390A-100000@ns.kconline.com> from "Jim Riffle" at Aug 19, 96 07:57:11 am

next in thread | previous in thread | raw e-mail | index | archive | help
> I feel like a total fool, but I am having troubles deciphering exactly how
> /etc/security works.
> Here is what troubles me..
> 
> MP=`mount -t ufs | sed 's;/dev/;&r;' | awk '{ print $3 }'`
> set $MP
> while test $# -ge 1; do
> 	mount=$1
> 	shift
> 	find $mount -xdev \( -perm -u+s -or -perm -g+s \) | sort
> done | xargs -n 20 ls -lgTd > $TMP
> 
> ----------------------
> 
> I understand the find command, but the rest of that, I am just not sure as
> to what is really going on.  In the end, what I am wanting to do is have
> it skip /var/news alltogether while doing find on everything else.  Could
> one of you sh wizards please decipher this for me?

This probably belongs on -questions...

MP=`mount -t ufs | grep -v " on /news " | sed 's;/dev/;&r;' | awk '{ print $3 }'`

would probably be sufficient... oops, /var/news for you.

As for what's going on...

The MP= sets the variable "MP" to have a list of all the "ufs" filesystems 
locally (the keys are the mount and the awk, step through the commands
adding one at a time to the pipeline to see the effect).

The "set" essentially tells sh that you intend to start manipulating the
following variable as though it was your argument list.

The "while test" checks to see if there are remaining elements in the list.

The mount=$1 assigns "${mount}" the value of the first element.

The shift deletes the first element and moves elements 2 to N down to 1 to
N-1.

In this manner, the "find" command is fed each element of "${MP}" in turn.

This ends up producing a list of all local files on all local filesystems
meeting the "find" criteria.

Pipe all that into xargs (read the man page) and get a listing.  :-)

... JG



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199608191400.JAA19138>