1993-03-21 12:45:37 +03:00
|
|
|
#!/bin/sh -
|
|
|
|
#
|
2004-07-23 10:12:16 +04:00
|
|
|
# $NetBSD: security,v 1.91 2004/07/23 06:12:16 lukem Exp $
|
1994-06-15 08:28:06 +04:00
|
|
|
# from: @(#)security 8.1 (Berkeley) 6/9/93
|
1993-03-21 12:45:37 +03:00
|
|
|
#
|
1994-06-15 08:28:06 +04:00
|
|
|
|
|
|
|
PATH=/sbin:/usr/sbin:/bin:/usr/bin
|
|
|
|
|
2004-04-02 17:13:47 +04:00
|
|
|
rcvar_manpage='security.conf(5)'
|
|
|
|
|
1998-01-26 15:02:43 +03:00
|
|
|
if [ -f /etc/rc.subr ]; then
|
|
|
|
. /etc/rc.subr
|
|
|
|
else
|
|
|
|
echo "Can't read /etc/rc.subr; aborting."
|
|
|
|
exit 1;
|
|
|
|
fi
|
|
|
|
|
1994-06-15 08:28:06 +04:00
|
|
|
umask 077
|
2001-10-03 11:04:32 +04:00
|
|
|
TZ=UTC; export TZ
|
1994-06-15 08:28:06 +04:00
|
|
|
|
1997-01-05 14:46:12 +03:00
|
|
|
if [ -s /etc/security.conf ]; then
|
|
|
|
. /etc/security.conf
|
|
|
|
fi
|
1994-06-15 08:28:06 +04:00
|
|
|
|
Major overhaul, with help from Andrew Brown <atatat@netbsd.org>.
Features:
- Add a bunch of stuff to /etc/mtree/special to enable removal of
/etc/changelist:
- files which we want to monitor for changes but don't want to
see the diffs of (master.passwd, ssh_host_key, ...) are
tagged with "nomail"
- files which we don't want to monitor are tagged with "exclude"
(such as netgroup.db, kvm.db, ...)
- monitor /etc/mtree/special.local, /root/.ssh/*
- remove /etc/changelist, and a bunch of XXX comments
- use mtree(8)'s -D, -I, and -E to generate lists of files to
actually do the changelist stuff on.
- support /etc/mtree/special.local as an optional user-provided
version of /etc/mtree/special (effectively, an enhanced
/etc/changelist)
- Add code to monitor: /etc/ifconfig.* /etc/raid*.conf /etc/rc.conf.d/*
including support for these files being added and removed at will.
- If /sbin/fdisk exists, backup the output of "fdisk $disk" for all
the active disk drives as part of $check_disklabels
- Check permissions on: ~/.ssh/* ~/.shosts
Details:
- Reorder initialisation of defaults
- Remove special case for /etc/master.passwd "monitor but don't email diffs"
with general case for other similar files.
- Keep all `autogenerated' files (such as disklabel.*, setuid.current, ...)
in "$backup_dir/work", to minimise name clashes.
- Add migrate_file(old, new) to do the hard work of migrating files
from the old `top level' /var/backups mechanism to the `full path'
mechanism recently added. Use this appropriately.
- Add backup_and_diff(file, printdiffs), to the hard work of backing-up
and diff-ing files.
- Cleanup use of shell redirects
- /bin/sh supports ~root globbing, so use it.
- Improve umask checking; use awk regex rather than awk math
2001-10-12 09:18:23 +04:00
|
|
|
# Set reasonable defaults (if they're not set in security.conf)
|
|
|
|
#
|
|
|
|
backup_dir=${backup_dir:-/var/backups}
|
|
|
|
pkgdb_dir=${pkgdb_dir:-/var/db/pkg}
|
|
|
|
max_loginlen=${max_loginlen:-8}
|
|
|
|
max_grouplen=${max_grouplen:-8}
|
|
|
|
|
|
|
|
# Other configurable variables
|
|
|
|
#
|
|
|
|
special_files="/etc/mtree/special /etc/mtree/special.local"
|
|
|
|
MP=/etc/master.passwd
|
|
|
|
CHANGELIST=""
|
|
|
|
work_dir=$backup_dir/work
|
|
|
|
|
|
|
|
if [ ! -d "$work_dir" ]; then
|
|
|
|
mkdir -p "$work_dir"
|
|
|
|
fi
|
|
|
|
|
2001-06-18 14:54:02 +04:00
|
|
|
SECUREDIR=`mktemp -d /tmp/_securedir.XXXXXX` || exit 1
|
1994-06-15 08:28:06 +04:00
|
|
|
|
Major overhaul, with help from Andrew Brown <atatat@netbsd.org>.
Features:
- Add a bunch of stuff to /etc/mtree/special to enable removal of
/etc/changelist:
- files which we want to monitor for changes but don't want to
see the diffs of (master.passwd, ssh_host_key, ...) are
tagged with "nomail"
- files which we don't want to monitor are tagged with "exclude"
(such as netgroup.db, kvm.db, ...)
- monitor /etc/mtree/special.local, /root/.ssh/*
- remove /etc/changelist, and a bunch of XXX comments
- use mtree(8)'s -D, -I, and -E to generate lists of files to
actually do the changelist stuff on.
- support /etc/mtree/special.local as an optional user-provided
version of /etc/mtree/special (effectively, an enhanced
/etc/changelist)
- Add code to monitor: /etc/ifconfig.* /etc/raid*.conf /etc/rc.conf.d/*
including support for these files being added and removed at will.
- If /sbin/fdisk exists, backup the output of "fdisk $disk" for all
the active disk drives as part of $check_disklabels
- Check permissions on: ~/.ssh/* ~/.shosts
Details:
- Reorder initialisation of defaults
- Remove special case for /etc/master.passwd "monitor but don't email diffs"
with general case for other similar files.
- Keep all `autogenerated' files (such as disklabel.*, setuid.current, ...)
in "$backup_dir/work", to minimise name clashes.
- Add migrate_file(old, new) to do the hard work of migrating files
from the old `top level' /var/backups mechanism to the `full path'
mechanism recently added. Use this appropriately.
- Add backup_and_diff(file, printdiffs), to the hard work of backing-up
and diff-ing files.
- Cleanup use of shell redirects
- /bin/sh supports ~root globbing, so use it.
- Improve umask checking; use awk regex rather than awk math
2001-10-12 09:18:23 +04:00
|
|
|
trap "/bin/rm -rf $SECUREDIR ; exit 0" EXIT INT QUIT PIPE
|
2001-06-18 14:54:02 +04:00
|
|
|
|
|
|
|
if ! cd "$SECUREDIR"; then
|
|
|
|
echo "Can not cd to $SECUREDIR".
|
1997-01-05 14:46:12 +03:00
|
|
|
exit 1
|
1994-06-15 08:28:06 +04:00
|
|
|
fi
|
|
|
|
|
2004-07-23 10:12:16 +04:00
|
|
|
ERR=err.$$
|
|
|
|
TMP1=tmp1.$$
|
|
|
|
TMP2=tmp2.$$
|
|
|
|
MPBYUID=mpbyuid.$$
|
|
|
|
MPBYPATH=mpbypath.$$
|
|
|
|
LIST=list.$$
|
|
|
|
OUTPUT=output.$$
|
|
|
|
LABELS=labels.$$
|
|
|
|
PKGS=pkgs.$$
|
|
|
|
CHANGEFILES=changefiles.$$
|
|
|
|
SPECIALSPEC=specialspec.$$
|
1997-01-05 14:46:12 +03:00
|
|
|
|
2001-01-09 20:30:29 +03:00
|
|
|
|
Major overhaul, with help from Andrew Brown <atatat@netbsd.org>.
Features:
- Add a bunch of stuff to /etc/mtree/special to enable removal of
/etc/changelist:
- files which we want to monitor for changes but don't want to
see the diffs of (master.passwd, ssh_host_key, ...) are
tagged with "nomail"
- files which we don't want to monitor are tagged with "exclude"
(such as netgroup.db, kvm.db, ...)
- monitor /etc/mtree/special.local, /root/.ssh/*
- remove /etc/changelist, and a bunch of XXX comments
- use mtree(8)'s -D, -I, and -E to generate lists of files to
actually do the changelist stuff on.
- support /etc/mtree/special.local as an optional user-provided
version of /etc/mtree/special (effectively, an enhanced
/etc/changelist)
- Add code to monitor: /etc/ifconfig.* /etc/raid*.conf /etc/rc.conf.d/*
including support for these files being added and removed at will.
- If /sbin/fdisk exists, backup the output of "fdisk $disk" for all
the active disk drives as part of $check_disklabels
- Check permissions on: ~/.ssh/* ~/.shosts
Details:
- Reorder initialisation of defaults
- Remove special case for /etc/master.passwd "monitor but don't email diffs"
with general case for other similar files.
- Keep all `autogenerated' files (such as disklabel.*, setuid.current, ...)
in "$backup_dir/work", to minimise name clashes.
- Add migrate_file(old, new) to do the hard work of migrating files
from the old `top level' /var/backups mechanism to the `full path'
mechanism recently added. Use this appropriately.
- Add backup_and_diff(file, printdiffs), to the hard work of backing-up
and diff-ing files.
- Cleanup use of shell redirects
- /bin/sh supports ~root globbing, so use it.
- Improve umask checking; use awk regex rather than awk math
2001-10-12 09:18:23 +04:00
|
|
|
# migrate_file old new
|
|
|
|
# Determine if the "${old}" path name needs to be migrated to the
|
|
|
|
# "${new}" path. Also checks if "${old}.current" needs migrating,
|
|
|
|
# and if so, migrate it and possibly "${old}.current,v" and
|
|
|
|
# "${old}.backup".
|
|
|
|
#
|
|
|
|
migrate_file()
|
|
|
|
{
|
|
|
|
_old=$1
|
|
|
|
_new=$2
|
|
|
|
if [ -z "$_old" -o -z "$_new" ]; then
|
|
|
|
err 3 "USAGE: migrate_file old new"
|
|
|
|
fi
|
|
|
|
if [ ! -d "${_new%/*}" ]; then
|
|
|
|
mkdir -p "${_new%/*}"
|
|
|
|
fi
|
|
|
|
if [ -f "${_old}" -a ! -f "${_new}" ]; then
|
|
|
|
echo "==> migrating ${_old}"
|
|
|
|
echo " to ${_new}"
|
|
|
|
mv "${_old}" "${_new}"
|
|
|
|
fi
|
|
|
|
if [ -f "${_old}.current" -a ! -f "${_new}.current" ]; then
|
|
|
|
echo "==> migrating ${_old}.current"
|
|
|
|
echo " to ${_new}.current"
|
|
|
|
mv "${_old}.current" "${_new}.current"
|
|
|
|
if [ -f "${_old}.current,v" -a ! -f "${_new}.current,v" ]; then
|
|
|
|
echo "==> migrating ${_old}.current,v"
|
|
|
|
echo " to ${_new}.current,v"
|
|
|
|
mv "${_old}.current,v" "${_new}.current,v"
|
|
|
|
fi
|
|
|
|
if [ -f "${_old}.backup" -a ! -f "${_new}.backup" ]; then
|
|
|
|
echo "==> migrating ${_old}.backup"
|
|
|
|
echo " to ${_new}.backup"
|
|
|
|
mv "${_old}.backup" "${_new}.backup"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# backup_and_diff file printdiff
|
|
|
|
# Determine if file needs backing up, and if so, do it.
|
|
|
|
# If printdiff is yes, display the diffs, otherwise
|
|
|
|
# just print a message saying "[changes omitted]".
|
|
|
|
#
|
|
|
|
backup_and_diff()
|
|
|
|
{
|
|
|
|
_file=$1
|
|
|
|
_printdiff=$2
|
|
|
|
if [ -z "$_file" -o -z "$_printdiff" ]; then
|
|
|
|
err 3 "USAGE: backup_and_diff file printdiff"
|
|
|
|
fi
|
|
|
|
! checkyesno _printdiff
|
|
|
|
_printdiff=$?
|
|
|
|
|
|
|
|
_old=$backup_dir/${_file##*/}
|
|
|
|
case "$_file" in
|
|
|
|
$work_dir/*)
|
|
|
|
_new=$_file
|
|
|
|
migrate_file "$backup_dir/$_old" "$_new"
|
|
|
|
migrate_file "$_old" "$_new"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
_new=$backup_dir/$_file
|
|
|
|
migrate_file "$_old" "$_new"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
CUR=${_new}.current
|
|
|
|
BACK=${_new}.backup
|
|
|
|
if [ -f $_file ]; then
|
|
|
|
if [ -f $CUR ] ; then
|
|
|
|
if [ "$_printdiff" -ne 0 ]; then
|
2003-02-22 01:47:51 +03:00
|
|
|
diff ${diff_options} $CUR $_file > $OUTPUT
|
Major overhaul, with help from Andrew Brown <atatat@netbsd.org>.
Features:
- Add a bunch of stuff to /etc/mtree/special to enable removal of
/etc/changelist:
- files which we want to monitor for changes but don't want to
see the diffs of (master.passwd, ssh_host_key, ...) are
tagged with "nomail"
- files which we don't want to monitor are tagged with "exclude"
(such as netgroup.db, kvm.db, ...)
- monitor /etc/mtree/special.local, /root/.ssh/*
- remove /etc/changelist, and a bunch of XXX comments
- use mtree(8)'s -D, -I, and -E to generate lists of files to
actually do the changelist stuff on.
- support /etc/mtree/special.local as an optional user-provided
version of /etc/mtree/special (effectively, an enhanced
/etc/changelist)
- Add code to monitor: /etc/ifconfig.* /etc/raid*.conf /etc/rc.conf.d/*
including support for these files being added and removed at will.
- If /sbin/fdisk exists, backup the output of "fdisk $disk" for all
the active disk drives as part of $check_disklabels
- Check permissions on: ~/.ssh/* ~/.shosts
Details:
- Reorder initialisation of defaults
- Remove special case for /etc/master.passwd "monitor but don't email diffs"
with general case for other similar files.
- Keep all `autogenerated' files (such as disklabel.*, setuid.current, ...)
in "$backup_dir/work", to minimise name clashes.
- Add migrate_file(old, new) to do the hard work of migrating files
from the old `top level' /var/backups mechanism to the `full path'
mechanism recently added. Use this appropriately.
- Add backup_and_diff(file, printdiffs), to the hard work of backing-up
and diff-ing files.
- Cleanup use of shell redirects
- /bin/sh supports ~root globbing, so use it.
- Improve umask checking; use awk regex rather than awk math
2001-10-12 09:18:23 +04:00
|
|
|
else
|
|
|
|
if ! cmp -s $CUR $_file; then
|
|
|
|
echo "[changes omitted]"
|
|
|
|
fi > $OUTPUT
|
|
|
|
fi
|
|
|
|
if [ -s $OUTPUT ] ; then
|
|
|
|
printf \
|
|
|
|
"\n======\n%s diffs (OLD < > NEW)\n======\n" $_file
|
|
|
|
cat $OUTPUT
|
|
|
|
backup_file update $_file $CUR $BACK
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
printf "\n======\n%s added\n======\n" $_file
|
|
|
|
if [ "$_printdiff" -ne 0 ]; then
|
2003-02-22 01:47:51 +03:00
|
|
|
diff ${diff_options} /dev/null $_file
|
Major overhaul, with help from Andrew Brown <atatat@netbsd.org>.
Features:
- Add a bunch of stuff to /etc/mtree/special to enable removal of
/etc/changelist:
- files which we want to monitor for changes but don't want to
see the diffs of (master.passwd, ssh_host_key, ...) are
tagged with "nomail"
- files which we don't want to monitor are tagged with "exclude"
(such as netgroup.db, kvm.db, ...)
- monitor /etc/mtree/special.local, /root/.ssh/*
- remove /etc/changelist, and a bunch of XXX comments
- use mtree(8)'s -D, -I, and -E to generate lists of files to
actually do the changelist stuff on.
- support /etc/mtree/special.local as an optional user-provided
version of /etc/mtree/special (effectively, an enhanced
/etc/changelist)
- Add code to monitor: /etc/ifconfig.* /etc/raid*.conf /etc/rc.conf.d/*
including support for these files being added and removed at will.
- If /sbin/fdisk exists, backup the output of "fdisk $disk" for all
the active disk drives as part of $check_disklabels
- Check permissions on: ~/.ssh/* ~/.shosts
Details:
- Reorder initialisation of defaults
- Remove special case for /etc/master.passwd "monitor but don't email diffs"
with general case for other similar files.
- Keep all `autogenerated' files (such as disklabel.*, setuid.current, ...)
in "$backup_dir/work", to minimise name clashes.
- Add migrate_file(old, new) to do the hard work of migrating files
from the old `top level' /var/backups mechanism to the `full path'
mechanism recently added. Use this appropriately.
- Add backup_and_diff(file, printdiffs), to the hard work of backing-up
and diff-ing files.
- Cleanup use of shell redirects
- /bin/sh supports ~root globbing, so use it.
- Improve umask checking; use awk regex rather than awk math
2001-10-12 09:18:23 +04:00
|
|
|
else
|
|
|
|
echo "[changes omitted]"
|
|
|
|
fi
|
|
|
|
backup_file add $_file $CUR $BACK
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
if [ -f $CUR ]; then
|
|
|
|
printf "\n======\n%s removed\n======\n" $_file
|
|
|
|
if [ "$_printdiff" -ne 0 ]; then
|
2003-02-22 01:47:51 +03:00
|
|
|
diff ${diff_options} $CUR /dev/null
|
Major overhaul, with help from Andrew Brown <atatat@netbsd.org>.
Features:
- Add a bunch of stuff to /etc/mtree/special to enable removal of
/etc/changelist:
- files which we want to monitor for changes but don't want to
see the diffs of (master.passwd, ssh_host_key, ...) are
tagged with "nomail"
- files which we don't want to monitor are tagged with "exclude"
(such as netgroup.db, kvm.db, ...)
- monitor /etc/mtree/special.local, /root/.ssh/*
- remove /etc/changelist, and a bunch of XXX comments
- use mtree(8)'s -D, -I, and -E to generate lists of files to
actually do the changelist stuff on.
- support /etc/mtree/special.local as an optional user-provided
version of /etc/mtree/special (effectively, an enhanced
/etc/changelist)
- Add code to monitor: /etc/ifconfig.* /etc/raid*.conf /etc/rc.conf.d/*
including support for these files being added and removed at will.
- If /sbin/fdisk exists, backup the output of "fdisk $disk" for all
the active disk drives as part of $check_disklabels
- Check permissions on: ~/.ssh/* ~/.shosts
Details:
- Reorder initialisation of defaults
- Remove special case for /etc/master.passwd "monitor but don't email diffs"
with general case for other similar files.
- Keep all `autogenerated' files (such as disklabel.*, setuid.current, ...)
in "$backup_dir/work", to minimise name clashes.
- Add migrate_file(old, new) to do the hard work of migrating files
from the old `top level' /var/backups mechanism to the `full path'
mechanism recently added. Use this appropriately.
- Add backup_and_diff(file, printdiffs), to the hard work of backing-up
and diff-ing files.
- Cleanup use of shell redirects
- /bin/sh supports ~root globbing, so use it.
- Improve umask checking; use awk regex rather than awk math
2001-10-12 09:18:23 +04:00
|
|
|
else
|
|
|
|
echo "[changes omitted]"
|
|
|
|
fi
|
|
|
|
backup_file remove $_file $CUR $BACK
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
1997-01-05 14:46:12 +03:00
|
|
|
|
Major overhaul, with help from Andrew Brown <atatat@netbsd.org>.
Features:
- Add a bunch of stuff to /etc/mtree/special to enable removal of
/etc/changelist:
- files which we want to monitor for changes but don't want to
see the diffs of (master.passwd, ssh_host_key, ...) are
tagged with "nomail"
- files which we don't want to monitor are tagged with "exclude"
(such as netgroup.db, kvm.db, ...)
- monitor /etc/mtree/special.local, /root/.ssh/*
- remove /etc/changelist, and a bunch of XXX comments
- use mtree(8)'s -D, -I, and -E to generate lists of files to
actually do the changelist stuff on.
- support /etc/mtree/special.local as an optional user-provided
version of /etc/mtree/special (effectively, an enhanced
/etc/changelist)
- Add code to monitor: /etc/ifconfig.* /etc/raid*.conf /etc/rc.conf.d/*
including support for these files being added and removed at will.
- If /sbin/fdisk exists, backup the output of "fdisk $disk" for all
the active disk drives as part of $check_disklabels
- Check permissions on: ~/.ssh/* ~/.shosts
Details:
- Reorder initialisation of defaults
- Remove special case for /etc/master.passwd "monitor but don't email diffs"
with general case for other similar files.
- Keep all `autogenerated' files (such as disklabel.*, setuid.current, ...)
in "$backup_dir/work", to minimise name clashes.
- Add migrate_file(old, new) to do the hard work of migrating files
from the old `top level' /var/backups mechanism to the `full path'
mechanism recently added. Use this appropriately.
- Add backup_and_diff(file, printdiffs), to the hard work of backing-up
and diff-ing files.
- Cleanup use of shell redirects
- /bin/sh supports ~root globbing, so use it.
- Improve umask checking; use awk regex rather than awk math
2001-10-12 09:18:23 +04:00
|
|
|
# These are used several times.
|
|
|
|
#
|
2004-07-23 10:12:16 +04:00
|
|
|
awk -F: '!/^\+/ { print $1 " " $3 }' $MP | sort -k2n > $MPBYUID
|
1997-09-23 18:36:56 +04:00
|
|
|
awk -F: '{ print $1 " " $9 }' $MP | sort -k2 > $MPBYPATH
|
2004-07-23 10:12:16 +04:00
|
|
|
for file in $special_files; do
|
|
|
|
[ -s $file ] && cat $file
|
|
|
|
done | mtree -CM -k all > $SPECIALSPEC || exit 1
|
1997-01-05 14:46:12 +03:00
|
|
|
|
Major overhaul, with help from Andrew Brown <atatat@netbsd.org>.
Features:
- Add a bunch of stuff to /etc/mtree/special to enable removal of
/etc/changelist:
- files which we want to monitor for changes but don't want to
see the diffs of (master.passwd, ssh_host_key, ...) are
tagged with "nomail"
- files which we don't want to monitor are tagged with "exclude"
(such as netgroup.db, kvm.db, ...)
- monitor /etc/mtree/special.local, /root/.ssh/*
- remove /etc/changelist, and a bunch of XXX comments
- use mtree(8)'s -D, -I, and -E to generate lists of files to
actually do the changelist stuff on.
- support /etc/mtree/special.local as an optional user-provided
version of /etc/mtree/special (effectively, an enhanced
/etc/changelist)
- Add code to monitor: /etc/ifconfig.* /etc/raid*.conf /etc/rc.conf.d/*
including support for these files being added and removed at will.
- If /sbin/fdisk exists, backup the output of "fdisk $disk" for all
the active disk drives as part of $check_disklabels
- Check permissions on: ~/.ssh/* ~/.shosts
Details:
- Reorder initialisation of defaults
- Remove special case for /etc/master.passwd "monitor but don't email diffs"
with general case for other similar files.
- Keep all `autogenerated' files (such as disklabel.*, setuid.current, ...)
in "$backup_dir/work", to minimise name clashes.
- Add migrate_file(old, new) to do the hard work of migrating files
from the old `top level' /var/backups mechanism to the `full path'
mechanism recently added. Use this appropriately.
- Add backup_and_diff(file, printdiffs), to the hard work of backing-up
and diff-ing files.
- Cleanup use of shell redirects
- /bin/sh supports ~root globbing, so use it.
- Improve umask checking; use awk regex rather than awk math
2001-10-12 09:18:23 +04:00
|
|
|
|
1997-01-05 14:46:12 +03:00
|
|
|
# Check the master password file syntax.
|
1998-08-25 17:47:29 +04:00
|
|
|
#
|
1998-01-26 15:02:43 +03:00
|
|
|
if checkyesno check_passwd; then
|
2003-11-18 06:23:53 +03:00
|
|
|
# XXX: the sense of permit_star is reversed; the code works as
|
|
|
|
# implemented, but usage needs to be negated.
|
2003-02-13 04:55:10 +03:00
|
|
|
checkyesno check_passwd_permit_star && permit_star=0 || permit_star=1
|
|
|
|
awk -v "len=$max_loginlen" \
|
|
|
|
-v "nowarn_shells_list=$check_passwd_nowarn_shells" \
|
|
|
|
-v "nowarn_users_list=$check_passwd_nowarn_users" \
|
|
|
|
-v "permit_star=$permit_star" '
|
1997-06-24 06:32:38 +04:00
|
|
|
BEGIN {
|
|
|
|
while ( getline < "/etc/shells" > 0 ) {
|
1999-07-22 04:47:50 +04:00
|
|
|
if ($0 ~ /^\#/ || $0 ~ /^$/ )
|
1997-06-24 06:32:38 +04:00
|
|
|
continue;
|
|
|
|
shells[$1]++;
|
|
|
|
}
|
2003-02-13 04:55:10 +03:00
|
|
|
split(nowarn_shells_list, a);
|
|
|
|
for (i in a) nowarn_shells[a[i]]++;
|
|
|
|
split(nowarn_users_list, a);
|
|
|
|
for (i in a) nowarn_users[a[i]]++;
|
|
|
|
uid0_users_list="root toor"
|
|
|
|
split(uid0_users_list, a);
|
|
|
|
for (i in a) uid0_users[a[i]]++;
|
1997-06-24 06:32:38 +04:00
|
|
|
FS=":";
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
1997-01-05 14:46:12 +03:00
|
|
|
if ($0 ~ /^[ ]*$/) {
|
1997-06-24 06:32:38 +04:00
|
|
|
printf "Line %d is a blank line.\n", NR;
|
1997-01-05 14:46:12 +03:00
|
|
|
next;
|
|
|
|
}
|
1999-02-18 21:53:32 +03:00
|
|
|
if (NF != 10 && ($1 != "+" || NF != 1))
|
1997-06-24 06:32:38 +04:00
|
|
|
printf "Line %d has the wrong number of fields.\n", NR;
|
1999-02-18 21:53:32 +03:00
|
|
|
if ($1 == "+" ) {
|
|
|
|
if (NF != 1 && $3 == 0)
|
2003-02-13 04:55:10 +03:00
|
|
|
printf "Line %d includes entries with uid 0.\n",
|
|
|
|
NR;
|
1999-02-18 21:53:32 +03:00
|
|
|
next;
|
|
|
|
}
|
2001-05-10 18:10:15 +04:00
|
|
|
if ($1 !~ /^[A-Za-z0-9]([-A-Za-z0-9]*[A-Za-z0-9])*$/)
|
1997-06-24 06:32:38 +04:00
|
|
|
printf "Login %s has non-alphanumeric characters.\n",
|
|
|
|
$1;
|
1999-02-18 21:53:32 +03:00
|
|
|
if (length($1) > len)
|
2003-02-13 04:55:10 +03:00
|
|
|
printf "Login %s has more than "len" characters.\n",
|
|
|
|
$1;
|
|
|
|
if ($2 == "" && !nowarn_users[$1])
|
|
|
|
printf "Login %s has no password.\n", $1;
|
|
|
|
if (!nowarn_shells[$10] && !nowarn_users[$1]) {
|
|
|
|
if (length($2) != 13 &&
|
|
|
|
length($2) != 20 &&
|
|
|
|
$2 !~ /^\$1/ &&
|
|
|
|
$2 !~ /^\$2/ &&
|
|
|
|
$2 != "" &&
|
|
|
|
(permit_star || $2 != "*") &&
|
|
|
|
$2 !~ /^\*[A-z-]+$/ &&
|
|
|
|
$1 != "toor") {
|
|
|
|
if ($10 == "" || shells[$10])
|
|
|
|
printf "Login %s is off but still has "\
|
|
|
|
"a valid shell (%s)\n", $1, $10;
|
|
|
|
} else if (! shells[$10])
|
|
|
|
printf "Login %s does not have a valid "\
|
|
|
|
"shell (%s)\n", $1, $10;
|
|
|
|
}
|
|
|
|
if ($3 == 0 && !uid0_users[$1] && !nowarn_users[$1])
|
1997-06-24 06:32:38 +04:00
|
|
|
printf "Login %s has a user id of 0.\n", $1;
|
1997-01-05 14:46:12 +03:00
|
|
|
if ($3 < 0)
|
1997-06-24 06:32:38 +04:00
|
|
|
printf "Login %s has a negative user id.\n", $1;
|
1997-01-05 14:46:12 +03:00
|
|
|
if ($4 < 0)
|
1997-06-24 06:32:38 +04:00
|
|
|
printf "Login %s has a negative group id.\n", $1;
|
1997-01-05 14:46:12 +03:00
|
|
|
}' < $MP > $OUTPUT
|
|
|
|
if [ -s $OUTPUT ] ; then
|
|
|
|
printf "\nChecking the $MP file:\n"
|
|
|
|
cat $OUTPUT
|
|
|
|
fi
|
|
|
|
|
|
|
|
awk -F: '{ print $1 }' $MP | sort | uniq -d > $OUTPUT
|
|
|
|
if [ -s $OUTPUT ] ; then
|
|
|
|
printf "\n$MP has duplicate user names.\n"
|
|
|
|
column $OUTPUT
|
|
|
|
fi
|
|
|
|
|
1999-03-17 22:11:05 +03:00
|
|
|
# To not exclude 'toor', a standard duplicate root account, from the duplicate
|
|
|
|
# account test, uncomment the line below (without egrep in it)and comment
|
|
|
|
# out the line (with egrep in it) below it.
|
|
|
|
#
|
|
|
|
# < $MPBYUID uniq -d -f 1 | awk '{ print $2 }' > $TMP2
|
1999-03-17 05:58:11 +03:00
|
|
|
< $MPBYUID egrep -v '^toor ' | uniq -d -f 1 | awk '{ print $2 }' > $TMP2
|
1997-01-05 14:46:12 +03:00
|
|
|
if [ -s $TMP2 ] ; then
|
|
|
|
printf "\n$MP has duplicate user id's.\n"
|
|
|
|
while read uid; do
|
1997-09-18 09:16:19 +04:00
|
|
|
grep -w $uid $MPBYUID
|
1997-01-05 14:46:12 +03:00
|
|
|
done < $TMP2 | column
|
|
|
|
fi
|
1994-06-15 08:28:06 +04:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Check the group file syntax.
|
1998-08-25 17:47:29 +04:00
|
|
|
#
|
1998-01-26 15:02:43 +03:00
|
|
|
if checkyesno check_group; then
|
1997-01-05 14:46:12 +03:00
|
|
|
GRP=/etc/group
|
2001-02-11 12:55:09 +03:00
|
|
|
awk -F: -v "len=$max_grouplen" '{
|
1997-01-05 14:46:12 +03:00
|
|
|
if ($0 ~ /^[ ]*$/) {
|
1997-06-24 06:32:38 +04:00
|
|
|
printf "Line %d is a blank line.\n", NR;
|
1997-01-05 14:46:12 +03:00
|
|
|
next;
|
|
|
|
}
|
1999-02-18 21:53:32 +03:00
|
|
|
if (NF != 4 && ($1 != "+" || NF != 1))
|
1997-06-24 06:32:38 +04:00
|
|
|
printf "Line %d has the wrong number of fields.\n", NR;
|
1999-02-18 21:53:32 +03:00
|
|
|
if ($1 == "+" ) {
|
|
|
|
next;
|
|
|
|
}
|
2001-05-10 18:10:15 +04:00
|
|
|
if ($1 !~ /^[A-Za-z0-9]([-A-Za-z0-9]*[A-Za-z0-9])*$/)
|
1997-06-24 06:32:38 +04:00
|
|
|
printf "Group %s has non-alphanumeric characters.\n",
|
|
|
|
$1;
|
2001-02-11 12:55:09 +03:00
|
|
|
if (length($1) > len)
|
|
|
|
printf "Group %s has more than "len" characters.\n", $1;
|
1997-01-05 14:46:12 +03:00
|
|
|
if ($3 !~ /[0-9]*/)
|
1997-06-24 06:32:38 +04:00
|
|
|
printf "Login %s has a negative group id.\n", $1;
|
1997-01-05 14:46:12 +03:00
|
|
|
}' < $GRP > $OUTPUT
|
|
|
|
if [ -s $OUTPUT ] ; then
|
|
|
|
printf "\nChecking the $GRP file:\n"
|
|
|
|
cat $OUTPUT
|
|
|
|
fi
|
1994-06-15 08:28:06 +04:00
|
|
|
|
1997-01-05 14:46:12 +03:00
|
|
|
awk -F: '{ print $1 }' $GRP | sort | uniq -d > $OUTPUT
|
|
|
|
if [ -s $OUTPUT ] ; then
|
|
|
|
printf "\n$GRP has duplicate group names.\n"
|
|
|
|
column $OUTPUT
|
|
|
|
fi
|
1994-06-15 08:28:06 +04:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Check for root paths, umask values in startup files.
|
|
|
|
# The check for the root paths is problematical -- it's likely to fail
|
|
|
|
# in other environments. Once the shells have been modified to warn
|
|
|
|
# of '.' in the path, the path tests should go away.
|
1998-08-25 17:47:29 +04:00
|
|
|
#
|
1998-01-26 15:02:43 +03:00
|
|
|
if checkyesno check_rootdotfiles; then
|
Major overhaul, with help from Andrew Brown <atatat@netbsd.org>.
Features:
- Add a bunch of stuff to /etc/mtree/special to enable removal of
/etc/changelist:
- files which we want to monitor for changes but don't want to
see the diffs of (master.passwd, ssh_host_key, ...) are
tagged with "nomail"
- files which we don't want to monitor are tagged with "exclude"
(such as netgroup.db, kvm.db, ...)
- monitor /etc/mtree/special.local, /root/.ssh/*
- remove /etc/changelist, and a bunch of XXX comments
- use mtree(8)'s -D, -I, and -E to generate lists of files to
actually do the changelist stuff on.
- support /etc/mtree/special.local as an optional user-provided
version of /etc/mtree/special (effectively, an enhanced
/etc/changelist)
- Add code to monitor: /etc/ifconfig.* /etc/raid*.conf /etc/rc.conf.d/*
including support for these files being added and removed at will.
- If /sbin/fdisk exists, backup the output of "fdisk $disk" for all
the active disk drives as part of $check_disklabels
- Check permissions on: ~/.ssh/* ~/.shosts
Details:
- Reorder initialisation of defaults
- Remove special case for /etc/master.passwd "monitor but don't email diffs"
with general case for other similar files.
- Keep all `autogenerated' files (such as disklabel.*, setuid.current, ...)
in "$backup_dir/work", to minimise name clashes.
- Add migrate_file(old, new) to do the hard work of migrating files
from the old `top level' /var/backups mechanism to the `full path'
mechanism recently added. Use this appropriately.
- Add backup_and_diff(file, printdiffs), to the hard work of backing-up
and diff-ing files.
- Cleanup use of shell redirects
- /bin/sh supports ~root globbing, so use it.
- Improve umask checking; use awk regex rather than awk math
2001-10-12 09:18:23 +04:00
|
|
|
rhome=~root
|
1997-01-05 14:46:12 +03:00
|
|
|
umaskset=no
|
|
|
|
list="/etc/csh.cshrc /etc/csh.login ${rhome}/.cshrc ${rhome}/.login"
|
|
|
|
for i in $list ; do
|
|
|
|
if [ -f $i ] ; then
|
Major overhaul, with help from Andrew Brown <atatat@netbsd.org>.
Features:
- Add a bunch of stuff to /etc/mtree/special to enable removal of
/etc/changelist:
- files which we want to monitor for changes but don't want to
see the diffs of (master.passwd, ssh_host_key, ...) are
tagged with "nomail"
- files which we don't want to monitor are tagged with "exclude"
(such as netgroup.db, kvm.db, ...)
- monitor /etc/mtree/special.local, /root/.ssh/*
- remove /etc/changelist, and a bunch of XXX comments
- use mtree(8)'s -D, -I, and -E to generate lists of files to
actually do the changelist stuff on.
- support /etc/mtree/special.local as an optional user-provided
version of /etc/mtree/special (effectively, an enhanced
/etc/changelist)
- Add code to monitor: /etc/ifconfig.* /etc/raid*.conf /etc/rc.conf.d/*
including support for these files being added and removed at will.
- If /sbin/fdisk exists, backup the output of "fdisk $disk" for all
the active disk drives as part of $check_disklabels
- Check permissions on: ~/.ssh/* ~/.shosts
Details:
- Reorder initialisation of defaults
- Remove special case for /etc/master.passwd "monitor but don't email diffs"
with general case for other similar files.
- Keep all `autogenerated' files (such as disklabel.*, setuid.current, ...)
in "$backup_dir/work", to minimise name clashes.
- Add migrate_file(old, new) to do the hard work of migrating files
from the old `top level' /var/backups mechanism to the `full path'
mechanism recently added. Use this appropriately.
- Add backup_and_diff(file, printdiffs), to the hard work of backing-up
and diff-ing files.
- Cleanup use of shell redirects
- /bin/sh supports ~root globbing, so use it.
- Improve umask checking; use awk regex rather than awk math
2001-10-12 09:18:23 +04:00
|
|
|
if egrep '^[ \t]*umask[ \t]+[0-7]+' $i > /dev/null ;
|
|
|
|
then
|
1997-01-05 14:46:12 +03:00
|
|
|
umaskset=yes
|
|
|
|
fi
|
2001-10-03 04:12:17 +04:00
|
|
|
# Double check the umask value itself; ensure that
|
Major overhaul, with help from Andrew Brown <atatat@netbsd.org>.
Features:
- Add a bunch of stuff to /etc/mtree/special to enable removal of
/etc/changelist:
- files which we want to monitor for changes but don't want to
see the diffs of (master.passwd, ssh_host_key, ...) are
tagged with "nomail"
- files which we don't want to monitor are tagged with "exclude"
(such as netgroup.db, kvm.db, ...)
- monitor /etc/mtree/special.local, /root/.ssh/*
- remove /etc/changelist, and a bunch of XXX comments
- use mtree(8)'s -D, -I, and -E to generate lists of files to
actually do the changelist stuff on.
- support /etc/mtree/special.local as an optional user-provided
version of /etc/mtree/special (effectively, an enhanced
/etc/changelist)
- Add code to monitor: /etc/ifconfig.* /etc/raid*.conf /etc/rc.conf.d/*
including support for these files being added and removed at will.
- If /sbin/fdisk exists, backup the output of "fdisk $disk" for all
the active disk drives as part of $check_disklabels
- Check permissions on: ~/.ssh/* ~/.shosts
Details:
- Reorder initialisation of defaults
- Remove special case for /etc/master.passwd "monitor but don't email diffs"
with general case for other similar files.
- Keep all `autogenerated' files (such as disklabel.*, setuid.current, ...)
in "$backup_dir/work", to minimise name clashes.
- Add migrate_file(old, new) to do the hard work of migrating files
from the old `top level' /var/backups mechanism to the `full path'
mechanism recently added. Use this appropriately.
- Add backup_and_diff(file, printdiffs), to the hard work of backing-up
and diff-ing files.
- Cleanup use of shell redirects
- /bin/sh supports ~root globbing, so use it.
- Improve umask checking; use awk regex rather than awk math
2001-10-12 09:18:23 +04:00
|
|
|
# both the group and other write bits are set.
|
|
|
|
#
|
2000-07-03 02:27:47 +04:00
|
|
|
egrep '^[ \t]*umask[ \t]+[0-7]+' $i |
|
2001-10-03 04:12:17 +04:00
|
|
|
awk '{
|
Major overhaul, with help from Andrew Brown <atatat@netbsd.org>.
Features:
- Add a bunch of stuff to /etc/mtree/special to enable removal of
/etc/changelist:
- files which we want to monitor for changes but don't want to
see the diffs of (master.passwd, ssh_host_key, ...) are
tagged with "nomail"
- files which we don't want to monitor are tagged with "exclude"
(such as netgroup.db, kvm.db, ...)
- monitor /etc/mtree/special.local, /root/.ssh/*
- remove /etc/changelist, and a bunch of XXX comments
- use mtree(8)'s -D, -I, and -E to generate lists of files to
actually do the changelist stuff on.
- support /etc/mtree/special.local as an optional user-provided
version of /etc/mtree/special (effectively, an enhanced
/etc/changelist)
- Add code to monitor: /etc/ifconfig.* /etc/raid*.conf /etc/rc.conf.d/*
including support for these files being added and removed at will.
- If /sbin/fdisk exists, backup the output of "fdisk $disk" for all
the active disk drives as part of $check_disklabels
- Check permissions on: ~/.ssh/* ~/.shosts
Details:
- Reorder initialisation of defaults
- Remove special case for /etc/master.passwd "monitor but don't email diffs"
with general case for other similar files.
- Keep all `autogenerated' files (such as disklabel.*, setuid.current, ...)
in "$backup_dir/work", to minimise name clashes.
- Add migrate_file(old, new) to do the hard work of migrating files
from the old `top level' /var/backups mechanism to the `full path'
mechanism recently added. Use this appropriately.
- Add backup_and_diff(file, printdiffs), to the hard work of backing-up
and diff-ing files.
- Cleanup use of shell redirects
- /bin/sh supports ~root globbing, so use it.
- Improve umask checking; use awk regex rather than awk math
2001-10-12 09:18:23 +04:00
|
|
|
if ($2 ~ /^.$/ || $2 ~! /[^2367].$/) {
|
2003-01-06 23:30:28 +03:00
|
|
|
print "\tRoot umask is group writable"
|
2001-10-03 04:12:17 +04:00
|
|
|
}
|
Major overhaul, with help from Andrew Brown <atatat@netbsd.org>.
Features:
- Add a bunch of stuff to /etc/mtree/special to enable removal of
/etc/changelist:
- files which we want to monitor for changes but don't want to
see the diffs of (master.passwd, ssh_host_key, ...) are
tagged with "nomail"
- files which we don't want to monitor are tagged with "exclude"
(such as netgroup.db, kvm.db, ...)
- monitor /etc/mtree/special.local, /root/.ssh/*
- remove /etc/changelist, and a bunch of XXX comments
- use mtree(8)'s -D, -I, and -E to generate lists of files to
actually do the changelist stuff on.
- support /etc/mtree/special.local as an optional user-provided
version of /etc/mtree/special (effectively, an enhanced
/etc/changelist)
- Add code to monitor: /etc/ifconfig.* /etc/raid*.conf /etc/rc.conf.d/*
including support for these files being added and removed at will.
- If /sbin/fdisk exists, backup the output of "fdisk $disk" for all
the active disk drives as part of $check_disklabels
- Check permissions on: ~/.ssh/* ~/.shosts
Details:
- Reorder initialisation of defaults
- Remove special case for /etc/master.passwd "monitor but don't email diffs"
with general case for other similar files.
- Keep all `autogenerated' files (such as disklabel.*, setuid.current, ...)
in "$backup_dir/work", to minimise name clashes.
- Add migrate_file(old, new) to do the hard work of migrating files
from the old `top level' /var/backups mechanism to the `full path'
mechanism recently added. Use this appropriately.
- Add backup_and_diff(file, printdiffs), to the hard work of backing-up
and diff-ing files.
- Cleanup use of shell redirects
- /bin/sh supports ~root globbing, so use it.
- Improve umask checking; use awk regex rather than awk math
2001-10-12 09:18:23 +04:00
|
|
|
if ($2 ~ /[^2367]$/) {
|
2003-01-06 23:30:28 +03:00
|
|
|
print "\tRoot umask is other writable"
|
2001-10-03 04:12:17 +04:00
|
|
|
}
|
Major overhaul, with help from Andrew Brown <atatat@netbsd.org>.
Features:
- Add a bunch of stuff to /etc/mtree/special to enable removal of
/etc/changelist:
- files which we want to monitor for changes but don't want to
see the diffs of (master.passwd, ssh_host_key, ...) are
tagged with "nomail"
- files which we don't want to monitor are tagged with "exclude"
(such as netgroup.db, kvm.db, ...)
- monitor /etc/mtree/special.local, /root/.ssh/*
- remove /etc/changelist, and a bunch of XXX comments
- use mtree(8)'s -D, -I, and -E to generate lists of files to
actually do the changelist stuff on.
- support /etc/mtree/special.local as an optional user-provided
version of /etc/mtree/special (effectively, an enhanced
/etc/changelist)
- Add code to monitor: /etc/ifconfig.* /etc/raid*.conf /etc/rc.conf.d/*
including support for these files being added and removed at will.
- If /sbin/fdisk exists, backup the output of "fdisk $disk" for all
the active disk drives as part of $check_disklabels
- Check permissions on: ~/.ssh/* ~/.shosts
Details:
- Reorder initialisation of defaults
- Remove special case for /etc/master.passwd "monitor but don't email diffs"
with general case for other similar files.
- Keep all `autogenerated' files (such as disklabel.*, setuid.current, ...)
in "$backup_dir/work", to minimise name clashes.
- Add migrate_file(old, new) to do the hard work of migrating files
from the old `top level' /var/backups mechanism to the `full path'
mechanism recently added. Use this appropriately.
- Add backup_and_diff(file, printdiffs), to the hard work of backing-up
and diff-ing files.
- Cleanup use of shell redirects
- /bin/sh supports ~root globbing, so use it.
- Improve umask checking; use awk regex rather than awk math
2001-10-12 09:18:23 +04:00
|
|
|
}' | sort -u
|
1997-08-19 16:08:35 +04:00
|
|
|
SAVE_PATH=$PATH
|
|
|
|
unset PATH
|
1997-01-05 14:46:12 +03:00
|
|
|
/bin/csh -f -s << end-of-csh > /dev/null 2>&1
|
|
|
|
source $i
|
|
|
|
/bin/ls -ldgT \$path > $TMP1
|
1994-06-15 08:28:06 +04:00
|
|
|
end-of-csh
|
2002-06-10 20:04:48 +04:00
|
|
|
export PATH=$SAVE_PATH
|
1997-01-05 14:46:12 +03:00
|
|
|
awk '{
|
|
|
|
if ($10 ~ /^\.$/) {
|
1997-08-22 13:40:17 +04:00
|
|
|
print "\tThe root path includes .";
|
1997-01-05 14:46:12 +03:00
|
|
|
next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$1 ~ /^d....w/ \
|
2003-01-06 23:30:28 +03:00
|
|
|
{ print "\tRoot path directory " $10 " is group writable." } \
|
1997-01-05 14:46:12 +03:00
|
|
|
$1 ~ /^d.......w/ \
|
2003-01-06 23:30:28 +03:00
|
|
|
{ print "\tRoot path directory " $10 " is other writable." }' \
|
Major overhaul, with help from Andrew Brown <atatat@netbsd.org>.
Features:
- Add a bunch of stuff to /etc/mtree/special to enable removal of
/etc/changelist:
- files which we want to monitor for changes but don't want to
see the diffs of (master.passwd, ssh_host_key, ...) are
tagged with "nomail"
- files which we don't want to monitor are tagged with "exclude"
(such as netgroup.db, kvm.db, ...)
- monitor /etc/mtree/special.local, /root/.ssh/*
- remove /etc/changelist, and a bunch of XXX comments
- use mtree(8)'s -D, -I, and -E to generate lists of files to
actually do the changelist stuff on.
- support /etc/mtree/special.local as an optional user-provided
version of /etc/mtree/special (effectively, an enhanced
/etc/changelist)
- Add code to monitor: /etc/ifconfig.* /etc/raid*.conf /etc/rc.conf.d/*
including support for these files being added and removed at will.
- If /sbin/fdisk exists, backup the output of "fdisk $disk" for all
the active disk drives as part of $check_disklabels
- Check permissions on: ~/.ssh/* ~/.shosts
Details:
- Reorder initialisation of defaults
- Remove special case for /etc/master.passwd "monitor but don't email diffs"
with general case for other similar files.
- Keep all `autogenerated' files (such as disklabel.*, setuid.current, ...)
in "$backup_dir/work", to minimise name clashes.
- Add migrate_file(old, new) to do the hard work of migrating files
from the old `top level' /var/backups mechanism to the `full path'
mechanism recently added. Use this appropriately.
- Add backup_and_diff(file, printdiffs), to the hard work of backing-up
and diff-ing files.
- Cleanup use of shell redirects
- /bin/sh supports ~root globbing, so use it.
- Improve umask checking; use awk regex rather than awk math
2001-10-12 09:18:23 +04:00
|
|
|
< $TMP1
|
1997-01-05 14:46:12 +03:00
|
|
|
fi
|
Major overhaul, with help from Andrew Brown <atatat@netbsd.org>.
Features:
- Add a bunch of stuff to /etc/mtree/special to enable removal of
/etc/changelist:
- files which we want to monitor for changes but don't want to
see the diffs of (master.passwd, ssh_host_key, ...) are
tagged with "nomail"
- files which we don't want to monitor are tagged with "exclude"
(such as netgroup.db, kvm.db, ...)
- monitor /etc/mtree/special.local, /root/.ssh/*
- remove /etc/changelist, and a bunch of XXX comments
- use mtree(8)'s -D, -I, and -E to generate lists of files to
actually do the changelist stuff on.
- support /etc/mtree/special.local as an optional user-provided
version of /etc/mtree/special (effectively, an enhanced
/etc/changelist)
- Add code to monitor: /etc/ifconfig.* /etc/raid*.conf /etc/rc.conf.d/*
including support for these files being added and removed at will.
- If /sbin/fdisk exists, backup the output of "fdisk $disk" for all
the active disk drives as part of $check_disklabels
- Check permissions on: ~/.ssh/* ~/.shosts
Details:
- Reorder initialisation of defaults
- Remove special case for /etc/master.passwd "monitor but don't email diffs"
with general case for other similar files.
- Keep all `autogenerated' files (such as disklabel.*, setuid.current, ...)
in "$backup_dir/work", to minimise name clashes.
- Add migrate_file(old, new) to do the hard work of migrating files
from the old `top level' /var/backups mechanism to the `full path'
mechanism recently added. Use this appropriately.
- Add backup_and_diff(file, printdiffs), to the hard work of backing-up
and diff-ing files.
- Cleanup use of shell redirects
- /bin/sh supports ~root globbing, so use it.
- Improve umask checking; use awk regex rather than awk math
2001-10-12 09:18:23 +04:00
|
|
|
done > $OUTPUT
|
1997-01-05 14:46:12 +03:00
|
|
|
if [ $umaskset = "no" -o -s $OUTPUT ] ; then
|
1997-08-22 13:40:17 +04:00
|
|
|
printf "\nChecking root csh paths, umask values:\n$list\n\n"
|
1997-01-05 14:46:12 +03:00
|
|
|
if [ -s $OUTPUT ]; then
|
|
|
|
cat $OUTPUT
|
|
|
|
fi
|
|
|
|
if [ $umaskset = "no" ] ; then
|
1997-08-22 13:40:17 +04:00
|
|
|
printf "\tRoot csh startup files do not set the umask.\n"
|
1997-01-05 14:46:12 +03:00
|
|
|
fi
|
1994-06-15 08:28:06 +04:00
|
|
|
fi
|
|
|
|
|
1997-01-05 14:46:12 +03:00
|
|
|
umaskset=no
|
1997-06-23 15:59:30 +04:00
|
|
|
list="/etc/profile ${rhome}/.profile"
|
1997-01-05 14:46:12 +03:00
|
|
|
for i in $list; do
|
|
|
|
if [ -f $i ] ; then
|
|
|
|
if egrep umask $i > /dev/null ; then
|
|
|
|
umaskset=yes
|
|
|
|
fi
|
|
|
|
egrep umask $i |
|
Major overhaul, with help from Andrew Brown <atatat@netbsd.org>.
Features:
- Add a bunch of stuff to /etc/mtree/special to enable removal of
/etc/changelist:
- files which we want to monitor for changes but don't want to
see the diffs of (master.passwd, ssh_host_key, ...) are
tagged with "nomail"
- files which we don't want to monitor are tagged with "exclude"
(such as netgroup.db, kvm.db, ...)
- monitor /etc/mtree/special.local, /root/.ssh/*
- remove /etc/changelist, and a bunch of XXX comments
- use mtree(8)'s -D, -I, and -E to generate lists of files to
actually do the changelist stuff on.
- support /etc/mtree/special.local as an optional user-provided
version of /etc/mtree/special (effectively, an enhanced
/etc/changelist)
- Add code to monitor: /etc/ifconfig.* /etc/raid*.conf /etc/rc.conf.d/*
including support for these files being added and removed at will.
- If /sbin/fdisk exists, backup the output of "fdisk $disk" for all
the active disk drives as part of $check_disklabels
- Check permissions on: ~/.ssh/* ~/.shosts
Details:
- Reorder initialisation of defaults
- Remove special case for /etc/master.passwd "monitor but don't email diffs"
with general case for other similar files.
- Keep all `autogenerated' files (such as disklabel.*, setuid.current, ...)
in "$backup_dir/work", to minimise name clashes.
- Add migrate_file(old, new) to do the hard work of migrating files
from the old `top level' /var/backups mechanism to the `full path'
mechanism recently added. Use this appropriately.
- Add backup_and_diff(file, printdiffs), to the hard work of backing-up
and diff-ing files.
- Cleanup use of shell redirects
- /bin/sh supports ~root globbing, so use it.
- Improve umask checking; use awk regex rather than awk math
2001-10-12 09:18:23 +04:00
|
|
|
awk '$2 ~ /^.$/ || $2 ~ /[^2367].$/ \
|
2003-01-06 23:30:28 +03:00
|
|
|
{ print "\tRoot umask is group writable" } \
|
Major overhaul, with help from Andrew Brown <atatat@netbsd.org>.
Features:
- Add a bunch of stuff to /etc/mtree/special to enable removal of
/etc/changelist:
- files which we want to monitor for changes but don't want to
see the diffs of (master.passwd, ssh_host_key, ...) are
tagged with "nomail"
- files which we don't want to monitor are tagged with "exclude"
(such as netgroup.db, kvm.db, ...)
- monitor /etc/mtree/special.local, /root/.ssh/*
- remove /etc/changelist, and a bunch of XXX comments
- use mtree(8)'s -D, -I, and -E to generate lists of files to
actually do the changelist stuff on.
- support /etc/mtree/special.local as an optional user-provided
version of /etc/mtree/special (effectively, an enhanced
/etc/changelist)
- Add code to monitor: /etc/ifconfig.* /etc/raid*.conf /etc/rc.conf.d/*
including support for these files being added and removed at will.
- If /sbin/fdisk exists, backup the output of "fdisk $disk" for all
the active disk drives as part of $check_disklabels
- Check permissions on: ~/.ssh/* ~/.shosts
Details:
- Reorder initialisation of defaults
- Remove special case for /etc/master.passwd "monitor but don't email diffs"
with general case for other similar files.
- Keep all `autogenerated' files (such as disklabel.*, setuid.current, ...)
in "$backup_dir/work", to minimise name clashes.
- Add migrate_file(old, new) to do the hard work of migrating files
from the old `top level' /var/backups mechanism to the `full path'
mechanism recently added. Use this appropriately.
- Add backup_and_diff(file, printdiffs), to the hard work of backing-up
and diff-ing files.
- Cleanup use of shell redirects
- /bin/sh supports ~root globbing, so use it.
- Improve umask checking; use awk regex rather than awk math
2001-10-12 09:18:23 +04:00
|
|
|
$2 ~ /[^2367]$/ \
|
2003-01-06 23:30:28 +03:00
|
|
|
{ print "\tRoot umask is other writable" }'
|
1997-08-19 16:08:35 +04:00
|
|
|
SAVE_PATH=$PATH
|
|
|
|
unset PATH
|
1997-01-05 14:46:12 +03:00
|
|
|
/bin/sh << end-of-sh > /dev/null 2>&1
|
|
|
|
. $i
|
1997-08-19 16:08:35 +04:00
|
|
|
list=\`echo \$PATH | /usr/bin/sed -e \
|
|
|
|
's/^:/.:/;s/:$/:./;s/::/:.:/g;s/:/ /g'\`
|
1997-01-05 14:46:12 +03:00
|
|
|
/bin/ls -ldgT \$list > $TMP1
|
1994-06-15 08:28:06 +04:00
|
|
|
end-of-sh
|
2002-06-10 20:04:48 +04:00
|
|
|
export PATH=$SAVE_PATH
|
1997-01-05 14:46:12 +03:00
|
|
|
awk '{
|
|
|
|
if ($10 ~ /^\.$/) {
|
1997-08-22 13:40:17 +04:00
|
|
|
print "\tThe root path includes .";
|
1997-01-05 14:46:12 +03:00
|
|
|
next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$1 ~ /^d....w/ \
|
2003-01-06 23:30:28 +03:00
|
|
|
{ print "\tRoot path directory " $10 " is group writable." } \
|
1997-01-05 14:46:12 +03:00
|
|
|
$1 ~ /^d.......w/ \
|
2003-01-06 23:30:28 +03:00
|
|
|
{ print "\tRoot path directory " $10 " is other writable." }' \
|
Major overhaul, with help from Andrew Brown <atatat@netbsd.org>.
Features:
- Add a bunch of stuff to /etc/mtree/special to enable removal of
/etc/changelist:
- files which we want to monitor for changes but don't want to
see the diffs of (master.passwd, ssh_host_key, ...) are
tagged with "nomail"
- files which we don't want to monitor are tagged with "exclude"
(such as netgroup.db, kvm.db, ...)
- monitor /etc/mtree/special.local, /root/.ssh/*
- remove /etc/changelist, and a bunch of XXX comments
- use mtree(8)'s -D, -I, and -E to generate lists of files to
actually do the changelist stuff on.
- support /etc/mtree/special.local as an optional user-provided
version of /etc/mtree/special (effectively, an enhanced
/etc/changelist)
- Add code to monitor: /etc/ifconfig.* /etc/raid*.conf /etc/rc.conf.d/*
including support for these files being added and removed at will.
- If /sbin/fdisk exists, backup the output of "fdisk $disk" for all
the active disk drives as part of $check_disklabels
- Check permissions on: ~/.ssh/* ~/.shosts
Details:
- Reorder initialisation of defaults
- Remove special case for /etc/master.passwd "monitor but don't email diffs"
with general case for other similar files.
- Keep all `autogenerated' files (such as disklabel.*, setuid.current, ...)
in "$backup_dir/work", to minimise name clashes.
- Add migrate_file(old, new) to do the hard work of migrating files
from the old `top level' /var/backups mechanism to the `full path'
mechanism recently added. Use this appropriately.
- Add backup_and_diff(file, printdiffs), to the hard work of backing-up
and diff-ing files.
- Cleanup use of shell redirects
- /bin/sh supports ~root globbing, so use it.
- Improve umask checking; use awk regex rather than awk math
2001-10-12 09:18:23 +04:00
|
|
|
< $TMP1
|
1994-06-15 08:28:06 +04:00
|
|
|
|
1997-01-05 14:46:12 +03:00
|
|
|
fi
|
Major overhaul, with help from Andrew Brown <atatat@netbsd.org>.
Features:
- Add a bunch of stuff to /etc/mtree/special to enable removal of
/etc/changelist:
- files which we want to monitor for changes but don't want to
see the diffs of (master.passwd, ssh_host_key, ...) are
tagged with "nomail"
- files which we don't want to monitor are tagged with "exclude"
(such as netgroup.db, kvm.db, ...)
- monitor /etc/mtree/special.local, /root/.ssh/*
- remove /etc/changelist, and a bunch of XXX comments
- use mtree(8)'s -D, -I, and -E to generate lists of files to
actually do the changelist stuff on.
- support /etc/mtree/special.local as an optional user-provided
version of /etc/mtree/special (effectively, an enhanced
/etc/changelist)
- Add code to monitor: /etc/ifconfig.* /etc/raid*.conf /etc/rc.conf.d/*
including support for these files being added and removed at will.
- If /sbin/fdisk exists, backup the output of "fdisk $disk" for all
the active disk drives as part of $check_disklabels
- Check permissions on: ~/.ssh/* ~/.shosts
Details:
- Reorder initialisation of defaults
- Remove special case for /etc/master.passwd "monitor but don't email diffs"
with general case for other similar files.
- Keep all `autogenerated' files (such as disklabel.*, setuid.current, ...)
in "$backup_dir/work", to minimise name clashes.
- Add migrate_file(old, new) to do the hard work of migrating files
from the old `top level' /var/backups mechanism to the `full path'
mechanism recently added. Use this appropriately.
- Add backup_and_diff(file, printdiffs), to the hard work of backing-up
and diff-ing files.
- Cleanup use of shell redirects
- /bin/sh supports ~root globbing, so use it.
- Improve umask checking; use awk regex rather than awk math
2001-10-12 09:18:23 +04:00
|
|
|
done > $OUTPUT
|
1997-01-05 14:46:12 +03:00
|
|
|
if [ $umaskset = "no" -o -s $OUTPUT ] ; then
|
|
|
|
printf "\nChecking root sh paths, umask values:\n$list\n"
|
|
|
|
if [ -s $OUTPUT ]; then
|
|
|
|
cat $OUTPUT
|
|
|
|
fi
|
|
|
|
if [ $umaskset = "no" ] ; then
|
1997-08-22 13:40:17 +04:00
|
|
|
printf "\tRoot sh startup files do not set the umask.\n"
|
1997-01-05 14:46:12 +03:00
|
|
|
fi
|
1994-06-15 08:28:06 +04:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Root and uucp should both be in /etc/ftpusers.
|
1998-08-25 17:47:29 +04:00
|
|
|
#
|
1998-01-26 15:02:43 +03:00
|
|
|
if checkyesno check_ftpusers; then
|
1997-09-18 09:16:19 +04:00
|
|
|
list="uucp "`awk '$2 == 0 { print $1 }' $MPBYUID`
|
1997-08-22 13:40:17 +04:00
|
|
|
for i in $list; do
|
1997-09-23 18:36:56 +04:00
|
|
|
if /usr/libexec/ftpd -C $i ; then
|
Major overhaul, with help from Andrew Brown <atatat@netbsd.org>.
Features:
- Add a bunch of stuff to /etc/mtree/special to enable removal of
/etc/changelist:
- files which we want to monitor for changes but don't want to
see the diffs of (master.passwd, ssh_host_key, ...) are
tagged with "nomail"
- files which we don't want to monitor are tagged with "exclude"
(such as netgroup.db, kvm.db, ...)
- monitor /etc/mtree/special.local, /root/.ssh/*
- remove /etc/changelist, and a bunch of XXX comments
- use mtree(8)'s -D, -I, and -E to generate lists of files to
actually do the changelist stuff on.
- support /etc/mtree/special.local as an optional user-provided
version of /etc/mtree/special (effectively, an enhanced
/etc/changelist)
- Add code to monitor: /etc/ifconfig.* /etc/raid*.conf /etc/rc.conf.d/*
including support for these files being added and removed at will.
- If /sbin/fdisk exists, backup the output of "fdisk $disk" for all
the active disk drives as part of $check_disklabels
- Check permissions on: ~/.ssh/* ~/.shosts
Details:
- Reorder initialisation of defaults
- Remove special case for /etc/master.passwd "monitor but don't email diffs"
with general case for other similar files.
- Keep all `autogenerated' files (such as disklabel.*, setuid.current, ...)
in "$backup_dir/work", to minimise name clashes.
- Add migrate_file(old, new) to do the hard work of migrating files
from the old `top level' /var/backups mechanism to the `full path'
mechanism recently added. Use this appropriately.
- Add backup_and_diff(file, printdiffs), to the hard work of backing-up
and diff-ing files.
- Cleanup use of shell redirects
- /bin/sh supports ~root globbing, so use it.
- Improve umask checking; use awk regex rather than awk math
2001-10-12 09:18:23 +04:00
|
|
|
printf "\t$i is not denied\n"
|
1997-08-22 13:40:17 +04:00
|
|
|
fi
|
Major overhaul, with help from Andrew Brown <atatat@netbsd.org>.
Features:
- Add a bunch of stuff to /etc/mtree/special to enable removal of
/etc/changelist:
- files which we want to monitor for changes but don't want to
see the diffs of (master.passwd, ssh_host_key, ...) are
tagged with "nomail"
- files which we don't want to monitor are tagged with "exclude"
(such as netgroup.db, kvm.db, ...)
- monitor /etc/mtree/special.local, /root/.ssh/*
- remove /etc/changelist, and a bunch of XXX comments
- use mtree(8)'s -D, -I, and -E to generate lists of files to
actually do the changelist stuff on.
- support /etc/mtree/special.local as an optional user-provided
version of /etc/mtree/special (effectively, an enhanced
/etc/changelist)
- Add code to monitor: /etc/ifconfig.* /etc/raid*.conf /etc/rc.conf.d/*
including support for these files being added and removed at will.
- If /sbin/fdisk exists, backup the output of "fdisk $disk" for all
the active disk drives as part of $check_disklabels
- Check permissions on: ~/.ssh/* ~/.shosts
Details:
- Reorder initialisation of defaults
- Remove special case for /etc/master.passwd "monitor but don't email diffs"
with general case for other similar files.
- Keep all `autogenerated' files (such as disklabel.*, setuid.current, ...)
in "$backup_dir/work", to minimise name clashes.
- Add migrate_file(old, new) to do the hard work of migrating files
from the old `top level' /var/backups mechanism to the `full path'
mechanism recently added. Use this appropriately.
- Add backup_and_diff(file, printdiffs), to the hard work of backing-up
and diff-ing files.
- Cleanup use of shell redirects
- /bin/sh supports ~root globbing, so use it.
- Improve umask checking; use awk regex rather than awk math
2001-10-12 09:18:23 +04:00
|
|
|
done > $OUTPUT
|
1997-09-18 09:16:19 +04:00
|
|
|
if [ -s $OUTPUT ]; then
|
|
|
|
printf "\nChecking the /etc/ftpusers configuration:\n"
|
|
|
|
cat $OUTPUT
|
|
|
|
fi
|
1994-06-15 08:28:06 +04:00
|
|
|
fi
|
|
|
|
|
2000-05-05 22:28:53 +04:00
|
|
|
# Uudecode should not be in the /etc/mail/aliases file.
|
1998-08-25 17:47:29 +04:00
|
|
|
#
|
1998-01-26 15:02:43 +03:00
|
|
|
if checkyesno check_aliases; then
|
2000-05-05 22:28:53 +04:00
|
|
|
for f in /etc/mail/aliases /etc/aliases; do
|
|
|
|
if [ -f $f ] && egrep '^[^#]*(uudecode|decode).*\|' $f; then
|
|
|
|
printf "\nEntry for uudecode in $f file.\n"
|
|
|
|
fi
|
|
|
|
done
|
1994-06-15 08:28:06 +04:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Files that should not have + signs.
|
1998-08-25 17:47:29 +04:00
|
|
|
#
|
1998-01-26 15:02:43 +03:00
|
|
|
if checkyesno check_rhosts; then
|
1997-01-05 14:46:12 +03:00
|
|
|
list="/etc/hosts.equiv /etc/hosts.lpd"
|
|
|
|
for f in $list ; do
|
|
|
|
if [ -f $f ] && egrep '\+' $f > /dev/null ; then
|
|
|
|
printf "\nPlus sign in $f file.\n"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
# Check for special users with .rhosts files. Only root and toor should
|
1997-02-14 11:52:05 +03:00
|
|
|
# have .rhosts files. Also, .rhosts files should not have plus signs.
|
1997-01-05 14:46:12 +03:00
|
|
|
awk -F: '$1 != "root" && $1 != "toor" && \
|
|
|
|
($3 < 100 || $1 == "ftp" || $1 == "uucp") \
|
1997-04-21 15:19:57 +04:00
|
|
|
{ print $1 " " $9 }' $MP |
|
1997-04-21 15:14:41 +04:00
|
|
|
sort -k2 |
|
1997-01-05 14:46:12 +03:00
|
|
|
while read uid homedir; do
|
|
|
|
if [ -f ${homedir}/.rhosts ] ; then
|
|
|
|
rhost=`ls -ldgT ${homedir}/.rhosts`
|
2000-09-11 01:27:50 +04:00
|
|
|
printf -- "$uid: $rhost\n"
|
1997-01-05 14:46:12 +03:00
|
|
|
fi
|
|
|
|
done > $OUTPUT
|
|
|
|
if [ -s $OUTPUT ] ; then
|
|
|
|
printf "\nChecking for special users with .rhosts files.\n"
|
|
|
|
cat $OUTPUT
|
1994-06-15 08:28:06 +04:00
|
|
|
fi
|
|
|
|
|
1997-01-05 14:46:12 +03:00
|
|
|
while read uid homedir; do
|
1999-03-16 09:18:17 +03:00
|
|
|
if [ -f ${homedir}/.rhosts -a -r ${homedir}/.rhosts ] && \
|
2000-01-15 04:15:12 +03:00
|
|
|
cat -f ${homedir}/.rhosts | egrep '\+' > /dev/null ; then
|
2000-09-11 01:27:50 +04:00
|
|
|
printf -- "$uid: + in .rhosts file.\n"
|
1997-01-05 14:46:12 +03:00
|
|
|
fi
|
1997-09-23 18:36:56 +04:00
|
|
|
done < $MPBYPATH > $OUTPUT
|
1997-01-05 14:46:12 +03:00
|
|
|
if [ -s $OUTPUT ] ; then
|
|
|
|
printf "\nChecking .rhosts files syntax.\n"
|
|
|
|
cat $OUTPUT
|
1994-06-15 08:28:06 +04:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Check home directories. Directories should not be owned by someone else
|
2003-01-06 23:30:28 +03:00
|
|
|
# or writable.
|
1998-08-25 17:47:29 +04:00
|
|
|
#
|
1998-01-26 15:02:43 +03:00
|
|
|
if checkyesno check_homes; then
|
2003-11-18 06:23:53 +03:00
|
|
|
checkyesno check_homes_permit_usergroups && \
|
|
|
|
permit_usergroups=1 || permit_usergroups=0
|
1997-01-05 14:46:12 +03:00
|
|
|
while read uid homedir; do
|
|
|
|
if [ -d ${homedir}/ ] ; then
|
|
|
|
file=`ls -ldgT ${homedir}`
|
2000-09-11 01:27:50 +04:00
|
|
|
printf -- "$uid $file\n"
|
1997-01-05 14:46:12 +03:00
|
|
|
fi
|
1997-09-23 18:36:56 +04:00
|
|
|
done < $MPBYPATH |
|
2003-11-18 06:23:53 +03:00
|
|
|
awk -v "usergroups=$permit_usergroups" '
|
|
|
|
$1 != $4 && $4 != "root" \
|
1997-01-05 14:46:12 +03:00
|
|
|
{ print "user " $1 " home directory is owned by " $4 }
|
2004-02-09 12:04:13 +03:00
|
|
|
$2 ~ /^-....w/ && (!usergroups || $5 != $1) \
|
2003-01-06 23:30:28 +03:00
|
|
|
{ print "user " $1 " home directory is group writable" }
|
1997-01-05 14:46:12 +03:00
|
|
|
$2 ~ /^-.......w/ \
|
2003-01-06 23:30:28 +03:00
|
|
|
{ print "user " $1 " home directory is other writable" }' \
|
1997-08-22 13:40:17 +04:00
|
|
|
> $OUTPUT
|
1997-01-05 14:46:12 +03:00
|
|
|
if [ -s $OUTPUT ] ; then
|
|
|
|
printf "\nChecking home directories.\n"
|
|
|
|
cat $OUTPUT
|
1994-06-15 08:28:06 +04:00
|
|
|
fi
|
|
|
|
|
1997-01-05 14:46:12 +03:00
|
|
|
# Files that should not be owned by someone else or readable.
|
Major overhaul, with help from Andrew Brown <atatat@netbsd.org>.
Features:
- Add a bunch of stuff to /etc/mtree/special to enable removal of
/etc/changelist:
- files which we want to monitor for changes but don't want to
see the diffs of (master.passwd, ssh_host_key, ...) are
tagged with "nomail"
- files which we don't want to monitor are tagged with "exclude"
(such as netgroup.db, kvm.db, ...)
- monitor /etc/mtree/special.local, /root/.ssh/*
- remove /etc/changelist, and a bunch of XXX comments
- use mtree(8)'s -D, -I, and -E to generate lists of files to
actually do the changelist stuff on.
- support /etc/mtree/special.local as an optional user-provided
version of /etc/mtree/special (effectively, an enhanced
/etc/changelist)
- Add code to monitor: /etc/ifconfig.* /etc/raid*.conf /etc/rc.conf.d/*
including support for these files being added and removed at will.
- If /sbin/fdisk exists, backup the output of "fdisk $disk" for all
the active disk drives as part of $check_disklabels
- Check permissions on: ~/.ssh/* ~/.shosts
Details:
- Reorder initialisation of defaults
- Remove special case for /etc/master.passwd "monitor but don't email diffs"
with general case for other similar files.
- Keep all `autogenerated' files (such as disklabel.*, setuid.current, ...)
in "$backup_dir/work", to minimise name clashes.
- Add migrate_file(old, new) to do the hard work of migrating files
from the old `top level' /var/backups mechanism to the `full path'
mechanism recently added. Use this appropriately.
- Add backup_and_diff(file, printdiffs), to the hard work of backing-up
and diff-ing files.
- Cleanup use of shell redirects
- /bin/sh supports ~root globbing, so use it.
- Improve umask checking; use awk regex rather than awk math
2001-10-12 09:18:23 +04:00
|
|
|
list=".Xauthority .netrc .ssh/id_dsa .ssh/id_rsa .ssh/identity"
|
1997-01-05 14:46:12 +03:00
|
|
|
while read uid homedir; do
|
|
|
|
for f in $list ; do
|
|
|
|
file=${homedir}/${f}
|
|
|
|
if [ -f $file ] ; then
|
2000-09-11 01:27:50 +04:00
|
|
|
printf -- "$uid $f `ls -ldgT $file`\n"
|
1997-01-05 14:46:12 +03:00
|
|
|
fi
|
|
|
|
done
|
1997-09-23 18:36:56 +04:00
|
|
|
done < $MPBYPATH |
|
2003-11-18 06:23:53 +03:00
|
|
|
awk -v "usergroups=$permit_usergroups" '
|
|
|
|
$1 != $5 && $5 != "root" \
|
1997-01-05 14:46:12 +03:00
|
|
|
{ print "user " $1 " " $2 " file is owned by " $5 }
|
2003-11-18 06:23:53 +03:00
|
|
|
$3 ~ /^-...r/ && (!usergroups || $6 != $1) \
|
1997-01-05 14:46:12 +03:00
|
|
|
{ print "user " $1 " " $2 " file is group readable" }
|
|
|
|
$3 ~ /^-......r/ \
|
|
|
|
{ print "user " $1 " " $2 " file is other readable" }
|
2003-11-18 06:23:53 +03:00
|
|
|
$3 ~ /^-....w/ && (!usergroups || $6 != $1) \
|
2003-01-06 23:30:28 +03:00
|
|
|
{ print "user " $1 " " $2 " file is group writable" }
|
1997-01-05 14:46:12 +03:00
|
|
|
$3 ~ /^-.......w/ \
|
2003-01-06 23:30:28 +03:00
|
|
|
{ print "user " $1 " " $2 " file is other writable" }' \
|
1997-08-22 13:40:17 +04:00
|
|
|
> $OUTPUT
|
1997-01-05 14:46:12 +03:00
|
|
|
|
2003-01-06 23:30:28 +03:00
|
|
|
# Files that should not be owned by someone else or writable.
|
1997-04-21 15:14:41 +04:00
|
|
|
list=".bash_history .bash_login .bash_logout .bash_profile .bashrc \
|
2002-08-20 11:53:51 +04:00
|
|
|
.cshrc .emacs .exrc .forward .history .k5login .klogin .login \
|
|
|
|
.logout .profile .qmail .rc_history .rhosts .shosts ssh .tcshrc \
|
|
|
|
.twmrc .xinitrc .xsession .ssh/authorized_keys \
|
|
|
|
.ssh/authorized_keys2 .ssh/config .ssh/id_dsa.pub \
|
|
|
|
.ssh/id_rsa.pub .ssh/identity.pub .ssh/known_hosts \
|
|
|
|
.ssh/known_hosts2"
|
1997-01-05 14:46:12 +03:00
|
|
|
while read uid homedir; do
|
|
|
|
for f in $list ; do
|
|
|
|
file=${homedir}/${f}
|
|
|
|
if [ -f $file ] ; then
|
2000-09-11 01:27:50 +04:00
|
|
|
printf -- "$uid $f `ls -ldgT $file`\n"
|
1997-01-05 14:46:12 +03:00
|
|
|
fi
|
|
|
|
done
|
1997-09-23 18:36:56 +04:00
|
|
|
done < $MPBYPATH |
|
2003-11-18 06:23:53 +03:00
|
|
|
awk -v "usergroups=$permit_usergroups" '
|
|
|
|
$1 != $5 && $5 != "root" \
|
1997-01-05 14:46:12 +03:00
|
|
|
{ print "user " $1 " " $2 " file is owned by " $5 }
|
2003-11-18 06:23:53 +03:00
|
|
|
$3 ~ /^-....w/ && (!usergroups || $6 != $1) \
|
2003-01-06 23:30:28 +03:00
|
|
|
{ print "user " $1 " " $2 " file is group writable" }
|
1997-01-05 14:46:12 +03:00
|
|
|
$3 ~ /^-.......w/ \
|
2003-01-06 23:30:28 +03:00
|
|
|
{ print "user " $1 " " $2 " file is other writable" }' \
|
1997-08-22 13:40:17 +04:00
|
|
|
>> $OUTPUT
|
1997-01-05 14:46:12 +03:00
|
|
|
if [ -s $OUTPUT ] ; then
|
|
|
|
printf "\nChecking dot files.\n"
|
|
|
|
cat $OUTPUT
|
|
|
|
fi
|
1994-06-15 08:28:06 +04:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Mailboxes should be owned by user and unreadable.
|
1998-08-25 17:47:29 +04:00
|
|
|
#
|
1998-01-26 15:02:43 +03:00
|
|
|
if checkyesno check_varmail; then
|
2003-11-18 06:30:40 +03:00
|
|
|
ls -lA /var/mail | \
|
2001-10-03 04:12:17 +04:00
|
|
|
awk ' NR == 1 { next; }
|
2003-11-18 06:30:40 +03:00
|
|
|
$9 ~ /^\./ {next; }
|
2001-10-03 04:12:17 +04:00
|
|
|
$3 != $9 {
|
|
|
|
print "user " $9 " mailbox is owned by " $3
|
|
|
|
}
|
|
|
|
$1 != "-rw-------" {
|
|
|
|
print "user " $9 " mailbox is " $1 ", group " $4
|
|
|
|
}' > $OUTPUT
|
1997-01-05 14:46:12 +03:00
|
|
|
if [ -s $OUTPUT ] ; then
|
|
|
|
printf "\nChecking mailbox ownership.\n"
|
|
|
|
cat $OUTPUT
|
|
|
|
fi
|
1994-06-15 08:28:06 +04:00
|
|
|
fi
|
|
|
|
|
1998-08-25 17:47:29 +04:00
|
|
|
# NFS exports shouldn't be globally exported
|
|
|
|
#
|
|
|
|
if checkyesno check_nfs && [ -f /etc/exports ]; then
|
|
|
|
awk '{
|
1997-06-23 05:49:15 +04:00
|
|
|
# ignore comments and blank lines
|
1999-07-22 04:47:50 +04:00
|
|
|
if ($0 ~ /^\#/ || $0 ~ /^$/ )
|
1997-06-23 05:49:15 +04:00
|
|
|
next;
|
|
|
|
|
1997-01-05 14:46:12 +03:00
|
|
|
readonly = 0;
|
|
|
|
for (i = 2; i <= NF; ++i) {
|
|
|
|
if ($i ~ /-ro/)
|
|
|
|
readonly = 1;
|
|
|
|
else if ($i !~ /^-/)
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
if (readonly)
|
|
|
|
print "File system " $1 " globally exported, read-only."
|
|
|
|
else
|
|
|
|
print "File system " $1 " globally exported, read-write."
|
1998-08-25 17:47:29 +04:00
|
|
|
}' < /etc/exports > $OUTPUT
|
|
|
|
if [ -s $OUTPUT ] ; then
|
1997-01-05 14:46:12 +03:00
|
|
|
printf "\nChecking for globally exported file systems.\n"
|
|
|
|
cat $OUTPUT
|
|
|
|
fi
|
1994-06-15 08:28:06 +04:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Display any changes in setuid files and devices.
|
1998-08-25 17:47:29 +04:00
|
|
|
#
|
1998-01-26 15:02:43 +03:00
|
|
|
if checkyesno check_devices; then
|
1997-09-18 09:16:19 +04:00
|
|
|
> $ERR
|
1997-01-05 14:46:12 +03:00
|
|
|
(find / \( ! -fstype local -o -fstype fdesc -o -fstype kernfs \
|
2001-12-18 03:44:20 +03:00
|
|
|
-o -fstype null \
|
1997-01-05 14:46:12 +03:00
|
|
|
-o -fstype procfs \) -a -prune -o \
|
1997-04-21 21:38:39 +04:00
|
|
|
\( \( -perm -u+s -a ! -type d \) -o \
|
|
|
|
\( -perm -g+s -a ! -type d \) -o \
|
1997-06-24 05:16:47 +04:00
|
|
|
-type b -o -type c \) -print0 | \
|
|
|
|
xargs -0 ls -ldgTq | sort +9 > $LIST) 2> $OUTPUT
|
1997-01-05 14:46:12 +03:00
|
|
|
|
|
|
|
# Display any errors that occurred during system file walk.
|
|
|
|
if [ -s $OUTPUT ] ; then
|
1997-09-18 09:16:19 +04:00
|
|
|
printf "Setuid/device find errors:\n" >> $ERR
|
|
|
|
cat $OUTPUT >> $ERR
|
|
|
|
printf "\n" >> $ERR
|
1994-06-15 08:28:06 +04:00
|
|
|
fi
|
|
|
|
|
1997-01-05 14:46:12 +03:00
|
|
|
# Display any changes in the setuid file list.
|
|
|
|
egrep -v '^[bc]' $LIST > $TMP1
|
|
|
|
if [ -s $TMP1 ] ; then
|
|
|
|
# Check to make sure uudecode isn't setuid.
|
|
|
|
if grep -w uudecode $TMP1 > /dev/null ; then
|
1997-09-18 09:16:19 +04:00
|
|
|
printf "\nUudecode is setuid.\n" >> $ERR
|
1997-01-05 14:46:12 +03:00
|
|
|
fi
|
1994-06-15 08:28:06 +04:00
|
|
|
|
Major overhaul, with help from Andrew Brown <atatat@netbsd.org>.
Features:
- Add a bunch of stuff to /etc/mtree/special to enable removal of
/etc/changelist:
- files which we want to monitor for changes but don't want to
see the diffs of (master.passwd, ssh_host_key, ...) are
tagged with "nomail"
- files which we don't want to monitor are tagged with "exclude"
(such as netgroup.db, kvm.db, ...)
- monitor /etc/mtree/special.local, /root/.ssh/*
- remove /etc/changelist, and a bunch of XXX comments
- use mtree(8)'s -D, -I, and -E to generate lists of files to
actually do the changelist stuff on.
- support /etc/mtree/special.local as an optional user-provided
version of /etc/mtree/special (effectively, an enhanced
/etc/changelist)
- Add code to monitor: /etc/ifconfig.* /etc/raid*.conf /etc/rc.conf.d/*
including support for these files being added and removed at will.
- If /sbin/fdisk exists, backup the output of "fdisk $disk" for all
the active disk drives as part of $check_disklabels
- Check permissions on: ~/.ssh/* ~/.shosts
Details:
- Reorder initialisation of defaults
- Remove special case for /etc/master.passwd "monitor but don't email diffs"
with general case for other similar files.
- Keep all `autogenerated' files (such as disklabel.*, setuid.current, ...)
in "$backup_dir/work", to minimise name clashes.
- Add migrate_file(old, new) to do the hard work of migrating files
from the old `top level' /var/backups mechanism to the `full path'
mechanism recently added. Use this appropriately.
- Add backup_and_diff(file, printdiffs), to the hard work of backing-up
and diff-ing files.
- Cleanup use of shell redirects
- /bin/sh supports ~root globbing, so use it.
- Improve umask checking; use awk regex rather than awk math
2001-10-12 09:18:23 +04:00
|
|
|
file=$work_dir/setuid
|
|
|
|
migrate_file "$backup_dir/setuid" "$file"
|
|
|
|
CUR=${file}.current
|
|
|
|
BACK=${file}.backup
|
1997-01-05 14:46:12 +03:00
|
|
|
if [ -s $CUR ] ; then
|
|
|
|
if cmp -s $CUR $TMP1 ; then
|
|
|
|
:
|
|
|
|
else
|
|
|
|
> $TMP2
|
|
|
|
join -110 -210 -v2 $CUR $TMP1 > $OUTPUT
|
|
|
|
if [ -s $OUTPUT ] ; then
|
1997-09-18 09:16:19 +04:00
|
|
|
printf "Setuid additions:\n" >> $ERR
|
|
|
|
tee -a $TMP2 < $OUTPUT >> $ERR
|
|
|
|
printf "\n" >> $ERR
|
1997-01-05 14:46:12 +03:00
|
|
|
fi
|
1994-06-15 08:28:06 +04:00
|
|
|
|
1997-01-05 14:46:12 +03:00
|
|
|
join -110 -210 -v1 $CUR $TMP1 > $OUTPUT
|
|
|
|
if [ -s $OUTPUT ] ; then
|
1997-09-18 09:16:19 +04:00
|
|
|
printf "Setuid deletions:\n" >> $ERR
|
|
|
|
tee -a $TMP2 < $OUTPUT >> $ERR
|
|
|
|
printf "\n" >> $ERR
|
1997-01-05 14:46:12 +03:00
|
|
|
fi
|
1994-06-15 08:28:06 +04:00
|
|
|
|
1997-04-21 15:19:57 +04:00
|
|
|
sort -k10 $TMP2 $CUR $TMP1 | \
|
1997-08-22 13:40:17 +04:00
|
|
|
sed -e 's/[ ][ ]*/ /g' | \
|
|
|
|
uniq -u > $OUTPUT
|
1997-01-05 14:46:12 +03:00
|
|
|
if [ -s $OUTPUT ] ; then
|
1997-09-18 09:16:19 +04:00
|
|
|
printf "Setuid changes:\n" >> $ERR
|
|
|
|
column -t $OUTPUT >> $ERR
|
|
|
|
printf "\n" >> $ERR
|
1997-01-05 14:46:12 +03:00
|
|
|
fi
|
|
|
|
|
2001-04-04 07:17:19 +04:00
|
|
|
backup_file update $TMP1 $CUR $BACK
|
1997-01-05 14:46:12 +03:00
|
|
|
fi
|
|
|
|
else
|
1997-09-18 09:16:19 +04:00
|
|
|
printf "Setuid additions:\n" >> $ERR
|
|
|
|
column -t $TMP1 >> $ERR
|
|
|
|
printf "\n" >> $ERR
|
2001-04-04 07:17:19 +04:00
|
|
|
backup_file add $TMP1 $CUR $BACK
|
1994-06-15 08:28:06 +04:00
|
|
|
fi
|
1997-01-05 14:46:12 +03:00
|
|
|
fi
|
|
|
|
|
1997-08-22 13:40:17 +04:00
|
|
|
# Check for block and character disk devices that are readable or
|
2003-01-06 23:30:28 +03:00
|
|
|
# writable or not owned by root.operator.
|
1997-01-05 14:46:12 +03:00
|
|
|
>$TMP1
|
2001-09-24 07:19:43 +04:00
|
|
|
DISKLIST="ccd ch hk hp ld md ra raid rb rd rl rx \
|
2001-08-26 15:55:38 +04:00
|
|
|
sd se ss uk up vnd wd xd xy"
|
1997-08-22 13:40:17 +04:00
|
|
|
# DISKLIST="$DISKLIST ct mt st wt"
|
1997-01-05 14:46:12 +03:00
|
|
|
for i in $DISKLIST; do
|
|
|
|
egrep "^b.*/${i}[0-9][0-9]*[a-p]$" $LIST >> $TMP1
|
|
|
|
egrep "^c.*/r${i}[0-9][0-9]*[a-p]$" $LIST >> $TMP1
|
|
|
|
done
|
|
|
|
|
|
|
|
awk '$3 != "root" || $4 != "operator" || $1 !~ /.rw-r-----/ \
|
1997-06-24 06:32:38 +04:00
|
|
|
{ printf "Disk %s is user %s, group %s, permissions %s.\n", \
|
|
|
|
$11, $3, $4, $1; }' < $TMP1 > $OUTPUT
|
1997-01-05 14:46:12 +03:00
|
|
|
if [ -s $OUTPUT ] ; then
|
1997-09-18 09:16:19 +04:00
|
|
|
printf "\nChecking disk ownership and permissions.\n" >> $ERR
|
|
|
|
cat $OUTPUT >> $ERR
|
|
|
|
printf "\n" >> $ERR
|
1994-06-15 08:28:06 +04:00
|
|
|
fi
|
|
|
|
|
1997-01-05 14:46:12 +03:00
|
|
|
# Display any changes in the device file list.
|
1997-04-21 15:19:57 +04:00
|
|
|
egrep '^[bc]' $LIST | sort -k11 > $TMP1
|
1997-01-05 14:46:12 +03:00
|
|
|
if [ -s $TMP1 ] ; then
|
Major overhaul, with help from Andrew Brown <atatat@netbsd.org>.
Features:
- Add a bunch of stuff to /etc/mtree/special to enable removal of
/etc/changelist:
- files which we want to monitor for changes but don't want to
see the diffs of (master.passwd, ssh_host_key, ...) are
tagged with "nomail"
- files which we don't want to monitor are tagged with "exclude"
(such as netgroup.db, kvm.db, ...)
- monitor /etc/mtree/special.local, /root/.ssh/*
- remove /etc/changelist, and a bunch of XXX comments
- use mtree(8)'s -D, -I, and -E to generate lists of files to
actually do the changelist stuff on.
- support /etc/mtree/special.local as an optional user-provided
version of /etc/mtree/special (effectively, an enhanced
/etc/changelist)
- Add code to monitor: /etc/ifconfig.* /etc/raid*.conf /etc/rc.conf.d/*
including support for these files being added and removed at will.
- If /sbin/fdisk exists, backup the output of "fdisk $disk" for all
the active disk drives as part of $check_disklabels
- Check permissions on: ~/.ssh/* ~/.shosts
Details:
- Reorder initialisation of defaults
- Remove special case for /etc/master.passwd "monitor but don't email diffs"
with general case for other similar files.
- Keep all `autogenerated' files (such as disklabel.*, setuid.current, ...)
in "$backup_dir/work", to minimise name clashes.
- Add migrate_file(old, new) to do the hard work of migrating files
from the old `top level' /var/backups mechanism to the `full path'
mechanism recently added. Use this appropriately.
- Add backup_and_diff(file, printdiffs), to the hard work of backing-up
and diff-ing files.
- Cleanup use of shell redirects
- /bin/sh supports ~root globbing, so use it.
- Improve umask checking; use awk regex rather than awk math
2001-10-12 09:18:23 +04:00
|
|
|
file=$work_dir/device
|
|
|
|
migrate_file "$backup_dir/device" "$file"
|
|
|
|
CUR=${file}.current
|
|
|
|
BACK=${file}.backup
|
1994-06-15 08:28:06 +04:00
|
|
|
|
1997-01-05 14:46:12 +03:00
|
|
|
if [ -s $CUR ] ; then
|
|
|
|
if cmp -s $CUR $TMP1 ; then
|
|
|
|
:
|
|
|
|
else
|
|
|
|
> $TMP2
|
|
|
|
join -111 -211 -v2 $CUR $TMP1 > $OUTPUT
|
|
|
|
if [ -s $OUTPUT ] ; then
|
1997-09-18 09:16:19 +04:00
|
|
|
printf "Device additions:\n" >> $ERR
|
|
|
|
tee -a $TMP2 < $OUTPUT >> $ERR
|
|
|
|
printf "\n" >> $ERR
|
1997-01-05 14:46:12 +03:00
|
|
|
fi
|
1994-06-15 08:28:06 +04:00
|
|
|
|
1997-01-05 14:46:12 +03:00
|
|
|
join -111 -211 -v1 $CUR $TMP1 > $OUTPUT
|
|
|
|
if [ -s $OUTPUT ] ; then
|
1997-09-18 09:16:19 +04:00
|
|
|
printf "Device deletions:\n" >> $ERR
|
|
|
|
tee -a $TMP2 < $OUTPUT >> $ERR
|
|
|
|
printf "\n" >> $ERR
|
1997-01-05 14:46:12 +03:00
|
|
|
fi
|
1994-06-15 08:28:06 +04:00
|
|
|
|
1997-08-22 13:40:17 +04:00
|
|
|
# Report any block device change. Ignore
|
|
|
|
# character devices, only the name is
|
|
|
|
# significant.
|
1997-01-05 14:46:12 +03:00
|
|
|
cat $TMP2 $CUR $TMP1 | \
|
1997-08-22 13:40:17 +04:00
|
|
|
sed -e '/^c/d' | \
|
|
|
|
sort -k11 | \
|
|
|
|
sed -e 's/[ ][ ]*/ /g' | \
|
|
|
|
uniq -u > $OUTPUT
|
1997-01-05 14:46:12 +03:00
|
|
|
if [ -s $OUTPUT ] ; then
|
1997-09-18 09:16:19 +04:00
|
|
|
printf "Block device changes:\n" >> $ERR
|
|
|
|
column -t $OUTPUT >> $ERR
|
|
|
|
printf "\n" >> $ERR
|
1997-01-05 14:46:12 +03:00
|
|
|
fi
|
1994-06-15 08:28:06 +04:00
|
|
|
|
2001-04-04 07:17:19 +04:00
|
|
|
backup_file update $TMP1 $CUR $BACK
|
1994-06-15 08:28:06 +04:00
|
|
|
fi
|
1997-01-05 14:46:12 +03:00
|
|
|
else
|
1997-09-18 09:16:19 +04:00
|
|
|
printf "Device additions:\n" >> $ERR
|
|
|
|
column -t $TMP1 >> $ERR
|
|
|
|
printf "\n" >> $ERR
|
2001-04-04 07:17:19 +04:00
|
|
|
backup_file add $TMP1 $CUR $BACK >> $ERR
|
1994-06-15 08:28:06 +04:00
|
|
|
fi
|
|
|
|
fi
|
1997-09-18 09:16:19 +04:00
|
|
|
if [ -s $ERR ] ; then
|
|
|
|
printf "\nChecking setuid files and devices:\n"
|
|
|
|
cat $ERR
|
|
|
|
printf "\n"
|
|
|
|
fi
|
1994-06-15 08:28:06 +04:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Check special files.
|
|
|
|
# Check system binaries.
|
|
|
|
#
|
|
|
|
# Create the mtree tree specifications using:
|
Major overhaul, with help from Andrew Brown <atatat@netbsd.org>.
Features:
- Add a bunch of stuff to /etc/mtree/special to enable removal of
/etc/changelist:
- files which we want to monitor for changes but don't want to
see the diffs of (master.passwd, ssh_host_key, ...) are
tagged with "nomail"
- files which we don't want to monitor are tagged with "exclude"
(such as netgroup.db, kvm.db, ...)
- monitor /etc/mtree/special.local, /root/.ssh/*
- remove /etc/changelist, and a bunch of XXX comments
- use mtree(8)'s -D, -I, and -E to generate lists of files to
actually do the changelist stuff on.
- support /etc/mtree/special.local as an optional user-provided
version of /etc/mtree/special (effectively, an enhanced
/etc/changelist)
- Add code to monitor: /etc/ifconfig.* /etc/raid*.conf /etc/rc.conf.d/*
including support for these files being added and removed at will.
- If /sbin/fdisk exists, backup the output of "fdisk $disk" for all
the active disk drives as part of $check_disklabels
- Check permissions on: ~/.ssh/* ~/.shosts
Details:
- Reorder initialisation of defaults
- Remove special case for /etc/master.passwd "monitor but don't email diffs"
with general case for other similar files.
- Keep all `autogenerated' files (such as disklabel.*, setuid.current, ...)
in "$backup_dir/work", to minimise name clashes.
- Add migrate_file(old, new) to do the hard work of migrating files
from the old `top level' /var/backups mechanism to the `full path'
mechanism recently added. Use this appropriately.
- Add backup_and_diff(file, printdiffs), to the hard work of backing-up
and diff-ing files.
- Cleanup use of shell redirects
- /bin/sh supports ~root globbing, so use it.
- Improve umask checking; use awk regex rather than awk math
2001-10-12 09:18:23 +04:00
|
|
|
# mtree -cx -pDIR -kmd5,uid,gid,mode,nlink,size,link,time > DIR.secure
|
1999-04-23 12:20:28 +04:00
|
|
|
# chown root:wheel DIR.secure
|
Major overhaul, with help from Andrew Brown <atatat@netbsd.org>.
Features:
- Add a bunch of stuff to /etc/mtree/special to enable removal of
/etc/changelist:
- files which we want to monitor for changes but don't want to
see the diffs of (master.passwd, ssh_host_key, ...) are
tagged with "nomail"
- files which we don't want to monitor are tagged with "exclude"
(such as netgroup.db, kvm.db, ...)
- monitor /etc/mtree/special.local, /root/.ssh/*
- remove /etc/changelist, and a bunch of XXX comments
- use mtree(8)'s -D, -I, and -E to generate lists of files to
actually do the changelist stuff on.
- support /etc/mtree/special.local as an optional user-provided
version of /etc/mtree/special (effectively, an enhanced
/etc/changelist)
- Add code to monitor: /etc/ifconfig.* /etc/raid*.conf /etc/rc.conf.d/*
including support for these files being added and removed at will.
- If /sbin/fdisk exists, backup the output of "fdisk $disk" for all
the active disk drives as part of $check_disklabels
- Check permissions on: ~/.ssh/* ~/.shosts
Details:
- Reorder initialisation of defaults
- Remove special case for /etc/master.passwd "monitor but don't email diffs"
with general case for other similar files.
- Keep all `autogenerated' files (such as disklabel.*, setuid.current, ...)
in "$backup_dir/work", to minimise name clashes.
- Add migrate_file(old, new) to do the hard work of migrating files
from the old `top level' /var/backups mechanism to the `full path'
mechanism recently added. Use this appropriately.
- Add backup_and_diff(file, printdiffs), to the hard work of backing-up
and diff-ing files.
- Cleanup use of shell redirects
- /bin/sh supports ~root globbing, so use it.
- Improve umask checking; use awk regex rather than awk math
2001-10-12 09:18:23 +04:00
|
|
|
# chmod u+r,go= DIR.secure
|
1994-06-15 08:28:06 +04:00
|
|
|
#
|
|
|
|
# Note, this is not complete protection against Trojan horsed binaries, as
|
|
|
|
# the hacker can modify the tree specification to match the replaced binary.
|
|
|
|
# For details on really protecting yourself against modified binaries, see
|
|
|
|
# the mtree(8) manual page.
|
1998-08-25 17:47:29 +04:00
|
|
|
#
|
1998-01-26 15:02:43 +03:00
|
|
|
if checkyesno check_mtree; then
|
2003-02-13 05:42:06 +03:00
|
|
|
if checkyesno check_mtree_follow_symlinks; then
|
|
|
|
check_mtree_flags="-L"
|
|
|
|
else
|
|
|
|
check_mtree_flags=""
|
|
|
|
fi
|
2004-07-23 10:12:16 +04:00
|
|
|
mtree -e -l -p / $check_mtree_flags -f $SPECIALSPEC 3>&1 >$OUTPUT 2>&3 |
|
2003-11-19 23:28:19 +03:00
|
|
|
grep -v '^mtree: dev/tty: Device not configured$' >&2
|
1997-01-05 14:46:12 +03:00
|
|
|
if [ -s $OUTPUT ]; then
|
1994-06-15 08:28:06 +04:00
|
|
|
printf "\nChecking special files and directories.\n"
|
|
|
|
cat $OUTPUT
|
|
|
|
fi
|
|
|
|
|
1997-02-14 11:52:05 +03:00
|
|
|
for file in /etc/mtree/*.secure; do
|
|
|
|
[ $file = '/etc/mtree/*.secure' ] && continue
|
1994-06-15 08:28:06 +04:00
|
|
|
tree=`sed -n -e '3s/.* //p' -e 3q $file`
|
2003-02-13 05:42:06 +03:00
|
|
|
mtree $check_mtree_flags -f $file -p $tree > $TMP1
|
1994-06-15 08:28:06 +04:00
|
|
|
if [ -s $TMP1 ]; then
|
Major overhaul, with help from Andrew Brown <atatat@netbsd.org>.
Features:
- Add a bunch of stuff to /etc/mtree/special to enable removal of
/etc/changelist:
- files which we want to monitor for changes but don't want to
see the diffs of (master.passwd, ssh_host_key, ...) are
tagged with "nomail"
- files which we don't want to monitor are tagged with "exclude"
(such as netgroup.db, kvm.db, ...)
- monitor /etc/mtree/special.local, /root/.ssh/*
- remove /etc/changelist, and a bunch of XXX comments
- use mtree(8)'s -D, -I, and -E to generate lists of files to
actually do the changelist stuff on.
- support /etc/mtree/special.local as an optional user-provided
version of /etc/mtree/special (effectively, an enhanced
/etc/changelist)
- Add code to monitor: /etc/ifconfig.* /etc/raid*.conf /etc/rc.conf.d/*
including support for these files being added and removed at will.
- If /sbin/fdisk exists, backup the output of "fdisk $disk" for all
the active disk drives as part of $check_disklabels
- Check permissions on: ~/.ssh/* ~/.shosts
Details:
- Reorder initialisation of defaults
- Remove special case for /etc/master.passwd "monitor but don't email diffs"
with general case for other similar files.
- Keep all `autogenerated' files (such as disklabel.*, setuid.current, ...)
in "$backup_dir/work", to minimise name clashes.
- Add migrate_file(old, new) to do the hard work of migrating files
from the old `top level' /var/backups mechanism to the `full path'
mechanism recently added. Use this appropriately.
- Add backup_and_diff(file, printdiffs), to the hard work of backing-up
and diff-ing files.
- Cleanup use of shell redirects
- /bin/sh supports ~root globbing, so use it.
- Improve umask checking; use awk regex rather than awk math
2001-10-12 09:18:23 +04:00
|
|
|
printf "\nChecking $tree:\n"
|
|
|
|
cat $TMP1
|
1994-06-15 08:28:06 +04:00
|
|
|
fi
|
Major overhaul, with help from Andrew Brown <atatat@netbsd.org>.
Features:
- Add a bunch of stuff to /etc/mtree/special to enable removal of
/etc/changelist:
- files which we want to monitor for changes but don't want to
see the diffs of (master.passwd, ssh_host_key, ...) are
tagged with "nomail"
- files which we don't want to monitor are tagged with "exclude"
(such as netgroup.db, kvm.db, ...)
- monitor /etc/mtree/special.local, /root/.ssh/*
- remove /etc/changelist, and a bunch of XXX comments
- use mtree(8)'s -D, -I, and -E to generate lists of files to
actually do the changelist stuff on.
- support /etc/mtree/special.local as an optional user-provided
version of /etc/mtree/special (effectively, an enhanced
/etc/changelist)
- Add code to monitor: /etc/ifconfig.* /etc/raid*.conf /etc/rc.conf.d/*
including support for these files being added and removed at will.
- If /sbin/fdisk exists, backup the output of "fdisk $disk" for all
the active disk drives as part of $check_disklabels
- Check permissions on: ~/.ssh/* ~/.shosts
Details:
- Reorder initialisation of defaults
- Remove special case for /etc/master.passwd "monitor but don't email diffs"
with general case for other similar files.
- Keep all `autogenerated' files (such as disklabel.*, setuid.current, ...)
in "$backup_dir/work", to minimise name clashes.
- Add migrate_file(old, new) to do the hard work of migrating files
from the old `top level' /var/backups mechanism to the `full path'
mechanism recently added. Use this appropriately.
- Add backup_and_diff(file, printdiffs), to the hard work of backing-up
and diff-ing files.
- Cleanup use of shell redirects
- /bin/sh supports ~root globbing, so use it.
- Improve umask checking; use awk regex rather than awk math
2001-10-12 09:18:23 +04:00
|
|
|
done > $OUTPUT
|
1997-01-05 14:46:12 +03:00
|
|
|
if [ -s $OUTPUT ]; then
|
1994-06-15 08:28:06 +04:00
|
|
|
printf "\nChecking system binaries:\n"
|
|
|
|
cat $OUTPUT
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
1998-08-25 17:47:29 +04:00
|
|
|
# Backup disklabels of available disks
|
|
|
|
#
|
|
|
|
if checkyesno check_disklabels; then
|
Major overhaul, with help from Andrew Brown <atatat@netbsd.org>.
Features:
- Add a bunch of stuff to /etc/mtree/special to enable removal of
/etc/changelist:
- files which we want to monitor for changes but don't want to
see the diffs of (master.passwd, ssh_host_key, ...) are
tagged with "nomail"
- files which we don't want to monitor are tagged with "exclude"
(such as netgroup.db, kvm.db, ...)
- monitor /etc/mtree/special.local, /root/.ssh/*
- remove /etc/changelist, and a bunch of XXX comments
- use mtree(8)'s -D, -I, and -E to generate lists of files to
actually do the changelist stuff on.
- support /etc/mtree/special.local as an optional user-provided
version of /etc/mtree/special (effectively, an enhanced
/etc/changelist)
- Add code to monitor: /etc/ifconfig.* /etc/raid*.conf /etc/rc.conf.d/*
including support for these files being added and removed at will.
- If /sbin/fdisk exists, backup the output of "fdisk $disk" for all
the active disk drives as part of $check_disklabels
- Check permissions on: ~/.ssh/* ~/.shosts
Details:
- Reorder initialisation of defaults
- Remove special case for /etc/master.passwd "monitor but don't email diffs"
with general case for other similar files.
- Keep all `autogenerated' files (such as disklabel.*, setuid.current, ...)
in "$backup_dir/work", to minimise name clashes.
- Add migrate_file(old, new) to do the hard work of migrating files
from the old `top level' /var/backups mechanism to the `full path'
mechanism recently added. Use this appropriately.
- Add backup_and_diff(file, printdiffs), to the hard work of backing-up
and diff-ing files.
- Cleanup use of shell redirects
- /bin/sh supports ~root globbing, so use it.
- Improve umask checking; use awk regex rather than awk math
2001-10-12 09:18:23 +04:00
|
|
|
# migrate old disklabels
|
|
|
|
for file in `ls -1d $backup_dir/$backup_dir/disklabel.* \
|
|
|
|
$backup_dir/disklabel.* 2>/dev/null`; do
|
|
|
|
migrate_file "$file" "$work_dir/${file##*/}"
|
|
|
|
done
|
|
|
|
|
|
|
|
# generate list of old disklabels & fdisks and remove them
|
|
|
|
ls -1d $work_dir/disklabel.* $work_dir/fdisk.* 2>/dev/null |
|
2001-04-04 07:17:19 +04:00
|
|
|
egrep -v '\.(backup|current)(,v)?$' > $LABELS
|
1998-08-25 17:47:29 +04:00
|
|
|
xargs rm < $LABELS
|
|
|
|
|
Major overhaul, with help from Andrew Brown <atatat@netbsd.org>.
Features:
- Add a bunch of stuff to /etc/mtree/special to enable removal of
/etc/changelist:
- files which we want to monitor for changes but don't want to
see the diffs of (master.passwd, ssh_host_key, ...) are
tagged with "nomail"
- files which we don't want to monitor are tagged with "exclude"
(such as netgroup.db, kvm.db, ...)
- monitor /etc/mtree/special.local, /root/.ssh/*
- remove /etc/changelist, and a bunch of XXX comments
- use mtree(8)'s -D, -I, and -E to generate lists of files to
actually do the changelist stuff on.
- support /etc/mtree/special.local as an optional user-provided
version of /etc/mtree/special (effectively, an enhanced
/etc/changelist)
- Add code to monitor: /etc/ifconfig.* /etc/raid*.conf /etc/rc.conf.d/*
including support for these files being added and removed at will.
- If /sbin/fdisk exists, backup the output of "fdisk $disk" for all
the active disk drives as part of $check_disklabels
- Check permissions on: ~/.ssh/* ~/.shosts
Details:
- Reorder initialisation of defaults
- Remove special case for /etc/master.passwd "monitor but don't email diffs"
with general case for other similar files.
- Keep all `autogenerated' files (such as disklabel.*, setuid.current, ...)
in "$backup_dir/work", to minimise name clashes.
- Add migrate_file(old, new) to do the hard work of migrating files
from the old `top level' /var/backups mechanism to the `full path'
mechanism recently added. Use this appropriately.
- Add backup_and_diff(file, printdiffs), to the hard work of backing-up
and diff-ing files.
- Cleanup use of shell redirects
- /bin/sh supports ~root globbing, so use it.
- Improve umask checking; use awk regex rather than awk math
2001-10-12 09:18:23 +04:00
|
|
|
# generate disklabels of all disks excluding: cd fd md
|
2001-10-03 04:12:17 +04:00
|
|
|
disks=`iostat -x | awk 'NR > 1 && $1 !~ /^[cfm]d/ { print $1; }'`
|
1998-08-25 17:47:29 +04:00
|
|
|
for i in $disks; do
|
Major overhaul, with help from Andrew Brown <atatat@netbsd.org>.
Features:
- Add a bunch of stuff to /etc/mtree/special to enable removal of
/etc/changelist:
- files which we want to monitor for changes but don't want to
see the diffs of (master.passwd, ssh_host_key, ...) are
tagged with "nomail"
- files which we don't want to monitor are tagged with "exclude"
(such as netgroup.db, kvm.db, ...)
- monitor /etc/mtree/special.local, /root/.ssh/*
- remove /etc/changelist, and a bunch of XXX comments
- use mtree(8)'s -D, -I, and -E to generate lists of files to
actually do the changelist stuff on.
- support /etc/mtree/special.local as an optional user-provided
version of /etc/mtree/special (effectively, an enhanced
/etc/changelist)
- Add code to monitor: /etc/ifconfig.* /etc/raid*.conf /etc/rc.conf.d/*
including support for these files being added and removed at will.
- If /sbin/fdisk exists, backup the output of "fdisk $disk" for all
the active disk drives as part of $check_disklabels
- Check permissions on: ~/.ssh/* ~/.shosts
Details:
- Reorder initialisation of defaults
- Remove special case for /etc/master.passwd "monitor but don't email diffs"
with general case for other similar files.
- Keep all `autogenerated' files (such as disklabel.*, setuid.current, ...)
in "$backup_dir/work", to minimise name clashes.
- Add migrate_file(old, new) to do the hard work of migrating files
from the old `top level' /var/backups mechanism to the `full path'
mechanism recently added. Use this appropriately.
- Add backup_and_diff(file, printdiffs), to the hard work of backing-up
and diff-ing files.
- Cleanup use of shell redirects
- /bin/sh supports ~root globbing, so use it.
- Improve umask checking; use awk regex rather than awk math
2001-10-12 09:18:23 +04:00
|
|
|
disklabel $i > "$work_dir/disklabel.$i" 2>/dev/null
|
1998-08-25 17:47:29 +04:00
|
|
|
done
|
|
|
|
|
Major overhaul, with help from Andrew Brown <atatat@netbsd.org>.
Features:
- Add a bunch of stuff to /etc/mtree/special to enable removal of
/etc/changelist:
- files which we want to monitor for changes but don't want to
see the diffs of (master.passwd, ssh_host_key, ...) are
tagged with "nomail"
- files which we don't want to monitor are tagged with "exclude"
(such as netgroup.db, kvm.db, ...)
- monitor /etc/mtree/special.local, /root/.ssh/*
- remove /etc/changelist, and a bunch of XXX comments
- use mtree(8)'s -D, -I, and -E to generate lists of files to
actually do the changelist stuff on.
- support /etc/mtree/special.local as an optional user-provided
version of /etc/mtree/special (effectively, an enhanced
/etc/changelist)
- Add code to monitor: /etc/ifconfig.* /etc/raid*.conf /etc/rc.conf.d/*
including support for these files being added and removed at will.
- If /sbin/fdisk exists, backup the output of "fdisk $disk" for all
the active disk drives as part of $check_disklabels
- Check permissions on: ~/.ssh/* ~/.shosts
Details:
- Reorder initialisation of defaults
- Remove special case for /etc/master.passwd "monitor but don't email diffs"
with general case for other similar files.
- Keep all `autogenerated' files (such as disklabel.*, setuid.current, ...)
in "$backup_dir/work", to minimise name clashes.
- Add migrate_file(old, new) to do the hard work of migrating files
from the old `top level' /var/backups mechanism to the `full path'
mechanism recently added. Use this appropriately.
- Add backup_and_diff(file, printdiffs), to the hard work of backing-up
and diff-ing files.
- Cleanup use of shell redirects
- /bin/sh supports ~root globbing, so use it.
- Improve umask checking; use awk regex rather than awk math
2001-10-12 09:18:23 +04:00
|
|
|
# if fdisk is available, generate fdisks for: ed ld sd wd
|
|
|
|
if [ -x /sbin/fdisk ]; then
|
|
|
|
disks=`iostat -x| awk 'NR > 1 && $1 ~ /^[elsw]d/ { print $1; }'`
|
|
|
|
for i in $disks; do
|
|
|
|
/sbin/fdisk $i > "$work_dir/fdisk.$i" 2>/dev/null
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
|
|
|
# append list of new disklabels and fdisks
|
|
|
|
ls -1d $work_dir/disklabel.* $work_dir/fdisk.* 2>/dev/null |
|
2001-04-04 07:17:19 +04:00
|
|
|
egrep -v '\.(backup|current)(,v)?$' >> $LABELS
|
2001-10-01 06:21:20 +04:00
|
|
|
CHANGELIST="$LABELS $CHANGELIST"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Check for changes in the list of installed pkgs
|
|
|
|
#
|
2001-10-03 19:41:25 +04:00
|
|
|
if checkyesno check_pkgs && [ -d $pkgdb_dir ]; then
|
Major overhaul, with help from Andrew Brown <atatat@netbsd.org>.
Features:
- Add a bunch of stuff to /etc/mtree/special to enable removal of
/etc/changelist:
- files which we want to monitor for changes but don't want to
see the diffs of (master.passwd, ssh_host_key, ...) are
tagged with "nomail"
- files which we don't want to monitor are tagged with "exclude"
(such as netgroup.db, kvm.db, ...)
- monitor /etc/mtree/special.local, /root/.ssh/*
- remove /etc/changelist, and a bunch of XXX comments
- use mtree(8)'s -D, -I, and -E to generate lists of files to
actually do the changelist stuff on.
- support /etc/mtree/special.local as an optional user-provided
version of /etc/mtree/special (effectively, an enhanced
/etc/changelist)
- Add code to monitor: /etc/ifconfig.* /etc/raid*.conf /etc/rc.conf.d/*
including support for these files being added and removed at will.
- If /sbin/fdisk exists, backup the output of "fdisk $disk" for all
the active disk drives as part of $check_disklabels
- Check permissions on: ~/.ssh/* ~/.shosts
Details:
- Reorder initialisation of defaults
- Remove special case for /etc/master.passwd "monitor but don't email diffs"
with general case for other similar files.
- Keep all `autogenerated' files (such as disklabel.*, setuid.current, ...)
in "$backup_dir/work", to minimise name clashes.
- Add migrate_file(old, new) to do the hard work of migrating files
from the old `top level' /var/backups mechanism to the `full path'
mechanism recently added. Use this appropriately.
- Add backup_and_diff(file, printdiffs), to the hard work of backing-up
and diff-ing files.
- Cleanup use of shell redirects
- /bin/sh supports ~root globbing, so use it.
- Improve umask checking; use awk regex rather than awk math
2001-10-12 09:18:23 +04:00
|
|
|
pkgs=$work_dir/pkgs
|
|
|
|
migrate_file "$backup_dir/pkgs" "$pkgs"
|
2001-10-03 19:41:25 +04:00
|
|
|
( cd $pkgdb_dir
|
2001-10-01 06:21:20 +04:00
|
|
|
pkg_info | sort
|
|
|
|
echo ""
|
|
|
|
find . \( -name +REQUIRED_BY -o -name +CONTENTS \) -print0 |
|
2001-10-18 20:08:24 +04:00
|
|
|
xargs -0 ls -ldgTq | sort -t. +1 | sed -e 's, \./, ,'
|
2001-10-01 06:21:20 +04:00
|
|
|
) > $pkgs
|
Major overhaul, with help from Andrew Brown <atatat@netbsd.org>.
Features:
- Add a bunch of stuff to /etc/mtree/special to enable removal of
/etc/changelist:
- files which we want to monitor for changes but don't want to
see the diffs of (master.passwd, ssh_host_key, ...) are
tagged with "nomail"
- files which we don't want to monitor are tagged with "exclude"
(such as netgroup.db, kvm.db, ...)
- monitor /etc/mtree/special.local, /root/.ssh/*
- remove /etc/changelist, and a bunch of XXX comments
- use mtree(8)'s -D, -I, and -E to generate lists of files to
actually do the changelist stuff on.
- support /etc/mtree/special.local as an optional user-provided
version of /etc/mtree/special (effectively, an enhanced
/etc/changelist)
- Add code to monitor: /etc/ifconfig.* /etc/raid*.conf /etc/rc.conf.d/*
including support for these files being added and removed at will.
- If /sbin/fdisk exists, backup the output of "fdisk $disk" for all
the active disk drives as part of $check_disklabels
- Check permissions on: ~/.ssh/* ~/.shosts
Details:
- Reorder initialisation of defaults
- Remove special case for /etc/master.passwd "monitor but don't email diffs"
with general case for other similar files.
- Keep all `autogenerated' files (such as disklabel.*, setuid.current, ...)
in "$backup_dir/work", to minimise name clashes.
- Add migrate_file(old, new) to do the hard work of migrating files
from the old `top level' /var/backups mechanism to the `full path'
mechanism recently added. Use this appropriately.
- Add backup_and_diff(file, printdiffs), to the hard work of backing-up
and diff-ing files.
- Cleanup use of shell redirects
- /bin/sh supports ~root globbing, so use it.
- Improve umask checking; use awk regex rather than awk math
2001-10-12 09:18:23 +04:00
|
|
|
echo "$pkgs" > $PKGS
|
2001-10-01 06:21:20 +04:00
|
|
|
CHANGELIST="$PKGS $CHANGELIST"
|
1998-08-25 17:47:29 +04:00
|
|
|
fi
|
|
|
|
|
Major overhaul, with help from Andrew Brown <atatat@netbsd.org>.
Features:
- Add a bunch of stuff to /etc/mtree/special to enable removal of
/etc/changelist:
- files which we want to monitor for changes but don't want to
see the diffs of (master.passwd, ssh_host_key, ...) are
tagged with "nomail"
- files which we don't want to monitor are tagged with "exclude"
(such as netgroup.db, kvm.db, ...)
- monitor /etc/mtree/special.local, /root/.ssh/*
- remove /etc/changelist, and a bunch of XXX comments
- use mtree(8)'s -D, -I, and -E to generate lists of files to
actually do the changelist stuff on.
- support /etc/mtree/special.local as an optional user-provided
version of /etc/mtree/special (effectively, an enhanced
/etc/changelist)
- Add code to monitor: /etc/ifconfig.* /etc/raid*.conf /etc/rc.conf.d/*
including support for these files being added and removed at will.
- If /sbin/fdisk exists, backup the output of "fdisk $disk" for all
the active disk drives as part of $check_disklabels
- Check permissions on: ~/.ssh/* ~/.shosts
Details:
- Reorder initialisation of defaults
- Remove special case for /etc/master.passwd "monitor but don't email diffs"
with general case for other similar files.
- Keep all `autogenerated' files (such as disklabel.*, setuid.current, ...)
in "$backup_dir/work", to minimise name clashes.
- Add migrate_file(old, new) to do the hard work of migrating files
from the old `top level' /var/backups mechanism to the `full path'
mechanism recently added. Use this appropriately.
- Add backup_and_diff(file, printdiffs), to the hard work of backing-up
and diff-ing files.
- Cleanup use of shell redirects
- /bin/sh supports ~root globbing, so use it.
- Improve umask checking; use awk regex rather than awk math
2001-10-12 09:18:23 +04:00
|
|
|
# List of files that get backed up and checked for any modifications.
|
1994-06-15 08:28:06 +04:00
|
|
|
# Any changes cause the files to rotate.
|
1998-08-25 17:47:29 +04:00
|
|
|
#
|
Major overhaul, with help from Andrew Brown <atatat@netbsd.org>.
Features:
- Add a bunch of stuff to /etc/mtree/special to enable removal of
/etc/changelist:
- files which we want to monitor for changes but don't want to
see the diffs of (master.passwd, ssh_host_key, ...) are
tagged with "nomail"
- files which we don't want to monitor are tagged with "exclude"
(such as netgroup.db, kvm.db, ...)
- monitor /etc/mtree/special.local, /root/.ssh/*
- remove /etc/changelist, and a bunch of XXX comments
- use mtree(8)'s -D, -I, and -E to generate lists of files to
actually do the changelist stuff on.
- support /etc/mtree/special.local as an optional user-provided
version of /etc/mtree/special (effectively, an enhanced
/etc/changelist)
- Add code to monitor: /etc/ifconfig.* /etc/raid*.conf /etc/rc.conf.d/*
including support for these files being added and removed at will.
- If /sbin/fdisk exists, backup the output of "fdisk $disk" for all
the active disk drives as part of $check_disklabels
- Check permissions on: ~/.ssh/* ~/.shosts
Details:
- Reorder initialisation of defaults
- Remove special case for /etc/master.passwd "monitor but don't email diffs"
with general case for other similar files.
- Keep all `autogenerated' files (such as disklabel.*, setuid.current, ...)
in "$backup_dir/work", to minimise name clashes.
- Add migrate_file(old, new) to do the hard work of migrating files
from the old `top level' /var/backups mechanism to the `full path'
mechanism recently added. Use this appropriately.
- Add backup_and_diff(file, printdiffs), to the hard work of backing-up
and diff-ing files.
- Cleanup use of shell redirects
- /bin/sh supports ~root globbing, so use it.
- Improve umask checking; use awk regex rather than awk math
2001-10-12 09:18:23 +04:00
|
|
|
if checkyesno check_changelist ; then
|
2004-07-23 10:12:16 +04:00
|
|
|
mtree -D -k type -f $SPECIALSPEC -E exclude |
|
|
|
|
sed '/^type=file/!d ; s/type=file \.//' | unvis > $CHANGEFILES
|
Major overhaul, with help from Andrew Brown <atatat@netbsd.org>.
Features:
- Add a bunch of stuff to /etc/mtree/special to enable removal of
/etc/changelist:
- files which we want to monitor for changes but don't want to
see the diffs of (master.passwd, ssh_host_key, ...) are
tagged with "nomail"
- files which we don't want to monitor are tagged with "exclude"
(such as netgroup.db, kvm.db, ...)
- monitor /etc/mtree/special.local, /root/.ssh/*
- remove /etc/changelist, and a bunch of XXX comments
- use mtree(8)'s -D, -I, and -E to generate lists of files to
actually do the changelist stuff on.
- support /etc/mtree/special.local as an optional user-provided
version of /etc/mtree/special (effectively, an enhanced
/etc/changelist)
- Add code to monitor: /etc/ifconfig.* /etc/raid*.conf /etc/rc.conf.d/*
including support for these files being added and removed at will.
- If /sbin/fdisk exists, backup the output of "fdisk $disk" for all
the active disk drives as part of $check_disklabels
- Check permissions on: ~/.ssh/* ~/.shosts
Details:
- Reorder initialisation of defaults
- Remove special case for /etc/master.passwd "monitor but don't email diffs"
with general case for other similar files.
- Keep all `autogenerated' files (such as disklabel.*, setuid.current, ...)
in "$backup_dir/work", to minimise name clashes.
- Add migrate_file(old, new) to do the hard work of migrating files
from the old `top level' /var/backups mechanism to the `full path'
mechanism recently added. Use this appropriately.
- Add backup_and_diff(file, printdiffs), to the hard work of backing-up
and diff-ing files.
- Cleanup use of shell redirects
- /bin/sh supports ~root globbing, so use it.
- Improve umask checking; use awk regex rather than awk math
2001-10-12 09:18:23 +04:00
|
|
|
|
2002-05-21 17:50:46 +04:00
|
|
|
(
|
2001-10-13 18:22:11 +04:00
|
|
|
# Add other files which might dynamically exist:
|
Major overhaul, with help from Andrew Brown <atatat@netbsd.org>.
Features:
- Add a bunch of stuff to /etc/mtree/special to enable removal of
/etc/changelist:
- files which we want to monitor for changes but don't want to
see the diffs of (master.passwd, ssh_host_key, ...) are
tagged with "nomail"
- files which we don't want to monitor are tagged with "exclude"
(such as netgroup.db, kvm.db, ...)
- monitor /etc/mtree/special.local, /root/.ssh/*
- remove /etc/changelist, and a bunch of XXX comments
- use mtree(8)'s -D, -I, and -E to generate lists of files to
actually do the changelist stuff on.
- support /etc/mtree/special.local as an optional user-provided
version of /etc/mtree/special (effectively, an enhanced
/etc/changelist)
- Add code to monitor: /etc/ifconfig.* /etc/raid*.conf /etc/rc.conf.d/*
including support for these files being added and removed at will.
- If /sbin/fdisk exists, backup the output of "fdisk $disk" for all
the active disk drives as part of $check_disklabels
- Check permissions on: ~/.ssh/* ~/.shosts
Details:
- Reorder initialisation of defaults
- Remove special case for /etc/master.passwd "monitor but don't email diffs"
with general case for other similar files.
- Keep all `autogenerated' files (such as disklabel.*, setuid.current, ...)
in "$backup_dir/work", to minimise name clashes.
- Add migrate_file(old, new) to do the hard work of migrating files
from the old `top level' /var/backups mechanism to the `full path'
mechanism recently added. Use this appropriately.
- Add backup_and_diff(file, printdiffs), to the hard work of backing-up
and diff-ing files.
- Cleanup use of shell redirects
- /bin/sh supports ~root globbing, so use it.
- Improve umask checking; use awk regex rather than awk math
2001-10-12 09:18:23 +04:00
|
|
|
# /etc/ifconfig.*
|
|
|
|
# /etc/raid*.conf
|
2001-10-13 18:22:11 +04:00
|
|
|
# /etc/rc.d/*
|
Major overhaul, with help from Andrew Brown <atatat@netbsd.org>.
Features:
- Add a bunch of stuff to /etc/mtree/special to enable removal of
/etc/changelist:
- files which we want to monitor for changes but don't want to
see the diffs of (master.passwd, ssh_host_key, ...) are
tagged with "nomail"
- files which we don't want to monitor are tagged with "exclude"
(such as netgroup.db, kvm.db, ...)
- monitor /etc/mtree/special.local, /root/.ssh/*
- remove /etc/changelist, and a bunch of XXX comments
- use mtree(8)'s -D, -I, and -E to generate lists of files to
actually do the changelist stuff on.
- support /etc/mtree/special.local as an optional user-provided
version of /etc/mtree/special (effectively, an enhanced
/etc/changelist)
- Add code to monitor: /etc/ifconfig.* /etc/raid*.conf /etc/rc.conf.d/*
including support for these files being added and removed at will.
- If /sbin/fdisk exists, backup the output of "fdisk $disk" for all
the active disk drives as part of $check_disklabels
- Check permissions on: ~/.ssh/* ~/.shosts
Details:
- Reorder initialisation of defaults
- Remove special case for /etc/master.passwd "monitor but don't email diffs"
with general case for other similar files.
- Keep all `autogenerated' files (such as disklabel.*, setuid.current, ...)
in "$backup_dir/work", to minimise name clashes.
- Add migrate_file(old, new) to do the hard work of migrating files
from the old `top level' /var/backups mechanism to the `full path'
mechanism recently added. Use this appropriately.
- Add backup_and_diff(file, printdiffs), to the hard work of backing-up
and diff-ing files.
- Cleanup use of shell redirects
- /bin/sh supports ~root globbing, so use it.
- Improve umask checking; use awk regex rather than awk math
2001-10-12 09:18:23 +04:00
|
|
|
# /etc/rc.conf.d/*
|
2001-10-13 18:22:11 +04:00
|
|
|
#
|
2002-05-21 17:50:46 +04:00
|
|
|
echo "/etc/ifconfig.*"
|
|
|
|
echo "/etc/raid*.conf"
|
|
|
|
echo "/etc/rc.d/*"
|
|
|
|
echo "/etc/rc.conf.d/*"
|
Major overhaul, with help from Andrew Brown <atatat@netbsd.org>.
Features:
- Add a bunch of stuff to /etc/mtree/special to enable removal of
/etc/changelist:
- files which we want to monitor for changes but don't want to
see the diffs of (master.passwd, ssh_host_key, ...) are
tagged with "nomail"
- files which we don't want to monitor are tagged with "exclude"
(such as netgroup.db, kvm.db, ...)
- monitor /etc/mtree/special.local, /root/.ssh/*
- remove /etc/changelist, and a bunch of XXX comments
- use mtree(8)'s -D, -I, and -E to generate lists of files to
actually do the changelist stuff on.
- support /etc/mtree/special.local as an optional user-provided
version of /etc/mtree/special (effectively, an enhanced
/etc/changelist)
- Add code to monitor: /etc/ifconfig.* /etc/raid*.conf /etc/rc.conf.d/*
including support for these files being added and removed at will.
- If /sbin/fdisk exists, backup the output of "fdisk $disk" for all
the active disk drives as part of $check_disklabels
- Check permissions on: ~/.ssh/* ~/.shosts
Details:
- Reorder initialisation of defaults
- Remove special case for /etc/master.passwd "monitor but don't email diffs"
with general case for other similar files.
- Keep all `autogenerated' files (such as disklabel.*, setuid.current, ...)
in "$backup_dir/work", to minimise name clashes.
- Add migrate_file(old, new) to do the hard work of migrating files
from the old `top level' /var/backups mechanism to the `full path'
mechanism recently added. Use this appropriately.
- Add backup_and_diff(file, printdiffs), to the hard work of backing-up
and diff-ing files.
- Cleanup use of shell redirects
- /bin/sh supports ~root globbing, so use it.
- Improve umask checking; use awk regex rather than awk math
2001-10-12 09:18:23 +04:00
|
|
|
|
2001-10-13 18:22:11 +04:00
|
|
|
# Add /etc/changelist
|
|
|
|
#
|
2002-05-21 17:50:46 +04:00
|
|
|
if [ -s /etc/changelist ]; then
|
|
|
|
grep -v '^#' /etc/changelist
|
|
|
|
fi
|
|
|
|
) | while read file; do
|
|
|
|
case "$file" in
|
|
|
|
*[\*\?\[]*) # If changelist line is a glob ...
|
|
|
|
# ... expand possible backup files
|
|
|
|
#
|
|
|
|
ls -1d $(echo $backup_dir/${file}.current) 2>/dev/null \
|
|
|
|
| sed "s,^$backup_dir/,, ; s,\.current$,,"
|
|
|
|
|
|
|
|
# ... expand possible files
|
|
|
|
#
|
|
|
|
ls -1d $(echo $file) 2>/dev/null
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
# Otherwise, just print the filename
|
|
|
|
echo $file
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done >> $CHANGEFILES
|
Major overhaul, with help from Andrew Brown <atatat@netbsd.org>.
Features:
- Add a bunch of stuff to /etc/mtree/special to enable removal of
/etc/changelist:
- files which we want to monitor for changes but don't want to
see the diffs of (master.passwd, ssh_host_key, ...) are
tagged with "nomail"
- files which we don't want to monitor are tagged with "exclude"
(such as netgroup.db, kvm.db, ...)
- monitor /etc/mtree/special.local, /root/.ssh/*
- remove /etc/changelist, and a bunch of XXX comments
- use mtree(8)'s -D, -I, and -E to generate lists of files to
actually do the changelist stuff on.
- support /etc/mtree/special.local as an optional user-provided
version of /etc/mtree/special (effectively, an enhanced
/etc/changelist)
- Add code to monitor: /etc/ifconfig.* /etc/raid*.conf /etc/rc.conf.d/*
including support for these files being added and removed at will.
- If /sbin/fdisk exists, backup the output of "fdisk $disk" for all
the active disk drives as part of $check_disklabels
- Check permissions on: ~/.ssh/* ~/.shosts
Details:
- Reorder initialisation of defaults
- Remove special case for /etc/master.passwd "monitor but don't email diffs"
with general case for other similar files.
- Keep all `autogenerated' files (such as disklabel.*, setuid.current, ...)
in "$backup_dir/work", to minimise name clashes.
- Add migrate_file(old, new) to do the hard work of migrating files
from the old `top level' /var/backups mechanism to the `full path'
mechanism recently added. Use this appropriately.
- Add backup_and_diff(file, printdiffs), to the hard work of backing-up
and diff-ing files.
- Cleanup use of shell redirects
- /bin/sh supports ~root globbing, so use it.
- Improve umask checking; use awk regex rather than awk math
2001-10-12 09:18:23 +04:00
|
|
|
CHANGELIST="$CHANGEFILES $CHANGELIST"
|
1998-08-25 17:47:29 +04:00
|
|
|
fi
|
|
|
|
|
Major overhaul, with help from Andrew Brown <atatat@netbsd.org>.
Features:
- Add a bunch of stuff to /etc/mtree/special to enable removal of
/etc/changelist:
- files which we want to monitor for changes but don't want to
see the diffs of (master.passwd, ssh_host_key, ...) are
tagged with "nomail"
- files which we don't want to monitor are tagged with "exclude"
(such as netgroup.db, kvm.db, ...)
- monitor /etc/mtree/special.local, /root/.ssh/*
- remove /etc/changelist, and a bunch of XXX comments
- use mtree(8)'s -D, -I, and -E to generate lists of files to
actually do the changelist stuff on.
- support /etc/mtree/special.local as an optional user-provided
version of /etc/mtree/special (effectively, an enhanced
/etc/changelist)
- Add code to monitor: /etc/ifconfig.* /etc/raid*.conf /etc/rc.conf.d/*
including support for these files being added and removed at will.
- If /sbin/fdisk exists, backup the output of "fdisk $disk" for all
the active disk drives as part of $check_disklabels
- Check permissions on: ~/.ssh/* ~/.shosts
Details:
- Reorder initialisation of defaults
- Remove special case for /etc/master.passwd "monitor but don't email diffs"
with general case for other similar files.
- Keep all `autogenerated' files (such as disklabel.*, setuid.current, ...)
in "$backup_dir/work", to minimise name clashes.
- Add migrate_file(old, new) to do the hard work of migrating files
from the old `top level' /var/backups mechanism to the `full path'
mechanism recently added. Use this appropriately.
- Add backup_and_diff(file, printdiffs), to the hard work of backing-up
and diff-ing files.
- Cleanup use of shell redirects
- /bin/sh supports ~root globbing, so use it.
- Improve umask checking; use awk regex rather than awk math
2001-10-12 09:18:23 +04:00
|
|
|
# Special case backups, including the master password file and
|
|
|
|
# ssh private host keys. The normal backup mechanisms for
|
|
|
|
# $check_changelist (see below) also print out the actual file
|
|
|
|
# differences and we don't want to do that for these files
|
|
|
|
#
|
|
|
|
echo $MP > $TMP1 # always add /etc/master.passwd
|
2004-07-23 10:12:16 +04:00
|
|
|
mtree -D -k type -f $SPECIALSPEC -I nodiff |
|
|
|
|
sed '/^type=file/!d ; s/type=file \.//' | unvis >> $TMP1
|
2001-11-09 12:01:20 +03:00
|
|
|
grep -v '^$' $TMP1 | sort -u > $TMP2
|
2001-10-13 18:22:11 +04:00
|
|
|
|
2001-10-14 04:42:31 +04:00
|
|
|
while read file; do
|
Major overhaul, with help from Andrew Brown <atatat@netbsd.org>.
Features:
- Add a bunch of stuff to /etc/mtree/special to enable removal of
/etc/changelist:
- files which we want to monitor for changes but don't want to
see the diffs of (master.passwd, ssh_host_key, ...) are
tagged with "nomail"
- files which we don't want to monitor are tagged with "exclude"
(such as netgroup.db, kvm.db, ...)
- monitor /etc/mtree/special.local, /root/.ssh/*
- remove /etc/changelist, and a bunch of XXX comments
- use mtree(8)'s -D, -I, and -E to generate lists of files to
actually do the changelist stuff on.
- support /etc/mtree/special.local as an optional user-provided
version of /etc/mtree/special (effectively, an enhanced
/etc/changelist)
- Add code to monitor: /etc/ifconfig.* /etc/raid*.conf /etc/rc.conf.d/*
including support for these files being added and removed at will.
- If /sbin/fdisk exists, backup the output of "fdisk $disk" for all
the active disk drives as part of $check_disklabels
- Check permissions on: ~/.ssh/* ~/.shosts
Details:
- Reorder initialisation of defaults
- Remove special case for /etc/master.passwd "monitor but don't email diffs"
with general case for other similar files.
- Keep all `autogenerated' files (such as disklabel.*, setuid.current, ...)
in "$backup_dir/work", to minimise name clashes.
- Add migrate_file(old, new) to do the hard work of migrating files
from the old `top level' /var/backups mechanism to the `full path'
mechanism recently added. Use this appropriately.
- Add backup_and_diff(file, printdiffs), to the hard work of backing-up
and diff-ing files.
- Cleanup use of shell redirects
- /bin/sh supports ~root globbing, so use it.
- Improve umask checking; use awk regex rather than awk math
2001-10-12 09:18:23 +04:00
|
|
|
backup_and_diff "$file" no
|
2001-10-14 04:42:31 +04:00
|
|
|
done < $TMP2
|
Major overhaul, with help from Andrew Brown <atatat@netbsd.org>.
Features:
- Add a bunch of stuff to /etc/mtree/special to enable removal of
/etc/changelist:
- files which we want to monitor for changes but don't want to
see the diffs of (master.passwd, ssh_host_key, ...) are
tagged with "nomail"
- files which we don't want to monitor are tagged with "exclude"
(such as netgroup.db, kvm.db, ...)
- monitor /etc/mtree/special.local, /root/.ssh/*
- remove /etc/changelist, and a bunch of XXX comments
- use mtree(8)'s -D, -I, and -E to generate lists of files to
actually do the changelist stuff on.
- support /etc/mtree/special.local as an optional user-provided
version of /etc/mtree/special (effectively, an enhanced
/etc/changelist)
- Add code to monitor: /etc/ifconfig.* /etc/raid*.conf /etc/rc.conf.d/*
including support for these files being added and removed at will.
- If /sbin/fdisk exists, backup the output of "fdisk $disk" for all
the active disk drives as part of $check_disklabels
- Check permissions on: ~/.ssh/* ~/.shosts
Details:
- Reorder initialisation of defaults
- Remove special case for /etc/master.passwd "monitor but don't email diffs"
with general case for other similar files.
- Keep all `autogenerated' files (such as disklabel.*, setuid.current, ...)
in "$backup_dir/work", to minimise name clashes.
- Add migrate_file(old, new) to do the hard work of migrating files
from the old `top level' /var/backups mechanism to the `full path'
mechanism recently added. Use this appropriately.
- Add backup_and_diff(file, printdiffs), to the hard work of backing-up
and diff-ing files.
- Cleanup use of shell redirects
- /bin/sh supports ~root globbing, so use it.
- Improve umask checking; use awk regex rather than awk math
2001-10-12 09:18:23 +04:00
|
|
|
|
|
|
|
|
1998-08-25 17:47:29 +04:00
|
|
|
if [ -n "$CHANGELIST" ]; then
|
2001-11-09 12:01:20 +03:00
|
|
|
grep -h -v '^$' $CHANGELIST | sort -u > $TMP1
|
2001-10-13 18:22:11 +04:00
|
|
|
comm -23 $TMP1 $TMP2 | while read file; do
|
Major overhaul, with help from Andrew Brown <atatat@netbsd.org>.
Features:
- Add a bunch of stuff to /etc/mtree/special to enable removal of
/etc/changelist:
- files which we want to monitor for changes but don't want to
see the diffs of (master.passwd, ssh_host_key, ...) are
tagged with "nomail"
- files which we don't want to monitor are tagged with "exclude"
(such as netgroup.db, kvm.db, ...)
- monitor /etc/mtree/special.local, /root/.ssh/*
- remove /etc/changelist, and a bunch of XXX comments
- use mtree(8)'s -D, -I, and -E to generate lists of files to
actually do the changelist stuff on.
- support /etc/mtree/special.local as an optional user-provided
version of /etc/mtree/special (effectively, an enhanced
/etc/changelist)
- Add code to monitor: /etc/ifconfig.* /etc/raid*.conf /etc/rc.conf.d/*
including support for these files being added and removed at will.
- If /sbin/fdisk exists, backup the output of "fdisk $disk" for all
the active disk drives as part of $check_disklabels
- Check permissions on: ~/.ssh/* ~/.shosts
Details:
- Reorder initialisation of defaults
- Remove special case for /etc/master.passwd "monitor but don't email diffs"
with general case for other similar files.
- Keep all `autogenerated' files (such as disklabel.*, setuid.current, ...)
in "$backup_dir/work", to minimise name clashes.
- Add migrate_file(old, new) to do the hard work of migrating files
from the old `top level' /var/backups mechanism to the `full path'
mechanism recently added. Use this appropriately.
- Add backup_and_diff(file, printdiffs), to the hard work of backing-up
and diff-ing files.
- Cleanup use of shell redirects
- /bin/sh supports ~root globbing, so use it.
- Improve umask checking; use awk regex rather than awk math
2001-10-12 09:18:23 +04:00
|
|
|
backup_and_diff "$file" yes
|
1994-06-15 08:28:06 +04:00
|
|
|
done
|
|
|
|
fi
|
2000-04-25 03:46:37 +04:00
|
|
|
|
2000-05-26 21:08:21 +04:00
|
|
|
if [ -f /etc/security.local ]; then
|
2004-04-09 21:33:35 +04:00
|
|
|
. /etc/security.local > $OUTPUT 2>&1
|
2003-10-01 08:29:03 +04:00
|
|
|
if [ -s $OUTPUT ] ; then
|
|
|
|
printf "\nRunning /etc/security.local:\n"
|
|
|
|
cat $OUTPUT
|
|
|
|
fi
|
2000-05-26 21:08:21 +04:00
|
|
|
fi
|