home *** CD-ROM | disk | FTP | other *** search
/ ftp.rsa.com / 2014.05.ftp.rsa.com.tar / ftp.rsa.com / pub / agents / PAM-Agent_v7.0.1.29.02_25_11_04_30_33.tar / PAM-Agent_v7.0.0.29.02_25_11_04_30_33 / uninstall_pam.sh < prev   
Linux/UNIX/POSIX Shell Script  |  2011-02-25  |  11KB  |  350 lines

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