## /bin/sh
##
## Script to add stuff to .ulogin file to check
## for changes to .login file (possible trojans
## and for '+ +' string in .rhosts file
##
## By
##     Nick Smith 1995 <nasmith@bradford.ac.uk>
##
## NB: To use it you must have $HOME defined
##     e.g. setenv $HOME /homedir/nasmith/

## The .login.log file is used to store an old
## description of the .login file

ls -l $HOME/.login > $HOME/.login.log

## Add the script to your .ulogin file

cat >> $HOME/.ulogin << 'EOF'


echo ''

set FILE = .login

## test for alteration in .login

ls -l $HOME/$FILE > $HOME/.login.log.compare
diff $HOME/.login.log $HOME/.login.log.compare > $HOME/.login.diff

if (-z $HOME/.login.diff) then
  goto carryon
else
  echo "File $FILE has been changed"
  echo '' 
  echo -n "Do you want to see $FILE ? "
  set answer = $<
  if ($answer == 'y' || $answer == 'Y') then
    cat $HOME/$FILE | more
  endif
  echo ''
  echo -n "Have you changed it? "
  set answer = $<
  if ($answer == 'n' || $answer == 'N') then
    echo ''
    echo -n "Do you want to change your password? "
    set answer = $<
    echo ''
    if ($answer == 'y' || $answer == 'Y') then
      passwd
    else
      echo "WARNING... Someone may have got access to your account"
    endif
  endif
  echo ''
endif


carryon:

## Check .rhosts file

if (-e $HOME/.rhosts) then
  cat $HOME/.rhosts | grep -i '+ +' > $HOME/.rhosts.check
  if (-z $HOME/.rhosts.check) then
    goto tidyup
  else
    echo "The string '+ +' has been found in your .rhosts file"
    echo "This means everyone is a trusted user"
    echo ''
    echo -n "Do you want to delete this file? "
    set answer = $<
    if ($answer == 'y' || $answer == 'Y') then
      rm -f .rhosts
    else
      echo "WARNING.... Anyone can rlogin into your account"
    endif
  endif
endif


tidyup:

## Remove temporary files

rm -f $HOME/.login.diff $HOME/.login.log.compare $HOME/.rhosts.check

__EOF__


------------------------ CUT HERE ------------------------

-- 
n.a.smith@bradford.ac.uk              http://www.brad.ac.uk/~nasmith/index.html
finger nasmith@muser.brad.ac.uk	      Maintainer of the hip-hop WWW lyrics site 
for PGP block
              "Jesus Saves! Moses has the rebound, he shoots, he scores!"

