security revision 1.87
11.1Scgd#!/bin/sh -
21.1Scgd#
31.87Sjhawk#	$NetBSD: security,v 1.87 2003/11/19 20:28:19 jhawk Exp $
41.9Scgd#	from: @(#)security	8.1 (Berkeley) 6/9/93
51.1Scgd#
61.1Scgd
71.9ScgdPATH=/sbin:/usr/sbin:/bin:/usr/bin
81.1Scgd
91.31Slukemif [ -f /etc/rc.subr ]; then
101.31Slukem	. /etc/rc.subr
111.31Slukemelse
121.31Slukem	echo "Can't read /etc/rc.subr; aborting."
131.31Slukem	exit 1;
141.31Slukemfi
151.31Slukem
161.9Scgdumask 077
171.64ScjsTZ=UTC; export TZ
181.1Scgd
191.15Smrgif [ -s /etc/security.conf ]; then
201.15Smrg	. /etc/security.conf
211.15Smrgfi
221.15Smrg
231.67Slukem# Set reasonable defaults (if they're not set in security.conf)
241.67Slukem#
251.67Slukembackup_dir=${backup_dir:-/var/backups}
261.67Slukempkgdb_dir=${pkgdb_dir:-/var/db/pkg}
271.67Slukemmax_loginlen=${max_loginlen:-8}
281.67Slukemmax_grouplen=${max_grouplen:-8}
291.67Slukem
301.67Slukem# Other configurable variables
311.67Slukem#
321.67Slukemspecial_files="/etc/mtree/special /etc/mtree/special.local"
331.67SlukemMP=/etc/master.passwd
341.67SlukemCHANGELIST=""
351.67Slukemwork_dir=$backup_dir/work
361.67Slukem
371.67Slukemif [ ! -d "$work_dir" ]; then
381.67Slukem	mkdir -p "$work_dir"
391.67Slukemfi
401.67Slukem
411.56SlukemSECUREDIR=`mktemp -d /tmp/_securedir.XXXXXX` || exit 1
421.56Slukem
431.67Slukemtrap "/bin/rm -rf $SECUREDIR ; exit 0" EXIT INT QUIT PIPE
441.15Smrg
451.56Slukemif ! cd "$SECUREDIR"; then
461.56Slukem	echo "Can not cd to $SECUREDIR".
471.15Smrg	exit 1
481.15Smrgfi
491.15Smrg
501.15SmrgERR=secure1.$$
511.15SmrgTMP1=secure2.$$
521.15SmrgTMP2=secure3.$$
531.28SlukemMPBYUID=secure4.$$
541.29SlukemMPBYPATH=secure5.$$
551.27SlukemLIST=secure6.$$
561.27SlukemOUTPUT=secure7.$$
571.32SlukemLABELS=secure8.$$
581.62SatatatPKGS=secure9.$$
591.67SlukemCHANGEFILES=secure10.$$
601.67Slukem
611.15Smrg
621.67Slukem# migrate_file old new
631.67Slukem#	Determine if the "${old}" path name needs to be migrated to the
641.67Slukem#	"${new}" path. Also checks if "${old}.current" needs migrating,
651.67Slukem#	and if so, migrate it and possibly "${old}.current,v" and
661.67Slukem#	"${old}.backup".
671.67Slukem#
681.67Slukemmigrate_file()
691.67Slukem{
701.67Slukem	_old=$1
711.67Slukem	_new=$2
721.67Slukem	if [ -z "$_old" -o -z "$_new" ]; then
731.67Slukem		err 3 "USAGE: migrate_file old new"
741.67Slukem	fi
751.67Slukem	if [ ! -d "${_new%/*}" ]; then
761.67Slukem		mkdir -p "${_new%/*}"
771.67Slukem	fi
781.67Slukem	if [ -f "${_old}" -a ! -f "${_new}" ]; then
791.67Slukem		echo "==> migrating ${_old}"
801.67Slukem		echo "           to ${_new}"
811.67Slukem		mv "${_old}" "${_new}"
821.67Slukem	fi
831.67Slukem	if [ -f "${_old}.current" -a ! -f "${_new}.current" ]; then
841.67Slukem		echo "==> migrating ${_old}.current"
851.67Slukem		echo "           to ${_new}.current"
861.67Slukem		mv "${_old}.current" "${_new}.current"
871.67Slukem		if [ -f "${_old}.current,v" -a ! -f "${_new}.current,v" ]; then
881.67Slukem			echo "==> migrating ${_old}.current,v"
891.67Slukem			echo "           to ${_new}.current,v"
901.67Slukem			mv "${_old}.current,v" "${_new}.current,v"
911.67Slukem		fi
921.67Slukem		if [ -f "${_old}.backup" -a ! -f "${_new}.backup" ]; then
931.67Slukem			echo "==> migrating ${_old}.backup"
941.67Slukem			echo "           to ${_new}.backup"
951.67Slukem			mv "${_old}.backup" "${_new}.backup"
961.67Slukem		fi
971.67Slukem	fi
981.67Slukem}
991.67Slukem
1001.67Slukem
1011.67Slukem# backup_and_diff file printdiff
1021.67Slukem#	Determine if file needs backing up, and if so, do it.
1031.67Slukem#	If printdiff is yes, display the diffs, otherwise 
1041.67Slukem#	just print a message saying "[changes omitted]".
1051.67Slukem#
1061.67Slukembackup_and_diff()
1071.67Slukem{
1081.67Slukem	_file=$1
1091.67Slukem	_printdiff=$2
1101.67Slukem	if [ -z "$_file" -o -z "$_printdiff" ]; then
1111.67Slukem		err 3 "USAGE: backup_and_diff file printdiff"
1121.67Slukem	fi
1131.67Slukem	! checkyesno _printdiff
1141.67Slukem	_printdiff=$?
1151.67Slukem
1161.67Slukem	_old=$backup_dir/${_file##*/}
1171.67Slukem	case "$_file" in
1181.67Slukem	$work_dir/*)
1191.67Slukem		_new=$_file
1201.67Slukem		migrate_file "$backup_dir/$_old" "$_new"
1211.67Slukem		migrate_file "$_old" "$_new"
1221.67Slukem		;;
1231.67Slukem	*)
1241.67Slukem		_new=$backup_dir/$_file
1251.67Slukem		migrate_file "$_old" "$_new"
1261.67Slukem		;;
1271.67Slukem	esac
1281.67Slukem	CUR=${_new}.current
1291.67Slukem	BACK=${_new}.backup
1301.67Slukem	if [ -f $_file ]; then
1311.67Slukem		if [ -f $CUR ] ; then
1321.67Slukem			if [ "$_printdiff" -ne 0 ]; then
1331.83Sjhawk				diff ${diff_options} $CUR $_file > $OUTPUT
1341.67Slukem			else
1351.67Slukem				if ! cmp -s $CUR $_file; then
1361.67Slukem					echo "[changes omitted]"
1371.67Slukem				fi > $OUTPUT
1381.67Slukem			fi
1391.67Slukem			if [ -s $OUTPUT ] ; then
1401.67Slukem				printf \
1411.67Slukem			"\n======\n%s diffs (OLD < > NEW)\n======\n" $_file
1421.67Slukem				cat $OUTPUT
1431.67Slukem				backup_file update $_file $CUR $BACK
1441.67Slukem			fi
1451.67Slukem		else
1461.67Slukem			printf "\n======\n%s added\n======\n" $_file
1471.67Slukem			if [ "$_printdiff" -ne 0 ]; then
1481.83Sjhawk				diff ${diff_options} /dev/null $_file
1491.67Slukem			else
1501.67Slukem				echo "[changes omitted]"
1511.67Slukem			fi
1521.67Slukem			backup_file add $_file $CUR $BACK
1531.67Slukem		fi
1541.67Slukem	else
1551.67Slukem		if [ -f $CUR ]; then
1561.67Slukem			printf "\n======\n%s removed\n======\n" $_file
1571.67Slukem			if [ "$_printdiff" -ne 0 ]; then
1581.83Sjhawk				diff ${diff_options} $CUR /dev/null
1591.67Slukem			else
1601.67Slukem				echo "[changes omitted]"
1611.67Slukem			fi
1621.67Slukem			backup_file remove $_file $CUR $BACK
1631.67Slukem		fi
1641.67Slukem	fi
1651.67Slukem}
1661.48Sabs
1671.9Scgd
1681.67Slukem# These are used several times.
1691.67Slukem#
1701.34Sabsawk -F: '!/^+/ { print $1 " " $3 }' $MP | sort -k2n > $MPBYUID
1711.29Slukemawk -F: '{ print $1 " " $9 }' $MP | sort -k2 > $MPBYPATH
1721.9Scgd
1731.67Slukem
1741.9Scgd# Check the master password file syntax.
1751.32Slukem#
1761.31Slukemif checkyesno check_passwd; then
1771.85Sjhawk        # XXX: the sense of permit_star is reversed; the code works as
1781.85Sjhawk        # implemented, but usage needs to be negated.
1791.81Sjhawk	checkyesno check_passwd_permit_star && permit_star=0 || permit_star=1
1801.81Sjhawk	awk -v "len=$max_loginlen" \
1811.81Sjhawk	    -v "nowarn_shells_list=$check_passwd_nowarn_shells" \
1821.81Sjhawk	    -v "nowarn_users_list=$check_passwd_nowarn_users" \
1831.81Sjhawk	    -v "permit_star=$permit_star" '
1841.25Slukem	BEGIN {
1851.25Slukem		while ( getline < "/etc/shells" > 0 ) {
1861.39Shubertf			if ($0 ~ /^\#/ || $0 ~ /^$/ )
1871.25Slukem				continue;
1881.25Slukem			shells[$1]++;
1891.25Slukem		}
1901.81Sjhawk		split(nowarn_shells_list, a);
1911.81Sjhawk		for (i in a) nowarn_shells[a[i]]++;
1921.81Sjhawk		split(nowarn_users_list, a);
1931.81Sjhawk		for (i in a) nowarn_users[a[i]]++;
1941.81Sjhawk		uid0_users_list="root toor"
1951.81Sjhawk		split(uid0_users_list, a);
1961.81Sjhawk		for (i in a) uid0_users[a[i]]++;
1971.25Slukem		FS=":";
1981.25Slukem	}
1991.25Slukem
2001.25Slukem	{
2011.15Smrg		if ($0 ~ /^[	 ]*$/) {
2021.25Slukem			printf "Line %d is a blank line.\n", NR;
2031.15Smrg			next;
2041.15Smrg		}
2051.34Sabs		if (NF != 10 && ($1 != "+" || NF != 1))
2061.25Slukem			printf "Line %d has the wrong number of fields.\n", NR;
2071.34Sabs		if ($1 == "+" )  {
2081.34Sabs			if (NF != 1 && $3 == 0)
2091.81Sjhawk			    printf "Line %d includes entries with uid 0.\n",
2101.81Sjhawk			        NR;
2111.34Sabs			next;
2121.34Sabs		}
2131.53Satatat		if ($1 !~ /^[A-Za-z0-9]([-A-Za-z0-9]*[A-Za-z0-9])*$/)
2141.25Slukem			printf "Login %s has non-alphanumeric characters.\n",
2151.25Slukem			    $1;
2161.34Sabs		if (length($1) > len)
2171.81Sjhawk			printf "Login %s has more than "len" characters.\n",
2181.81Sjhawk			    $1;
2191.81Sjhawk		if ($2 == "" && !nowarn_users[$1])
2201.81Sjhawk			    printf "Login %s has no password.\n", $1;
2211.81Sjhawk		if (!nowarn_shells[$10] && !nowarn_users[$1]) {
2221.81Sjhawk		    if (length($2) != 13 &&
2231.81Sjhawk		    	length($2) != 20 &&
2241.81Sjhawk		    	$2 !~ /^\$1/ &&
2251.81Sjhawk		    	$2 !~ /^\$2/ &&
2261.81Sjhawk		    	$2 != "" &&
2271.81Sjhawk			(permit_star || $2 != "*") &&
2281.81Sjhawk		    	$2 !~ /^\*[A-z-]+$/ &&
2291.81Sjhawk			$1 != "toor") {
2301.81Sjhawk		    	    if ($10 == "" || shells[$10])
2311.81Sjhawk				printf "Login %s is off but still has "\
2321.81Sjhawk				  "a valid shell (%s)\n", $1, $10;
2331.81Sjhawk		    } else if (! shells[$10])
2341.81Sjhawk		    	    printf "Login %s does not have a valid "\
2351.81Sjhawk			    "shell (%s)\n", $1, $10;
2361.81Sjhawk		}
2371.81Sjhawk		if ($3 == 0 && !uid0_users[$1] && !nowarn_users[$1])
2381.25Slukem			printf "Login %s has a user id of 0.\n", $1;
2391.15Smrg		if ($3 < 0)
2401.25Slukem			printf "Login %s has a negative user id.\n", $1;
2411.15Smrg		if ($4 < 0)
2421.25Slukem			printf "Login %s has a negative group id.\n", $1;
2431.15Smrg	}' < $MP > $OUTPUT
2441.15Smrg	if [ -s $OUTPUT ] ; then
2451.15Smrg		printf "\nChecking the $MP file:\n"
2461.15Smrg		cat $OUTPUT
2471.15Smrg	fi
2481.15Smrg
2491.15Smrg	awk -F: '{ print $1 }' $MP | sort | uniq -d > $OUTPUT
2501.15Smrg	if [ -s $OUTPUT ] ; then
2511.15Smrg		printf "\n$MP has duplicate user names.\n"
2521.15Smrg		column $OUTPUT
2531.15Smrg	fi
2541.15Smrg
2551.37Swrstuden# To not exclude 'toor', a standard duplicate root account, from the duplicate
2561.37Swrstuden# account test, uncomment the line below (without egrep in it)and comment
2571.37Swrstuden# out the line (with egrep in it) below it.
2581.37Swrstuden#
2591.37Swrstuden#	< $MPBYUID uniq -d -f 1 | awk '{ print $2 }' > $TMP2
2601.36Swrstuden	< $MPBYUID egrep -v '^toor ' | uniq -d -f 1 | awk '{ print $2 }' > $TMP2
2611.15Smrg	if [ -s $TMP2 ] ; then
2621.15Smrg		printf "\n$MP has duplicate user id's.\n"
2631.15Smrg		while read uid; do
2641.28Slukem			grep -w $uid $MPBYUID
2651.15Smrg		done < $TMP2 | column
2661.15Smrg	fi
2671.9Scgdfi
2681.9Scgd
2691.9Scgd# Check the group file syntax.
2701.32Slukem#
2711.31Slukemif checkyesno check_group; then
2721.15Smrg	GRP=/etc/group
2731.49Sjdolecek	awk -F: -v "len=$max_grouplen" '{
2741.15Smrg		if ($0 ~ /^[	 ]*$/) {
2751.25Slukem			printf "Line %d is a blank line.\n", NR;
2761.15Smrg			next;
2771.15Smrg		}
2781.34Sabs		if (NF != 4 && ($1 != "+" || NF != 1))
2791.25Slukem			printf "Line %d has the wrong number of fields.\n", NR;
2801.34Sabs		if ($1 == "+" )  {
2811.34Sabs			next;
2821.34Sabs		}
2831.53Satatat		if ($1 !~ /^[A-Za-z0-9]([-A-Za-z0-9]*[A-Za-z0-9])*$/)
2841.25Slukem			printf "Group %s has non-alphanumeric characters.\n",
2851.25Slukem			    $1;
2861.49Sjdolecek		if (length($1) > len)
2871.49Sjdolecek			printf "Group %s has more than "len" characters.\n", $1;
2881.15Smrg		if ($3 !~ /[0-9]*/)
2891.25Slukem			printf "Login %s has a negative group id.\n", $1;
2901.15Smrg	}' < $GRP > $OUTPUT
2911.15Smrg	if [ -s $OUTPUT ] ; then
2921.15Smrg		printf "\nChecking the $GRP file:\n"
2931.15Smrg		cat $OUTPUT
2941.15Smrg	fi
2951.15Smrg
2961.15Smrg	awk -F: '{ print $1 }' $GRP | sort | uniq -d > $OUTPUT
2971.15Smrg	if [ -s $OUTPUT ] ; then
2981.15Smrg		printf "\n$GRP has duplicate group names.\n"
2991.15Smrg		column $OUTPUT
3001.15Smrg	fi
3011.9Scgdfi
3021.9Scgd
3031.9Scgd# Check for root paths, umask values in startup files.
3041.9Scgd# The check for the root paths is problematical -- it's likely to fail
3051.9Scgd# in other environments.  Once the shells have been modified to warn
3061.9Scgd# of '.' in the path, the path tests should go away.
3071.32Slukem#
3081.31Slukemif checkyesno check_rootdotfiles; then
3091.67Slukem	rhome=~root
3101.15Smrg	umaskset=no
3111.15Smrg	list="/etc/csh.cshrc /etc/csh.login ${rhome}/.cshrc ${rhome}/.login"
3121.15Smrg	for i in $list ; do
3131.15Smrg		if [ -f $i ] ; then
3141.67Slukem			if egrep '^[ \t]*umask[ \t]+[0-7]+' $i > /dev/null ;
3151.67Slukem			then
3161.15Smrg				umaskset=yes
3171.15Smrg			fi
3181.63Slukem			# Double check the umask value itself; ensure that
3191.67Slukem			# both the group and other write bits are set.
3201.67Slukem			#
3211.45Ssommerfe			egrep '^[ \t]*umask[ \t]+[0-7]+' $i |
3221.63Slukem			awk '{
3231.67Slukem				if ($2 ~ /^.$/ || $2 ~! /[^2367].$/) {
3241.80Swiz					print "\tRoot umask is group writable"
3251.63Slukem				}
3261.67Slukem				if ($2 ~ /[^2367]$/) {
3271.80Swiz					print "\tRoot umask is other writable"
3281.63Slukem			    	}
3291.67Slukem			    }' | sort -u
3301.26Slukem			SAVE_PATH=$PATH
3311.26Slukem			unset PATH
3321.15Smrg			/bin/csh -f -s << end-of-csh > /dev/null 2>&1
3331.15Smrg				source $i
3341.15Smrg				/bin/ls -ldgT \$path > $TMP1
3351.9Scgdend-of-csh
3361.76Satatat			export PATH=$SAVE_PATH
3371.15Smrg			awk '{
3381.15Smrg				if ($10 ~ /^\.$/) {
3391.27Slukem					print "\tThe root path includes .";
3401.15Smrg					next;
3411.15Smrg				}
3421.15Smrg			     }
3431.15Smrg			     $1 ~ /^d....w/ \
3441.80Swiz		{ print "\tRoot path directory " $10 " is group writable." } \
3451.15Smrg			     $1 ~ /^d.......w/ \
3461.80Swiz		{ print "\tRoot path directory " $10 " is other writable." }' \
3471.67Slukem			< $TMP1
3481.15Smrg		fi
3491.67Slukem	done > $OUTPUT
3501.15Smrg	if [ $umaskset = "no" -o -s $OUTPUT ] ; then
3511.27Slukem		printf "\nChecking root csh paths, umask values:\n$list\n\n"
3521.15Smrg		if [ -s $OUTPUT ]; then
3531.15Smrg			cat $OUTPUT
3541.15Smrg		fi
3551.15Smrg		if [ $umaskset = "no" ] ; then
3561.27Slukem		    printf "\tRoot csh startup files do not set the umask.\n"
3571.15Smrg		fi
3581.9Scgd	fi
3591.9Scgd
3601.15Smrg	umaskset=no
3611.23Slukem	list="/etc/profile ${rhome}/.profile"
3621.15Smrg	for i in $list; do
3631.15Smrg		if [ -f $i ] ; then
3641.15Smrg			if egrep umask $i > /dev/null ; then
3651.15Smrg				umaskset=yes
3661.15Smrg			fi
3671.15Smrg			egrep umask $i |
3681.67Slukem			awk '$2 ~ /^.$/ || $2 ~ /[^2367].$/ \
3691.80Swiz				{ print "\tRoot umask is group writable" } \
3701.67Slukem			     $2 ~ /[^2367]$/ \
3711.80Swiz				{ print "\tRoot umask is other writable" }'
3721.26Slukem			SAVE_PATH=$PATH
3731.26Slukem			unset PATH
3741.15Smrg			/bin/sh << end-of-sh > /dev/null 2>&1
3751.15Smrg				. $i
3761.26Slukem				list=\`echo \$PATH | /usr/bin/sed -e \
3771.26Slukem				    's/^:/.:/;s/:$/:./;s/::/:.:/g;s/:/ /g'\`
3781.15Smrg				/bin/ls -ldgT \$list > $TMP1
3791.9Scgdend-of-sh
3801.76Satatat			export PATH=$SAVE_PATH
3811.15Smrg			awk '{
3821.15Smrg				if ($10 ~ /^\.$/) {
3831.27Slukem					print "\tThe root path includes .";
3841.15Smrg					next;
3851.15Smrg				}
3861.15Smrg			     }
3871.15Smrg			     $1 ~ /^d....w/ \
3881.80Swiz		{ print "\tRoot path directory " $10 " is group writable." } \
3891.15Smrg			     $1 ~ /^d.......w/ \
3901.80Swiz		{ print "\tRoot path directory " $10 " is other writable." }' \
3911.67Slukem			< $TMP1
3921.9Scgd
3931.15Smrg		fi
3941.67Slukem	done > $OUTPUT
3951.15Smrg	if [ $umaskset = "no" -o -s $OUTPUT ] ; then
3961.15Smrg		printf "\nChecking root sh paths, umask values:\n$list\n"
3971.15Smrg		if [ -s $OUTPUT ]; then
3981.15Smrg			cat $OUTPUT
3991.15Smrg		fi
4001.15Smrg		if [ $umaskset = "no" ] ; then
4011.27Slukem			printf "\tRoot sh startup files do not set the umask.\n"
4021.15Smrg		fi
4031.9Scgd	fi
4041.9Scgdfi
4051.9Scgd
4061.9Scgd# Root and uucp should both be in /etc/ftpusers.
4071.32Slukem#
4081.31Slukemif checkyesno check_ftpusers; then
4091.28Slukem	list="uucp "`awk '$2 == 0 { print $1 }' $MPBYUID`
4101.27Slukem	for i in $list; do
4111.29Slukem		if /usr/libexec/ftpd -C $i ; then
4121.67Slukem			printf "\t$i is not denied\n"
4131.27Slukem		fi
4141.67Slukem	done > $OUTPUT
4151.28Slukem	if [ -s $OUTPUT ]; then
4161.28Slukem		printf "\nChecking the /etc/ftpusers configuration:\n"
4171.28Slukem		cat $OUTPUT
4181.28Slukem	fi
4191.9Scgdfi
4201.9Scgd
4211.43Sitojun# Uudecode should not be in the /etc/mail/aliases file.
4221.32Slukem#
4231.31Slukemif checkyesno check_aliases; then
4241.43Sitojun	for f in /etc/mail/aliases /etc/aliases; do
4251.43Sitojun		if [ -f $f ] && egrep '^[^#]*(uudecode|decode).*\|' $f; then
4261.43Sitojun			printf "\nEntry for uudecode in $f file.\n"
4271.43Sitojun		fi
4281.43Sitojun	done
4291.9Scgdfi
4301.9Scgd
4311.9Scgd# Files that should not have + signs.
4321.32Slukem#
4331.31Slukemif checkyesno check_rhosts; then
4341.15Smrg	list="/etc/hosts.equiv /etc/hosts.lpd"
4351.15Smrg	for f in $list ; do
4361.15Smrg		if [ -f $f ] && egrep '\+' $f > /dev/null ; then
4371.15Smrg			printf "\nPlus sign in $f file.\n"
4381.15Smrg		fi
4391.15Smrg	done
4401.15Smrg
4411.15Smrg	# Check for special users with .rhosts files.  Only root and toor should
4421.16Smikel	# have .rhosts files.  Also, .rhosts files should not have plus signs.
4431.15Smrg	awk -F: '$1 != "root" && $1 != "toor" && \
4441.15Smrg		($3 < 100 || $1 == "ftp" || $1 == "uucp") \
4451.20Smycroft			{ print $1 " " $9 }' $MP |
4461.19Smycroft	sort -k2 |
4471.15Smrg	while read uid homedir; do
4481.15Smrg		if [ -f ${homedir}/.rhosts ] ; then
4491.15Smrg			rhost=`ls -ldgT ${homedir}/.rhosts`
4501.46Schristos			printf -- "$uid: $rhost\n"
4511.15Smrg		fi
4521.15Smrg	done > $OUTPUT
4531.15Smrg	if [ -s $OUTPUT ] ; then
4541.15Smrg		printf "\nChecking for special users with .rhosts files.\n"
4551.15Smrg		cat $OUTPUT
4561.15Smrg	fi
4571.15Smrg
4581.15Smrg	while read uid homedir; do
4591.35Sfair		if [ -f ${homedir}/.rhosts -a -r ${homedir}/.rhosts ] && \
4601.41Schristos		    cat -f ${homedir}/.rhosts | egrep '\+' > /dev/null ; then
4611.46Schristos			printf -- "$uid: + in .rhosts file.\n"
4621.15Smrg		fi
4631.29Slukem	done < $MPBYPATH > $OUTPUT
4641.15Smrg	if [ -s $OUTPUT ] ; then
4651.15Smrg		printf "\nChecking .rhosts files syntax.\n"
4661.15Smrg		cat $OUTPUT
4671.15Smrg	fi
4681.9Scgdfi
4691.9Scgd
4701.9Scgd# Check home directories.  Directories should not be owned by someone else
4711.80Swiz# or writable.
4721.32Slukem#
4731.31Slukemif checkyesno check_homes; then
4741.85Sjhawk	checkyesno check_homes_permit_usergroups && \
4751.85Sjhawk		permit_usergroups=1 || permit_usergroups=0
4761.15Smrg	while read uid homedir; do
4771.15Smrg		if [ -d ${homedir}/ ] ; then
4781.15Smrg			file=`ls -ldgT ${homedir}`
4791.46Schristos			printf -- "$uid $file\n"
4801.9Scgd		fi
4811.29Slukem	done < $MPBYPATH |
4821.85Sjhawk	awk -v "usergroups=$permit_usergroups" '
4831.85Sjhawk	     $1 != $4 && $4 != "root" \
4841.15Smrg		{ print "user " $1 " home directory is owned by " $4 }
4851.85Sjhawk	     $2 ~ /^-....w/ (!usergroups || $5 != $1) \
4861.80Swiz		{ print "user " $1 " home directory is group writable" }
4871.15Smrg	     $2 ~ /^-.......w/ \
4881.80Swiz		{ print "user " $1 " home directory is other writable" }' \
4891.27Slukem	    > $OUTPUT
4901.15Smrg	if [ -s $OUTPUT ] ; then
4911.15Smrg		printf "\nChecking home directories.\n"
4921.15Smrg		cat $OUTPUT
4931.15Smrg	fi
4941.15Smrg
4951.15Smrg	# Files that should not be owned by someone else or readable.
4961.67Slukem	list=".Xauthority .netrc .ssh/id_dsa .ssh/id_rsa .ssh/identity"
4971.15Smrg	while read uid homedir; do
4981.15Smrg		for f in $list ; do
4991.15Smrg			file=${homedir}/${f}
5001.15Smrg			if [ -f $file ] ; then
5011.46Schristos				printf -- "$uid $f `ls -ldgT $file`\n"
5021.15Smrg			fi
5031.15Smrg		done
5041.29Slukem	done < $MPBYPATH |
5051.85Sjhawk	awk  -v "usergroups=$permit_usergroups" '
5061.85Sjhawk	     $1 != $5 && $5 != "root" \
5071.15Smrg		{ print "user " $1 " " $2 " file is owned by " $5 }
5081.85Sjhawk	     $3 ~ /^-...r/ && (!usergroups || $6 != $1) \
5091.15Smrg		{ print "user " $1 " " $2 " file is group readable" }
5101.15Smrg	     $3 ~ /^-......r/ \
5111.15Smrg		{ print "user " $1 " " $2 " file is other readable" }
5121.85Sjhawk	     $3 ~ /^-....w/ && (!usergroups || $6 != $1) \
5131.80Swiz		{ print "user " $1 " " $2 " file is group writable" }
5141.15Smrg	     $3 ~ /^-.......w/ \
5151.80Swiz		{ print "user " $1 " " $2 " file is other writable" }' \
5161.27Slukem	    > $OUTPUT
5171.15Smrg
5181.80Swiz	# Files that should not be owned by someone else or writable.
5191.19Smycroft	list=".bash_history .bash_login .bash_logout .bash_profile .bashrc \
5201.79Selric	      .cshrc .emacs .exrc .forward .history .k5login .klogin .login \
5211.79Selric	      .logout .profile .qmail .rc_history .rhosts .shosts ssh .tcshrc \
5221.79Selric	      .twmrc .xinitrc .xsession .ssh/authorized_keys \
5231.79Selric	      .ssh/authorized_keys2 .ssh/config .ssh/id_dsa.pub \
5241.79Selric	      .ssh/id_rsa.pub .ssh/identity.pub .ssh/known_hosts \
5251.79Selric	      .ssh/known_hosts2"
5261.15Smrg	while read uid homedir; do
5271.15Smrg		for f in $list ; do
5281.15Smrg			file=${homedir}/${f}
5291.15Smrg			if [ -f $file ] ; then
5301.46Schristos				printf -- "$uid $f `ls -ldgT $file`\n"
5311.15Smrg			fi
5321.15Smrg		done
5331.29Slukem	done < $MPBYPATH |
5341.85Sjhawk	awk -v "usergroups=$permit_usergroups" '
5351.85Sjhawk	     $1 != $5 && $5 != "root" \
5361.15Smrg		{ print "user " $1 " " $2 " file is owned by " $5 }
5371.85Sjhawk	     $3 ~ /^-....w/ && (!usergroups || $6 != $1) \
5381.80Swiz		{ print "user " $1 " " $2 " file is group writable" }
5391.15Smrg	     $3 ~ /^-.......w/ \
5401.80Swiz		{ print "user " $1 " " $2 " file is other writable" }' \
5411.27Slukem	    >> $OUTPUT
5421.15Smrg	if [ -s $OUTPUT ] ; then
5431.15Smrg		printf "\nChecking dot files.\n"
5441.15Smrg		cat $OUTPUT
5451.15Smrg	fi
5461.9Scgdfi
5471.9Scgd
5481.9Scgd# Mailboxes should be owned by user and unreadable.
5491.32Slukem#
5501.31Slukemif checkyesno check_varmail; then
5511.86Sjhawk	ls -lA /var/mail | \
5521.63Slukem	awk '	NR == 1 { next; }
5531.86Sjhawk		$9 ~ /^\./ {next; }
5541.63Slukem	    	$3 != $9 {
5551.63Slukem			print "user " $9 " mailbox is owned by " $3
5561.63Slukem		}
5571.63Slukem		$1 != "-rw-------" {
5581.63Slukem			print "user " $9 " mailbox is " $1 ", group " $4
5591.63Slukem		}' > $OUTPUT
5601.15Smrg	if [ -s $OUTPUT ] ; then
5611.15Smrg		printf "\nChecking mailbox ownership.\n"
5621.15Smrg		cat $OUTPUT
5631.15Smrg	fi
5641.15Smrgfi
5651.15Smrg
5661.32Slukem# NFS exports shouldn't be globally exported
5671.32Slukem#
5681.32Slukemif checkyesno check_nfs && [ -f /etc/exports ]; then
5691.32Slukem	awk '{
5701.22Slukem		# ignore comments and blank lines
5711.39Shubertf		if ($0 ~ /^\#/ || $0 ~ /^$/ )
5721.22Slukem			next;
5731.22Slukem
5741.15Smrg		readonly = 0;
5751.15Smrg		for (i = 2; i <= NF; ++i) {
5761.15Smrg			if ($i ~ /-ro/)
5771.15Smrg				readonly = 1;
5781.15Smrg			else if ($i !~ /^-/)
5791.15Smrg				next;
5801.15Smrg		}
5811.15Smrg		if (readonly)
5821.15Smrg			print "File system " $1 " globally exported, read-only."
5831.15Smrg		else
5841.15Smrg			print "File system " $1 " globally exported, read-write."
5851.32Slukem	}' < /etc/exports > $OUTPUT
5861.32Slukem	if [ -s $OUTPUT ] ; then
5871.15Smrg		printf "\nChecking for globally exported file systems.\n"
5881.15Smrg		cat $OUTPUT
5891.15Smrg	fi
5901.9Scgdfi
5911.9Scgd
5921.9Scgd# Display any changes in setuid files and devices.
5931.32Slukem#
5941.31Slukemif checkyesno check_devices; then
5951.28Slukem	> $ERR
5961.15Smrg	(find / \( ! -fstype local -o -fstype fdesc -o -fstype kernfs \
5971.74Slukem			-o -fstype null \
5981.15Smrg			-o -fstype procfs \) -a -prune -o \
5991.21Smycroft	    \( \( -perm -u+s -a ! -type d \) -o \
6001.21Smycroft	       \( -perm -g+s -a ! -type d \) -o \
6011.24Slukem	       -type b -o -type c \) -print0 | \
6021.24Slukem	xargs -0 ls -ldgTq | sort +9 > $LIST) 2> $OUTPUT
6031.15Smrg
6041.15Smrg	# Display any errors that occurred during system file walk.
6051.15Smrg	if [ -s $OUTPUT ] ; then
6061.28Slukem		printf "Setuid/device find errors:\n" >> $ERR
6071.28Slukem		cat $OUTPUT >> $ERR
6081.28Slukem		printf "\n" >> $ERR
6091.15Smrg	fi
6101.15Smrg
6111.15Smrg	# Display any changes in the setuid file list.
6121.15Smrg	egrep -v '^[bc]' $LIST > $TMP1
6131.15Smrg	if [ -s $TMP1 ] ; then
6141.15Smrg		# Check to make sure uudecode isn't setuid.
6151.15Smrg		if grep -w uudecode $TMP1 > /dev/null ; then
6161.28Slukem			printf "\nUudecode is setuid.\n" >> $ERR
6171.15Smrg		fi
6181.15Smrg
6191.67Slukem		file=$work_dir/setuid
6201.67Slukem		migrate_file "$backup_dir/setuid" "$file"
6211.67Slukem		CUR=${file}.current
6221.67Slukem		BACK=${file}.backup
6231.15Smrg		if [ -s $CUR ] ; then
6241.15Smrg			if cmp -s $CUR $TMP1 ; then
6251.15Smrg				:
6261.15Smrg			else
6271.15Smrg				> $TMP2
6281.15Smrg				join -110 -210 -v2 $CUR $TMP1 > $OUTPUT
6291.15Smrg				if [ -s $OUTPUT ] ; then
6301.28Slukem					printf "Setuid additions:\n" >> $ERR
6311.28Slukem					tee -a $TMP2 < $OUTPUT >> $ERR
6321.28Slukem					printf "\n" >> $ERR
6331.15Smrg				fi
6341.15Smrg
6351.15Smrg				join -110 -210 -v1 $CUR $TMP1 > $OUTPUT
6361.15Smrg				if [ -s $OUTPUT ] ; then
6371.28Slukem					printf "Setuid deletions:\n" >> $ERR
6381.28Slukem					tee -a $TMP2 < $OUTPUT >> $ERR
6391.28Slukem					printf "\n" >> $ERR
6401.15Smrg				fi
6411.15Smrg
6421.20Smycroft				sort -k10 $TMP2 $CUR $TMP1 | \
6431.27Slukem				    sed -e 's/[	 ][	 ]*/ /g' | \
6441.27Slukem				    uniq -u > $OUTPUT
6451.15Smrg				if [ -s $OUTPUT ] ; then
6461.28Slukem					printf "Setuid changes:\n" >> $ERR
6471.28Slukem					column -t $OUTPUT >> $ERR
6481.28Slukem					printf "\n" >> $ERR
6491.15Smrg				fi
6501.9Scgd
6511.52Satatat				backup_file update $TMP1 $CUR $BACK
6521.9Scgd			fi
6531.15Smrg		else
6541.28Slukem			printf "Setuid additions:\n" >> $ERR
6551.28Slukem			column -t $TMP1 >> $ERR
6561.28Slukem			printf "\n" >> $ERR
6571.52Satatat			backup_file add $TMP1 $CUR $BACK
6581.9Scgd		fi
6591.15Smrg	fi
6601.15Smrg
6611.27Slukem	# Check for block and character disk devices that are readable or
6621.80Swiz	# writable or not owned by root.operator.
6631.15Smrg	>$TMP1
6641.61Slukem	DISKLIST="ccd ch hk hp ld md ra raid rb rd rl rx \
6651.57Ssimonb	    sd se ss uk up vnd wd xd xy"
6661.27Slukem#	DISKLIST="$DISKLIST ct mt st wt"
6671.15Smrg	for i in $DISKLIST; do
6681.15Smrg		egrep "^b.*/${i}[0-9][0-9]*[a-p]$"  $LIST >> $TMP1
6691.15Smrg		egrep "^c.*/r${i}[0-9][0-9]*[a-p]$"  $LIST >> $TMP1
6701.15Smrg	done
6711.15Smrg
6721.15Smrg	awk '$3 != "root" || $4 != "operator" || $1 !~ /.rw-r-----/ \
6731.25Slukem		{ printf "Disk %s is user %s, group %s, permissions %s.\n", \
6741.25Slukem		    $11, $3, $4, $1; }' < $TMP1 > $OUTPUT
6751.15Smrg	if [ -s $OUTPUT ] ; then
6761.28Slukem		printf "\nChecking disk ownership and permissions.\n" >> $ERR
6771.28Slukem		cat $OUTPUT >> $ERR
6781.28Slukem		printf "\n" >> $ERR
6791.9Scgd	fi
6801.9Scgd
6811.15Smrg	# Display any changes in the device file list.
6821.20Smycroft	egrep '^[bc]' $LIST | sort -k11 > $TMP1
6831.15Smrg	if [ -s $TMP1 ] ; then
6841.67Slukem		file=$work_dir/device
6851.67Slukem		migrate_file "$backup_dir/device" "$file"
6861.67Slukem		CUR=${file}.current
6871.67Slukem		BACK=${file}.backup
6881.15Smrg
6891.15Smrg		if [ -s $CUR ] ; then
6901.15Smrg			if cmp -s $CUR $TMP1 ; then
6911.15Smrg				:
6921.15Smrg			else
6931.15Smrg				> $TMP2
6941.15Smrg				join -111 -211 -v2 $CUR $TMP1 > $OUTPUT
6951.15Smrg				if [ -s $OUTPUT ] ; then
6961.28Slukem					printf "Device additions:\n" >> $ERR
6971.28Slukem					tee -a $TMP2 < $OUTPUT >> $ERR
6981.28Slukem					printf "\n" >> $ERR
6991.15Smrg				fi
7001.15Smrg
7011.15Smrg				join -111 -211 -v1 $CUR $TMP1 > $OUTPUT
7021.15Smrg				if [ -s $OUTPUT ] ; then
7031.28Slukem					printf "Device deletions:\n" >> $ERR
7041.28Slukem					tee -a $TMP2 < $OUTPUT >> $ERR
7051.28Slukem					printf "\n" >> $ERR
7061.15Smrg				fi
7071.15Smrg
7081.27Slukem				# Report any block device change. Ignore
7091.27Slukem				# character devices, only the name is
7101.27Slukem				# significant.
7111.15Smrg				cat $TMP2 $CUR $TMP1 | \
7121.27Slukem				    sed -e '/^c/d' | \
7131.27Slukem				    sort -k11 | \
7141.27Slukem				    sed -e 's/[	 ][	 ]*/ /g' | \
7151.27Slukem				    uniq -u > $OUTPUT
7161.15Smrg				if [ -s $OUTPUT ] ; then
7171.28Slukem					printf "Block device changes:\n" >> $ERR
7181.28Slukem					column -t $OUTPUT >> $ERR
7191.28Slukem					printf "\n" >> $ERR
7201.15Smrg				fi
7211.9Scgd
7221.52Satatat				backup_file update $TMP1 $CUR $BACK
7231.9Scgd			fi
7241.15Smrg		else
7251.28Slukem			printf "Device additions:\n" >> $ERR
7261.28Slukem			column -t $TMP1 >> $ERR
7271.28Slukem			printf "\n" >> $ERR
7281.52Satatat			backup_file add $TMP1 $CUR $BACK >> $ERR
7291.9Scgd		fi
7301.28Slukem	fi
7311.28Slukem	if [ -s $ERR ] ; then
7321.28Slukem		printf "\nChecking setuid files and devices:\n"
7331.28Slukem		cat $ERR
7341.28Slukem		printf "\n"
7351.9Scgd	fi
7361.9Scgdfi
7371.9Scgd
7381.9Scgd# Check special files.
7391.9Scgd# Check system binaries.
7401.9Scgd#
7411.9Scgd# Create the mtree tree specifications using:
7421.67Slukem#	mtree -cx -pDIR -kmd5,uid,gid,mode,nlink,size,link,time > DIR.secure
7431.38Skleink#	chown root:wheel DIR.secure
7441.67Slukem#	chmod u+r,go= DIR.secure
7451.9Scgd#
7461.9Scgd# Note, this is not complete protection against Trojan horsed binaries, as
7471.9Scgd# the hacker can modify the tree specification to match the replaced binary.
7481.9Scgd# For details on really protecting yourself against modified binaries, see
7491.9Scgd# the mtree(8) manual page.
7501.32Slukem#
7511.31Slukemif checkyesno check_mtree; then
7521.82Sjhawk	if checkyesno check_mtree_follow_symlinks; then
7531.82Sjhawk		check_mtree_flags="-L"
7541.82Sjhawk	else
7551.82Sjhawk		check_mtree_flags=""
7561.82Sjhawk	fi
7571.67Slukem	for file in $special_files; do
7581.67Slukem		[ ! -s $file ] && continue
7591.82Sjhawk		mtree -e -l -p / $check_mtree_flags -f $file
7601.87Sjhawk	done 3>&1 >$OUTPUT 2>&3 |
7611.87Sjhawk		grep -v '^mtree: dev/tty: Device not configured$' >&2
7621.15Smrg	if [ -s $OUTPUT ]; then
7631.9Scgd		printf "\nChecking special files and directories.\n"
7641.9Scgd		cat $OUTPUT
7651.9Scgd	fi
7661.9Scgd
7671.16Smikel	for file in /etc/mtree/*.secure; do
7681.16Smikel		[ $file = '/etc/mtree/*.secure' ] && continue
7691.9Scgd		tree=`sed -n -e '3s/.* //p' -e 3q $file`
7701.82Sjhawk		mtree $check_mtree_flags -f $file -p $tree > $TMP1
7711.9Scgd		if [ -s $TMP1 ]; then
7721.67Slukem			printf "\nChecking $tree:\n"
7731.67Slukem			cat $TMP1
7741.9Scgd		fi
7751.67Slukem	done > $OUTPUT
7761.15Smrg	if [ -s $OUTPUT ]; then
7771.9Scgd		printf "\nChecking system binaries:\n"
7781.9Scgd		cat $OUTPUT
7791.9Scgd	fi
7801.9Scgdfi
7811.9Scgd
7821.32Slukem# Backup disklabels of available disks
7831.32Slukem#
7841.32Slukemif checkyesno check_disklabels; then
7851.67Slukem		# migrate old disklabels
7861.67Slukem	for file in `ls -1d $backup_dir/$backup_dir/disklabel.* \
7871.67Slukem	    $backup_dir/disklabel.* 2>/dev/null`; do
7881.67Slukem		migrate_file "$file" "$work_dir/${file##*/}"
7891.67Slukem	done
7901.67Slukem
7911.67Slukem		# generate list of old disklabels & fdisks and remove them
7921.67Slukem	ls -1d $work_dir/disklabel.* $work_dir/fdisk.* 2>/dev/null |
7931.52Satatat	    egrep -v '\.(backup|current)(,v)?$' > $LABELS
7941.32Slukem	xargs rm < $LABELS
7951.32Slukem
7961.67Slukem		# generate disklabels of all disks excluding:	cd fd md
7971.63Slukem	disks=`iostat -x | awk 'NR > 1 && $1 !~ /^[cfm]d/ { print $1; }'`
7981.32Slukem	for i in $disks; do
7991.67Slukem		disklabel $i > "$work_dir/disklabel.$i" 2>/dev/null
8001.32Slukem	done
8011.32Slukem
8021.67Slukem		# if fdisk is available, generate fdisks for:	ed ld sd wd
8031.67Slukem	if [ -x /sbin/fdisk ]; then
8041.67Slukem		disks=`iostat -x| awk 'NR > 1 && $1 ~ /^[elsw]d/ { print $1; }'`
8051.67Slukem		for i in $disks; do
8061.67Slukem			/sbin/fdisk $i > "$work_dir/fdisk.$i" 2>/dev/null
8071.67Slukem		done
8081.67Slukem	fi
8091.67Slukem
8101.67Slukem		# append list of new disklabels and fdisks
8111.67Slukem	ls -1d $work_dir/disklabel.* $work_dir/fdisk.* 2>/dev/null |
8121.52Satatat	    egrep -v '\.(backup|current)(,v)?$' >> $LABELS
8131.62Satatat	CHANGELIST="$LABELS $CHANGELIST"
8141.62Satatatfi
8151.62Satatat
8161.62Satatat# Check for changes in the list of installed pkgs
8171.62Satatat#
8181.65Slukemif checkyesno check_pkgs && [ -d $pkgdb_dir ]; then
8191.67Slukem	pkgs=$work_dir/pkgs
8201.67Slukem	migrate_file "$backup_dir/pkgs" "$pkgs"
8211.65Slukem	(	cd $pkgdb_dir
8221.62Satatat		pkg_info | sort
8231.62Satatat		echo ""
8241.62Satatat		find . \( -name +REQUIRED_BY -o -name +CONTENTS \) -print0 |
8251.72Slukem			xargs -0 ls -ldgTq | sort -t. +1 | sed -e 's, \./, ,'
8261.62Satatat	 ) > $pkgs
8271.67Slukem	echo "$pkgs" > $PKGS
8281.62Satatat	CHANGELIST="$PKGS $CHANGELIST"
8291.32Slukemfi
8301.32Slukem
8311.67Slukem# List of files that get backed up and checked for any modifications.
8321.9Scgd# Any changes cause the files to rotate.
8331.32Slukem#
8341.67Slukemif checkyesno check_changelist ; then
8351.67Slukem	for file in $special_files; do
8361.67Slukem		[ ! -s $file ] && continue
8371.67Slukem		mtree -D -k type -f $file -E exclude |
8381.67Slukem		    sed '/^type=file/!d ; s/type=file \.//'
8391.67Slukem	done > $CHANGEFILES
8401.67Slukem
8411.75Slukem	(
8421.68Slukem		# Add other files which might dynamically exist:
8431.67Slukem		#	/etc/ifconfig.*
8441.67Slukem		#	/etc/raid*.conf
8451.68Slukem		#	/etc/rc.d/*
8461.67Slukem		#	/etc/rc.conf.d/*
8471.68Slukem		#
8481.75Slukem		echo "/etc/ifconfig.*"
8491.75Slukem		echo "/etc/raid*.conf"
8501.75Slukem		echo "/etc/rc.d/*"
8511.75Slukem		echo "/etc/rc.conf.d/*"
8521.67Slukem
8531.68Slukem		# Add /etc/changelist
8541.68Slukem		#
8551.75Slukem		if [ -s /etc/changelist ]; then
8561.75Slukem			grep -v '^#' /etc/changelist
8571.75Slukem		fi
8581.75Slukem	) | while read file; do
8591.75Slukem		case "$file" in
8601.75Slukem		*[\*\?\[]*)	# If changelist line is a glob ...
8611.75Slukem				# ... expand possible backup files
8621.75Slukem				#
8631.75Slukem			ls -1d $(echo $backup_dir/${file}.current) 2>/dev/null \
8641.75Slukem			    | sed "s,^$backup_dir/,, ; s,\.current$,,"
8651.75Slukem				
8661.75Slukem				# ... expand possible files
8671.75Slukem				#
8681.75Slukem			ls -1d $(echo $file) 2>/dev/null
8691.75Slukem			;;
8701.75Slukem		*)
8711.75Slukem				# Otherwise, just print the filename
8721.75Slukem			echo $file
8731.75Slukem			;;
8741.75Slukem		esac
8751.75Slukem	done >> $CHANGEFILES
8761.67Slukem	CHANGELIST="$CHANGEFILES $CHANGELIST"
8771.67Slukemfi
8781.67Slukem
8791.67Slukem# Special case backups, including the master password file and
8801.67Slukem# ssh private host keys. The normal backup mechanisms for
8811.67Slukem# $check_changelist (see below) also print out the actual file
8821.67Slukem# differences and we don't want to do that for these files
8831.67Slukem#
8841.67Slukemecho $MP > $TMP1			# always add /etc/master.passwd
8851.67Slukemfor file in $special_files; do
8861.67Slukem	[ ! -s $file ] && continue
8871.70Slukem	mtree -D -k type -f $file -I nodiff |
8881.67Slukem	    sed '/^type=file/!d ; s/type=file \.//'
8891.67Slukemdone >> $TMP1
8901.73Slukemgrep -v '^$' $TMP1 | sort -u > $TMP2
8911.68Slukem
8921.69Slukemwhile read file; do
8931.67Slukem	backup_and_diff "$file" no
8941.69Slukemdone < $TMP2
8951.67Slukem
8961.32Slukem
8971.32Slukemif [ -n "$CHANGELIST" ]; then
8981.73Slukem	grep -h -v '^$' $CHANGELIST | sort -u > $TMP1
8991.68Slukem	comm -23 $TMP1 $TMP2 | while read file; do
9001.67Slukem		backup_and_diff "$file" yes
9011.9Scgd	done
9021.44Sadfi
9031.44Sad
9041.44Sadif [ -f /etc/security.local ]; then
9051.84Sjhawk	. /etc/security.local > $OUTPUT
9061.84Sjhawk	if [ -s $OUTPUT ] ; then
9071.84Sjhawk		printf "\nRunning /etc/security.local:\n"
9081.84Sjhawk		cat $OUTPUT
9091.84Sjhawk	fi
9101.9Scgdfi
911