intercept 926 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #!/bin/sh
  2. # usage:
  3. # /usr/bin/intercept program <args>
  4. if [ $# = 0 ] ; then
  5. echo "$0: insufficient arguments"
  6. exit
  7. fi
  8. case "$1" in
  9. on)
  10. if [ -z "$LD_PRELOAD" ]
  11. then
  12. export LD_PRELOAD="/lib/libintercept.so.1.0"
  13. else
  14. echo $LD_PRELOAD | grep -q "/lib/libintercept\.so.1.0" || \
  15. export LD_PRELOAD="/lib/libintercept.so $LD_PRELOAD"
  16. fi
  17. ;;
  18. off)
  19. export LD_PRELOAD=`echo -n $LD_PRELOAD | sed 's/\/lib\/libintercept.so.1.0 \?//'`
  20. if [ -z "$LD_PRELOAD" ]
  21. then
  22. unset LD_PRELOAD
  23. fi
  24. ;;
  25. show|sh)
  26. echo "LD_PRELOAD=\"$LD_PRELOAD\""
  27. ;;
  28. -h|-?)
  29. echo ""
  30. ;;
  31. *)
  32. if [ -z "$LD_PRELOAD" ]
  33. then
  34. export LD_PRELOAD="/lib/libintercept.so.1.0"
  35. else
  36. echo $LD_PRELOAD | grep -q "/lib/libintercept\.so.1.0" || \
  37. export LD_PRELOAD="/lib/libintercept.so.1.0 $LD_PRELOAD"
  38. fi
  39. if [ $# = 0 ]
  40. then
  41. ${SHELL:-/bin/sh}
  42. fi
  43. if [ $# -gt 0 ]
  44. then
  45. exec "$@"
  46. fi
  47. ;;
  48. esac
  49. #EOF