home *** CD-ROM | disk | FTP | other *** search
/ ftp.rsa.com / 2014.05.ftp.rsa.com.tar / ftp.rsa.com / pub / agents / old_AuthenticationAgent_534_PAM.tar / install_pam.sh next >
Linux/UNIX/POSIX Shell Script  |  2005-06-29  |  14KB  |  487 lines

  1. #!/bin/sh 
  2. #
  3. # Installation script for the RSA Authentication Agent 5.3 for PAM.
  4. #
  5. #
  6. #********************************************************************************
  7. #* COPYRIGHT (C) 2003  by RSA Security Inc.
  8. #*    ---ALL RIGHTS RESERVED---
  9. #********************************************************************************
  10. #
  11.  
  12. ############################################################
  13. # Set default values and commands for the shell script.
  14. ############################################################
  15. UNAME=`uname`
  16. UNAMER=`uname -r`
  17. HOSTNAME=`hostname`
  18. USER_NAME=""
  19.  
  20. HERE=`dirname $0` 
  21. THEPWD=`/bin/pwd`
  22. if [ "$HERE" = "." ]; then
  23.     HERE="$THEPWD"
  24. else
  25. #if $HERE isn't absolute path add `pwd` to it
  26.  
  27.     cd $HERE
  28.     HERE=`/bin/pwd`
  29.     cd $THEPWD
  30. fi
  31.  
  32. #suji needs to change
  33. ########################
  34. ########################
  35. CONFIG_FILE=""
  36. PAM_AGENT="/tmp/toto"
  37. PAM_AGENT_TAR="sd_pam_agent.tar"
  38. PAM_AGENT_MODULE="pam_securid"
  39. PAM_AGENT_DOC="doc"
  40. PAM_AGENT_README="readme.html"
  41. PAM_AGENT_TAR_GZ="$PAM_AGENT_TAR.gz"
  42. LICENSE="$HERE/license.txt"
  43. LICENSE2="$HERE/license2.txt"
  44. MODULE_DIR="/usr/lib/security"
  45. PATH_ROOT=""
  46. echo_no_nl_mode="unknown"
  47.  
  48. ##############################################################################
  49. # Trap 
  50. #    this will trap any escape characters, and allow the program to abort normally 
  51. #    by calling abort_installation
  52. ##############################################################################
  53. trap 'trap "" 1 2 15; abort_installation' 1 2 15
  54.  
  55. ##############################################################################
  56. # echo_no_nl()
  57. #       Echo a string with no carriage return (if possible).  Must set
  58. #       $echo_no_nl to "unknown" before using for the first time.
  59. ##############################################################################
  60. echo_no_nl()
  61. {
  62.   if [ "$echo_no_nl_mode" = "unknown" ] ; then
  63.      echo_test=`echo \\\c`
  64.      if [ "$echo_test" = "\c" ] ; then
  65.         echo_no_nl_mode="-n"
  66.      else
  67.         echo_no_nl_mode="\c"
  68.      fi
  69.   fi
  70.  
  71.   if [ "$echo_no_nl_mode" = "\c" ] ; then
  72.      echo $* \\c
  73.   else
  74.      echo -n $*
  75.   fi
  76. }
  77.  
  78.  
  79. ##############################################################################
  80. # getfilename()
  81. # Gets a filename
  82. #   $1  The string to print to prompt the user
  83. #   $2  The default value if user hits <Enter> (y/n)
  84. #   $3  Type : DIRECTORY, EXISTINGFILE, NEWFILE, NEWDIRECTORY
  85. # The variable $YESORNO is set in accordance to what the user entered.
  86. ##############################################################################
  87. getfilename()
  88. {
  89. #####################################################
  90. # Set up line parameters as $1 and $2 are overwritten
  91. #####################################################
  92.   theprompt=$1
  93.   thedefault=$2
  94.   thetype=$3
  95.  
  96.   theans=""
  97.   until [ -n "$theans" ] ;
  98.   do
  99.     echo ""
  100.     echo_no_nl "$theprompt [$thedefault] "
  101.     read theans
  102.  
  103.     if [ "$theans" = "" ] ; then
  104.       theans=$thedefault
  105.     fi
  106.     case $thetype in
  107.         DIRECTORY) if [ ! -d "$theans" ]; then
  108.                         echo Directory $theans doesn\'t exist
  109.                         theans=""
  110.                    fi;;
  111.         READFILE)  if [ ! -f "$theans" ]; then
  112.                         echo File $theans doesn\'t exist
  113.                         theans=""
  114.                    elif [ ! -r "$theans" ]; then
  115.                         echo File "$theans" isn\'t readable
  116.                         theans=""
  117.                    fi;;
  118.         WRITEFILE)  if [ ! -f "$theans" ]; then
  119.                         echo File $theans doesn\'t exist
  120.                         theans=""
  121.                    elif [ ! -w "$theans" ]; then
  122.                         echo File "$theans" isn\'t writable
  123.                         theans=""
  124.                    fi;;
  125.         EXECFILE)  if [ ! -f "$theans" ]; then
  126.                         echo File $theans doesn\'t exist
  127.                         theans=""
  128.                    elif [ ! -x "$theans" ]; then
  129.                         echo File "$theans" isn\'t writable
  130.                         theans=""
  131.                    fi;;
  132.         NEWFILE)   if [ -f "$theans" ]; then
  133.                         echo File $theans already exist
  134.                         theans=""
  135.                    elif [ ! -d `dirname $theans` ]; then
  136.                         echo Directory `dirname $theans` doesn\'t exist
  137.                         theans=""
  138.                    elif [ ! -w `dirname $theans` ]; then
  139.                         echo Directory `dirname $theans` isn\'t writable
  140.                         theans=""
  141.                    fi;;
  142.         *);;
  143.     esac
  144.   done
  145.  
  146. }
  147.  
  148. ##############################################################################
  149. # getAcceptDecline()
  150. # Gets either a "Accept" or a "Decline" in the traditional (a/d) pattern 
  151. #               $1      The default value if user hits <Enter> (TRUE/FALSE)
  152. #               $2      The string to print to prompt the user
  153. # The variable $AORD is set in accordance to what the user entered.
  154. ##############################################################################
  155. getAcceptDecline()
  156. {
  157. #####################################################
  158. # Set up line parameters as $1 and $2 are overwritten
  159. #####################################################
  160.   AorDdef=$1
  161.   AorDprompt=$2
  162.  
  163.   AORD=""
  164.   until [ -n "$AORD" ] ;
  165.   do
  166.     echo ""
  167.     echo_no_nl $AorDprompt
  168.     read AORD
  169.  
  170.     AORD=`echo $AORD | tr '[a-z]' '[A-Z]'`
  171.  
  172.     case "$AORD"
  173.     in
  174.       A|ACCEPT )  AORD=TRUE;;
  175.       D|DECLINE )  AORD=FALSE;;
  176.       ''  )  AORD=$AorDdef;;
  177.       *   )  echo ""
  178.              echo "Please enter 'A', 'D' or '<return>' "
  179.              AORD="";;
  180.     esac
  181.   done
  182.  
  183. }
  184.  
  185.  
  186. ##############################################################################
  187. # getyesorno()
  188. # Gets either a "yes" or a "no" in the traditional (y/n) pattern 
  189. #               $1      The default value if user hits <Enter> (TRUE/FALSE)
  190. #               $2      The string to print to prompt the user
  191. # The variable $YESORNO is set in accordance to what the user entered.
  192. ##############################################################################
  193. getyesorno()
  194. {
  195. #####################################################
  196. # Set up line parameters as $1 and $2 are overwritten
  197. #####################################################
  198.   yesornodef=$1
  199.   yesornoprompt=$2
  200.  
  201.   YESORNO=""
  202.   until [ -n "$YESORNO" ] ;
  203.   do
  204.     echo ""
  205.     echo_no_nl $yesornoprompt
  206.     read YESORNO
  207.  
  208.     case "$YESORNO"
  209.     in
  210.       y|Y )  YESORNO=TRUE;;
  211.       n|N )  YESORNO=FALSE;;
  212.       ''  )  YESORNO=$yesornodef;;
  213.       *   )  echo ""
  214.              echo "Please enter 'y', 'n' or '<return>' "
  215.              YESORNO="";;
  216.     esac
  217.   done
  218.  
  219. }
  220.  
  221.  
  222. ##############################################################################
  223. # abort_installation()
  224. # This subroutine removes files that were recently installed and restores
  225. # the previous installation files, if they existed.
  226. ##############################################################################
  227. abort_installation()
  228. {
  229. #CP__need to fix this when done. Make sure to set values for each file placed somewhere
  230. echo ""
  231.   echo "Aborting Installation..."
  232.   exit 1
  233. }
  234.  
  235.  
  236. ############################################################
  237. # Display the License and Copyright files.
  238. ############################################################
  239. startup_screen()
  240. {
  241.  
  242.     # Changed so that we could have both license files shown
  243.     getyesorno TRUE "ARE YOU A CUSTOMER ORDERING THIS RSA PRODUCT FROM RSA SECURITY INC., FROM EITHER NORTH AMERICA, SOUTH AMERICA OR THE PEOPLE'S REPUBLIC OF CHINA (EXCLUDING HONG KONG): (y/n) [y]"
  244.     if [ "$YESORNO" = TRUE ] ; then
  245.         if [ -f $LICENSE ] ; then
  246.         more $LICENSE 
  247.     else
  248.         echo "The License Agreement text file could not be found in the current directory."
  249.         echo "Installation is aborting..."
  250.             abort_installation
  251.     fi
  252.     else
  253.         if [ -f $LICENSE2 ] ; then
  254.         more $LICENSE2 
  255.     else
  256.         echo "The License Agreement text file could not be found in the current directory."
  257.         echo "Installation is aborting..."
  258.         abort_installation
  259.     fi
  260.     fi
  261.  
  262.      getAcceptDecline FALSE "Do you accept the License Terms and Conditions stated above? (Accept/Decline) [D]"
  263.     if [ "$AORD" = FALSE ] ; then
  264.     abort_installation;
  265.     fi
  266.     echo ""
  267.     echo ""
  268.     echo ""
  269. }
  270.  
  271. ############################################################
  272. # Check to see if the environment variable VAR_ACE is
  273. # defined and sdconf.rec exists
  274. ############################################################
  275. check_sdconf()
  276. {
  277. noerror=0
  278. if [ ! -n "$VAR_ACE" ]; then
  279.     VAR_ACE="/var/ace"
  280. fi
  281. theans=""
  282. while [ "$theans" = "" ] 
  283. do
  284.     getfilename "Enter Directory where sdconf.rec is located" $VAR_ACE DIRECTORY
  285.     if [ ! -f "$theans/sdconf.rec" ]; then 
  286.     echo file "$theans/sdconf.rec" not found
  287.     theans=""
  288.     elif [ ! -r "$theans/sdconf.rec" ]; then
  289.     echo file "$theans/sdconf.rec" not readable: change protection if needed
  290.         VAR_ACE="$theans"
  291.     theans=""
  292.     else
  293.     if [ "$theans" != "" ]; then
  294.             VAR_ACE="$theans"
  295.     fi
  296.     break
  297.     fi
  298.     
  299. done
  300.  
  301. }
  302.  
  303. ############################################################
  304. # Check to see if this is a supported platform.
  305. ############################################################
  306. check_platform()
  307. {
  308. case $UNAME
  309.    in
  310.      'SunOS'  )  SUN_VERS=`echo $UNAMER `
  311.                 case "$SUN_VERS" in
  312.                 * )
  313.             WHOAMISOL=`/usr/ucb/whoami`
  314.                     OS_DIR="sol" 
  315.             OS_EXT="so"
  316.             USER_NAME=`echo $WHOAMISOL`;;
  317.                 esac;;
  318.  
  319.      'Linux' ) LNX_VERS=`echo $UNAMER `
  320.                 case "$LNX_VERS" in
  321.                 * ) 
  322.                     WHOAMILNX=`/usr/bin/whoami`
  323.                     OS_DIR="lnxas3"
  324.                     OS_EXT="so"
  325.                     MODULE_DIR="/lib/security"
  326.                     USER_NAME=`echo $WHOAMILNX`;;
  327.                 esac;;
  328.  
  329.      'HP-UX' ) HP_VERS=`echo $UNAMER`
  330.                case "$HP_VERS" in
  331.                * )
  332.            WHOAMIHP11=`/bin/whoami`
  333.                    OS_DIR="hp11"
  334.                    OS_EXT="1"
  335.            USER_NAME=`echo $WHOAMIHP11`;;
  336.                esac;;
  337.      
  338.      'AIX' ) AIX_VERS=`uname -vr | awk '{print $2 * 1000 + $1}'`
  339.                 case "$AIX_VERS" in 
  340.             *)
  341.             OS_DIR="aix"
  342.                    OS_EXT="so";
  343.                     USER_NAME=`/usr/bin/whoami`
  344.                esac;; 
  345.      *   )  echo ""
  346.             echo "Sorry, $UNAME is not currently supported."
  347.             echo ""
  348.             abort_installation ;;
  349. esac
  350. }
  351.  
  352.  
  353. ############################################################
  354. # Ask the user for the destination of the Agent files and
  355. # other installation information, documentation
  356. ############################################################
  357. setup_paths()
  358. {
  359. ###########################################
  360. # Get the Agent directory path
  361. ###########################################
  362. theans=""
  363. DEFAULT_AGENT_ROOT="/opt"
  364. AGENT_ROOT=""
  365.  
  366. echo ""
  367. getfilename "Please enter the root path for the RSA Authentication Agent for PAM directory" $DEFAULT_AGENT_ROOT DIRECTORY
  368. if [ "$theans" = "" ]; then
  369.     theans="$DEFAULT_AGENT_ROOT"
  370. fi
  371. while [ -d "$theans/pam" ] 
  372. do
  373.     echo PAM Agent is already installed in the "$theans/pam"
  374.     getyesorno TRUE "Would you like to over write it? (y/n) [y]"
  375.     if [ "$YESORNO" = FALSE ] ; then
  376.         getfilename "Please enter the root path for the new RSA Authentication Agent for PAM directory" $DEFAULT_AGENT_ROOT DIRECTORY
  377.     else
  378.         AGENT_ROOT="$theans"
  379.         break
  380.     fi
  381. done
  382. if [ "$AGENT_ROOT" = "" ]; then
  383.     AGENT_ROOT="$theans"
  384. fi
  385.  
  386.  
  387. echo ""
  388. echo "The RSA Authentication Agent for PAM will be installed in the $AGENT_ROOT directory."
  389.  
  390. }
  391.  
  392. create_conf()
  393. {
  394. #################
  395. # create sd_pam.conf
  396. #################
  397.  
  398. touch /etc/sd_pam.conf
  399. rm /etc/sd_pam.conf
  400.  
  401. echo "#VAR_ACE ::  the location where the sdconf.rec, sdstatus.12 and securid files will go" >> /etc/sd_pam.conf
  402. echo "VAR_ACE=$VAR_ACE" >> /etc/sd_pam.conf
  403. echo "" >> /etc/sd_pam.conf
  404. echo "" >> /etc/sd_pam.conf
  405. echo "#ENALE_GROUP_SUPPORT :: 1 to enable; 0 to disable group support" >> /etc/sd_pam.conf
  406. echo "ENABLE_GROUP_SUPPORT=0" >> /etc/sd_pam.conf
  407. echo "" >> /etc/sd_pam.conf
  408. echo "" >> /etc/sd_pam.conf
  409. echo "#INCL_EXCL_GROUPS :: 1 to always prompt the listed groups for securid authentication (include)" >> /etc/sd_pam.conf
  410. echo "#                 :: 0 to never prompt the listed groups for securid authentication (exclude)" >> /etc/sd_pam.conf
  411. echo "INCL_EXCL_GROUPS=0" >> /etc/sd_pam.conf
  412. echo "" >> /etc/sd_pam.conf
  413. echo "" >> /etc/sd_pam.conf
  414. echo "#LIST_OF_GROUPS :: a list of groups to include or exclude...Example" >> /etc/sd_pam.conf
  415. echo "LIST_OF_GROUPS=other:wheel:eng:othergroupnames " >> /etc/sd_pam.conf
  416. chmod 644 /etc/sd_pam.conf 
  417. }
  418.  
  419.  
  420. ############################################################
  421. # Install the RSA Authentication Agent 5.3 for PAM library and documentation.
  422. ############################################################
  423. install_pam_agent()
  424. {
  425. ##############
  426. #untar the RPM file
  427. ##############
  428.  
  429. cd $AGENT_ROOT/
  430. if [ -f $HERE/$OS_DIR/$PAM_AGENT_TAR ]; then
  431.     tar xvf $HERE/$OS_DIR/$PAM_AGENT_TAR
  432. elif [ -f $HERE/$OS_DIR/$PAM_AGENT_TAR_GZ ]; then
  433.     tar xzvf $HERE/$OS_DIR/$PAM_AGENT_TAR_GZ
  434. else
  435.     echo Error $HERE/$OS_DIR/$PAM_AGENT_TAR or $HERE/$OS_DIR/$PAM_AGENT_TAR_GZ does not exist
  436.     abort_installation
  437. fi
  438.  
  439. if [ -d $HERE/$PAM_AGENT_DOC ]; then
  440.     cp -r $HERE/$PAM_AGENT_DOC $WEB_AGENT_DIR
  441. fi
  442.  
  443. if [ -f $HERE/$PAM_AGENT_README ]; then
  444.     cp $HERE/$PAM_AGENT_README $WEB_AGENT_DIR
  445. fi
  446.  
  447. if [ -f $AGENT_ROOT/pam/lib/$PAM_AGENT_MODULE.$OS_EXT ]; then
  448.         cp $HERE/uninstall* $AGENT_ROOT/pam
  449.         cp $AGENT_ROOT/pam/lib/$PAM_AGENT_MODULE.$OS_EXT $MODULE_DIR
  450.         chmod 755 $MODULE_DIR/$PAM_AGENT_MODULE.$OS_EXT
  451. else
  452.         echo Error Could not find $PAM_AGENT_MODULE.$OS_EXT in $AGENT_ROOT/pam/$OS_DIR directory.
  453.         abort_installation
  454. fi
  455. cd $HERE
  456. chown -R root $AGENT_ROOT/pam
  457. chmod -R 700  $AGENT_ROOT/pam
  458.  
  459. }
  460.  
  461. check_user()
  462. {
  463. #########################
  464. # make sure user is root
  465. #########################
  466.  
  467. if [ "$USER_NAME" != root ]; then 
  468.     echo "You Must be ROOT to install this agent"
  469.     abort_installation
  470. fi
  471. }
  472.  
  473.  
  474. check_platform
  475. check_user
  476. startup_screen
  477. check_sdconf
  478. setup_paths
  479. install_pam_agent
  480. create_conf
  481.  
  482. echo ""
  483. echo "*************************************************************"
  484. echo "* You have successfully installed RSA Authentication Agent 5.3 for PAM"
  485. echo "*************************************************************"
  486. echo ""
  487.