Opened 13 years ago

Last modified 13 years ago

#558 closed enhancement (Implemented)

Use Launchd for starting Tor on OS X

Reported by: igel Owned by: phobos
Priority: Low Milestone: post 0.2.0.x
Component: Applications/Tor bundles/installation Version:
Severity: Keywords:
Cc: nickm Actual Points:
Parent ID: Points:
Reviewer: Sponsor:


Launchd allows to fire up Tor as soon as the port that Tor is being assigned to is being contacted.
As an initial setup, add this code as a file named org.tor.plist into the directory called /Library/LaunchAgents:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-AppleDTD PLIST 1.0EN" "">
<plist version="1.0">












Of course, the TimeOut feature is discussible and can be omitted. Its usefulness depends mainly on the question how hard it is to fire up Tor.

The easier it is, the more usefl this option will be.

This will work already! But you will have to hit the reload button upon first access to Tor, as the first access is swallowed by Launchd.

Launchd can give you the initial request with a couple of simple API calls. The source code package of launchd brings a decent example. Download it here:

It will contain a file called sample.c. It's easy to understand and should pretty much be exactly what needs to be pasted into the Tor binary.

Altogether, this will take no longer than 10 minutes but will make life a little happier!


[Automatically added by flyspray2trac: Operating System: OSX 10.4 Tiger]

Child Tickets

Change History (8)

comment:1 Changed 13 years ago by igel

Forgot to mention: This will NOT work with panther! For panther, a more unix-like startup process is required.

comment:2 Changed 13 years ago by phobos

At one point a year ago or so, I managed to convert everything to launchd. I ran into compatibility problems between
tiger and leopard (beta at the time) launchd differences. Are you testing this under tiger or leopard?

comment:3 Changed 13 years ago by igel

I'm testing under Leopard. It runs fine. Only that I have to hit reload upon first access.

comment:4 Changed 13 years ago by phobos

So, launching tor on demand probably isn't what we want. We probably want tor to start up as a daemon and sit and wait
for traffic. This way tor can keep the directory up to date and ready for use when the user passes traffic. I'll dig
up my old launch agent xml for tor and figure out which keys to merge into one xml file. thanks.

comment:5 Changed 13 years ago by jasemandude

Here's my tor launch daemon xml - note that it is located in /Library/LaunchDaemons rather than /Library/LaunchAgents. In order to have a circuit up and ready, it runs at load rather than on demand. I found that defining Listeners in the xml made launchd grab the port before tor had the chance and this would cause tor to exit, so Listeners is left undefined.

---cut here---

bash-3.2$ cat /Library/LaunchDaemons/com.jason.launchd.tor.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-Apple ComputerDTD PLIST 1.0EN"


<plist version="1.0">






comment:6 Changed 13 years ago by jasemandude

Hmmm... it's stripped all the xml, perhaps I need to escape it

bash-3.2$ cat /Library/LaunchDaemons/com.jason.launchd.tor.plist
\<?xml version="1.0" encoding="UTF-8"?\>
\<!DOCTYPE plist PUBLIC "-Apple ComputerDTD PLIST 1.0EN"


\<plist version="1.0"\>






comment:7 Changed 13 years ago by jasemandude

Third time lucky!...

bash-3.2$ cat /Library/LaunchDaemons/com.jason.launchd.tor.plist
&lt;?xml version=\&quot;1.0\&quot; encoding=\&quot;UTF-8\&quot;?&gt;
&lt;!DOCTYPE plist PUBLIC \&quot;-Apple ComputerDTD PLIST 1.0EN\&quot;


&lt;plist version=\&quot;1.0\&quot;&gt;







comment:8 Changed 13 years ago by phobos

flyspray2trac: bug closed.
Commit to svn as r14147. Right now, it's optional.

Note: See TracTickets for help on using tickets.