#!/bin/sh -e

# Copyright (C) 2001, 2002, 2003, 2004 Joost van Baal
#
# This file is part of systraq.  Systraq is free software; you can redistribute
# it and/or modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of the License,
# or (at your option) any later version.  You should have received a copy of
# the GNU General Public License along with this file (see COPYING).

for h in `cut -d: -f6 /etc/passwd | sort -u`
do
    [ -d $h ] && HOMES="$HOMES $h"
done

SH_files="/etc/profile /etc/csh.cshrc /etc/csh.login /etc/bash.bashrc \
 /etc/zshenv /etc/zprofile /etc/zshrc /etc/zlogin /etc/zlogout \
 /etc/zsh-beta/zshenv /etc/zsh-beta/zprofile /etc/zsh-beta/zshrc \
 /etc/zsh-beta/zlogin /etc/zsh-beta/zlogout"
for f in $SH_files
do
    [ -f $f ] && SH_FILES="$SH_FILES $f"
done

SH_HOME=".profile .cshrc .tcshrc .login .logout .bash_profile .bashrc \
 .bash_login .bash_logout .klogin .zshenv .zprofile .zshrc .zlogin .zlogout"

HOMES="$HOMES /etc/skel"
for h in $HOMES
do
    for f in $SH_HOME
    do
        [ -f $h/$f ] && SH_FILES="$SH_FILES $h/$f"
    done
done

echo
echo 'check if umask (002 or 022 please) and PATH (no dot please) are sane'
for f in $SH_FILES
do
    if egrep umask\|PATH $f | grep -v '^#' | grep -v '^umask 0[02]2$' >/dev/null
    then
        echo 
        echo found in file $f:
        egrep umask\|PATH $f | grep -v '^#' | grep -v '^umask 0[02]2$'
    fi
done

