"Fossies" - the Fresh Open Source Software Archive

Member "libsafe-2.0-16/tools/libsafe_enable" (16 Oct 2001, 2111 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 #!/usr/bin/shellmod 
    2 #
    3 # Allow you to add or remove libsafe entries from /etc/ld.so.preload
    4 # Make sure you have shellmod installed. If shellmod is not under /usr/bin
    5 # then change the path for shellmod above. 
    6 # Also make sure shellmod-lib.sh is at the location below.
    7 #
    8 . /usr/lib/linuxconf/lib/shellmod-lib.sh 
    9 libsafe=/lib/libsafe.so.2
   10 preload=/etc/ld.so.preload
   11 tload=/etc/ld.so.preload.tmp
   12 
   13 
   14 addlib(){
   15            if [ -f $libsafe ]
   16            then
   17                echo notice \"Libsafe Added\"
   18                if [ -f $preload ]
   19            then
   20               cp -fp $preload $preload.bak
   21               grep -v libsafe $preload > $tload
   22               echo $libsafe >> $tload
   23               cp -fp  $tload $preload
   24               rm  -f $tload
   25            else 
   26               echo $libsafe >> $preload
   27            fi
   28            echo  notice \" The System will be protected by libsafe from now on.\"
   29         else    
   30            echo notice \" No change made as libsafe is not installed on the system. \"
   31         fi
   32 }
   33 
   34 
   35 removelib(){
   36            if [ -f $preload ]
   37            then
   38                cp -fp $preload $preload.bak
   39            grep -v libsafe $preload > $tload
   40            if [ -s $tload ]
   41            then
   42               cp -fp $tload $preload
   43            else
   44               rm -f $preload
   45            fi
   46            rm -f $tload
   47                    echo notice \"Libsafe Removed\"
   48         else
   49            echo notice \"No change made as /etc/ld.so.preload does not exist \"
   50         fi
   51 
   52 }
   53 
   54 main(){
   55            if [ $UID -ne 0 ]
   56            then
   57                echo  notice \"You must be root to run the $0\"
   58            exit 0
   59            fi
   60                echo DIALOG_MENU
   61                echo new_menuitem  addlib \"\" \"Add Libsafe\"
   62                echo new_menuitem removelib \"\" \"Remove Libsafe\"
   63            echo defval var1 Add Libsafe: adds an entry to /etc/ld.so.preload 
   64            echo defval var1 and will protect all processes on the system.
   65            echo defval var1 
   66            echo defval var1 Remove Libsafe: Removes all entries with the 
   67            echo defval var1 word libsafe from /etc/ld.so.preload and saves 
   68            echo defval var1 the original to /etc/ld.so.preload.bak
   69                echo editmenu  \"Libsafe Configuration\"=var1
   70                dispatch
   71                echo end
   72 }
   73 dispatch