#!/bin/sh # Author: Lubomir Host 'rajo' # $Id: check-permisions.sh,v 1.1 2002/02/01 22:52:46 host8 Exp $ # Use this script to check permision of your files! # Security options! umask 077 # File with files to ignore file's permisions # USE THIS WITH CARE!!! IGNORE_FILE="$HOME/.check-permisions.ignore" # Use $IGNORE file if required {{{ if [ $# -gt 0 ]; then if [ "x$1" = "x-ignore" ]; then echo "Ignoring files from $IGNORE_FILE !" IGNORE="yes" fi if [ "x$1" = "x--ignore" ]; then echo "Ignoring files from $IGNORE_FILE !" IGNORE="yes" fi if [ "x$IGNORE" = "xyes" ]; then if [ ! -f "$IGNORE_FILE" ]; then # if not exists echo "$IGNORE_FILE not found!" IGNORE="no" fi if [ ! -s "$IGNORE_FILE" ]; then # if not exists or size=0 IGNORE="no" fi fi fi # }}} # $IGNORE_FILE is OK, counting ignored files {{{ if [ "x$IGNORE" = "xyes" ]; then IGNORE_MSG="Files with bad permisions which were ignored:" FIND_ARGS="" # Removing line numbers for empty lines or comments LINES="`cat -n $IGNORE_FILE | \ egrep -v '^[ ]*([[:digit:]]*)([ ]*)[#;"]' | \ egrep -v '^[ ]*([[:digit:]]*)([ ]*)$' | \ awk '{ print $1}' `" for i in $LINES do #IGNORE_PATH=`tail --lines=$i $IGNORE_FILE | head --lines=1 ` IGNORE_PATH=`awk "{ if (NR == $i) print }" $IGNORE_FILE ` COUNT=`find $IGNORE_PATH \! -type l -perm +077 -print | wc -l ` IGNORE_MSG="$IGNORE_MSG $COUNT in $IGNORE_PATH" FIND_ARGS="$FIND_ARGS -path $IGNORE_PATH -prune -o" done IGNORE_MSG="$IGNORE_MSG ---" fi # }}} cat <