04-27-06 12:55 PM
On 2006-04-10, mac8500 wrote:
> I'm looking for a simple shell script that would compare uid et gid
> files on a bunch of servers (solaris, aix) from a white list. Looking
> for a local solution as no nis, ldap, nis+ running.
>
> I tought of using a diff -f and toy with the output (as it gives the ed
> help lines). But there as to be a simpler way.
>
> I also tought of using a single cmp line and mail myself the results
> (server x, y, z are not identical) but i'm pretty much interested in
> the output.
>
> White list
>
> root:0
> test:89
> user1:88
> user2:89
> user3:90
>
> server x /etc/passwd
>
> root:0
> test:88
> user1:88
> user2:90
> user3:91
>
> Would report in a temp file user2, user3 on server x is different.
>
> I know some sysadmins used that before
If whitelist just contains fields 1 and 3 from /etc/passwd:
awk -F: 'FILENAME == "whitelist" { u[$1,$2]++; next }
u[$1,$3] == 0 { print $1 ":" $3 }' whitelist /etc/passwd
If it contains the entire passwd file:
awk -F: 'FILENAME == "whitelist" { u[$1,$3]++; next }
u[$1,$3] == 0 { print $1 ":" $3 }' whitelist /etc/passwd
--
Chris F.A. Johnson, author | <http://cfaj.freeshell.org>
Shell Scripting Recipes: | My code in this post, if any,
A Problem-Solution Approach | is released under the
2005, Apress | GNU General Public Licence
[ Post a follow-up to this message ]
|