Opened 8 years ago

Closed 8 years ago

#8063 closed defect (fixed)

torsocks on doesn't work.

Reported by: okoeroo Owned by:
Priority: Medium Milestone:
Component: Core Tor/Torsocks Version:
Severity: Keywords: shell
Cc: Actual Points:
Parent ID: Points:
Reviewer: Sponsor:



The "torsocks on" subcommand exports the LD_PRELOAD (Linux) or DYLD_INSERT_LIBRARIES (OSX), but as the torsocks script finishes in bash the exports are lost, as the control returns to the parent process (the bash shell) of the torsocks script.

The easiest fix is to start a new shell from the "torsocks on" subcommand execution.


Child Tickets

Attachments (1)

torsocks_on.patch (409 bytes) - added by okoeroo 8 years ago.
git diff -u

Download all attachments as: .zip

Change History (8)

Changed 8 years ago by okoeroo

Attachment: torsocks_on.patch added

git diff -u

comment:1 Changed 8 years ago by okoeroo

This patch is tested to work against the current git HEAD and 1.2 tag on OSX 10.6 and Ubuntu 12.10. On both installation I've tested this using a bash, dash and zsh. Also verified on dash and zsh that this problem exists.

In all cases the oneliner fix solves the problem for this subcommand. After all, this is just how shells should behave with exported environment variables by spawning a new shell of whatever /bin/sh points to.

The SHELL default export doesn't exist on most shells. I don't understand why this is set to be the default.

comment:2 Changed 8 years ago by ioerror

Resolution: fixed
Status: newclosed

Ok, I've created a new branch to address this change:

[torsocks_on 2542b53] patch by okoeroo to fix torsocks on; trac ticket #8063

1 files changed, 1 insertions(+), 0 deletions(-)

I've merged it cleanly into my pending-changes branch. It seems to be fine. It will go into the next release.

comment:3 Changed 8 years ago by rransom

Resolution: fixed
Status: closedreopened

You just broke the correct usage of torsocks on for everyone who bothered to RTFM or RTFS.

From the torsocks script:

# 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
# variable). This form must be _sourced_ into the user's existing session
# (and will only work with bourne shell users):
# . /usr/bin/torsocks on
# telnet 
# . /usr/bin/torsocks off
# Or
# source /usr/bin/torsocks on
# telnet
# source /usr/bin/torsocks off
# The third form creates a new shell with LD_PRELOAD set and is achieved
# simply by running the script with no arguments 
# /usr/bin/torsocks
# When finished the user can simply terminate the shell with 'exit'

From the torsocks(1) man page:

              this  option  adds  or  removes  torsocks(8) from the LD_PRELOAD
              environment variable. When torsocks(8) is in this  variable  all
              executed  applications are automatically socksified. If you want
              to use this function, you HAVE to source the shell  script  from
              yours, like this: "source /usr/bin/torsocks" or ". /usr/bin/tor‐
              ". torsocks on" -- add the torsocks lib to LD_PRELOAD
              ". torsocks off" -- remove the torsocks lib from LD_PRELOAD
       <without any argument>
              create a new shell with LD_PRELOAD including torsocks(8).

comment:4 Changed 8 years ago by okoeroo

Wow, I've been blinded by an online example that provided the wrong explanation. I've made a major mistake with this...

comment:5 Changed 8 years ago by ioerror

I'll revert this patch shortly.

comment:6 Changed 8 years ago by ioerror

I've reverted this commit in 20346251b2305d4c36676b4a4e16650eb42e9e2c (torsocks master).

comment:7 Changed 8 years ago by ioerror

Resolution: fixed
Status: reopenedclosed
Note: See TracTickets for help on using tickets.