1#!/bin/sh 2# 3# $FreeBSD$ 4# 5 6# If there is a global system configuration file, suck it in. 7# 8if [ -r /etc/defaults/periodic.conf ] 9then 10 . /etc/defaults/periodic.conf 11 source_periodic_confs 12fi 13 14case "$daily_backup_passwd_enable" in 15 [Yy][Ee][Ss]) 16 if [ ! -f /etc/master.passwd ] 17 then 18 echo '$daily_backup_passwd_enable" is set but /etc/master.passwd' \ 19 "doesn't exist" 20 rc=2 21 elif [ ! -f /etc/group ] 22 then 23 echo '$daily_backup_passwd_enable" is set but /etc/group' \ 24 "doesn't exist" 25 rc=2 26 else 27 bak=/var/backups 28 rc=0 29 30 echo "" 31 echo "Backup passwd and group files:" 32 33 if [ ! -f $bak/master.passwd.bak ] 34 then 35 rc=1 36 echo "no $bak/master.passwd.bak" 37 cp -p /etc/master.passwd $bak/master.passwd.bak || rc=3 38 fi 39 40 if ! cmp -s $bak/master.passwd.bak /etc/master.passwd 41 then 42 [ $rc -lt 1 ] && rc=1 43 echo "$host passwd diffs:" 44 diff -uI '^#' $bak/master.passwd.bak /etc/master.passwd |\ 45 sed 's/^\([-+ ][^:]*\):[^:]*:/\1:(password):/' 46 mv $bak/master.passwd.bak $bak/master.passwd.bak2 47 cp -p /etc/master.passwd $bak/master.passwd.bak || rc=3 48 fi 49 50 if [ ! -f $bak/group.bak ] 51 then 52 [ $rc -lt 1 ] && rc=1 53 echo "no $bak/group.bak" 54 cp -p /etc/group $bak/group.bak || rc=3 55 fi 56 57 if ! cmp -s $bak/group.bak /etc/group 58 then 59 [ $rc -lt 1 ] && rc=1 60 echo "$host group diffs:" 61 diff -u $bak/group.bak /etc/group 62 mv $bak/group.bak $bak/group.bak2 63 cp -p /etc/group $bak/group.bak || rc=3 64 fi 65 66 if [ -f /etc/group ] 67 then 68 echo "" 69 echo "Verifying group file syntax:" 70 chkgrp /etc/group || rc=3 71 fi 72 fi;; 73 74 *) rc=0;; 75esac 76 77exit $rc 78