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