#!/bin/sh
# /etc/cron.daily/standard: standard daily maintenance script
# Written by Ian A. Murdock <imurdock@gnu.ai.mit.edu>
# Modified by Ian Jackson <ijackson@nyx.cs.du.edu>
# Modified by Steve Greenland <stevegr@master.debian.org>

bak=/var/backups

# The following three find commands are commented out do to the
# severe, easily exploited security hole introduced by 'find . _stuff_
# | xargs rm' style commands. Changing it to '-exec rm {}' doesn't
# help. If you need a program to prune back your tmp directories, try
# filereaper, also a Debian package.

# if [ -d /tmp -a ! -L /tmp ] && cd /tmp
# then
# 	find . -type f -atime +3 -print0 | xargs -r0 rm -f --
# 	find . ! -name . -type d -mtime +1 -print0 | xargs -r0 rmdir -- >/dev/null 2>&1
# fi

# if [ -d /var/tmp -a ! -L /var/tmp ] && cd /var/tmp
# then
# 	find . -type f -atime +7 -print0 | xargs -r0 rm -f --
# 	find . ! -name . -type d -mtime +1 -print0 | xargs -r0 rmdir -- >/dev/null 2>&1
# fi

#if cd /var/spool/cron/crontabs
#then
#	find . -name 'tmp.[0-9]*' -mtime +2 -print0 | xargs -r0 rm -f --
#fi

umask 022
if cd $bak
then
	cmp -s passwd.bak /etc/passwd || cp -p /etc/passwd passwd.bak
	cmp -s group.bak  /etc/group  || cp -p /etc/group  group.bak
fi

cd /var/lib/dpkg
if ! cmp -s status.yesterday.0 status
then
	cp -p status status.yesterday
	savelog -c 7 status.yesterday >/dev/null
fi

cd /var/log
umask 027
savelog -c 7 setuid.changes >/dev/null
checksecurity >setuid.changes
