home *** CD-ROM | disk | FTP | other *** search
/ ftp.rsa.com / 2014.05.ftp.rsa.com.tar / ftp.rsa.com / pub / agents / AuthenticationAgent_60_PAM_95_060308.tar / uninstall_pam.sh < prev   
Linux/UNIX/POSIX Shell Script  |  2008-06-03  |  9KB  |  298 lines

  1. #!/bin/sh
  2. #
  3. # Installation script for the RSA Authentication Agent 6.0 for PAM.
  4. #
  5. #
  6. #********************************************************************************
  7. #* COPYRIGHT (C) 2007  by RSA Security Inc.
  8. #*      ---ALL RIGHTS RESERVED---
  9. #********************************************************************************
  10. #
  11. echo_no_nl_mode="unknown"
  12. UNAME=`uname`
  13. UNAMER=`uname -r`
  14. MODULE_DIR="/usr/lib/security"
  15. PAM_AGENT_MODULE="pam_securid"
  16.  
  17. ##############################################################################
  18. # Trap
  19. #       this will trap any escape characters, and allow the program to abort normally
  20. #       by calling abort_installation
  21. ##############################################################################
  22. trap 'trap "" 1 2 15; abort_installation' 1 2 15
  23.  
  24. ##############################################################################
  25. # abort_installation()
  26. # This subroutine removes files that were recently installed and restores
  27. # the previous installation files, if they existed.
  28. ##############################################################################
  29. abort_installation()
  30. {
  31. #CP__need to fix this when done. Make sure to set values for each file placed somewhere
  32. echo ""
  33.   echo "Aborting Un-install"
  34.  
  35.   exit 1
  36. }
  37.  
  38. ##############################################################################
  39. # echo_no_nl()
  40. #       Echo a string with no carriage return (if possible).  Must set
  41. #       $echo_no_nl to "unknown" before using for the first time.
  42. ##############################################################################
  43. echo_no_nl()
  44. {
  45.   if [ "$echo_no_nl_mode" = "unknown" ] ; then
  46.      echo_test=`echo \\\c`
  47.      if [ "$echo_test" = "\c" ] ; then
  48.         echo_no_nl_mode="-n"
  49.      else
  50.         echo_no_nl_mode="\c"
  51.      fi
  52.   fi
  53.  
  54.   if [ "$echo_no_nl_mode" = "\c" ] ; then
  55.      echo $* \\c
  56.   else
  57.      echo -n $*
  58.   fi
  59. }
  60.  
  61. ##############################################################################
  62. # getfilename()
  63. # Gets a filename
  64. #   $1  The string to print to prompt the user
  65. #   $2  The default value if user hits <Enter> (y/n)
  66. #   $3  Type : DIRECTORY, EXISTINGFILE, NEWFILE, NEWDIRECTORY
  67. # The variable $YESORNO is set in accordance to what the user entered.
  68. ##############################################################################
  69. getfilename()
  70. {
  71. #####################################################
  72. # Set up line parameters as $1 and $2 are overwritten
  73. #####################################################
  74.   theprompt=$1
  75.   thedefault=$2
  76.   thetype=$3
  77.  
  78.   theans=""
  79.   until [ -n "$theans" ] ;
  80.   do
  81.     echo ""
  82.     echo_no_nl "$theprompt [$thedefault] "
  83.     read theans
  84.  
  85.     if [ "$theans" = "" ] ; then
  86.       theans=$thedefault
  87.     fi
  88.     case $thetype in
  89.         DIRECTORY) if [ ! -d "$theans" ]; then
  90.                         echo Directory $theans doesn\'t exist
  91.                         theans=""
  92.                    fi;;
  93.         READFILE)  if [ ! -f "$theans" ]; then
  94.                         echo File $theans doesn\'t exist
  95.                         theans=""
  96.                    elif [ ! -r "$theans" ]; then
  97.                         echo File "$theans" isn\'t readable
  98.                         theans=""
  99.                    fi;;
  100.         WRITEFILE)  if [ ! -f "$theans" ]; then
  101.                         echo File $theans doesn\'t exist
  102.                         theans=""
  103.                    elif [ ! -w "$theans" ]; then
  104.                         echo File "$theans" isn\'t writable
  105.                         theans=""
  106.                    fi;;
  107.         EXECFILE)  if [ ! -f "$theans" ]; then
  108.                         echo File $theans doesn\'t exist
  109.                         theans=""
  110.                    elif [ ! -x "$theans" ]; then
  111.                         echo File "$theans" isn\'t writable
  112.                         theans=""
  113.                    fi;;
  114.         NEWFILE)   if [ -f "$theans" ]; then
  115.                         echo File $theans already exist
  116.                         theans=""
  117.                    elif [ ! -d `dirname $theans` ]; then
  118.                         echo Directory `dirname $theans` doesn\'t exist
  119.                         theans=""
  120.                    elif [ ! -w `dirname $theans` ]; then
  121.                         echo Directory `dirname $theans` isn\'t writable
  122.                         theans=""
  123.                    fi;;
  124.         *);;
  125.     esac
  126.   done
  127.  
  128. }
  129.  
  130. ##############################################################################
  131. # getyesorno()
  132. # Gets either a "yes" or a "no" in the traditional (y/n) pattern
  133. #               $1      The default value if user hits <Enter> (TRUE/FALSE)
  134. #               $2      The string to print to prompt the user
  135. # The variable $YESORNO is set in accordance to what the user entered.
  136. ##############################################################################
  137. getyesorno()
  138. {
  139. #####################################################
  140. # Set up line parameters as $1 and $2 are overwritten
  141. #####################################################
  142.   yesornodef=$1
  143.   yesornoprompt=$2
  144.  
  145.   YESORNO=""
  146.   until [ -n "$YESORNO" ] ;
  147.   do
  148.     echo ""
  149.     echo_no_nl $yesornoprompt
  150.     read YESORNO
  151.  
  152.     case "$YESORNO"
  153.     in
  154.       y|Y )  YESORNO=TRUE;;
  155.       n|N )  YESORNO=FALSE;;
  156.       ''  )  YESORNO=$yesornodef;;
  157.       *   )  echo ""
  158.              echo "Please enter 'y', 'n' or '<return>' "
  159.              YESORNO="";;
  160.     esac
  161.   done
  162.  
  163. }
  164.  
  165. check_user()
  166. {
  167. #########################
  168. # make sure user is root
  169. #########################
  170.  
  171.  
  172. if [ "$USER_NAME" != root ]; then
  173.     echo "You Must be ROOT to uninstall this agent"
  174.     abort_installation
  175. fi
  176. }
  177.  
  178. ############################################################
  179. # Check to see if this is a supported platform.
  180. ############################################################
  181. check_platform()
  182. {
  183. case $UNAME
  184.    in
  185.      'SunOS'  )  SUN_VERS=`echo $UNAMER `
  186.                case "$SUN_VERS" in
  187.                * )
  188.                     WHOAMISOL=`/usr/ucb/whoami`
  189.                     OS_EXT="so"
  190.                     USER_NAME=`echo $WHOAMISOL`;;
  191.         esac;;
  192.  
  193.      'Linux' ) LNX_VERS=`echo $UNAMER `
  194.                 case "$LNX_VERS" in
  195.                 * )
  196.                     WHOAMILNX=`/usr/bin/whoami`
  197.                     OS_EXT="so"
  198.             if [ -d "/lib64/security" ]; then
  199.             MODULE_DIR="/lib64/security"
  200.             else
  201.             MODULE_DIR="/lib/security"
  202.             fi
  203.                     USER_NAME=`echo $WHOAMILNX`;;
  204.                 esac;;
  205.  
  206.     'HP-UX' ) HP_VERS=`echo $UNAMER`
  207.     case "$HP_VERS" in
  208.         'B.11.23' )
  209.                    WHOAMIHP11=`/bin/whoami`
  210.                    OS_DIR="hpitan"
  211.                    OS_EXT="1"
  212.                    MODULE_DIR="/usr/lib/security/hpux32"
  213.                    USER_NAME=`echo $WHOAMIHP11`;;
  214.                * )
  215.                    WHOAMIHP11=`/bin/whoami`
  216.                    OS_DIR="hp11"
  217.                    OS_EXT="1"
  218.                    USER_NAME=`echo $WHOAMIHP11`;;
  219.                esac;;
  220.  
  221.      'AIX' ) AIX_VERS=`uname -vr | awk '{print $2 * 1000 + $1}'`
  222.                 case "$AIX_VERS" in
  223.                 *)
  224.                     OS_EXT="so";
  225.                     USER_NAME=`/usr/bin/whoami`
  226.                 esac;;
  227.      *   )  echo ""
  228.             echo "Sorry, $UNAME is not currently supported."
  229.             echo ""
  230.             abort_installation ;;
  231. esac
  232. }
  233.  
  234. ############################################################
  235. # Ask the user for the PAM installation directory.
  236. ############################################################
  237. setup_paths()
  238. {
  239. ###########################################
  240. # Get the Agent directory path
  241. ###########################################
  242. theans=""
  243. DEFAULT_AGENT_ROOT="/opt"
  244. AGENT_ROOT=""
  245.  
  246. echo ""
  247. getfilename "Please enter the root path for the RSA Authentication Agent for PAM directory" $DEFAULT_AGENT_ROOT DIRECTORY
  248. if [ "$theans" = "" ]; then
  249.     theans="$DEFAULT_AGENT_ROOT"
  250. fi
  251.  
  252. while [ ! -d "$theans/pam" ] 
  253. do
  254.     echo PAM Agent is not installed in "$theans/pam"
  255.     getfilename "Please enter the root path for the RSA Authentication Agent for PAM directory" $DEFAULT_AGENT_ROOT DIRECTORY
  256.     if [ "$theans" = "" ]; then
  257.         theans="$DEFAULT_AGENT_ROOT"
  258.     fi
  259. done
  260.  
  261. if [ "$AGENT_ROOT" = "" ]; then
  262.     AGENT_ROOT="$theans"
  263. fi
  264.  
  265.  
  266. echo ""
  267. getyesorno FALSE "The RSA Authentication Agent for PAM will be deleted from the $AGENT_ROOT directory.  Ok? (y/n) [n]"
  268. if [ "$YESORNO" = FALSE ] ; then
  269.     echo "Exiting without uninstalling the agent"
  270.     abort_installation
  271. fi
  272. }
  273.  
  274. uninstall()
  275. {
  276.     rm -rf "$AGENT_ROOT"/pam
  277.     rm /etc/sd_pam.conf
  278.     rm "$MODULE_DIR"/"$PAM_AGENT_MODULE"."$OS_EXT"
  279. }
  280.  
  281. getyesorno FALSE "Are you sure that you would like to uninstall the RSA Authentication Agent 6.0 for PAM? (y/n) [n]"
  282. if [ "$YESORNO" = FALSE ] ; then
  283.     echo "Exiting without uninstalling the agent"
  284.     abort_installation
  285. else
  286.     check_platform
  287.     check_user
  288.     setup_paths
  289.     uninstall
  290.     echo ""
  291.     echo "**********************************************************************"
  292.     echo "* You have successfully uninstalled RSA Authentication Agent 6.0 for PAM"
  293.     echo "**********************************************************************"
  294.     echo ""
  295. fi
  296.  
  297.  
  298.