#!/bin/sh # # "666.cgi" --- Doomed (unsafe) permission checker VER='0.13' # # This script checks all directories and files for unsafe permission # such as 666, 777, and anything writable by someone other than yourself, # and correct it. # # WARNING: Please place this in a protected directory # # Usage: http://yourdomaincom/protected/666.cgi # # Additional note to "PHP people": # This script and all other normal CGI need permission of 700 (or 500). # CGI script can be placed and used in ANY directory (on PowWeb servers). # # # This script comes with NO GUARANTY what so ever. # It works for me, but maybe not for you, # especially if you are not nice person. # It's not my problem if you experience any trouble with it. # # I totally neglected the design aspects of this script, as usuall. echo "Content-type: text/html 666.cgi ver.$VER

Checking and correcting doomed permission


"
exec 2>&1

waitbg () {
  CC=''; CCC='0'
  while :;do
    CC="${CC}x"; CCC=$(( $CCC + 1 ))
    case `jobs` in '') break;; esac
    sleep 3; echo -n '.'
    case "$CC" in "xxxxxxxxxx") CC=''; echo;;esac
    case "$CCC" in "$Max") echo "$Mess"; kill $!;Killed='1'; return;; esac
  done
}

hostname; date; uptime; ps uxww
USER=`whoami`
HOME="${HOME:-/www/${USER%${USER#?}}/${USER}}"
echo '
' find $HOME ! -type l -perm +022 -ls -exec chmod go-w {} \; & Max='300'; Mess="check process running too long. Terminating." waitbg; case "$Killed" in '1') return;;esac echo ' Done.
' date;uptime echo "
666.cgi ver.$VER
"