security revision 1.53
1#!/bin/sh - 2# 3# $NetBSD: security,v 1.53 2001/05/10 14:10:15 atatat Exp $ 4# from: @(#)security 8.1 (Berkeley) 6/9/93 5# 6 7PATH=/sbin:/usr/sbin:/bin:/usr/bin 8 9if [ -f /etc/rc.subr ]; then 10 . /etc/rc.subr 11else 12 echo "Can't read /etc/rc.subr; aborting." 13 exit 1; 14fi 15 16umask 077 17 18if [ -s /etc/security.conf ]; then 19 . /etc/security.conf 20fi 21 22SECUREDIR=/tmp/_securedir.$$ 23if ! mkdir $SECUREDIR; then 24 echo can not create $SECUREDIR. 25 exit 1 26fi 27 28if ! cd $SECUREDIR; then 29 echo can not chdir to $SECUREDIR. 30 exit 1 31fi 32 33if [ -z "$max_loginlen" ];then 34 max_loginlen=8 35fi 36 37if [ -z "$max_grouplen" ]; then 38 max_grouplen=8 39fi 40 41ERR=secure1.$$ 42TMP1=secure2.$$ 43TMP2=secure3.$$ 44MPBYUID=secure4.$$ 45MPBYPATH=secure5.$$ 46LIST=secure6.$$ 47OUTPUT=secure7.$$ 48LABELS=secure8.$$ 49 50trap '/bin/rm -rf $SECUREDIR ; exit 0' 0 2 3 51 52# Handle backup_dir not being set in .conf file 53backup_dir=${backup_dir:-/var/backups} 54 55MP=/etc/master.passwd 56 57# these is used several times. 58awk -F: '!/^+/ { print $1 " " $3 }' $MP | sort -k2n > $MPBYUID 59awk -F: '{ print $1 " " $9 }' $MP | sort -k2 > $MPBYPATH 60 61# Check the master password file syntax. 62# 63if checkyesno check_passwd; then 64 awk -v "len=$max_loginlen" ' 65 BEGIN { 66 while ( getline < "/etc/shells" > 0 ) { 67 if ($0 ~ /^\#/ || $0 ~ /^$/ ) 68 continue; 69 shells[$1]++; 70 } 71 FS=":"; 72 } 73 74 { 75 if ($0 ~ /^[ ]*$/) { 76 printf "Line %d is a blank line.\n", NR; 77 next; 78 } 79 if (NF != 10 && ($1 != "+" || NF != 1)) 80 printf "Line %d has the wrong number of fields.\n", NR; 81 if ($1 == "+" ) { 82 if (NF != 1 && $3 == 0) 83 printf "Line %d includes entries with uid 0.\n", NR; 84 next; 85 } 86 if ($1 !~ /^[A-Za-z0-9]([-A-Za-z0-9]*[A-Za-z0-9])*$/) 87 printf "Login %s has non-alphanumeric characters.\n", 88 $1; 89 if (length($1) > len) 90 printf "Login %s has more than "len" characters.\n", $1; 91 if ($2 == "") 92 printf "Login %s has no password.\n", $1; 93 if (length($2) != 13 && length($2) != 20 && length($2) != 34 && $2 != "") { 94 if ($10 == "" || shells[$10]) 95 printf "Login %s is off but still has a valid shell (%s)\n", 96 $1, $10; 97 } else if (! shells[$10]) 98 printf "Login %s does not have a valid shell (%s)\n", 99 $1, $10; 100 if ($3 == 0 && $1 != "root" && $1 != "toor") 101 printf "Login %s has a user id of 0.\n", $1; 102 if ($3 < 0) 103 printf "Login %s has a negative user id.\n", $1; 104 if ($4 < 0) 105 printf "Login %s has a negative group id.\n", $1; 106 }' < $MP > $OUTPUT 107 if [ -s $OUTPUT ] ; then 108 printf "\nChecking the $MP file:\n" 109 cat $OUTPUT 110 fi 111 112 awk -F: '{ print $1 }' $MP | sort | uniq -d > $OUTPUT 113 if [ -s $OUTPUT ] ; then 114 printf "\n$MP has duplicate user names.\n" 115 column $OUTPUT 116 fi 117 118# To not exclude 'toor', a standard duplicate root account, from the duplicate 119# account test, uncomment the line below (without egrep in it)and comment 120# out the line (with egrep in it) below it. 121# 122# < $MPBYUID uniq -d -f 1 | awk '{ print $2 }' > $TMP2 123 < $MPBYUID egrep -v '^toor ' | uniq -d -f 1 | awk '{ print $2 }' > $TMP2 124 if [ -s $TMP2 ] ; then 125 printf "\n$MP has duplicate user id's.\n" 126 while read uid; do 127 grep -w $uid $MPBYUID 128 done < $TMP2 | column 129 fi 130fi 131 132# Backup the master password file; a special case, the normal backup 133# mechanisms also print out file differences and we don't want to do 134# that because this file has encrypted passwords in it. 135# 136CUR=$backup_dir/${MP##*/}.current 137BACK=$backup_dir/${MP##*/}.backup 138if [ -s $CUR ] ; then 139 if cmp -s $CUR $MP; then 140 : 141 else 142 backup_file update $MP $CUR $BACK 143 fi 144else 145 backup_file add $MP $CUR $BACK 146fi 147 148# Check the group file syntax. 149# 150if checkyesno check_group; then 151 GRP=/etc/group 152 awk -F: -v "len=$max_grouplen" '{ 153 if ($0 ~ /^[ ]*$/) { 154 printf "Line %d is a blank line.\n", NR; 155 next; 156 } 157 if (NF != 4 && ($1 != "+" || NF != 1)) 158 printf "Line %d has the wrong number of fields.\n", NR; 159 if ($1 == "+" ) { 160 next; 161 } 162 if ($1 !~ /^[A-Za-z0-9]([-A-Za-z0-9]*[A-Za-z0-9])*$/) 163 printf "Group %s has non-alphanumeric characters.\n", 164 $1; 165 if (length($1) > len) 166 printf "Group %s has more than "len" characters.\n", $1; 167 if ($3 !~ /[0-9]*/) 168 printf "Login %s has a negative group id.\n", $1; 169 }' < $GRP > $OUTPUT 170 if [ -s $OUTPUT ] ; then 171 printf "\nChecking the $GRP file:\n" 172 cat $OUTPUT 173 fi 174 175 awk -F: '{ print $1 }' $GRP | sort | uniq -d > $OUTPUT 176 if [ -s $OUTPUT ] ; then 177 printf "\n$GRP has duplicate group names.\n" 178 column $OUTPUT 179 fi 180fi 181 182# Check for root paths, umask values in startup files. 183# The check for the root paths is problematical -- it's likely to fail 184# in other environments. Once the shells have been modified to warn 185# of '.' in the path, the path tests should go away. 186# 187if checkyesno check_rootdotfiles; then 188 > $OUTPUT 189 rhome=`csh -fc "echo ~root"` 190 umaskset=no 191 list="/etc/csh.cshrc /etc/csh.login ${rhome}/.cshrc ${rhome}/.login" 192 for i in $list ; do 193 if [ -f $i ] ; then 194 if egrep '^[ \t]*umask[ \t]+[0-7]+' $i > /dev/null ; then 195 umaskset=yes 196 fi 197 # double check the umask value itself; ensure that both the 198 # 020 and 002 bits are set. 199 # we handle this in decimal initially to extract the digits, 200 # and then extract the `2' bit of each digit. 201 # this is made especially painful because 202 # bitwise operations were left out of awk. 203 egrep '^[ \t]*umask[ \t]+[0-7]+' $i | 204 awk '{ g= ($2 % 100) - ($2 % 10); 205 g /= 10; 206 g = g % 4; 207 g -= g % 2; 208 if (g != 2) { print "\tRoot umask is group writeable" } 209 o = ($2 % 10); 210 o = o % 4; 211 o -= o % 2; 212 if (o != 2) { print "\tRoot umask is other writeable" } }' | 213 sort -u >> $OUTPUT 214 SAVE_PATH=$PATH 215 unset PATH 216 /bin/csh -f -s << end-of-csh > /dev/null 2>&1 217 source $i 218 /bin/ls -ldgT \$path > $TMP1 219end-of-csh 220 PATH=$SAVE_PATH 221 awk '{ 222 if ($10 ~ /^\.$/) { 223 print "\tThe root path includes ."; 224 next; 225 } 226 } 227 $1 ~ /^d....w/ \ 228 { print "\tRoot path directory " $10 " is group writeable." } \ 229 $1 ~ /^d.......w/ \ 230 { print "\tRoot path directory " $10 " is other writeable." }' \ 231 < $TMP1 >> $OUTPUT 232 fi 233 done 234 if [ $umaskset = "no" -o -s $OUTPUT ] ; then 235 printf "\nChecking root csh paths, umask values:\n$list\n\n" 236 if [ -s $OUTPUT ]; then 237 cat $OUTPUT 238 fi 239 if [ $umaskset = "no" ] ; then 240 printf "\tRoot csh startup files do not set the umask.\n" 241 fi 242 fi 243 244 > $OUTPUT 245 rhome=/root 246 umaskset=no 247 list="/etc/profile ${rhome}/.profile" 248 for i in $list; do 249 if [ -f $i ] ; then 250 if egrep umask $i > /dev/null ; then 251 umaskset=yes 252 fi 253 egrep umask $i | 254 awk '$2 % 100 < 20 \ 255 { print "\tRoot umask is group writeable" } \ 256 $2 % 10 < 2 \ 257 { print "\tRoot umask is other writeable" }' \ 258 >> $OUTPUT 259 SAVE_PATH=$PATH 260 unset PATH 261 /bin/sh << end-of-sh > /dev/null 2>&1 262 . $i 263 list=\`echo \$PATH | /usr/bin/sed -e \ 264 's/^:/.:/;s/:$/:./;s/::/:.:/g;s/:/ /g'\` 265 /bin/ls -ldgT \$list > $TMP1 266end-of-sh 267 PATH=$SAVE_PATH 268 awk '{ 269 if ($10 ~ /^\.$/) { 270 print "\tThe root path includes ."; 271 next; 272 } 273 } 274 $1 ~ /^d....w/ \ 275 { print "\tRoot path directory " $10 " is group writeable." } \ 276 $1 ~ /^d.......w/ \ 277 { print "\tRoot path directory " $10 " is other writeable." }' \ 278 < $TMP1 >> $OUTPUT 279 280 fi 281 done 282 if [ $umaskset = "no" -o -s $OUTPUT ] ; then 283 printf "\nChecking root sh paths, umask values:\n$list\n" 284 if [ -s $OUTPUT ]; then 285 cat $OUTPUT 286 fi 287 if [ $umaskset = "no" ] ; then 288 printf "\tRoot sh startup files do not set the umask.\n" 289 fi 290 fi 291fi 292 293# Root and uucp should both be in /etc/ftpusers. 294# 295if checkyesno check_ftpusers; then 296 > $OUTPUT 297 list="uucp "`awk '$2 == 0 { print $1 }' $MPBYUID` 298 for i in $list; do 299 if /usr/libexec/ftpd -C $i ; then 300 printf "\t$i is not denied\n" >> $OUTPUT 301 fi 302 done 303 if [ -s $OUTPUT ]; then 304 printf "\nChecking the /etc/ftpusers configuration:\n" 305 cat $OUTPUT 306 fi 307fi 308 309# Uudecode should not be in the /etc/mail/aliases file. 310# 311if checkyesno check_aliases; then 312 for f in /etc/mail/aliases /etc/aliases; do 313 if [ -f $f ] && egrep '^[^#]*(uudecode|decode).*\|' $f; then 314 printf "\nEntry for uudecode in $f file.\n" 315 fi 316 done 317fi 318 319# Files that should not have + signs. 320# 321if checkyesno check_rhosts; then 322 list="/etc/hosts.equiv /etc/hosts.lpd" 323 for f in $list ; do 324 if [ -f $f ] && egrep '\+' $f > /dev/null ; then 325 printf "\nPlus sign in $f file.\n" 326 fi 327 done 328 329 # Check for special users with .rhosts files. Only root and toor should 330 # have .rhosts files. Also, .rhosts files should not have plus signs. 331 awk -F: '$1 != "root" && $1 != "toor" && \ 332 ($3 < 100 || $1 == "ftp" || $1 == "uucp") \ 333 { print $1 " " $9 }' $MP | 334 sort -k2 | 335 while read uid homedir; do 336 if [ -f ${homedir}/.rhosts ] ; then 337 rhost=`ls -ldgT ${homedir}/.rhosts` 338 printf -- "$uid: $rhost\n" 339 fi 340 done > $OUTPUT 341 if [ -s $OUTPUT ] ; then 342 printf "\nChecking for special users with .rhosts files.\n" 343 cat $OUTPUT 344 fi 345 346 while read uid homedir; do 347 if [ -f ${homedir}/.rhosts -a -r ${homedir}/.rhosts ] && \ 348 cat -f ${homedir}/.rhosts | egrep '\+' > /dev/null ; then 349 printf -- "$uid: + in .rhosts file.\n" 350 fi 351 done < $MPBYPATH > $OUTPUT 352 if [ -s $OUTPUT ] ; then 353 printf "\nChecking .rhosts files syntax.\n" 354 cat $OUTPUT 355 fi 356fi 357 358# Check home directories. Directories should not be owned by someone else 359# or writeable. 360# 361if checkyesno check_homes; then 362 while read uid homedir; do 363 if [ -d ${homedir}/ ] ; then 364 file=`ls -ldgT ${homedir}` 365 printf -- "$uid $file\n" 366 fi 367 done < $MPBYPATH | 368 awk '$1 != $4 && $4 != "root" \ 369 { print "user " $1 " home directory is owned by " $4 } 370 $2 ~ /^-....w/ \ 371 { print "user " $1 " home directory is group writeable" } 372 $2 ~ /^-.......w/ \ 373 { print "user " $1 " home directory is other writeable" }' \ 374 > $OUTPUT 375 if [ -s $OUTPUT ] ; then 376 printf "\nChecking home directories.\n" 377 cat $OUTPUT 378 fi 379 380 # Files that should not be owned by someone else or readable. 381 list=".Xauthority .netrc" 382 while read uid homedir; do 383 for f in $list ; do 384 file=${homedir}/${f} 385 if [ -f $file ] ; then 386 printf -- "$uid $f `ls -ldgT $file`\n" 387 fi 388 done 389 done < $MPBYPATH | 390 awk '$1 != $5 && $5 != "root" \ 391 { print "user " $1 " " $2 " file is owned by " $5 } 392 $3 ~ /^-...r/ \ 393 { print "user " $1 " " $2 " file is group readable" } 394 $3 ~ /^-......r/ \ 395 { print "user " $1 " " $2 " file is other readable" } 396 $3 ~ /^-....w/ \ 397 { print "user " $1 " " $2 " file is group writeable" } 398 $3 ~ /^-.......w/ \ 399 { print "user " $1 " " $2 " file is other writeable" }' \ 400 > $OUTPUT 401 402 # Files that should not be owned by someone else or writeable. 403 list=".bash_history .bash_login .bash_logout .bash_profile .bashrc \ 404 .cshrc .emacs .exrc .forward .history .klogin .login .logout \ 405 .profile .qmail .rc_history .rhosts .tcshrc .twmrc .xinitrc \ 406 .xsession" 407 while read uid homedir; do 408 for f in $list ; do 409 file=${homedir}/${f} 410 if [ -f $file ] ; then 411 printf -- "$uid $f `ls -ldgT $file`\n" 412 fi 413 done 414 done < $MPBYPATH | 415 awk '$1 != $5 && $5 != "root" \ 416 { print "user " $1 " " $2 " file is owned by " $5 } 417 $3 ~ /^-....w/ \ 418 { print "user " $1 " " $2 " file is group writeable" } 419 $3 ~ /^-.......w/ \ 420 { print "user " $1 " " $2 " file is other writeable" }' \ 421 >> $OUTPUT 422 if [ -s $OUTPUT ] ; then 423 printf "\nChecking dot files.\n" 424 cat $OUTPUT 425 fi 426fi 427 428# Mailboxes should be owned by user and unreadable. 429# 430if checkyesno check_varmail; then 431 ls -l /var/mail | sed 1d | \ 432 awk '$3 != $9 \ 433 { print "user " $9 " mailbox is owned by " $3 } 434 $1 != "-rw-------" \ 435 { print "user " $9 " mailbox is " $1 ", group " $4 }' > $OUTPUT 436 if [ -s $OUTPUT ] ; then 437 printf "\nChecking mailbox ownership.\n" 438 cat $OUTPUT 439 fi 440fi 441 442# NFS exports shouldn't be globally exported 443# 444if checkyesno check_nfs && [ -f /etc/exports ]; then 445 awk '{ 446 # ignore comments and blank lines 447 if ($0 ~ /^\#/ || $0 ~ /^$/ ) 448 next; 449 450 readonly = 0; 451 for (i = 2; i <= NF; ++i) { 452 if ($i ~ /-ro/) 453 readonly = 1; 454 else if ($i !~ /^-/) 455 next; 456 } 457 if (readonly) 458 print "File system " $1 " globally exported, read-only." 459 else 460 print "File system " $1 " globally exported, read-write." 461 }' < /etc/exports > $OUTPUT 462 if [ -s $OUTPUT ] ; then 463 printf "\nChecking for globally exported file systems.\n" 464 cat $OUTPUT 465 fi 466fi 467 468# Display any changes in setuid files and devices. 469# 470if checkyesno check_devices; then 471 > $ERR 472 (find / \( ! -fstype local -o -fstype fdesc -o -fstype kernfs \ 473 -o -fstype procfs \) -a -prune -o \ 474 \( \( -perm -u+s -a ! -type d \) -o \ 475 \( -perm -g+s -a ! -type d \) -o \ 476 -type b -o -type c \) -print0 | \ 477 xargs -0 ls -ldgTq | sort +9 > $LIST) 2> $OUTPUT 478 479 # Display any errors that occurred during system file walk. 480 if [ -s $OUTPUT ] ; then 481 printf "Setuid/device find errors:\n" >> $ERR 482 cat $OUTPUT >> $ERR 483 printf "\n" >> $ERR 484 fi 485 486 # Display any changes in the setuid file list. 487 egrep -v '^[bc]' $LIST > $TMP1 488 if [ -s $TMP1 ] ; then 489 # Check to make sure uudecode isn't setuid. 490 if grep -w uudecode $TMP1 > /dev/null ; then 491 printf "\nUudecode is setuid.\n" >> $ERR 492 fi 493 494 CUR=$backup_dir/setuid.current 495 BACK=$backup_dir/setuid.backup 496 497 if [ -s $CUR ] ; then 498 if cmp -s $CUR $TMP1 ; then 499 : 500 else 501 > $TMP2 502 join -110 -210 -v2 $CUR $TMP1 > $OUTPUT 503 if [ -s $OUTPUT ] ; then 504 printf "Setuid additions:\n" >> $ERR 505 tee -a $TMP2 < $OUTPUT >> $ERR 506 printf "\n" >> $ERR 507 fi 508 509 join -110 -210 -v1 $CUR $TMP1 > $OUTPUT 510 if [ -s $OUTPUT ] ; then 511 printf "Setuid deletions:\n" >> $ERR 512 tee -a $TMP2 < $OUTPUT >> $ERR 513 printf "\n" >> $ERR 514 fi 515 516 sort -k10 $TMP2 $CUR $TMP1 | \ 517 sed -e 's/[ ][ ]*/ /g' | \ 518 uniq -u > $OUTPUT 519 if [ -s $OUTPUT ] ; then 520 printf "Setuid changes:\n" >> $ERR 521 column -t $OUTPUT >> $ERR 522 printf "\n" >> $ERR 523 fi 524 525 backup_file update $TMP1 $CUR $BACK 526 fi 527 else 528 printf "Setuid additions:\n" >> $ERR 529 column -t $TMP1 >> $ERR 530 printf "\n" >> $ERR 531 backup_file add $TMP1 $CUR $BACK 532 fi 533 fi 534 535 # Check for block and character disk devices that are readable or 536 # writeable or not owned by root.operator. 537 >$TMP1 538 DISKLIST="acd ccd cd ch fd hk hp mcd md ra rb rd rl rx rz \ 539 sd se ss tz uk up vnd wd xd xy" 540# DISKLIST="$DISKLIST ct mt st wt" 541 for i in $DISKLIST; do 542 egrep "^b.*/${i}[0-9][0-9]*[a-p]$" $LIST >> $TMP1 543 egrep "^c.*/r${i}[0-9][0-9]*[a-p]$" $LIST >> $TMP1 544 done 545 546 awk '$3 != "root" || $4 != "operator" || $1 !~ /.rw-r-----/ \ 547 { printf "Disk %s is user %s, group %s, permissions %s.\n", \ 548 $11, $3, $4, $1; }' < $TMP1 > $OUTPUT 549 if [ -s $OUTPUT ] ; then 550 printf "\nChecking disk ownership and permissions.\n" >> $ERR 551 cat $OUTPUT >> $ERR 552 printf "\n" >> $ERR 553 fi 554 555 # Display any changes in the device file list. 556 egrep '^[bc]' $LIST | sort -k11 > $TMP1 557 if [ -s $TMP1 ] ; then 558 CUR=$backup_dir/device.current 559 BACK=$backup_dir/device.backup 560 561 if [ -s $CUR ] ; then 562 if cmp -s $CUR $TMP1 ; then 563 : 564 else 565 > $TMP2 566 join -111 -211 -v2 $CUR $TMP1 > $OUTPUT 567 if [ -s $OUTPUT ] ; then 568 printf "Device additions:\n" >> $ERR 569 tee -a $TMP2 < $OUTPUT >> $ERR 570 printf "\n" >> $ERR 571 fi 572 573 join -111 -211 -v1 $CUR $TMP1 > $OUTPUT 574 if [ -s $OUTPUT ] ; then 575 printf "Device deletions:\n" >> $ERR 576 tee -a $TMP2 < $OUTPUT >> $ERR 577 printf "\n" >> $ERR 578 fi 579 580 # Report any block device change. Ignore 581 # character devices, only the name is 582 # significant. 583 cat $TMP2 $CUR $TMP1 | \ 584 sed -e '/^c/d' | \ 585 sort -k11 | \ 586 sed -e 's/[ ][ ]*/ /g' | \ 587 uniq -u > $OUTPUT 588 if [ -s $OUTPUT ] ; then 589 printf "Block device changes:\n" >> $ERR 590 column -t $OUTPUT >> $ERR 591 printf "\n" >> $ERR 592 fi 593 594 backup_file update $TMP1 $CUR $BACK 595 fi 596 else 597 printf "Device additions:\n" >> $ERR 598 column -t $TMP1 >> $ERR 599 printf "\n" >> $ERR 600 backup_file add $TMP1 $CUR $BACK >> $ERR 601 fi 602 fi 603 if [ -s $ERR ] ; then 604 printf "\nChecking setuid files and devices:\n" 605 cat $ERR 606 printf "\n" 607 fi 608fi 609 610# Check special files. 611# Check system binaries. 612# 613# Create the mtree tree specifications using: 614# 615# mtree -cx -pDIR -kcksum,gid,mode,nlink,size,link,time,uid > DIR.secure 616# chown root:wheel DIR.secure 617# chmod 600 DIR.secure 618# 619# Note, this is not complete protection against Trojan horsed binaries, as 620# the hacker can modify the tree specification to match the replaced binary. 621# For details on really protecting yourself against modified binaries, see 622# the mtree(8) manual page. 623# 624if checkyesno check_mtree; then 625 mtree -e -p / -f /etc/mtree/special > $OUTPUT 626 if [ -s $OUTPUT ]; then 627 printf "\nChecking special files and directories.\n" 628 cat $OUTPUT 629 fi 630 631 > $OUTPUT 632 for file in /etc/mtree/*.secure; do 633 [ $file = '/etc/mtree/*.secure' ] && continue 634 tree=`sed -n -e '3s/.* //p' -e 3q $file` 635 mtree -f $file -p $tree > $TMP1 636 if [ -s $TMP1 ]; then 637 printf "\nChecking $tree:\n" >> $OUTPUT 638 cat $TMP1 >> $OUTPUT 639 fi 640 done 641 if [ -s $OUTPUT ]; then 642 printf "\nChecking system binaries:\n" 643 cat $OUTPUT 644 fi 645fi 646 647CHANGELIST="" 648 649# Backup disklabels of available disks 650# 651if checkyesno check_disklabels; then 652 # generate list of old disklabels and remove them 653 ls -1d $backup_dir/disklabel.* 2>/dev/null | 654 egrep -v '\.(backup|current)(,v)?$' > $LABELS 655 xargs rm < $LABELS 656 657 disks=`iostat -x | sed 1d | awk '$1 !~ /^[cfm]d/ { print $1; }'` 658 for i in $disks; do 659 dlf="$backup_dir/disklabel.$i" 660 disklabel $i > $dlf 2>/dev/null 661 done 662 663 # append list of new disklabels, sort list 664 ls -1d $backup_dir/disklabel.* 2>/dev/null | 665 egrep -v '\.(backup|current)(,v)?$' >> $LABELS 666 sort -u -o $LABELS $LABELS 667 CHANGELIST=$LABELS 668fi 669 670# List of files that get backed up and checked for any modifications. Each 671# file is expected to have two backups, $backup_dir/file.{current,backup}. 672# Any changes cause the files to rotate. 673# 674if checkyesno check_changelist && [ -s /etc/changelist ] ; then 675 CHANGELIST="/etc/changelist $CHANGELIST" 676fi 677 678if [ -n "$CHANGELIST" ]; then 679 for file in `egrep -hv "^#|$MP" $CHANGELIST`; do 680 CUR=$backup_dir/${file##*/}.current 681 BACK=$backup_dir/${file##*/}.backup 682 if [ -f $file ]; then 683 if [ -f $CUR ] ; then 684 diff $CUR $file > $OUTPUT 685 if [ -s $OUTPUT ] ; then 686 printf "\n======\n%s diffs (OLD < > NEW)\n======\n" $file 687 cat $OUTPUT 688 backup_file update $file $CUR $BACK 689 fi 690 else 691 printf "\n======\n%s added\n======\n" $file 692 diff /dev/null $file 693 backup_file add $file $CUR $BACK 694 fi 695 else 696 if [ -f $CUR ]; then 697 printf "\n======\n%s removed\n======\n" $file 698 diff $CUR /dev/null 699 backup_file remove $file $CUR $BACK 700 fi 701 fi 702 done 703fi 704 705if [ -f /etc/security.local ]; then 706 echo "" 707 echo "Running /etc/security.local:" 708 . /etc/security.local 709fi 710