Newer, better, tsocks(1)-like wrapper script for D.U.M.A.
/trunk/scripts/build/debug/duma.in | 44 44 0 0 ++++++++++++++++++++++++++++++++++++++++
/trunk/scripts/build/debug/200-duma.sh | 12 3 9 0 +++--------
2 files changed, 47 insertions(+), 9 deletions(-)
1.1 --- a/scripts/build/debug/200-duma.sh Mon Jun 30 11:58:58 2008 +0000
1.2 +++ b/scripts/build/debug/200-duma.sh Mon Jun 30 20:37:14 2008 +0000
1.3 @@ -58,15 +58,9 @@
1.4 CT_DoLog EXTRA "Installing wrapper script"
1.5 mkdir -p "${CT_DEBUG_INSTALL_DIR}/usr/bin"
1.6 # Install a simpler, smaller, safer wrapper than the one provided by D.U.M.A.
1.7 - cat >"${CT_DEBUG_INSTALL_DIR}/usr/bin/duma" <<_EOF_
1.8 -#!/bin/sh
1.9 -if [ \$# -eq 0 ]; then
1.10 - echo "Usage: \$0 <executable [args]>"
1.11 - exit 1
1.12 -fi
1.13 -export LD_PRELOAD="${duma_so}"
1.14 -exec "\$@"
1.15 -_EOF_
1.16 + sed -r -e 's:^LIBDUMA_SO=.*:LIBDUMA_SO=/usr/lib/'"${duma_so}"':;' \
1.17 + "${CT_LIB_DIR}/scripts/build/debug/duma.in" \
1.18 + >"${CT_DEBUG_INSTALL_DIR}/usr/bin/duma"
1.19 chmod 755 "${CT_DEBUG_INSTALL_DIR}/usr/bin/duma"
1.20 fi
1.21
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/scripts/build/debug/duma.in Mon Jun 30 20:37:14 2008 +0000
2.3 @@ -0,0 +1,44 @@
2.4 +#!/bin/sh
2.5 +# (C) 2008 Yann E. MORIN <yann.morin.1998@anciens.enib.fr>
2.6 +# Licensed under the GPL v.2
2.7 +
2.8 +LIBDUMA_SO=
2.9 +
2.10 +case "$1" in
2.11 + -on)
2.12 + case "${LD_PRELOAD}" in
2.13 + *${LIBDUMA_SO}*) ;;
2.14 + *) LD_PRELOAD="${LIBDUMA_SO} ${LD_PRELOAD}";;
2.15 + esac
2.16 + shift
2.17 + ;;
2.18 + -off)
2.19 + LD_PRELOAD="${LD_PRELOAD//${LIBDUMA_SO}/}"
2.20 + shift
2.21 + ;;
2.22 + -show)
2.23 + case "${LD_PRELOAD}" in
2.24 + *${LIBDUMA_SO}*) echo "duma is enabled";;
2.25 + *) echo "duma is disabled";;
2.26 + esac
2.27 + exit 0
2.28 + ;;
2.29 + "")
2.30 + cat <<_EOF_
2.31 +Usage:
2.32 + . $0 <-on|-off|-show>
2.33 + Sets, unsets or show DUMA usage.
2.34 + $0 <executable [arg...]>
2.35 + Execute 'executable' (with arguments 'args') using DUMA.
2.36 +_EOF_
2.37 + false # Don't 'exit', we could well be source'd
2.38 + ;;
2.39 + *)
2.40 + exec "$0" -on "$@"
2.41 + ;;
2.42 +esac
2.43 +
2.44 +export LD_PRELOAD
2.45 +if [ -n "$1" ]; then
2.46 + exec "$@"
2.47 +fi