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