security revision 1.90
11.1Scgd#!/bin/sh -
21.1Scgd#
31.90Skim#	$NetBSD: security,v 1.90 2004/04/09 17:33:35 kim 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.89Sjmmvrcvar_manpage='security.conf(5)'
101.89Sjmmv
111.31Slukemif [ -f /etc/rc.subr ]; then
121.31Slukem	. /etc/rc.subr
131.31Slukemelse
141.31Slukem	echo "Can't read /etc/rc.subr; aborting."
151.31Slukem	exit 1;
161.31Slukemfi
171.31Slukem
181.9Scgdumask 077
191.64ScjsTZ=UTC; export TZ
201.1Scgd
211.15Smrgif [ -s /etc/security.conf ]; then
221.15Smrg	. /etc/security.conf
231.15Smrgfi
241.15Smrg
251.67Slukem# Set reasonable defaults (if they're not set in security.conf)
261.67Slukem#
271.67Slukembackup_dir=${backup_dir:-/var/backups}
281.67Slukempkgdb_dir=${pkgdb_dir:-/var/db/pkg}
291.67Slukemmax_loginlen=${max_loginlen:-8}
301.67Slukemmax_grouplen=${max_grouplen:-8}
311.67Slukem
321.67Slukem# Other configurable variables
331.67Slukem#
341.67Slukemspecial_files="/etc/mtree/special /etc/mtree/special.local"
351.67SlukemMP=/etc/master.passwd
361.67SlukemCHANGELIST=""
371.67Slukemwork_dir=$backup_dir/work
381.67Slukem
391.67Slukemif [ ! -d "$work_dir" ]; then
401.67Slukem	mkdir -p "$work_dir"
411.67Slukemfi
421.67Slukem
431.56SlukemSECUREDIR=`mktemp -d /tmp/_securedir.XXXXXX` || exit 1
441.56Slukem
451.67Slukemtrap "/bin/rm -rf $SECUREDIR ; exit 0" EXIT INT QUIT PIPE
461.15Smrg
471.56Slukemif ! cd "$SECUREDIR"; then
481.56Slukem	echo "Can not cd to $SECUREDIR".
491.15Smrg	exit 1
501.15Smrgfi
511.15Smrg
521.15SmrgERR=secure1.$$
531.15SmrgTMP1=secure2.$$
541.15SmrgTMP2=secure3.$$
551.28SlukemMPBYUID=secure4.$$
561.29SlukemMPBYPATH=secure5.$$
571.27SlukemLIST=secure6.$$
581.27SlukemOUTPUT=secure7.$$
591.32SlukemLABELS=secure8.$$
601.62SatatatPKGS=secure9.$$
611.67SlukemCHANGEFILES=secure10.$$
621.67Slukem
631.15Smrg
641.67Slukem# migrate_file old new
651.67Slukem#	Determine if the "${old}" path name needs to be migrated to the
661.67Slukem#	"${new}" path. Also checks if "${old}.current" needs migrating,
671.67Slukem#	and if so, migrate it and possibly "${old}.current,v" and
681.67Slukem#	"${old}.backup".
691.67Slukem#
701.67Slukemmigrate_file()
711.67Slukem{
721.67Slukem	_old=$1
731.67Slukem	_new=$2
741.67Slukem	if [ -z "$_old" -o -z "$_new" ]; then
751.67Slukem		err 3 "USAGE: migrate_file old new"
761.67Slukem	fi
771.67Slukem	if [ ! -d "${_new%/*}" ]; then
781.67Slukem		mkdir -p "${_new%/*}"
791.67Slukem	fi
801.67Slukem	if [ -f "${_old}" -a ! -f "${_new}" ]; then
811.67Slukem		echo "==> migrating ${_old}"
821.67Slukem		echo "           to ${_new}"
831.67Slukem		mv "${_old}" "${_new}"
841.67Slukem	fi
851.67Slukem	if [ -f "${_old}.current" -a ! -f "${_new}.current" ]; then
861.67Slukem		echo "==> migrating ${_old}.current"
871.67Slukem		echo "           to ${_new}.current"
881.67Slukem		mv "${_old}.current" "${_new}.current"
891.67Slukem		if [ -f "${_old}.current,v" -a ! -f "${_new}.current,v" ]; then
901.67Slukem			echo "==> migrating ${_old}.current,v"
911.67Slukem			echo "           to ${_new}.current,v"
921.67Slukem			mv "${_old}.current,v" "${_new}.current,v"
931.67Slukem		fi
941.67Slukem		if [ -f "${_old}.backup" -a ! -f "${_new}.backup" ]; then
951.67Slukem			echo "==> migrating ${_old}.backup"
961.67Slukem			echo "           to ${_new}.backup"
971.67Slukem			mv "${_old}.backup" "${_new}.backup"
981.67Slukem		fi
991.67Slukem	fi
1001.67Slukem}
1011.67Slukem
1021.67Slukem
1031.67Slukem# backup_and_diff file printdiff
1041.67Slukem#	Determine if file needs backing up, and if so, do it.
1051.67Slukem#	If printdiff is yes, display the diffs, otherwise 
1061.67Slukem#	just print a message saying "[changes omitted]".
1071.67Slukem#
1081.67Slukembackup_and_diff()
1091.67Slukem{
1101.67Slukem	_file=$1
1111.67Slukem	_printdiff=$2
1121.67Slukem	if [ -z "$_file" -o -z "$_printdiff" ]; then
1131.67Slukem		err 3 "USAGE: backup_and_diff file printdiff"
1141.67Slukem	fi
1151.67Slukem	! checkyesno _printdiff
1161.67Slukem	_printdiff=$?
1171.67Slukem
1181.67Slukem	_old=$backup_dir/${_file##*/}
1191.67Slukem	case "$_file" in
1201.67Slukem	$work_dir/*)
1211.67Slukem		_new=$_file
1221.67Slukem		migrate_file "$backup_dir/$_old" "$_new"
1231.67Slukem		migrate_file "$_old" "$_new"
1241.67Slukem		;;
1251.67Slukem	*)
1261.67Slukem		_new=$backup_dir/$_file
1271.67Slukem		migrate_file "$_old" "$_new"
1281.67Slukem		;;
1291.67Slukem	esac
1301.67Slukem	CUR=${_new}.current
1311.67Slukem	BACK=${_new}.backup
1321.67Slukem	if [ -f $_file ]; then
1331.67Slukem		if [ -f $CUR ] ; then
1341.67Slukem			if [ "$_printdiff" -ne 0 ]; then
1351.83Sjhawk				diff ${diff_options} $CUR $_file > $OUTPUT
1361.67Slukem			else
1371.67Slukem				if ! cmp -s $CUR $_file; then
1381.67Slukem					echo "[changes omitted]"
1391.67Slukem				fi > $OUTPUT
1401.67Slukem			fi
1411.67Slukem			if [ -s $OUTPUT ] ; then
1421.67Slukem				printf \
1431.67Slukem			"\n======\n%s diffs (OLD < > NEW)\n======\n" $_file
1441.67Slukem				cat $OUTPUT
1451.67Slukem				backup_file update $_file $CUR $BACK
1461.67Slukem			fi
1471.67Slukem		else
1481.67Slukem			printf "\n======\n%s added\n======\n" $_file
1491.67Slukem			if [ "$_printdiff" -ne 0 ]; then
1501.83Sjhawk				diff ${diff_options} /dev/null $_file
1511.67Slukem			else
1521.67Slukem				echo "[changes omitted]"
1531.67Slukem			fi
1541.67Slukem			backup_file add $_file $CUR $BACK
1551.67Slukem		fi
1561.67Slukem	else
1571.67Slukem		if [ -f $CUR ]; then
1581.67Slukem			printf "\n======\n%s removed\n======\n" $_file
1591.67Slukem			if [ "$_printdiff" -ne 0 ]; then
1601.83Sjhawk				diff ${diff_options} $CUR /dev/null
1611.67Slukem			else
1621.67Slukem				echo "[changes omitted]"
1631.67Slukem			fi
1641.67Slukem			backup_file remove $_file $CUR $BACK
1651.67Slukem		fi
1661.67Slukem	fi
1671.67Slukem}
1681.48Sabs
1691.9Scgd
1701.67Slukem# These are used several times.
1711.67Slukem#
1721.34Sabsawk -F: '!/^+/ { print $1 " " $3 }' $MP | sort -k2n > $MPBYUID
1731.29Slukemawk -F: '{ print $1 " " $9 }' $MP | sort -k2 > $MPBYPATH
1741.9Scgd
1751.67Slukem
1761.9Scgd# Check the master password file syntax.
1771.32Slukem#
1781.31Slukemif checkyesno check_passwd; then
1791.85Sjhawk        # XXX: the sense of permit_star is reversed; the code works as
1801.85Sjhawk        # implemented, but usage needs to be negated.
1811.81Sjhawk	checkyesno check_passwd_permit_star && permit_star=0 || permit_star=1
1821.81Sjhawk	awk -v "len=$max_loginlen" \
1831.81Sjhawk	    -v "nowarn_shells_list=$check_passwd_nowarn_shells" \
1841.81Sjhawk	    -v "nowarn_users_list=$check_passwd_nowarn_users" \
1851.81Sjhawk	    -v "permit_star=$permit_star" '
1861.25Slukem	BEGIN {
1871.25Slukem		while ( getline < "/etc/shells" > 0 ) {
1881.39Shubertf			if ($0 ~ /^\#/ || $0 ~ /^$/ )
1891.25Slukem				continue;
1901.25Slukem			shells[$1]++;
1911.25Slukem		}
1921.81Sjhawk		split(nowarn_shells_list, a);
1931.81Sjhawk		for (i in a) nowarn_shells[a[i]]++;
1941.81Sjhawk		split(nowarn_users_list, a);
1951.81Sjhawk		for (i in a) nowarn_users[a[i]]++;
1961.81Sjhawk		uid0_users_list="root toor"
1971.81Sjhawk		split(uid0_users_list, a);
1981.81Sjhawk		for (i in a) uid0_users[a[i]]++;
1991.25Slukem		FS=":";
2001.25Slukem	}
2011.25Slukem
2021.25Slukem	{
2031.15Smrg		if ($0 ~ /^[	 ]*$/) {
2041.25Slukem			printf "Line %d is a blank line.\n", NR;
2051.15Smrg			next;
2061.15Smrg		}
2071.34Sabs		if (NF != 10 && ($1 != "+" || NF != 1))
2081.25Slukem			printf "Line %d has the wrong number of fields.\n", NR;
2091.34Sabs		if ($1 == "+" )  {
2101.34Sabs			if (NF != 1 && $3 == 0)
2111.81Sjhawk			    printf "Line %d includes entries with uid 0.\n",
2121.81Sjhawk			        NR;
2131.34Sabs			next;
2141.34Sabs		}
2151.53Satatat		if ($1 !~ /^[A-Za-z0-9]([-A-Za-z0-9]*[A-Za-z0-9])*$/)
2161.25Slukem			printf "Login %s has non-alphanumeric characters.\n",
2171.25Slukem			    $1;
2181.34Sabs		if (length($1) > len)
2191.81Sjhawk			printf "Login %s has more than "len" characters.\n",
2201.81Sjhawk			    $1;
2211.81Sjhawk		if ($2 == "" && !nowarn_users[$1])
2221.81Sjhawk			    printf "Login %s has no password.\n", $1;
2231.81Sjhawk		if (!nowarn_shells[$10] && !nowarn_users[$1]) {
2241.81Sjhawk		    if (length($2) != 13 &&
2251.81Sjhawk		    	length($2) != 20 &&
2261.81Sjhawk		    	$2 !~ /^\$1/ &&
2271.81Sjhawk		    	$2 !~ /^\$2/ &&
2281.81Sjhawk		    	$2 != "" &&
2291.81Sjhawk			(permit_star || $2 != "*") &&
2301.81Sjhawk		    	$2 !~ /^\*[A-z-]+$/ &&
2311.81Sjhawk			$1 != "toor") {
2321.81Sjhawk		    	    if ($10 == "" || shells[$10])
2331.81Sjhawk				printf "Login %s is off but still has "\
2341.81Sjhawk				  "a valid shell (%s)\n", $1, $10;
2351.81Sjhawk		    } else if (! shells[$10])
2361.81Sjhawk		    	    printf "Login %s does not have a valid "\
2371.81Sjhawk			    "shell (%s)\n", $1, $10;
2381.81Sjhawk		}
2391.81Sjhawk		if ($3 == 0 && !uid0_users[$1] && !nowarn_users[$1])
2401.25Slukem			printf "Login %s has a user id of 0.\n", $1;
2411.15Smrg		if ($3 < 0)
2421.25Slukem			printf "Login %s has a negative user id.\n", $1;
2431.15Smrg		if ($4 < 0)
2441.25Slukem			printf "Login %s has a negative group id.\n", $1;
2451.15Smrg	}' < $MP > $OUTPUT
2461.15Smrg	if [ -s $OUTPUT ] ; then
2471.15Smrg		printf "\nChecking the $MP file:\n"
2481.15Smrg		cat $OUTPUT
2491.15Smrg	fi
2501.15Smrg
2511.15Smrg	awk -F: '{ print $1 }' $MP | sort | uniq -d > $OUTPUT
2521.15Smrg	if [ -s $OUTPUT ] ; then
2531.15Smrg		printf "\n$MP has duplicate user names.\n"
2541.15Smrg		column $OUTPUT
2551.15Smrg	fi
2561.15Smrg
2571.37Swrstuden# To not exclude 'toor', a standard duplicate root account, from the duplicate
2581.37Swrstuden# account test, uncomment the line below (without egrep in it)and comment
2591.37Swrstuden# out the line (with egrep in it) below it.
2601.37Swrstuden#
2611.37Swrstuden#	< $MPBYUID uniq -d -f 1 | awk '{ print $2 }' > $TMP2
2621.36Swrstuden	< $MPBYUID egrep -v '^toor ' | uniq -d -f 1 | awk '{ print $2 }' > $TMP2
2631.15Smrg	if [ -s $TMP2 ] ; then
2641.15Smrg		printf "\n$MP has duplicate user id's.\n"
2651.15Smrg		while read uid; do
2661.28Slukem			grep -w $uid $MPBYUID
2671.15Smrg		done < $TMP2 | column
2681.15Smrg	fi
2691.9Scgdfi
2701.9Scgd
2711.9Scgd# Check the group file syntax.
2721.32Slukem#
2731.31Slukemif checkyesno check_group; then
2741.15Smrg	GRP=/etc/group
2751.49Sjdolecek	awk -F: -v "len=$max_grouplen" '{
2761.15Smrg		if ($0 ~ /^[	 ]*$/) {
2771.25Slukem			printf "Line %d is a blank line.\n", NR;
2781.15Smrg			next;
2791.15Smrg		}
2801.34Sabs		if (NF != 4 && ($1 != "+" || NF != 1))
2811.25Slukem			printf "Line %d has the wrong number of fields.\n", NR;
2821.34Sabs		if ($1 == "+" )  {
2831.34Sabs			next;
2841.34Sabs		}
2851.53Satatat		if ($1 !~ /^[A-Za-z0-9]([-A-Za-z0-9]*[A-Za-z0-9])*$/)
2861.25Slukem			printf "Group %s has non-alphanumeric characters.\n",
2871.25Slukem			    $1;
2881.49Sjdolecek		if (length($1) > len)
2891.49Sjdolecek			printf "Group %s has more than "len" characters.\n", $1;
2901.15Smrg		if ($3 !~ /[0-9]*/)
2911.25Slukem			printf "Login %s has a negative group id.\n", $1;
2921.15Smrg	}' < $GRP > $OUTPUT
2931.15Smrg	if [ -s $OUTPUT ] ; then
2941.15Smrg		printf "\nChecking the $GRP file:\n"
2951.15Smrg		cat $OUTPUT
2961.15Smrg	fi
2971.15Smrg
2981.15Smrg	awk -F: '{ print $1 }' $GRP | sort | uniq -d > $OUTPUT
2991.15Smrg	if [ -s $OUTPUT ] ; then
3001.15Smrg		printf "\n$GRP has duplicate group names.\n"
3011.15Smrg		column $OUTPUT
3021.15Smrg	fi
3031.9Scgdfi
3041.9Scgd
3051.9Scgd# Check for root paths, umask values in startup files.
3061.9Scgd# The check for the root paths is problematical -- it's likely to fail
3071.9Scgd# in other environments.  Once the shells have been modified to warn
3081.9Scgd# of '.' in the path, the path tests should go away.
3091.32Slukem#
3101.31Slukemif checkyesno check_rootdotfiles; then
3111.67Slukem	rhome=~root
3121.15Smrg	umaskset=no
3131.15Smrg	list="/etc/csh.cshrc /etc/csh.login ${rhome}/.cshrc ${rhome}/.login"
3141.15Smrg	for i in $list ; do
3151.15Smrg		if [ -f $i ] ; then
3161.67Slukem			if egrep '^[ \t]*umask[ \t]+[0-7]+' $i > /dev/null ;
3171.67Slukem			then
3181.15Smrg				umaskset=yes
3191.15Smrg			fi
3201.63Slukem			# Double check the umask value itself; ensure that
3211.67Slukem			# both the group and other write bits are set.
3221.67Slukem			#
3231.45Ssommerfe			egrep '^[ \t]*umask[ \t]+[0-7]+' $i |
3241.63Slukem			awk '{
3251.67Slukem				if ($2 ~ /^.$/ || $2 ~! /[^2367].$/) {
3261.80Swiz					print "\tRoot umask is group writable"
3271.63Slukem				}
3281.67Slukem				if ($2 ~ /[^2367]$/) {
3291.80Swiz					print "\tRoot umask is other writable"
3301.63Slukem			    	}
3311.67Slukem			    }' | sort -u
3321.26Slukem			SAVE_PATH=$PATH
3331.26Slukem			unset PATH
3341.15Smrg			/bin/csh -f -s << end-of-csh > /dev/null 2>&1
3351.15Smrg				source $i
3361.15Smrg				/bin/ls -ldgT \$path > $TMP1
3371.9Scgdend-of-csh
3381.76Satatat			export PATH=$SAVE_PATH
3391.15Smrg			awk '{
3401.15Smrg				if ($10 ~ /^\.$/) {
3411.27Slukem					print "\tThe root path includes .";
3421.15Smrg					next;
3431.15Smrg				}
3441.15Smrg			     }
3451.15Smrg			     $1 ~ /^d....w/ \
3461.80Swiz		{ print "\tRoot path directory " $10 " is group writable." } \
3471.15Smrg			     $1 ~ /^d.......w/ \
3481.80Swiz		{ print "\tRoot path directory " $10 " is other writable." }' \
3491.67Slukem			< $TMP1
3501.15Smrg		fi
3511.67Slukem	done > $OUTPUT
3521.15Smrg	if [ $umaskset = "no" -o -s $OUTPUT ] ; then
3531.27Slukem		printf "\nChecking root csh paths, umask values:\n$list\n\n"
3541.15Smrg		if [ -s $OUTPUT ]; then
3551.15Smrg			cat $OUTPUT
3561.15Smrg		fi
3571.15Smrg		if [ $umaskset = "no" ] ; then
3581.27Slukem		    printf "\tRoot csh startup files do not set the umask.\n"
3591.15Smrg		fi
3601.9Scgd	fi
3611.9Scgd
3621.15Smrg	umaskset=no
3631.23Slukem	list="/etc/profile ${rhome}/.profile"
3641.15Smrg	for i in $list; do
3651.15Smrg		if [ -f $i ] ; then
3661.15Smrg			if egrep umask $i > /dev/null ; then
3671.15Smrg				umaskset=yes
3681.15Smrg			fi
3691.15Smrg			egrep umask $i |
3701.67Slukem			awk '$2 ~ /^.$/ || $2 ~ /[^2367].$/ \
3711.80Swiz				{ print "\tRoot umask is group writable" } \
3721.67Slukem			     $2 ~ /[^2367]$/ \
3731.80Swiz				{ print "\tRoot umask is other writable" }'
3741.26Slukem			SAVE_PATH=$PATH
3751.26Slukem			unset PATH
3761.15Smrg			/bin/sh << end-of-sh > /dev/null 2>&1
3771.15Smrg				. $i
3781.26Slukem				list=\`echo \$PATH | /usr/bin/sed -e \
3791.26Slukem				    's/^:/.:/;s/:$/:./;s/::/:.:/g;s/:/ /g'\`
3801.15Smrg				/bin/ls -ldgT \$list > $TMP1
3811.9Scgdend-of-sh
3821.76Satatat			export PATH=$SAVE_PATH
3831.15Smrg			awk '{
3841.15Smrg				if ($10 ~ /^\.$/) {
3851.27Slukem					print "\tThe root path includes .";
3861.15Smrg					next;
3871.15Smrg				}
3881.15Smrg			     }
3891.15Smrg			     $1 ~ /^d....w/ \
3901.80Swiz		{ print "\tRoot path directory " $10 " is group writable." } \
3911.15Smrg			     $1 ~ /^d.......w/ \
3921.80Swiz		{ print "\tRoot path directory " $10 " is other writable." }' \
3931.67Slukem			< $TMP1
3941.9Scgd
3951.15Smrg		fi
3961.67Slukem	done > $OUTPUT
3971.15Smrg	if [ $umaskset = "no" -o -s $OUTPUT ] ; then
3981.15Smrg		printf "\nChecking root sh paths, umask values:\n$list\n"
3991.15Smrg		if [ -s $OUTPUT ]; then
4001.15Smrg			cat $OUTPUT
4011.15Smrg		fi
4021.15Smrg		if [ $umaskset = "no" ] ; then
4031.27Slukem			printf "\tRoot sh startup files do not set the umask.\n"
4041.15Smrg		fi
4051.9Scgd	fi
4061.9Scgdfi
4071.9Scgd
4081.9Scgd# Root and uucp should both be in /etc/ftpusers.
4091.32Slukem#
4101.31Slukemif checkyesno check_ftpusers; then
4111.28Slukem	list="uucp "`awk '$2 == 0 { print $1 }' $MPBYUID`
4121.27Slukem	for i in $list; do
4131.29Slukem		if /usr/libexec/ftpd -C $i ; then
4141.67Slukem			printf "\t$i is not denied\n"
4151.27Slukem		fi
4161.67Slukem	done > $OUTPUT
4171.28Slukem	if [ -s $OUTPUT ]; then
4181.28Slukem		printf "\nChecking the /etc/ftpusers configuration:\n"
4191.28Slukem		cat $OUTPUT
4201.28Slukem	fi
4211.9Scgdfi
4221.9Scgd
4231.43Sitojun# Uudecode should not be in the /etc/mail/aliases file.
4241.32Slukem#
4251.31Slukemif checkyesno check_aliases; then
4261.43Sitojun	for f in /etc/mail/aliases /etc/aliases; do
4271.43Sitojun		if [ -f $f ] && egrep '^[^#]*(uudecode|decode).*\|' $f; then
4281.43Sitojun			printf "\nEntry for uudecode in $f file.\n"
4291.43Sitojun		fi
4301.43Sitojun	done
4311.9Scgdfi
4321.9Scgd
4331.9Scgd# Files that should not have + signs.
4341.32Slukem#
4351.31Slukemif checkyesno check_rhosts; then
4361.15Smrg	list="/etc/hosts.equiv /etc/hosts.lpd"
4371.15Smrg	for f in $list ; do
4381.15Smrg		if [ -f $f ] && egrep '\+' $f > /dev/null ; then
4391.15Smrg			printf "\nPlus sign in $f file.\n"
4401.15Smrg		fi
4411.15Smrg	done
4421.15Smrg
4431.15Smrg	# Check for special users with .rhosts files.  Only root and toor should
4441.16Smikel	# have .rhosts files.  Also, .rhosts files should not have plus signs.
4451.15Smrg	awk -F: '$1 != "root" && $1 != "toor" && \
4461.15Smrg		($3 < 100 || $1 == "ftp" || $1 == "uucp") \
4471.20Smycroft			{ print $1 " " $9 }' $MP |
4481.19Smycroft	sort -k2 |
4491.15Smrg	while read uid homedir; do
4501.15Smrg		if [ -f ${homedir}/.rhosts ] ; then
4511.15Smrg			rhost=`ls -ldgT ${homedir}/.rhosts`
4521.46Schristos			printf -- "$uid: $rhost\n"
4531.15Smrg		fi
4541.15Smrg	done > $OUTPUT
4551.15Smrg	if [ -s $OUTPUT ] ; then
4561.15Smrg		printf "\nChecking for special users with .rhosts files.\n"
4571.15Smrg		cat $OUTPUT
4581.15Smrg	fi
4591.15Smrg
4601.15Smrg	while read uid homedir; do
4611.35Sfair		if [ -f ${homedir}/.rhosts -a -r ${homedir}/.rhosts ] && \
4621.41Schristos		    cat -f ${homedir}/.rhosts | egrep '\+' > /dev/null ; then
4631.46Schristos			printf -- "$uid: + in .rhosts file.\n"
4641.15Smrg		fi
4651.29Slukem	done < $MPBYPATH > $OUTPUT
4661.15Smrg	if [ -s $OUTPUT ] ; then
4671.15Smrg		printf "\nChecking .rhosts files syntax.\n"
4681.15Smrg		cat $OUTPUT
4691.15Smrg	fi
4701.9Scgdfi
4711.9Scgd
4721.9Scgd# Check home directories.  Directories should not be owned by someone else
4731.80Swiz# or writable.
4741.32Slukem#
4751.31Slukemif checkyesno check_homes; then
4761.85Sjhawk	checkyesno check_homes_permit_usergroups && \
4771.85Sjhawk		permit_usergroups=1 || permit_usergroups=0
4781.15Smrg	while read uid homedir; do
4791.15Smrg		if [ -d ${homedir}/ ] ; then
4801.15Smrg			file=`ls -ldgT ${homedir}`
4811.46Schristos			printf -- "$uid $file\n"
4821.9Scgd		fi
4831.29Slukem	done < $MPBYPATH |
4841.85Sjhawk	awk -v "usergroups=$permit_usergroups" '
4851.85Sjhawk	     $1 != $4 && $4 != "root" \
4861.15Smrg		{ print "user " $1 " home directory is owned by " $4 }
4871.88Sjdolecek	     $2 ~ /^-....w/ && (!usergroups || $5 != $1) \
4881.80Swiz		{ print "user " $1 " home directory is group writable" }
4891.15Smrg	     $2 ~ /^-.......w/ \
4901.80Swiz		{ print "user " $1 " home directory is other writable" }' \
4911.27Slukem	    > $OUTPUT
4921.15Smrg	if [ -s $OUTPUT ] ; then
4931.15Smrg		printf "\nChecking home directories.\n"
4941.15Smrg		cat $OUTPUT
4951.15Smrg	fi
4961.15Smrg
4971.15Smrg	# Files that should not be owned by someone else or readable.
4981.67Slukem	list=".Xauthority .netrc .ssh/id_dsa .ssh/id_rsa .ssh/identity"
4991.15Smrg	while read uid homedir; do
5001.15Smrg		for f in $list ; do
5011.15Smrg			file=${homedir}/${f}
5021.15Smrg			if [ -f $file ] ; then
5031.46Schristos				printf -- "$uid $f `ls -ldgT $file`\n"
5041.15Smrg			fi
5051.15Smrg		done
5061.29Slukem	done < $MPBYPATH |
5071.85Sjhawk	awk  -v "usergroups=$permit_usergroups" '
5081.85Sjhawk	     $1 != $5 && $5 != "root" \
5091.15Smrg		{ print "user " $1 " " $2 " file is owned by " $5 }
5101.85Sjhawk	     $3 ~ /^-...r/ && (!usergroups || $6 != $1) \
5111.15Smrg		{ print "user " $1 " " $2 " file is group readable" }
5121.15Smrg	     $3 ~ /^-......r/ \
5131.15Smrg		{ print "user " $1 " " $2 " file is other readable" }
5141.85Sjhawk	     $3 ~ /^-....w/ && (!usergroups || $6 != $1) \
5151.80Swiz		{ print "user " $1 " " $2 " file is group writable" }
5161.15Smrg	     $3 ~ /^-.......w/ \
5171.80Swiz		{ print "user " $1 " " $2 " file is other writable" }' \
5181.27Slukem	    > $OUTPUT
5191.15Smrg
5201.80Swiz	# Files that should not be owned by someone else or writable.
5211.19Smycroft	list=".bash_history .bash_login .bash_logout .bash_profile .bashrc \
5221.79Selric	      .cshrc .emacs .exrc .forward .history .k5login .klogin .login \
5231.79Selric	      .logout .profile .qmail .rc_history .rhosts .shosts ssh .tcshrc \
5241.79Selric	      .twmrc .xinitrc .xsession .ssh/authorized_keys \
5251.79Selric	      .ssh/authorized_keys2 .ssh/config .ssh/id_dsa.pub \
5261.79Selric	      .ssh/id_rsa.pub .ssh/identity.pub .ssh/known_hosts \
5271.79Selric	      .ssh/known_hosts2"
5281.15Smrg	while read uid homedir; do
5291.15Smrg		for f in $list ; do
5301.15Smrg			file=${homedir}/${f}
5311.15Smrg			if [ -f $file ] ; then
5321.46Schristos				printf -- "$uid $f `ls -ldgT $file`\n"
5331.15Smrg			fi
5341.15Smrg		done
5351.29Slukem	done < $MPBYPATH |
5361.85Sjhawk	awk -v "usergroups=$permit_usergroups" '
5371.85Sjhawk	     $1 != $5 && $5 != "root" \
5381.15Smrg		{ print "user " $1 " " $2 " file is owned by " $5 }
5391.85Sjhawk	     $3 ~ /^-....w/ && (!usergroups || $6 != $1) \
5401.80Swiz		{ print "user " $1 " " $2 " file is group writable" }
5411.15Smrg	     $3 ~ /^-.......w/ \
5421.80Swiz		{ print "user " $1 " " $2 " file is other writable" }' \
5431.27Slukem	    >> $OUTPUT
5441.15Smrg	if [ -s $OUTPUT ] ; then
5451.15Smrg		printf "\nChecking dot files.\n"
5461.15Smrg		cat $OUTPUT
5471.15Smrg	fi
5481.9Scgdfi
5491.9Scgd
5501.9Scgd# Mailboxes should be owned by user and unreadable.
5511.32Slukem#
5521.31Slukemif checkyesno check_varmail; then
5531.86Sjhawk	ls -lA /var/mail | \
5541.63Slukem	awk '	NR == 1 { next; }
5551.86Sjhawk		$9 ~ /^\./ {next; }
5561.63Slukem	    	$3 != $9 {
5571.63Slukem			print "user " $9 " mailbox is owned by " $3
5581.63Slukem		}
5591.63Slukem		$1 != "-rw-------" {
5601.63Slukem			print "user " $9 " mailbox is " $1 ", group " $4
5611.63Slukem		}' > $OUTPUT
5621.15Smrg	if [ -s $OUTPUT ] ; then
5631.15Smrg		printf "\nChecking mailbox ownership.\n"
5641.15Smrg		cat $OUTPUT
5651.15Smrg	fi
5661.15Smrgfi
5671.15Smrg
5681.32Slukem# NFS exports shouldn't be globally exported
5691.32Slukem#
5701.32Slukemif checkyesno check_nfs && [ -f /etc/exports ]; then
5711.32Slukem	awk '{
5721.22Slukem		# ignore comments and blank lines
5731.39Shubertf		if ($0 ~ /^\#/ || $0 ~ /^$/ )
5741.22Slukem			next;
5751.22Slukem
5761.15Smrg		readonly = 0;
5771.15Smrg		for (i = 2; i <= NF; ++i) {
5781.15Smrg			if ($i ~ /-ro/)
5791.15Smrg				readonly = 1;
5801.15Smrg			else if ($i !~ /^-/)
5811.15Smrg				next;
5821.15Smrg		}
5831.15Smrg		if (readonly)
5841.15Smrg			print "File system " $1 " globally exported, read-only."
5851.15Smrg		else
5861.15Smrg			print "File system " $1 " globally exported, read-write."
5871.32Slukem	}' < /etc/exports > $OUTPUT
5881.32Slukem	if [ -s $OUTPUT ] ; then
5891.15Smrg		printf "\nChecking for globally exported file systems.\n"
5901.15Smrg		cat $OUTPUT
5911.15Smrg	fi
5921.9Scgdfi
5931.9Scgd
5941.9Scgd# Display any changes in setuid files and devices.
5951.32Slukem#
5961.31Slukemif checkyesno check_devices; then
5971.28Slukem	> $ERR
5981.15Smrg	(find / \( ! -fstype local -o -fstype fdesc -o -fstype kernfs \
5991.74Slukem			-o -fstype null \
6001.15Smrg			-o -fstype procfs \) -a -prune -o \
6011.21Smycroft	    \( \( -perm -u+s -a ! -type d \) -o \
6021.21Smycroft	       \( -perm -g+s -a ! -type d \) -o \
6031.24Slukem	       -type b -o -type c \) -print0 | \
6041.24Slukem	xargs -0 ls -ldgTq | sort +9 > $LIST) 2> $OUTPUT
6051.15Smrg
6061.15Smrg	# Display any errors that occurred during system file walk.
6071.15Smrg	if [ -s $OUTPUT ] ; then
6081.28Slukem		printf "Setuid/device find errors:\n" >> $ERR
6091.28Slukem		cat $OUTPUT >> $ERR
6101.28Slukem		printf "\n" >> $ERR
6111.15Smrg	fi
6121.15Smrg
6131.15Smrg	# Display any changes in the setuid file list.
6141.15Smrg	egrep -v '^[bc]' $LIST > $TMP1
6151.15Smrg	if [ -s $TMP1 ] ; then
6161.15Smrg		# Check to make sure uudecode isn't setuid.
6171.15Smrg		if grep -w uudecode $TMP1 > /dev/null ; then
6181.28Slukem			printf "\nUudecode is setuid.\n" >> $ERR
6191.15Smrg		fi
6201.15Smrg
6211.67Slukem		file=$work_dir/setuid
6221.67Slukem		migrate_file "$backup_dir/setuid" "$file"
6231.67Slukem		CUR=${file}.current
6241.67Slukem		BACK=${file}.backup
6251.15Smrg		if [ -s $CUR ] ; then
6261.15Smrg			if cmp -s $CUR $TMP1 ; then
6271.15Smrg				:
6281.15Smrg			else
6291.15Smrg				> $TMP2
6301.15Smrg				join -110 -210 -v2 $CUR $TMP1 > $OUTPUT
6311.15Smrg				if [ -s $OUTPUT ] ; then
6321.28Slukem					printf "Setuid additions:\n" >> $ERR
6331.28Slukem					tee -a $TMP2 < $OUTPUT >> $ERR
6341.28Slukem					printf "\n" >> $ERR
6351.15Smrg				fi
6361.15Smrg
6371.15Smrg				join -110 -210 -v1 $CUR $TMP1 > $OUTPUT
6381.15Smrg				if [ -s $OUTPUT ] ; then
6391.28Slukem					printf "Setuid deletions:\n" >> $ERR
6401.28Slukem					tee -a $TMP2 < $OUTPUT >> $ERR
6411.28Slukem					printf "\n" >> $ERR
6421.15Smrg				fi
6431.15Smrg
6441.20Smycroft				sort -k10 $TMP2 $CUR $TMP1 | \
6451.27Slukem				    sed -e 's/[	 ][	 ]*/ /g' | \
6461.27Slukem				    uniq -u > $OUTPUT
6471.15Smrg				if [ -s $OUTPUT ] ; then
6481.28Slukem					printf "Setuid changes:\n" >> $ERR
6491.28Slukem					column -t $OUTPUT >> $ERR
6501.28Slukem					printf "\n" >> $ERR
6511.15Smrg				fi
6521.9Scgd
6531.52Satatat				backup_file update $TMP1 $CUR $BACK
6541.9Scgd			fi
6551.15Smrg		else
6561.28Slukem			printf "Setuid additions:\n" >> $ERR
6571.28Slukem			column -t $TMP1 >> $ERR
6581.28Slukem			printf "\n" >> $ERR
6591.52Satatat			backup_file add $TMP1 $CUR $BACK
6601.9Scgd		fi
6611.15Smrg	fi
6621.15Smrg
6631.27Slukem	# Check for block and character disk devices that are readable or
6641.80Swiz	# writable or not owned by root.operator.
6651.15Smrg	>$TMP1
6661.61Slukem	DISKLIST="ccd ch hk hp ld md ra raid rb rd rl rx \
6671.57Ssimonb	    sd se ss uk up vnd wd xd xy"
6681.27Slukem#	DISKLIST="$DISKLIST ct mt st wt"
6691.15Smrg	for i in $DISKLIST; do
6701.15Smrg		egrep "^b.*/${i}[0-9][0-9]*[a-p]$"  $LIST >> $TMP1
6711.15Smrg		egrep "^c.*/r${i}[0-9][0-9]*[a-p]$"  $LIST >> $TMP1
6721.15Smrg	done
6731.15Smrg
6741.15Smrg	awk '$3 != "root" || $4 != "operator" || $1 !~ /.rw-r-----/ \
6751.25Slukem		{ printf "Disk %s is user %s, group %s, permissions %s.\n", \
6761.25Slukem		    $11, $3, $4, $1; }' < $TMP1 > $OUTPUT
6771.15Smrg	if [ -s $OUTPUT ] ; then
6781.28Slukem		printf "\nChecking disk ownership and permissions.\n" >> $ERR
6791.28Slukem		cat $OUTPUT >> $ERR
6801.28Slukem		printf "\n" >> $ERR
6811.9Scgd	fi
6821.9Scgd
6831.15Smrg	# Display any changes in the device file list.
6841.20Smycroft	egrep '^[bc]' $LIST | sort -k11 > $TMP1
6851.15Smrg	if [ -s $TMP1 ] ; then
6861.67Slukem		file=$work_dir/device
6871.67Slukem		migrate_file "$backup_dir/device" "$file"
6881.67Slukem		CUR=${file}.current
6891.67Slukem		BACK=${file}.backup
6901.15Smrg
6911.15Smrg		if [ -s $CUR ] ; then
6921.15Smrg			if cmp -s $CUR $TMP1 ; then
6931.15Smrg				:
6941.15Smrg			else
6951.15Smrg				> $TMP2
6961.15Smrg				join -111 -211 -v2 $CUR $TMP1 > $OUTPUT
6971.15Smrg				if [ -s $OUTPUT ] ; then
6981.28Slukem					printf "Device additions:\n" >> $ERR
6991.28Slukem					tee -a $TMP2 < $OUTPUT >> $ERR
7001.28Slukem					printf "\n" >> $ERR
7011.15Smrg				fi
7021.15Smrg
7031.15Smrg				join -111 -211 -v1 $CUR $TMP1 > $OUTPUT
7041.15Smrg				if [ -s $OUTPUT ] ; then
7051.28Slukem					printf "Device deletions:\n" >> $ERR
7061.28Slukem					tee -a $TMP2 < $OUTPUT >> $ERR
7071.28Slukem					printf "\n" >> $ERR
7081.15Smrg				fi
7091.15Smrg
7101.27Slukem				# Report any block device change. Ignore
7111.27Slukem				# character devices, only the name is
7121.27Slukem				# significant.
7131.15Smrg				cat $TMP2 $CUR $TMP1 | \
7141.27Slukem				    sed -e '/^c/d' | \
7151.27Slukem				    sort -k11 | \
7161.27Slukem				    sed -e 's/[	 ][	 ]*/ /g' | \
7171.27Slukem				    uniq -u > $OUTPUT
7181.15Smrg				if [ -s $OUTPUT ] ; then
7191.28Slukem					printf "Block device changes:\n" >> $ERR
7201.28Slukem					column -t $OUTPUT >> $ERR
7211.28Slukem					printf "\n" >> $ERR
7221.15Smrg				fi
7231.9Scgd
7241.52Satatat				backup_file update $TMP1 $CUR $BACK
7251.9Scgd			fi
7261.15Smrg		else
7271.28Slukem			printf "Device additions:\n" >> $ERR
7281.28Slukem			column -t $TMP1 >> $ERR
7291.28Slukem			printf "\n" >> $ERR
7301.52Satatat			backup_file add $TMP1 $CUR $BACK >> $ERR
7311.9Scgd		fi
7321.28Slukem	fi
7331.28Slukem	if [ -s $ERR ] ; then
7341.28Slukem		printf "\nChecking setuid files and devices:\n"
7351.28Slukem		cat $ERR
7361.28Slukem		printf "\n"
7371.9Scgd	fi
7381.9Scgdfi
7391.9Scgd
7401.9Scgd# Check special files.
7411.9Scgd# Check system binaries.
7421.9Scgd#
7431.9Scgd# Create the mtree tree specifications using:
7441.67Slukem#	mtree -cx -pDIR -kmd5,uid,gid,mode,nlink,size,link,time > DIR.secure
7451.38Skleink#	chown root:wheel DIR.secure
7461.67Slukem#	chmod u+r,go= DIR.secure
7471.9Scgd#
7481.9Scgd# Note, this is not complete protection against Trojan horsed binaries, as
7491.9Scgd# the hacker can modify the tree specification to match the replaced binary.
7501.9Scgd# For details on really protecting yourself against modified binaries, see
7511.9Scgd# the mtree(8) manual page.
7521.32Slukem#
7531.31Slukemif checkyesno check_mtree; then
7541.82Sjhawk	if checkyesno check_mtree_follow_symlinks; then
7551.82Sjhawk		check_mtree_flags="-L"
7561.82Sjhawk	else
7571.82Sjhawk		check_mtree_flags=""
7581.82Sjhawk	fi
7591.67Slukem	for file in $special_files; do
7601.67Slukem		[ ! -s $file ] && continue
7611.82Sjhawk		mtree -e -l -p / $check_mtree_flags -f $file
7621.87Sjhawk	done 3>&1 >$OUTPUT 2>&3 |
7631.87Sjhawk		grep -v '^mtree: dev/tty: Device not configured$' >&2
7641.15Smrg	if [ -s $OUTPUT ]; then
7651.9Scgd		printf "\nChecking special files and directories.\n"
7661.9Scgd		cat $OUTPUT
7671.9Scgd	fi
7681.9Scgd
7691.16Smikel	for file in /etc/mtree/*.secure; do
7701.16Smikel		[ $file = '/etc/mtree/*.secure' ] && continue
7711.9Scgd		tree=`sed -n -e '3s/.* //p' -e 3q $file`
7721.82Sjhawk		mtree $check_mtree_flags -f $file -p $tree > $TMP1
7731.9Scgd		if [ -s $TMP1 ]; then
7741.67Slukem			printf "\nChecking $tree:\n"
7751.67Slukem			cat $TMP1
7761.9Scgd		fi
7771.67Slukem	done > $OUTPUT
7781.15Smrg	if [ -s $OUTPUT ]; then
7791.9Scgd		printf "\nChecking system binaries:\n"
7801.9Scgd		cat $OUTPUT
7811.9Scgd	fi
7821.9Scgdfi
7831.9Scgd
7841.32Slukem# Backup disklabels of available disks
7851.32Slukem#
7861.32Slukemif checkyesno check_disklabels; then
7871.67Slukem		# migrate old disklabels
7881.67Slukem	for file in `ls -1d $backup_dir/$backup_dir/disklabel.* \
7891.67Slukem	    $backup_dir/disklabel.* 2>/dev/null`; do
7901.67Slukem		migrate_file "$file" "$work_dir/${file##*/}"
7911.67Slukem	done
7921.67Slukem
7931.67Slukem		# generate list of old disklabels & fdisks and remove them
7941.67Slukem	ls -1d $work_dir/disklabel.* $work_dir/fdisk.* 2>/dev/null |
7951.52Satatat	    egrep -v '\.(backup|current)(,v)?$' > $LABELS
7961.32Slukem	xargs rm < $LABELS
7971.32Slukem
7981.67Slukem		# generate disklabels of all disks excluding:	cd fd md
7991.63Slukem	disks=`iostat -x | awk 'NR > 1 && $1 !~ /^[cfm]d/ { print $1; }'`
8001.32Slukem	for i in $disks; do
8011.67Slukem		disklabel $i > "$work_dir/disklabel.$i" 2>/dev/null
8021.32Slukem	done
8031.32Slukem
8041.67Slukem		# if fdisk is available, generate fdisks for:	ed ld sd wd
8051.67Slukem	if [ -x /sbin/fdisk ]; then
8061.67Slukem		disks=`iostat -x| awk 'NR > 1 && $1 ~ /^[elsw]d/ { print $1; }'`
8071.67Slukem		for i in $disks; do
8081.67Slukem			/sbin/fdisk $i > "$work_dir/fdisk.$i" 2>/dev/null
8091.67Slukem		done
8101.67Slukem	fi
8111.67Slukem
8121.67Slukem		# append list of new disklabels and fdisks
8131.67Slukem	ls -1d $work_dir/disklabel.* $work_dir/fdisk.* 2>/dev/null |
8141.52Satatat	    egrep -v '\.(backup|current)(,v)?$' >> $LABELS
8151.62Satatat	CHANGELIST="$LABELS $CHANGELIST"
8161.62Satatatfi
8171.62Satatat
8181.62Satatat# Check for changes in the list of installed pkgs
8191.62Satatat#
8201.65Slukemif checkyesno check_pkgs && [ -d $pkgdb_dir ]; then
8211.67Slukem	pkgs=$work_dir/pkgs
8221.67Slukem	migrate_file "$backup_dir/pkgs" "$pkgs"
8231.65Slukem	(	cd $pkgdb_dir
8241.62Satatat		pkg_info | sort
8251.62Satatat		echo ""
8261.62Satatat		find . \( -name +REQUIRED_BY -o -name +CONTENTS \) -print0 |
8271.72Slukem			xargs -0 ls -ldgTq | sort -t. +1 | sed -e 's, \./, ,'
8281.62Satatat	 ) > $pkgs
8291.67Slukem	echo "$pkgs" > $PKGS
8301.62Satatat	CHANGELIST="$PKGS $CHANGELIST"
8311.32Slukemfi
8321.32Slukem
8331.67Slukem# List of files that get backed up and checked for any modifications.
8341.9Scgd# Any changes cause the files to rotate.
8351.32Slukem#
8361.67Slukemif checkyesno check_changelist ; then
8371.67Slukem	for file in $special_files; do
8381.67Slukem		[ ! -s $file ] && continue
8391.67Slukem		mtree -D -k type -f $file -E exclude |
8401.67Slukem		    sed '/^type=file/!d ; s/type=file \.//'
8411.67Slukem	done > $CHANGEFILES
8421.67Slukem
8431.75Slukem	(
8441.68Slukem		# Add other files which might dynamically exist:
8451.67Slukem		#	/etc/ifconfig.*
8461.67Slukem		#	/etc/raid*.conf
8471.68Slukem		#	/etc/rc.d/*
8481.67Slukem		#	/etc/rc.conf.d/*
8491.68Slukem		#
8501.75Slukem		echo "/etc/ifconfig.*"
8511.75Slukem		echo "/etc/raid*.conf"
8521.75Slukem		echo "/etc/rc.d/*"
8531.75Slukem		echo "/etc/rc.conf.d/*"
8541.67Slukem
8551.68Slukem		# Add /etc/changelist
8561.68Slukem		#
8571.75Slukem		if [ -s /etc/changelist ]; then
8581.75Slukem			grep -v '^#' /etc/changelist
8591.75Slukem		fi
8601.75Slukem	) | while read file; do
8611.75Slukem		case "$file" in
8621.75Slukem		*[\*\?\[]*)	# If changelist line is a glob ...
8631.75Slukem				# ... expand possible backup files
8641.75Slukem				#
8651.75Slukem			ls -1d $(echo $backup_dir/${file}.current) 2>/dev/null \
8661.75Slukem			    | sed "s,^$backup_dir/,, ; s,\.current$,,"
8671.75Slukem				
8681.75Slukem				# ... expand possible files
8691.75Slukem				#
8701.75Slukem			ls -1d $(echo $file) 2>/dev/null
8711.75Slukem			;;
8721.75Slukem		*)
8731.75Slukem				# Otherwise, just print the filename
8741.75Slukem			echo $file
8751.75Slukem			;;
8761.75Slukem		esac
8771.75Slukem	done >> $CHANGEFILES
8781.67Slukem	CHANGELIST="$CHANGEFILES $CHANGELIST"
8791.67Slukemfi
8801.67Slukem
8811.67Slukem# Special case backups, including the master password file and
8821.67Slukem# ssh private host keys. The normal backup mechanisms for
8831.67Slukem# $check_changelist (see below) also print out the actual file
8841.67Slukem# differences and we don't want to do that for these files
8851.67Slukem#
8861.67Slukemecho $MP > $TMP1			# always add /etc/master.passwd
8871.67Slukemfor file in $special_files; do
8881.67Slukem	[ ! -s $file ] && continue
8891.70Slukem	mtree -D -k type -f $file -I nodiff |
8901.67Slukem	    sed '/^type=file/!d ; s/type=file \.//'
8911.67Slukemdone >> $TMP1
8921.73Slukemgrep -v '^$' $TMP1 | sort -u > $TMP2
8931.68Slukem
8941.69Slukemwhile read file; do
8951.67Slukem	backup_and_diff "$file" no
8961.69Slukemdone < $TMP2
8971.67Slukem
8981.32Slukem
8991.32Slukemif [ -n "$CHANGELIST" ]; then
9001.73Slukem	grep -h -v '^$' $CHANGELIST | sort -u > $TMP1
9011.68Slukem	comm -23 $TMP1 $TMP2 | while read file; do
9021.67Slukem		backup_and_diff "$file" yes
9031.9Scgd	done
9041.44Sadfi
9051.44Sad
9061.44Sadif [ -f /etc/security.local ]; then
9071.90Skim	. /etc/security.local > $OUTPUT 2>&1
9081.84Sjhawk	if [ -s $OUTPUT ] ; then
9091.84Sjhawk		printf "\nRunning /etc/security.local:\n"
9101.84Sjhawk		cat $OUTPUT
9111.84Sjhawk	fi
9121.9Scgdfi
913