[tor-commits] [torsocks/master] Issue 25: Building within a sandbox environment fails

hoganrobert at torproject.org hoganrobert at torproject.org
Sun Oct 23 18:27:11 UTC 2011


commit 6403819745b44003f53776db0ae048f973f784a1
Author: Robert Hogan <robert at roberthogan.net>
Date:   Sun Oct 23 18:54:12 2011 +0100

    Issue 25: Building within a sandbox environment fails
    
    When building in a sandbox environment, the build system's substitution variable,
    @LD_PRELOAD@ is confused with the environment variable LD_PRELOAD and build fails
    with an error that it cannot load ld.so.
    
    By Renaming @LD_PRELOAD@ to @LDPRELOAD@, we disambiguate the two.
    
    Patch by: Athony Basile (blueness at gentoo.org)
---
 configure.in    |    8 ++++----
 src/torsocks.in |   32 ++++++++++++++++----------------
 2 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/configure.in b/configure.in
index 75d5e1c..bb98460 100644
--- a/configure.in
+++ b/configure.in
@@ -577,12 +577,12 @@ darwin*)
     AC_MSG_CHECKING(if the linker accepts -single_module)
     OLDLDFLAGS="$TORSOCKSLDFLAGS"
     SHLIB_EXT="so"
-    LD_PRELOAD="LD_PRELOAD"
+    LDPRELOAD="LD_PRELOAD"
     TORSOCKSLDFLAGS="$TORSOCKSLDFLAGS -single_module"
     AC_TRY_COMPILE(,,
        [
           SHLIB_EXT="dylib"
-          LD_PRELOAD="DYLD_INSERT_LIBRARIES"
+          LDPRELOAD="DYLD_INSERT_LIBRARIES"
           AC_MSG_RESULT(yes)
        ], [
           TORSOCKSLDFLAGS="$OLDLDFLAGS"
@@ -593,12 +593,12 @@ darwin*)
     ;;
 *)
     SHLIB_EXT="so"
-    LD_PRELOAD="LD_PRELOAD"
+    LDPRELOAD="LD_PRELOAD"
     ;;
 esac
 
 AC_SUBST(SHLIB_EXT)
-AC_SUBST(LD_PRELOAD)
+AC_SUBST(LDPRELOAD)
 AC_SUBST(TORSOCKSLDFLAGS)
 
 ##############################################################################
diff --git a/src/torsocks.in b/src/torsocks.in
index 075a5e4..27540ec 100755
--- a/src/torsocks.in
+++ b/src/torsocks.in
@@ -30,7 +30,7 @@
 #
 # @prefix@/bin/torsocks program [program arguments...]
 #
-# This form sets the users @LD_PRELOAD@ environment variable so that torsocks(8)
+# This form sets the users @LDPRELOAD@ environment variable so that torsocks(8)
 # will be loaded to socksify the application then executes the specified 
 # program (with the provided arguments). The following simple example might 
 # be used to telnet to www.foo.org via a torsocks.conf(5) configured socks server:
@@ -38,7 +38,7 @@
 # @prefix@/bin/torsocks telnet www.foo.org
 #
 # The second form allows for torsocks(8) to be switched on and off for a
-# session (that is, it adds and removes torsocks from the @LD_PRELOAD@ environment
+# session (that is, it adds and removes torsocks from the @LDPRELOAD@ environment
 # variable). This form must be _sourced_ into the user's existing session
 # (and will only work with bourne shell users):
 #
@@ -52,7 +52,7 @@
 # telnet www.foo.org
 # source @prefix@/bin/torsocks off
 #
-# The third form creates a new shell with @LD_PRELOAD@ set and is achieved
+# The third form creates a new shell with @LDPRELOAD@ set and is achieved
 # simply by running the script with no arguments 
 # 
 # @prefix@/bin/torsocks
@@ -80,12 +80,12 @@ SHLIB="${LIBDIR}/${LIB_NAME}.${SHLIB_EXT}"
 
 case "$1" in
   on)
-    if [ -z "$@LD_PRELOAD@" ]
+    if [ -z "$@LDPRELOAD@" ]
       then
-        export @LD_PRELOAD@="${SHLIB}"
+        export @LDPRELOAD@="${SHLIB}"
       else
-        echo $@LD_PRELOAD@ | grep -q "${SHLIB}" || \
-        export @LD_PRELOAD@="${SHLIB} $@LD_PRELOAD@"
+        echo $@LDPRELOAD@ | grep -q "${SHLIB}" || \
+        export @LDPRELOAD@="${SHLIB} $@LDPRELOAD@"
     fi
     # FIXME: This env variable is only meaningful on Mac OSX, so it would be better
     #        not to set it at all on other platforms.
@@ -94,29 +94,29 @@ case "$1" in
   off)
     #replace '/' with '\/' in @prefix@
     # escprefix=`echo '@prefix@' |sed 's/\\//\\\\\//g'`
-    # export @LD_PRELOAD@=`echo -n $@LD_PRELOAD@ | sed "s/$escprefix\/lib\/torsocks\/libtorsocks.so \?//"`
-    export @LD_PRELOAD@=`echo -n $@LD_PRELOAD@ | sed "s#@prefix@/lib/torsocks/libtorsocks\. at SHLIB_EXT@ *##"`
-    if [ -z "$@LD_PRELOAD@" ]
+    # export @LDPRELOAD@=`echo -n $@LDPRELOAD@ | sed "s/$escprefix\/lib\/torsocks\/libtorsocks.so \?//"`
+    export @LDPRELOAD@=`echo -n $@LDPRELOAD@ | sed "s#@prefix@/lib/torsocks/libtorsocks\. at SHLIB_EXT@ *##"`
+    if [ -z "$@LDPRELOAD@" ]
       then
-        unset @LD_PRELOAD@
+        unset @LDPRELOAD@
         # FIXME: This env variable is only meaningful on Mac OSX, so it would be better
         #        not to set it at all on other platforms.
         unset DYLD_FORCE_FLAT_NAMESPACE=1
     fi
   ;;
   show|sh)
-    echo "@LD_PRELOAD@=\"$@LD_PRELOAD@\""
+    echo "@LDPRELOAD@=\"$@LDPRELOAD@\""
   ;;
   -h|-?)
       echo "$0: Please see torsocks(1) or read comment at top of $0"
    ;;
   *)
-    if [ -z "$@LD_PRELOAD@" ]
+    if [ -z "$@LDPRELOAD@" ]
     then
-      export @LD_PRELOAD@="${SHLIB}"
+      export @LDPRELOAD@="${SHLIB}"
     else
-      echo $@LD_PRELOAD@ | grep -q "${SHLIB}" || \
-      export @LD_PRELOAD@="${SHLIB} $@LD_PRELOAD@"
+      echo $@LDPRELOAD@ | grep -q "${SHLIB}" || \
+      export @LDPRELOAD@="${SHLIB} $@LDPRELOAD@"
     fi
     export DYLD_FORCE_FLAT_NAMESPACE=1
 





More information about the tor-commits mailing list