security revision 1.104
11.1Scgd#!/bin/sh - 21.1Scgd# 31.104Sadrianp# $NetBSD: security,v 1.104 2007/08/27 19:57:02 adrianp 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.104Sadrianppkg_info=${pkg_info:-/usr/sbin/pkg_info} 321.67Slukem 331.67Slukem# Other configurable variables 341.67Slukem# 351.67Slukemspecial_files="/etc/mtree/special /etc/mtree/special.local" 361.67SlukemMP=/etc/master.passwd 371.67SlukemCHANGELIST="" 381.67Slukemwork_dir=$backup_dir/work 391.67Slukem 401.67Slukemif [ ! -d "$work_dir" ]; then 411.67Slukem mkdir -p "$work_dir" 421.67Slukemfi 431.67Slukem 441.102SmarttiSECUREDIR=$(mktemp -d -t _securedir) || exit 1 451.56Slukem 461.67Slukemtrap "/bin/rm -rf $SECUREDIR ; exit 0" EXIT INT QUIT PIPE 471.15Smrg 481.56Slukemif ! cd "$SECUREDIR"; then 491.56Slukem echo "Can not cd to $SECUREDIR". 501.15Smrg exit 1 511.15Smrgfi 521.15Smrg 531.91SlukemERR=err.$$ 541.91SlukemTMP1=tmp1.$$ 551.91SlukemTMP2=tmp2.$$ 561.91SlukemMPBYUID=mpbyuid.$$ 571.91SlukemMPBYPATH=mpbypath.$$ 581.91SlukemLIST=list.$$ 591.91SlukemOUTPUT=output.$$ 601.91SlukemLABELS=labels.$$ 611.91SlukemPKGS=pkgs.$$ 621.91SlukemCHANGEFILES=changefiles.$$ 631.91SlukemSPECIALSPEC=specialspec.$$ 641.67Slukem 651.15Smrg 661.67Slukem# migrate_file old new 671.67Slukem# Determine if the "${old}" path name needs to be migrated to the 681.67Slukem# "${new}" path. Also checks if "${old}.current" needs migrating, 691.67Slukem# and if so, migrate it and possibly "${old}.current,v" and 701.67Slukem# "${old}.backup". 711.67Slukem# 721.67Slukemmigrate_file() 731.67Slukem{ 741.67Slukem _old=$1 751.67Slukem _new=$2 761.67Slukem if [ -z "$_old" -o -z "$_new" ]; then 771.67Slukem err 3 "USAGE: migrate_file old new" 781.67Slukem fi 791.67Slukem if [ ! -d "${_new%/*}" ]; then 801.67Slukem mkdir -p "${_new%/*}" 811.67Slukem fi 821.67Slukem if [ -f "${_old}" -a ! -f "${_new}" ]; then 831.67Slukem echo "==> migrating ${_old}" 841.67Slukem echo " to ${_new}" 851.67Slukem mv "${_old}" "${_new}" 861.67Slukem fi 871.67Slukem if [ -f "${_old}.current" -a ! -f "${_new}.current" ]; then 881.67Slukem echo "==> migrating ${_old}.current" 891.67Slukem echo " to ${_new}.current" 901.67Slukem mv "${_old}.current" "${_new}.current" 911.67Slukem if [ -f "${_old}.current,v" -a ! -f "${_new}.current,v" ]; then 921.67Slukem echo "==> migrating ${_old}.current,v" 931.67Slukem echo " to ${_new}.current,v" 941.67Slukem mv "${_old}.current,v" "${_new}.current,v" 951.67Slukem fi 961.67Slukem if [ -f "${_old}.backup" -a ! -f "${_new}.backup" ]; then 971.67Slukem echo "==> migrating ${_old}.backup" 981.67Slukem echo " to ${_new}.backup" 991.67Slukem mv "${_old}.backup" "${_new}.backup" 1001.67Slukem fi 1011.67Slukem fi 1021.67Slukem} 1031.67Slukem 1041.67Slukem 1051.67Slukem# backup_and_diff file printdiff 1061.67Slukem# Determine if file needs backing up, and if so, do it. 1071.67Slukem# If printdiff is yes, display the diffs, otherwise 1081.67Slukem# just print a message saying "[changes omitted]". 1091.67Slukem# 1101.67Slukembackup_and_diff() 1111.67Slukem{ 1121.67Slukem _file=$1 1131.67Slukem _printdiff=$2 1141.67Slukem if [ -z "$_file" -o -z "$_printdiff" ]; then 1151.67Slukem err 3 "USAGE: backup_and_diff file printdiff" 1161.67Slukem fi 1171.67Slukem ! checkyesno _printdiff 1181.67Slukem _printdiff=$? 1191.67Slukem 1201.67Slukem _old=$backup_dir/${_file##*/} 1211.67Slukem case "$_file" in 1221.67Slukem $work_dir/*) 1231.67Slukem _new=$_file 1241.67Slukem migrate_file "$backup_dir/$_old" "$_new" 1251.67Slukem migrate_file "$_old" "$_new" 1261.67Slukem ;; 1271.67Slukem *) 1281.67Slukem _new=$backup_dir/$_file 1291.67Slukem migrate_file "$_old" "$_new" 1301.67Slukem ;; 1311.67Slukem esac 1321.67Slukem CUR=${_new}.current 1331.67Slukem BACK=${_new}.backup 1341.67Slukem if [ -f $_file ]; then 1351.67Slukem if [ -f $CUR ] ; then 1361.67Slukem if [ "$_printdiff" -ne 0 ]; then 1371.83Sjhawk diff ${diff_options} $CUR $_file > $OUTPUT 1381.67Slukem else 1391.67Slukem if ! cmp -s $CUR $_file; then 1401.67Slukem echo "[changes omitted]" 1411.67Slukem fi > $OUTPUT 1421.67Slukem fi 1431.67Slukem if [ -s $OUTPUT ] ; then 1441.67Slukem printf \ 1451.67Slukem "\n======\n%s diffs (OLD < > NEW)\n======\n" $_file 1461.67Slukem cat $OUTPUT 1471.67Slukem backup_file update $_file $CUR $BACK 1481.67Slukem fi 1491.67Slukem else 1501.67Slukem printf "\n======\n%s added\n======\n" $_file 1511.67Slukem if [ "$_printdiff" -ne 0 ]; then 1521.83Sjhawk diff ${diff_options} /dev/null $_file 1531.67Slukem else 1541.67Slukem echo "[changes omitted]" 1551.67Slukem fi 1561.67Slukem backup_file add $_file $CUR $BACK 1571.67Slukem fi 1581.67Slukem else 1591.67Slukem if [ -f $CUR ]; then 1601.67Slukem printf "\n======\n%s removed\n======\n" $_file 1611.67Slukem if [ "$_printdiff" -ne 0 ]; then 1621.83Sjhawk diff ${diff_options} $CUR /dev/null 1631.67Slukem else 1641.67Slukem echo "[changes omitted]" 1651.67Slukem fi 1661.67Slukem backup_file remove $_file $CUR $BACK 1671.67Slukem fi 1681.67Slukem fi 1691.67Slukem} 1701.48Sabs 1711.9Scgd 1721.67Slukem# These are used several times. 1731.67Slukem# 1741.91Slukemawk -F: '!/^\+/ { print $1 " " $3 }' $MP | sort -k2n > $MPBYUID 1751.29Slukemawk -F: '{ print $1 " " $9 }' $MP | sort -k2 > $MPBYPATH 1761.91Slukemfor file in $special_files; do 1771.91Slukem [ -s $file ] && cat $file 1781.91Slukemdone | mtree -CM -k all > $SPECIALSPEC || exit 1 1791.9Scgd 1801.67Slukem 1811.9Scgd# Check the master password file syntax. 1821.32Slukem# 1831.31Slukemif checkyesno check_passwd; then 1841.85Sjhawk # XXX: the sense of permit_star is reversed; the code works as 1851.85Sjhawk # implemented, but usage needs to be negated. 1861.81Sjhawk checkyesno check_passwd_permit_star && permit_star=0 || permit_star=1 1871.94Sjdolecek checkyesno check_passwd_permit_nonalpha \ 1881.94Sjdolecek && permit_nonalpha=1 || permit_nonalpha=0 1891.94Sjdolecek 1901.81Sjhawk awk -v "len=$max_loginlen" \ 1911.81Sjhawk -v "nowarn_shells_list=$check_passwd_nowarn_shells" \ 1921.81Sjhawk -v "nowarn_users_list=$check_passwd_nowarn_users" \ 1931.94Sjdolecek -v "permit_star=$permit_star" \ 1941.94Sjdolecek -v "permit_nonalpha=$permit_nonalpha" \ 1951.94Sjdolecek ' 1961.25Slukem BEGIN { 1971.25Slukem while ( getline < "/etc/shells" > 0 ) { 1981.39Shubertf if ($0 ~ /^\#/ || $0 ~ /^$/ ) 1991.25Slukem continue; 2001.25Slukem shells[$1]++; 2011.25Slukem } 2021.81Sjhawk split(nowarn_shells_list, a); 2031.81Sjhawk for (i in a) nowarn_shells[a[i]]++; 2041.81Sjhawk split(nowarn_users_list, a); 2051.81Sjhawk for (i in a) nowarn_users[a[i]]++; 2061.81Sjhawk uid0_users_list="root toor" 2071.81Sjhawk split(uid0_users_list, a); 2081.81Sjhawk for (i in a) uid0_users[a[i]]++; 2091.25Slukem FS=":"; 2101.25Slukem } 2111.25Slukem 2121.25Slukem { 2131.15Smrg if ($0 ~ /^[ ]*$/) { 2141.25Slukem printf "Line %d is a blank line.\n", NR; 2151.15Smrg next; 2161.15Smrg } 2171.34Sabs if (NF != 10 && ($1 != "+" || NF != 1)) 2181.25Slukem printf "Line %d has the wrong number of fields.\n", NR; 2191.34Sabs if ($1 == "+" ) { 2201.34Sabs if (NF != 1 && $3 == 0) 2211.81Sjhawk printf "Line %d includes entries with uid 0.\n", 2221.81Sjhawk NR; 2231.34Sabs next; 2241.34Sabs } 2251.94Sjdolecek if (!permit_nonalpha && 2261.95Speter $1 !~ /^[_A-Za-z0-9]([-A-Za-z0-9_.]*[A-Za-z0-9])*$/) 2271.25Slukem printf "Login %s has non-alphanumeric characters.\n", 2281.25Slukem $1; 2291.34Sabs if (length($1) > len) 2301.81Sjhawk printf "Login %s has more than "len" characters.\n", 2311.81Sjhawk $1; 2321.81Sjhawk if ($2 == "" && !nowarn_users[$1]) 2331.81Sjhawk printf "Login %s has no password.\n", $1; 2341.81Sjhawk if (!nowarn_shells[$10] && !nowarn_users[$1]) { 2351.81Sjhawk if (length($2) != 13 && 2361.81Sjhawk length($2) != 20 && 2371.81Sjhawk $2 !~ /^\$1/ && 2381.81Sjhawk $2 !~ /^\$2/ && 2391.99Sjmcneill $2 !~ /^\$sha1/ && 2401.81Sjhawk $2 != "" && 2411.81Sjhawk (permit_star || $2 != "*") && 2421.81Sjhawk $2 !~ /^\*[A-z-]+$/ && 2431.81Sjhawk $1 != "toor") { 2441.81Sjhawk if ($10 == "" || shells[$10]) 2451.81Sjhawk printf "Login %s is off but still has "\ 2461.81Sjhawk "a valid shell (%s)\n", $1, $10; 2471.81Sjhawk } else if (! shells[$10]) 2481.81Sjhawk printf "Login %s does not have a valid "\ 2491.81Sjhawk "shell (%s)\n", $1, $10; 2501.81Sjhawk } 2511.81Sjhawk if ($3 == 0 && !uid0_users[$1] && !nowarn_users[$1]) 2521.25Slukem printf "Login %s has a user id of 0.\n", $1; 2531.15Smrg if ($3 < 0) 2541.25Slukem printf "Login %s has a negative user id.\n", $1; 2551.15Smrg if ($4 < 0) 2561.25Slukem printf "Login %s has a negative group id.\n", $1; 2571.15Smrg }' < $MP > $OUTPUT 2581.15Smrg if [ -s $OUTPUT ] ; then 2591.15Smrg printf "\nChecking the $MP file:\n" 2601.15Smrg cat $OUTPUT 2611.15Smrg fi 2621.15Smrg 2631.15Smrg awk -F: '{ print $1 }' $MP | sort | uniq -d > $OUTPUT 2641.15Smrg if [ -s $OUTPUT ] ; then 2651.15Smrg printf "\n$MP has duplicate user names.\n" 2661.15Smrg column $OUTPUT 2671.15Smrg fi 2681.15Smrg 2691.37Swrstuden# To not exclude 'toor', a standard duplicate root account, from the duplicate 2701.37Swrstuden# account test, uncomment the line below (without egrep in it)and comment 2711.37Swrstuden# out the line (with egrep in it) below it. 2721.37Swrstuden# 2731.37Swrstuden# < $MPBYUID uniq -d -f 1 | awk '{ print $2 }' > $TMP2 2741.36Swrstuden < $MPBYUID egrep -v '^toor ' | uniq -d -f 1 | awk '{ print $2 }' > $TMP2 2751.15Smrg if [ -s $TMP2 ] ; then 2761.15Smrg printf "\n$MP has duplicate user id's.\n" 2771.15Smrg while read uid; do 2781.28Slukem grep -w $uid $MPBYUID 2791.15Smrg done < $TMP2 | column 2801.15Smrg fi 2811.9Scgdfi 2821.9Scgd 2831.9Scgd# Check the group file syntax. 2841.32Slukem# 2851.31Slukemif checkyesno check_group; then 2861.15Smrg GRP=/etc/group 2871.49Sjdolecek awk -F: -v "len=$max_grouplen" '{ 2881.15Smrg if ($0 ~ /^[ ]*$/) { 2891.25Slukem printf "Line %d is a blank line.\n", NR; 2901.15Smrg next; 2911.15Smrg } 2921.34Sabs if (NF != 4 && ($1 != "+" || NF != 1)) 2931.25Slukem printf "Line %d has the wrong number of fields.\n", NR; 2941.34Sabs if ($1 == "+" ) { 2951.34Sabs next; 2961.34Sabs } 2971.95Speter if ($1 !~ /^[_A-Za-z0-9]([-A-Za-z0-9_.]*[A-Za-z0-9])*$/) 2981.25Slukem printf "Group %s has non-alphanumeric characters.\n", 2991.25Slukem $1; 3001.49Sjdolecek if (length($1) > len) 3011.49Sjdolecek printf "Group %s has more than "len" characters.\n", $1; 3021.15Smrg if ($3 !~ /[0-9]*/) 3031.25Slukem printf "Login %s has a negative group id.\n", $1; 3041.15Smrg }' < $GRP > $OUTPUT 3051.15Smrg if [ -s $OUTPUT ] ; then 3061.15Smrg printf "\nChecking the $GRP file:\n" 3071.15Smrg cat $OUTPUT 3081.15Smrg fi 3091.15Smrg 3101.15Smrg awk -F: '{ print $1 }' $GRP | sort | uniq -d > $OUTPUT 3111.15Smrg if [ -s $OUTPUT ] ; then 3121.15Smrg printf "\n$GRP has duplicate group names.\n" 3131.15Smrg column $OUTPUT 3141.15Smrg fi 3151.9Scgdfi 3161.9Scgd 3171.9Scgd# Check for root paths, umask values in startup files. 3181.9Scgd# The check for the root paths is problematical -- it's likely to fail 3191.9Scgd# in other environments. Once the shells have been modified to warn 3201.9Scgd# of '.' in the path, the path tests should go away. 3211.32Slukem# 3221.31Slukemif checkyesno check_rootdotfiles; then 3231.67Slukem rhome=~root 3241.15Smrg umaskset=no 3251.15Smrg list="/etc/csh.cshrc /etc/csh.login ${rhome}/.cshrc ${rhome}/.login" 3261.15Smrg for i in $list ; do 3271.15Smrg if [ -f $i ] ; then 3281.67Slukem if egrep '^[ \t]*umask[ \t]+[0-7]+' $i > /dev/null ; 3291.67Slukem then 3301.15Smrg umaskset=yes 3311.15Smrg fi 3321.63Slukem # Double check the umask value itself; ensure that 3331.67Slukem # both the group and other write bits are set. 3341.67Slukem # 3351.45Ssommerfe egrep '^[ \t]*umask[ \t]+[0-7]+' $i | 3361.63Slukem awk '{ 3371.67Slukem if ($2 ~ /^.$/ || $2 ~! /[^2367].$/) { 3381.80Swiz print "\tRoot umask is group writable" 3391.63Slukem } 3401.67Slukem if ($2 ~ /[^2367]$/) { 3411.80Swiz print "\tRoot umask is other writable" 3421.63Slukem } 3431.67Slukem }' | sort -u 3441.26Slukem SAVE_PATH=$PATH 3451.26Slukem unset PATH 3461.15Smrg /bin/csh -f -s << end-of-csh > /dev/null 2>&1 3471.15Smrg source $i 3481.15Smrg /bin/ls -ldgT \$path > $TMP1 3491.9Scgdend-of-csh 3501.76Satatat export PATH=$SAVE_PATH 3511.15Smrg awk '{ 3521.15Smrg if ($10 ~ /^\.$/) { 3531.27Slukem print "\tThe root path includes ."; 3541.15Smrg next; 3551.15Smrg } 3561.15Smrg } 3571.15Smrg $1 ~ /^d....w/ \ 3581.80Swiz { print "\tRoot path directory " $10 " is group writable." } \ 3591.15Smrg $1 ~ /^d.......w/ \ 3601.80Swiz { print "\tRoot path directory " $10 " is other writable." }' \ 3611.67Slukem < $TMP1 3621.15Smrg fi 3631.67Slukem done > $OUTPUT 3641.15Smrg if [ $umaskset = "no" -o -s $OUTPUT ] ; then 3651.27Slukem printf "\nChecking root csh paths, umask values:\n$list\n\n" 3661.15Smrg if [ -s $OUTPUT ]; then 3671.15Smrg cat $OUTPUT 3681.15Smrg fi 3691.15Smrg if [ $umaskset = "no" ] ; then 3701.27Slukem printf "\tRoot csh startup files do not set the umask.\n" 3711.15Smrg fi 3721.9Scgd fi 3731.9Scgd 3741.15Smrg umaskset=no 3751.23Slukem list="/etc/profile ${rhome}/.profile" 3761.15Smrg for i in $list; do 3771.15Smrg if [ -f $i ] ; then 3781.15Smrg if egrep umask $i > /dev/null ; then 3791.15Smrg umaskset=yes 3801.15Smrg fi 3811.15Smrg egrep umask $i | 3821.67Slukem awk '$2 ~ /^.$/ || $2 ~ /[^2367].$/ \ 3831.80Swiz { print "\tRoot umask is group writable" } \ 3841.67Slukem $2 ~ /[^2367]$/ \ 3851.80Swiz { print "\tRoot umask is other writable" }' 3861.26Slukem SAVE_PATH=$PATH 3871.26Slukem unset PATH 3881.15Smrg /bin/sh << end-of-sh > /dev/null 2>&1 3891.15Smrg . $i 3901.26Slukem list=\`echo \$PATH | /usr/bin/sed -e \ 3911.26Slukem 's/^:/.:/;s/:$/:./;s/::/:.:/g;s/:/ /g'\` 3921.15Smrg /bin/ls -ldgT \$list > $TMP1 3931.9Scgdend-of-sh 3941.76Satatat export PATH=$SAVE_PATH 3951.15Smrg awk '{ 3961.15Smrg if ($10 ~ /^\.$/) { 3971.27Slukem print "\tThe root path includes ."; 3981.15Smrg next; 3991.15Smrg } 4001.15Smrg } 4011.15Smrg $1 ~ /^d....w/ \ 4021.80Swiz { print "\tRoot path directory " $10 " is group writable." } \ 4031.15Smrg $1 ~ /^d.......w/ \ 4041.80Swiz { print "\tRoot path directory " $10 " is other writable." }' \ 4051.67Slukem < $TMP1 4061.9Scgd 4071.15Smrg fi 4081.67Slukem done > $OUTPUT 4091.15Smrg if [ $umaskset = "no" -o -s $OUTPUT ] ; then 4101.15Smrg printf "\nChecking root sh paths, umask values:\n$list\n" 4111.15Smrg if [ -s $OUTPUT ]; then 4121.15Smrg cat $OUTPUT 4131.15Smrg fi 4141.15Smrg if [ $umaskset = "no" ] ; then 4151.27Slukem printf "\tRoot sh startup files do not set the umask.\n" 4161.15Smrg fi 4171.9Scgd fi 4181.9Scgdfi 4191.9Scgd 4201.9Scgd# Root and uucp should both be in /etc/ftpusers. 4211.32Slukem# 4221.31Slukemif checkyesno check_ftpusers; then 4231.28Slukem list="uucp "`awk '$2 == 0 { print $1 }' $MPBYUID` 4241.27Slukem for i in $list; do 4251.29Slukem if /usr/libexec/ftpd -C $i ; then 4261.67Slukem printf "\t$i is not denied\n" 4271.27Slukem fi 4281.67Slukem done > $OUTPUT 4291.28Slukem if [ -s $OUTPUT ]; then 4301.28Slukem printf "\nChecking the /etc/ftpusers configuration:\n" 4311.28Slukem cat $OUTPUT 4321.28Slukem fi 4331.9Scgdfi 4341.9Scgd 4351.43Sitojun# Uudecode should not be in the /etc/mail/aliases file. 4361.32Slukem# 4371.31Slukemif checkyesno check_aliases; then 4381.43Sitojun for f in /etc/mail/aliases /etc/aliases; do 4391.43Sitojun if [ -f $f ] && egrep '^[^#]*(uudecode|decode).*\|' $f; then 4401.43Sitojun printf "\nEntry for uudecode in $f file.\n" 4411.43Sitojun fi 4421.43Sitojun done 4431.9Scgdfi 4441.9Scgd 4451.9Scgd# Files that should not have + signs. 4461.32Slukem# 4471.31Slukemif checkyesno check_rhosts; then 4481.15Smrg list="/etc/hosts.equiv /etc/hosts.lpd" 4491.15Smrg for f in $list ; do 4501.15Smrg if [ -f $f ] && egrep '\+' $f > /dev/null ; then 4511.15Smrg printf "\nPlus sign in $f file.\n" 4521.15Smrg fi 4531.15Smrg done 4541.15Smrg 4551.15Smrg # Check for special users with .rhosts files. Only root and toor should 4561.16Smikel # have .rhosts files. Also, .rhosts files should not have plus signs. 4571.15Smrg awk -F: '$1 != "root" && $1 != "toor" && \ 4581.15Smrg ($3 < 100 || $1 == "ftp" || $1 == "uucp") \ 4591.20Smycroft { print $1 " " $9 }' $MP | 4601.19Smycroft sort -k2 | 4611.15Smrg while read uid homedir; do 4621.15Smrg if [ -f ${homedir}/.rhosts ] ; then 4631.15Smrg rhost=`ls -ldgT ${homedir}/.rhosts` 4641.46Schristos printf -- "$uid: $rhost\n" 4651.15Smrg fi 4661.15Smrg done > $OUTPUT 4671.15Smrg if [ -s $OUTPUT ] ; then 4681.15Smrg printf "\nChecking for special users with .rhosts files.\n" 4691.15Smrg cat $OUTPUT 4701.15Smrg fi 4711.15Smrg 4721.15Smrg while read uid homedir; do 4731.35Sfair if [ -f ${homedir}/.rhosts -a -r ${homedir}/.rhosts ] && \ 4741.41Schristos cat -f ${homedir}/.rhosts | egrep '\+' > /dev/null ; then 4751.46Schristos printf -- "$uid: + in .rhosts file.\n" 4761.15Smrg fi 4771.29Slukem done < $MPBYPATH > $OUTPUT 4781.15Smrg if [ -s $OUTPUT ] ; then 4791.15Smrg printf "\nChecking .rhosts files syntax.\n" 4801.15Smrg cat $OUTPUT 4811.15Smrg fi 4821.9Scgdfi 4831.9Scgd 4841.9Scgd# Check home directories. Directories should not be owned by someone else 4851.80Swiz# or writable. 4861.32Slukem# 4871.31Slukemif checkyesno check_homes; then 4881.85Sjhawk checkyesno check_homes_permit_usergroups && \ 4891.85Sjhawk permit_usergroups=1 || permit_usergroups=0 4901.15Smrg while read uid homedir; do 4911.15Smrg if [ -d ${homedir}/ ] ; then 4921.15Smrg file=`ls -ldgT ${homedir}` 4931.46Schristos printf -- "$uid $file\n" 4941.9Scgd fi 4951.29Slukem done < $MPBYPATH | 4961.85Sjhawk awk -v "usergroups=$permit_usergroups" ' 4971.85Sjhawk $1 != $4 && $4 != "root" \ 4981.15Smrg { print "user " $1 " home directory is owned by " $4 } 4991.101Sjnemeth $2 ~ /^d....w/ && (!usergroups || $5 != $1) \ 5001.80Swiz { print "user " $1 " home directory is group writable" } 5011.101Sjnemeth $2 ~ /^d.......w/ \ 5021.80Swiz { print "user " $1 " home directory is other writable" }' \ 5031.27Slukem > $OUTPUT 5041.15Smrg if [ -s $OUTPUT ] ; then 5051.15Smrg printf "\nChecking home directories.\n" 5061.15Smrg cat $OUTPUT 5071.15Smrg fi 5081.15Smrg 5091.15Smrg # Files that should not be owned by someone else or readable. 5101.67Slukem list=".Xauthority .netrc .ssh/id_dsa .ssh/id_rsa .ssh/identity" 5111.15Smrg while read uid homedir; do 5121.15Smrg for f in $list ; do 5131.15Smrg file=${homedir}/${f} 5141.15Smrg if [ -f $file ] ; then 5151.46Schristos printf -- "$uid $f `ls -ldgT $file`\n" 5161.15Smrg fi 5171.15Smrg done 5181.29Slukem done < $MPBYPATH | 5191.85Sjhawk awk -v "usergroups=$permit_usergroups" ' 5201.85Sjhawk $1 != $5 && $5 != "root" \ 5211.15Smrg { print "user " $1 " " $2 " file is owned by " $5 } 5221.85Sjhawk $3 ~ /^-...r/ && (!usergroups || $6 != $1) \ 5231.15Smrg { print "user " $1 " " $2 " file is group readable" } 5241.15Smrg $3 ~ /^-......r/ \ 5251.15Smrg { print "user " $1 " " $2 " file is other readable" } 5261.85Sjhawk $3 ~ /^-....w/ && (!usergroups || $6 != $1) \ 5271.80Swiz { print "user " $1 " " $2 " file is group writable" } 5281.15Smrg $3 ~ /^-.......w/ \ 5291.80Swiz { print "user " $1 " " $2 " file is other writable" }' \ 5301.27Slukem > $OUTPUT 5311.15Smrg 5321.80Swiz # Files that should not be owned by someone else or writable. 5331.19Smycroft list=".bash_history .bash_login .bash_logout .bash_profile .bashrc \ 5341.79Selric .cshrc .emacs .exrc .forward .history .k5login .klogin .login \ 5351.79Selric .logout .profile .qmail .rc_history .rhosts .shosts ssh .tcshrc \ 5361.79Selric .twmrc .xinitrc .xsession .ssh/authorized_keys \ 5371.79Selric .ssh/authorized_keys2 .ssh/config .ssh/id_dsa.pub \ 5381.79Selric .ssh/id_rsa.pub .ssh/identity.pub .ssh/known_hosts \ 5391.79Selric .ssh/known_hosts2" 5401.15Smrg while read uid homedir; do 5411.15Smrg for f in $list ; do 5421.15Smrg file=${homedir}/${f} 5431.15Smrg if [ -f $file ] ; then 5441.46Schristos printf -- "$uid $f `ls -ldgT $file`\n" 5451.15Smrg fi 5461.15Smrg done 5471.29Slukem done < $MPBYPATH | 5481.85Sjhawk awk -v "usergroups=$permit_usergroups" ' 5491.85Sjhawk $1 != $5 && $5 != "root" \ 5501.15Smrg { print "user " $1 " " $2 " file is owned by " $5 } 5511.85Sjhawk $3 ~ /^-....w/ && (!usergroups || $6 != $1) \ 5521.80Swiz { print "user " $1 " " $2 " file is group writable" } 5531.15Smrg $3 ~ /^-.......w/ \ 5541.80Swiz { print "user " $1 " " $2 " file is other writable" }' \ 5551.27Slukem >> $OUTPUT 5561.15Smrg if [ -s $OUTPUT ] ; then 5571.15Smrg printf "\nChecking dot files.\n" 5581.15Smrg cat $OUTPUT 5591.15Smrg fi 5601.9Scgdfi 5611.9Scgd 5621.9Scgd# Mailboxes should be owned by user and unreadable. 5631.32Slukem# 5641.31Slukemif checkyesno check_varmail; then 5651.86Sjhawk ls -lA /var/mail | \ 5661.63Slukem awk ' NR == 1 { next; } 5671.86Sjhawk $9 ~ /^\./ {next; } 5681.63Slukem $3 != $9 { 5691.63Slukem print "user " $9 " mailbox is owned by " $3 5701.63Slukem } 5711.63Slukem $1 != "-rw-------" { 5721.63Slukem print "user " $9 " mailbox is " $1 ", group " $4 5731.63Slukem }' > $OUTPUT 5741.15Smrg if [ -s $OUTPUT ] ; then 5751.15Smrg printf "\nChecking mailbox ownership.\n" 5761.15Smrg cat $OUTPUT 5771.15Smrg fi 5781.15Smrgfi 5791.15Smrg 5801.32Slukem# NFS exports shouldn't be globally exported 5811.32Slukem# 5821.32Slukemif checkyesno check_nfs && [ -f /etc/exports ]; then 5831.32Slukem awk '{ 5841.22Slukem # ignore comments and blank lines 5851.39Shubertf if ($0 ~ /^\#/ || $0 ~ /^$/ ) 5861.22Slukem next; 5871.100Stron # manage line continuation 5881.100Stron while ($NF ~ /^\\$/) { 5891.100Stron $NF = ""; 5901.100Stron line = $0 ""; 5911.100Stron getline; 5921.100Stron $0 = line $0 ""; 5931.100Stron } 5941.22Slukem 5951.100Stron delete dir; 5961.100Stron readonly = ndir = 0; 5971.100Stron for (i = 1; i <= NF; ++i) { 5981.100Stron if ($i ~ /^\//) dir[ndir++] = $i; 5991.100Stron else if ($i ~ /^-/) { 6001.100Stron if ($i ~ /^-(ro|o)$/) readonly = 1; 6011.100Stron if ($i ~ /^-network/) next; 6021.100Stron } 6031.100Stron else next; 6041.15Smrg } 6051.15Smrg if (readonly) 6061.100Stron for (item in dir) 6071.100Stron rodir[nrodir++] = dir[item]; 6081.15Smrg else 6091.100Stron for (item in dir) 6101.100Stron rwdir[nrwdir++] = dir[item]; 6111.100Stron 6121.100Stron } 6131.100Stron 6141.100Stron END { 6151.100Stron if (nrodir) { 6161.100Stron printf("Globally exported file system%s, read-only:\n", 6171.100Stron nrodir > 1 ? "s" : ""); 6181.100Stron for (item in rodir) 6191.100Stron printf("\t%s\n", rodir[item]); 6201.100Stron } 6211.100Stron if (nrwdir) { 6221.100Stron printf("Globally exported file system%s, read-write:\n", 6231.100Stron nrwdir > 1 ? "s" : ""); 6241.100Stron for (item in rwdir) 6251.100Stron printf("\t%s\n", rwdir[item]); 6261.100Stron } 6271.32Slukem }' < /etc/exports > $OUTPUT 6281.32Slukem if [ -s $OUTPUT ] ; then 6291.15Smrg printf "\nChecking for globally exported file systems.\n" 6301.15Smrg cat $OUTPUT 6311.15Smrg fi 6321.9Scgdfi 6331.9Scgd 6341.9Scgd# Display any changes in setuid files and devices. 6351.32Slukem# 6361.31Slukemif checkyesno check_devices; then 6371.28Slukem > $ERR 6381.92Serh ( 6391.98Slukem 6401.98Slukem # Convert check_devices_ignore_fstypes="foo !bar bax" 6411.98Slukem # into "-fstype foo -o ! -fstype bar -o -fstype bax" 6421.98Slukem # and check_devices_ignore_paths="/foo !/bar /bax" 6431.98Slukem # into " -path /foo -o ! -path /bar -o -path /bax" 6441.98Slukem # 6451.98Slukem ignexpr=$(\ 6461.98Slukem echo $check_devices_ignore_fstypes | \ 6471.98Slukem sed -e's/\(!*\)\([^[:space:]]\{1,\}\)/-o \1 -fstype \2/g' ; \ 6481.98Slukem echo $check_devices_ignore_paths | \ 6491.98Slukem sed -e's/\(!*\)\([^[:space:]]\{1,\}\)/-o \1 -path \2/g' \ 6501.98Slukem ) 6511.98Slukem 6521.98Slukem # Massage the expression into ( $ignexpr ) -a -prune -o 6531.98Slukem if [ -n "${ignexpr}" ]; then 6541.98Slukem ignexpr=$(\ 6551.98Slukem echo $ignexpr | \ 6561.98Slukem sed -e 's/^-o /( /' \ 6571.98Slukem -e 's/$/ ) -a -prune -o/' \ 6581.98Slukem ) 6591.98Slukem fi 6601.98Slukem 6611.98Slukem find / $ignexpr \ 6621.21Smycroft \( \( -perm -u+s -a ! -type d \) -o \ 6631.21Smycroft \( -perm -g+s -a ! -type d \) -o \ 6641.24Slukem -type b -o -type c \) -print0 | \ 6651.98Slukem xargs -0 ls -ldgTq | sort +9 > $LIST 6661.98Slukem 6671.98Slukem ) 2> $OUTPUT 6681.15Smrg 6691.15Smrg # Display any errors that occurred during system file walk. 6701.15Smrg if [ -s $OUTPUT ] ; then 6711.28Slukem printf "Setuid/device find errors:\n" >> $ERR 6721.28Slukem cat $OUTPUT >> $ERR 6731.28Slukem printf "\n" >> $ERR 6741.15Smrg fi 6751.15Smrg 6761.15Smrg # Display any changes in the setuid file list. 6771.15Smrg egrep -v '^[bc]' $LIST > $TMP1 6781.15Smrg if [ -s $TMP1 ] ; then 6791.15Smrg # Check to make sure uudecode isn't setuid. 6801.15Smrg if grep -w uudecode $TMP1 > /dev/null ; then 6811.28Slukem printf "\nUudecode is setuid.\n" >> $ERR 6821.15Smrg fi 6831.15Smrg 6841.67Slukem file=$work_dir/setuid 6851.67Slukem migrate_file "$backup_dir/setuid" "$file" 6861.67Slukem CUR=${file}.current 6871.67Slukem BACK=${file}.backup 6881.15Smrg if [ -s $CUR ] ; then 6891.15Smrg if cmp -s $CUR $TMP1 ; then 6901.15Smrg : 6911.15Smrg else 6921.15Smrg > $TMP2 6931.15Smrg join -110 -210 -v2 $CUR $TMP1 > $OUTPUT 6941.15Smrg if [ -s $OUTPUT ] ; then 6951.28Slukem printf "Setuid additions:\n" >> $ERR 6961.28Slukem tee -a $TMP2 < $OUTPUT >> $ERR 6971.28Slukem printf "\n" >> $ERR 6981.15Smrg fi 6991.15Smrg 7001.15Smrg join -110 -210 -v1 $CUR $TMP1 > $OUTPUT 7011.15Smrg if [ -s $OUTPUT ] ; then 7021.28Slukem printf "Setuid deletions:\n" >> $ERR 7031.28Slukem tee -a $TMP2 < $OUTPUT >> $ERR 7041.28Slukem printf "\n" >> $ERR 7051.15Smrg fi 7061.15Smrg 7071.20Smycroft sort -k10 $TMP2 $CUR $TMP1 | \ 7081.27Slukem sed -e 's/[ ][ ]*/ /g' | \ 7091.27Slukem uniq -u > $OUTPUT 7101.15Smrg if [ -s $OUTPUT ] ; then 7111.28Slukem printf "Setuid changes:\n" >> $ERR 7121.28Slukem column -t $OUTPUT >> $ERR 7131.28Slukem printf "\n" >> $ERR 7141.15Smrg fi 7151.9Scgd 7161.52Satatat backup_file update $TMP1 $CUR $BACK 7171.9Scgd fi 7181.15Smrg else 7191.28Slukem printf "Setuid additions:\n" >> $ERR 7201.28Slukem column -t $TMP1 >> $ERR 7211.28Slukem printf "\n" >> $ERR 7221.52Satatat backup_file add $TMP1 $CUR $BACK 7231.9Scgd fi 7241.15Smrg fi 7251.15Smrg 7261.27Slukem # Check for block and character disk devices that are readable or 7271.80Swiz # writable or not owned by root.operator. 7281.15Smrg >$TMP1 7291.61Slukem DISKLIST="ccd ch hk hp ld md ra raid rb rd rl rx \ 7301.57Ssimonb sd se ss uk up vnd wd xd xy" 7311.27Slukem# DISKLIST="$DISKLIST ct mt st wt" 7321.15Smrg for i in $DISKLIST; do 7331.15Smrg egrep "^b.*/${i}[0-9][0-9]*[a-p]$" $LIST >> $TMP1 7341.15Smrg egrep "^c.*/r${i}[0-9][0-9]*[a-p]$" $LIST >> $TMP1 7351.15Smrg done 7361.15Smrg 7371.15Smrg awk '$3 != "root" || $4 != "operator" || $1 !~ /.rw-r-----/ \ 7381.25Slukem { printf "Disk %s is user %s, group %s, permissions %s.\n", \ 7391.25Slukem $11, $3, $4, $1; }' < $TMP1 > $OUTPUT 7401.15Smrg if [ -s $OUTPUT ] ; then 7411.28Slukem printf "\nChecking disk ownership and permissions.\n" >> $ERR 7421.28Slukem cat $OUTPUT >> $ERR 7431.28Slukem printf "\n" >> $ERR 7441.9Scgd fi 7451.9Scgd 7461.15Smrg # Display any changes in the device file list. 7471.20Smycroft egrep '^[bc]' $LIST | sort -k11 > $TMP1 7481.15Smrg if [ -s $TMP1 ] ; then 7491.67Slukem file=$work_dir/device 7501.67Slukem migrate_file "$backup_dir/device" "$file" 7511.67Slukem CUR=${file}.current 7521.67Slukem BACK=${file}.backup 7531.15Smrg 7541.15Smrg if [ -s $CUR ] ; then 7551.15Smrg if cmp -s $CUR $TMP1 ; then 7561.15Smrg : 7571.15Smrg else 7581.15Smrg > $TMP2 7591.15Smrg join -111 -211 -v2 $CUR $TMP1 > $OUTPUT 7601.15Smrg if [ -s $OUTPUT ] ; then 7611.28Slukem printf "Device additions:\n" >> $ERR 7621.28Slukem tee -a $TMP2 < $OUTPUT >> $ERR 7631.28Slukem printf "\n" >> $ERR 7641.15Smrg fi 7651.15Smrg 7661.15Smrg join -111 -211 -v1 $CUR $TMP1 > $OUTPUT 7671.15Smrg if [ -s $OUTPUT ] ; then 7681.28Slukem printf "Device deletions:\n" >> $ERR 7691.28Slukem tee -a $TMP2 < $OUTPUT >> $ERR 7701.28Slukem printf "\n" >> $ERR 7711.15Smrg fi 7721.15Smrg 7731.27Slukem # Report any block device change. Ignore 7741.27Slukem # character devices, only the name is 7751.27Slukem # significant. 7761.15Smrg cat $TMP2 $CUR $TMP1 | \ 7771.27Slukem sed -e '/^c/d' | \ 7781.27Slukem sort -k11 | \ 7791.27Slukem sed -e 's/[ ][ ]*/ /g' | \ 7801.27Slukem uniq -u > $OUTPUT 7811.15Smrg if [ -s $OUTPUT ] ; then 7821.28Slukem printf "Block device changes:\n" >> $ERR 7831.28Slukem column -t $OUTPUT >> $ERR 7841.28Slukem printf "\n" >> $ERR 7851.15Smrg fi 7861.9Scgd 7871.52Satatat backup_file update $TMP1 $CUR $BACK 7881.9Scgd fi 7891.15Smrg else 7901.28Slukem printf "Device additions:\n" >> $ERR 7911.28Slukem column -t $TMP1 >> $ERR 7921.28Slukem printf "\n" >> $ERR 7931.52Satatat backup_file add $TMP1 $CUR $BACK >> $ERR 7941.9Scgd fi 7951.28Slukem fi 7961.28Slukem if [ -s $ERR ] ; then 7971.28Slukem printf "\nChecking setuid files and devices:\n" 7981.28Slukem cat $ERR 7991.28Slukem printf "\n" 8001.9Scgd fi 8011.9Scgdfi 8021.9Scgd 8031.9Scgd# Check special files. 8041.9Scgd# Check system binaries. 8051.9Scgd# 8061.9Scgd# Create the mtree tree specifications using: 8071.67Slukem# mtree -cx -pDIR -kmd5,uid,gid,mode,nlink,size,link,time > DIR.secure 8081.38Skleink# chown root:wheel DIR.secure 8091.67Slukem# chmod u+r,go= DIR.secure 8101.9Scgd# 8111.9Scgd# Note, this is not complete protection against Trojan horsed binaries, as 8121.9Scgd# the hacker can modify the tree specification to match the replaced binary. 8131.9Scgd# For details on really protecting yourself against modified binaries, see 8141.9Scgd# the mtree(8) manual page. 8151.32Slukem# 8161.31Slukemif checkyesno check_mtree; then 8171.82Sjhawk if checkyesno check_mtree_follow_symlinks; then 8181.82Sjhawk check_mtree_flags="-L" 8191.82Sjhawk else 8201.82Sjhawk check_mtree_flags="" 8211.82Sjhawk fi 8221.91Slukem mtree -e -l -p / $check_mtree_flags -f $SPECIALSPEC 3>&1 >$OUTPUT 2>&3 | 8231.87Sjhawk grep -v '^mtree: dev/tty: Device not configured$' >&2 8241.15Smrg if [ -s $OUTPUT ]; then 8251.9Scgd printf "\nChecking special files and directories.\n" 8261.9Scgd cat $OUTPUT 8271.9Scgd fi 8281.9Scgd 8291.16Smikel for file in /etc/mtree/*.secure; do 8301.16Smikel [ $file = '/etc/mtree/*.secure' ] && continue 8311.9Scgd tree=`sed -n -e '3s/.* //p' -e 3q $file` 8321.82Sjhawk mtree $check_mtree_flags -f $file -p $tree > $TMP1 8331.9Scgd if [ -s $TMP1 ]; then 8341.67Slukem printf "\nChecking $tree:\n" 8351.67Slukem cat $TMP1 8361.9Scgd fi 8371.67Slukem done > $OUTPUT 8381.15Smrg if [ -s $OUTPUT ]; then 8391.9Scgd printf "\nChecking system binaries:\n" 8401.9Scgd cat $OUTPUT 8411.9Scgd fi 8421.9Scgdfi 8431.9Scgd 8441.32Slukem# Backup disklabels of available disks 8451.32Slukem# 8461.32Slukemif checkyesno check_disklabels; then 8471.67Slukem # migrate old disklabels 8481.67Slukem for file in `ls -1d $backup_dir/$backup_dir/disklabel.* \ 8491.67Slukem $backup_dir/disklabel.* 2>/dev/null`; do 8501.67Slukem migrate_file "$file" "$work_dir/${file##*/}" 8511.67Slukem done 8521.67Slukem 8531.103Stron # generate list of old disklabels, fdisks & wedges and remove them 8541.103Stron ls -1d $work_dir/disklabel.* $work_dir/fdisk.* $work_dir/wedges.* 2>/dev/null | 8551.52Satatat egrep -v '\.(backup|current)(,v)?$' > $LABELS 8561.32Slukem xargs rm < $LABELS 8571.32Slukem 8581.103Stron # generate disklabels of all disks excluding: cd dk fd md st 8591.103Stron disks=`iostat -x | awk 'NR > 1 && $1 !~ /^[cfm]d|dk|st|nfs/ { print $1; }'` 8601.32Slukem for i in $disks; do 8611.67Slukem disklabel $i > "$work_dir/disklabel.$i" 2>/dev/null 8621.32Slukem done 8631.32Slukem 8641.67Slukem # if fdisk is available, generate fdisks for: ed ld sd wd 8651.67Slukem if [ -x /sbin/fdisk ]; then 8661.67Slukem disks=`iostat -x| awk 'NR > 1 && $1 ~ /^[elsw]d/ { print $1; }'` 8671.67Slukem for i in $disks; do 8681.67Slukem /sbin/fdisk $i > "$work_dir/fdisk.$i" 2>/dev/null 8691.67Slukem done 8701.67Slukem fi 8711.67Slukem 8721.103Stron # if dkctl is available, generate dkctl listwedges for: ed ld sd wd cgd ofdisk ra rl raid 8731.103Stron if [ -x /sbin/dkctl ]; then 8741.103Stron disks=`iostat -x| awk 'NR > 1 && $1 ~ /^[elsw]d|cgd|ofdisk|r[al]|raid/ { print $1; }'` 8751.103Stron for i in $disks; do 8761.103Stron /sbin/dkctl $i listwedges > "$work_dir/wedges.$i" 2>/dev/null 8771.103Stron done 8781.103Stron fi 8791.103Stron 8801.103Stron # append list of new disklabels, fdisks and wedges 8811.103Stron ls -1d $work_dir/disklabel.* $work_dir/fdisk.* $work_dir/wedges.* 2>/dev/null | 8821.52Satatat egrep -v '\.(backup|current)(,v)?$' >> $LABELS 8831.62Satatat CHANGELIST="$LABELS $CHANGELIST" 8841.62Satatatfi 8851.62Satatat 8861.62Satatat# Check for changes in the list of installed pkgs 8871.62Satatat# 8881.65Slukemif checkyesno check_pkgs && [ -d $pkgdb_dir ]; then 8891.67Slukem pkgs=$work_dir/pkgs 8901.67Slukem migrate_file "$backup_dir/pkgs" "$pkgs" 8911.65Slukem ( cd $pkgdb_dir 8921.104Sadrianp $pkg_info | sort 8931.62Satatat echo "" 8941.62Satatat find . \( -name +REQUIRED_BY -o -name +CONTENTS \) -print0 | 8951.72Slukem xargs -0 ls -ldgTq | sort -t. +1 | sed -e 's, \./, ,' 8961.62Satatat ) > $pkgs 8971.67Slukem echo "$pkgs" > $PKGS 8981.62Satatat CHANGELIST="$PKGS $CHANGELIST" 8991.32Slukemfi 9001.32Slukem 9011.67Slukem# List of files that get backed up and checked for any modifications. 9021.9Scgd# Any changes cause the files to rotate. 9031.32Slukem# 9041.67Slukemif checkyesno check_changelist ; then 9051.91Slukem mtree -D -k type -f $SPECIALSPEC -E exclude | 9061.91Slukem sed '/^type=file/!d ; s/type=file \.//' | unvis > $CHANGEFILES 9071.67Slukem 9081.75Slukem ( 9091.68Slukem # Add other files which might dynamically exist: 9101.67Slukem # /etc/ifconfig.* 9111.67Slukem # /etc/raid*.conf 9121.68Slukem # /etc/rc.d/* 9131.67Slukem # /etc/rc.conf.d/* 9141.68Slukem # 9151.75Slukem echo "/etc/ifconfig.*" 9161.75Slukem echo "/etc/raid*.conf" 9171.75Slukem echo "/etc/rc.d/*" 9181.75Slukem echo "/etc/rc.conf.d/*" 9191.67Slukem 9201.68Slukem # Add /etc/changelist 9211.68Slukem # 9221.75Slukem if [ -s /etc/changelist ]; then 9231.75Slukem grep -v '^#' /etc/changelist 9241.75Slukem fi 9251.75Slukem ) | while read file; do 9261.75Slukem case "$file" in 9271.75Slukem *[\*\?\[]*) # If changelist line is a glob ... 9281.75Slukem # ... expand possible backup files 9291.75Slukem # 9301.75Slukem ls -1d $(echo $backup_dir/${file}.current) 2>/dev/null \ 9311.75Slukem | sed "s,^$backup_dir/,, ; s,\.current$,," 9321.75Slukem 9331.75Slukem # ... expand possible files 9341.75Slukem # 9351.75Slukem ls -1d $(echo $file) 2>/dev/null 9361.75Slukem ;; 9371.75Slukem *) 9381.75Slukem # Otherwise, just print the filename 9391.75Slukem echo $file 9401.75Slukem ;; 9411.75Slukem esac 9421.75Slukem done >> $CHANGEFILES 9431.67Slukem CHANGELIST="$CHANGEFILES $CHANGELIST" 9441.67Slukemfi 9451.67Slukem 9461.67Slukem# Special case backups, including the master password file and 9471.67Slukem# ssh private host keys. The normal backup mechanisms for 9481.67Slukem# $check_changelist (see below) also print out the actual file 9491.67Slukem# differences and we don't want to do that for these files 9501.67Slukem# 9511.67Slukemecho $MP > $TMP1 # always add /etc/master.passwd 9521.91Slukemmtree -D -k type -f $SPECIALSPEC -I nodiff | 9531.91Slukem sed '/^type=file/!d ; s/type=file \.//' | unvis >> $TMP1 9541.73Slukemgrep -v '^$' $TMP1 | sort -u > $TMP2 9551.68Slukem 9561.69Slukemwhile read file; do 9571.67Slukem backup_and_diff "$file" no 9581.69Slukemdone < $TMP2 9591.67Slukem 9601.32Slukem 9611.32Slukemif [ -n "$CHANGELIST" ]; then 9621.73Slukem grep -h -v '^$' $CHANGELIST | sort -u > $TMP1 9631.68Slukem comm -23 $TMP1 $TMP2 | while read file; do 9641.67Slukem backup_and_diff "$file" yes 9651.9Scgd done 9661.44Sadfi 9671.44Sad 9681.44Sadif [ -f /etc/security.local ]; then 9691.90Skim . /etc/security.local > $OUTPUT 2>&1 9701.84Sjhawk if [ -s $OUTPUT ] ; then 9711.84Sjhawk printf "\nRunning /etc/security.local:\n" 9721.84Sjhawk cat $OUTPUT 9731.84Sjhawk fi 9741.9Scgdfi 975