#!/bin/sh
# Programm to run weekly 
# must be run by root
{
echo "Output from sulker `date` at `/bin/hostname`"
echo ""
# remove old core, a.out and .o files
/usr/bin/find / \( -name a.out -name core -name '*.o' \) -atime +7 \
   -exec /bin/rm -f {} \;

# clean up /tmp and /usr/tmp
/usr/bin/find /tmp -type f -atime +7 -exec /bin/rm -f {} \;
/usr/bin/find /usr/tmp -type f -atime +7 -exec /bin/rm -f {} \;

# find accounts without password
echo ""
echo "Accounts without password"
echo "-------------------------"
/usr/bin/grep '^[^:]*::' /etc/shadow

# find accounts with UID 0 and/or GID 0
echo ""
echo "Accounts with ID 0"
echo "------------------"
/usr/bin/grep ':00*:' /etc/passwd

echo "SUID-files"
echo "-----------"
/usr/bin/find / -perm -4000 -type f -exec ls -l {} \;
echo ""

echo "SGID-files"
echo "----------"
/usr/bin/find / -perm -2000 -type f -exec ls -l {} \;
# Find world-writable files
echo ""

echo "World-writable files"
echo "--------------------"
/usr/bin/find / -perm -2 \( -type f -o -type d \) -exec ls -l {} \;

# Find files without owner
echo ""
echo "Files without owner"
echo "-------------------"
/usr/bin/find / -nouser -exec ls -l {} \;

cat /etc/passwd | \
awk -F: '{ print $6 }' | \
grep "/home/" | uniq > /tmp/space.homedirs
echo ""
echo "Plattenbelegung in /home"
echo "------------------------"
du -s `cat /tmp/space.homedirs` | sort -nr

# Print sulog
echo ""
echo "/var/adm/sulog:"
echo "---------------"
cat /var/adm/sulog
} 2>&1 | mailx -s "Sulker" root 2>&1
