"Fossies" - the Fresh Open Source Software Archive

Member "libsafe-2.0-16/tools/libsafe-install.sh" (16 Oct 2001, 1177 Bytes) of package /linux/misc/old/libsafe-2.0-16.tgz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 #!/bin/bash
    2 #
    3 #Shell script for adding or removing libsafe entry from /etc/ld.so.preload
    4 #
    5 libsafe=/lib/libsafe.so.2
    6 preload=/etc/ld.so.preload
    7 tload=/tmp/ld.so.preload
    8 
    9 
   10 install-libsafe() {
   11     if [ -f $libsafe ]
   12     then
   13         if [ -f $preload ] 
   14         then
   15             cp -fp $preload $preload.bak
   16             grep -v libsafe $preload > $tload
   17             echo "$libsafe" >> $tload
   18             cp -fp $tload $preload
   19         else
   20             echo "$libsafe" > $preload
   21         fi
   22         echo "The system will be protected by libsafe from now on."
   23     else
   24             echo "No change made as libsafe is not installed on the system."
   25     fi
   26 }
   27 
   28 remove-libsafe() {
   29     if [ -f $preload ]
   30     then
   31         cp -fp $preload $preload.bak
   32         grep -v libsafe $preload.bak > $tload
   33         if [ -s $tload ]
   34         then 
   35             cp -fp  $tload $preload
   36         else
   37             rm -f $preload
   38         fi
   39             rm -f $tload
   40         echo "Libsafe Removed."
   41     else
   42         echo "No change made as /etc/ld.so.preload does not exist."
   43     fi
   44 }
   45     
   46 
   47 usage="Usage: $0 [-i] [-r]"
   48 
   49 if [ $UID -ne 0 ]
   50 then
   51    echo "You must be a root to run $0"
   52    exit 0
   53 fi
   54 
   55 while getopts ":ir" opt; do
   56     case $opt in
   57         i  ) install-libsafe  ;;
   58         r  ) remove-libsafe   ;;
   59         \? ) echo $usage
   60              exit 1 ;;
   61     esac
   62 done
   63 
   64 
   65 if [ -z "$@" ]
   66 then
   67     echo $usage
   68     exit 1
   69 fi