Commit a3b52392 authored by Tails developers's avatar Tails developers
Browse files

Create wrappers for (re)starting Tor and Vidalia.

If Vidalia is running, and Tor is restarted, then we also want to
restart Vidalia. This is because Vidalia doesn't re-connect to Tor
automatically, so the user has to restart it to be able to control Tor
again. Also, any options set by Vidalia will be lost since they
weren't written to torrc, which causes Tor to reach an inactive state
if it's restarted in "bridge mode".
parent 20e0755f
...@@ -21,11 +21,11 @@ fi ...@@ -21,11 +21,11 @@ fi
# A SIGHUP should be enough but there's a bug in Tor. Details: # A SIGHUP should be enough but there's a bug in Tor. Details:
# * https://trac.torproject.org/projects/tor/ticket/1247 # * https://trac.torproject.org/projects/tor/ticket/1247
# * https://tails.boum.org/bugs/tor_vs_networkmanager/ # * https://tails.boum.org/bugs/tor_vs_networkmanager/
service tor restart restart-tor
# In bridge mode Vidalia needs to start before tordate (20-time.sh) # In bridge mode Vidalia needs to start before tordate (20-time.sh)
# since we need bridges to be configured before any consensus or # since we need bridges to be configured before any consensus or
# descriptors can be downloaded, which tordate depends on. # descriptors can be downloaded, which tordate depends on.
if grep -qw bridge /proc/cmdline; then if grep -qw bridge /proc/cmdline; then
/etc/NetworkManager/dispatcher.d/60-vidalia.sh $@ restart-vidalia
fi fi
...@@ -111,7 +111,7 @@ wait_for_tor_consensus() { ...@@ -111,7 +111,7 @@ wait_for_tor_consensus() {
log "Waiting for a Tor consensus file to contain a valid time interval" log "Waiting for a Tor consensus file to contain a valid time interval"
if ! has_consensus && ! wait_for_tor_consensus_helper; then if ! has_consensus && ! wait_for_tor_consensus_helper; then
log "Unsuccessfully waited for Tor consensus, restarting Tor and retrying." log "Unsuccessfully waited for Tor consensus, restarting Tor and retrying."
service tor restart restart-tor
fi fi
if ! has_consensus && ! wait_for_tor_consensus_helper; then if ! has_consensus && ! wait_for_tor_consensus_helper; then
log "Unsuccessfully retried waiting for Tor consensus, aborting." log "Unsuccessfully retried waiting for Tor consensus, aborting."
...@@ -156,13 +156,6 @@ ${vendcons}" ...@@ -156,13 +156,6 @@ ${vendcons}"
[ "${order}" = "${ordersrt}" ] [ "${order}" = "${ordersrt}" ]
} }
restart_tor() {
if service tor status >/dev/null; then
log "Restarting Tor service"
service tor restart
fi
}
maybe_set_time_from_tor_consensus() { maybe_set_time_from_tor_consensus() {
local consensus=${TOR_CONSENSUS} local consensus=${TOR_CONSENSUS}
...@@ -202,7 +195,7 @@ maybe_set_time_from_tor_consensus() { ...@@ -202,7 +195,7 @@ maybe_set_time_from_tor_consensus() {
date -us "${vmid}" 1>/dev/null date -us "${vmid}" 1>/dev/null
# Tor is unreliable with picking a circuit after time change # Tor is unreliable with picking a circuit after time change
restart_tor restart-tor
} }
tor_cert_valid_after() { tor_cert_valid_after() {
......
...@@ -10,17 +10,9 @@ if [ $2 != "up" ]; then ...@@ -10,17 +10,9 @@ if [ $2 != "up" ]; then
exit 0 exit 0
fi fi
# Get LIVE_USERNAME
. /etc/live/config.d/username.conf
# Restart Vidalia because it does not automatically reconnect to the new # Restart Vidalia because it does not automatically reconnect to the new
# Tor instance. Use kill+start as: # Tor instance. Use kill+start as:
# - X-GNOME-AutoRestart does not exist in Lenny's Gnome # - X-GNOME-AutoRestart does not exist in Lenny's Gnome
# - we do not start Vidalia automatically anymore and *this* is the time # - we do not start Vidalia automatically anymore and *this* is the time
# when it is supposed to start. # when it is supposed to start.
if killall vidalia 2> /dev/null; then restart-vidalia
sleep 2 # give lckdo a chance to release the lockfile
fi
export DISPLAY=':0.0'
export XAUTHORITY="`echo /var/run/gdm3/auth-for-${LIVE_USERNAME}-*/database`"
exec /bin/su -c /usr/local/bin/vidalia-wrapper "${LIVE_USERNAME}" &
#!/bin/sh
set -e
service tor restart
# The main point of this script is to make sure that if vidalia is
# running, and Tor is restarted, then we also restart Vidalia. This is
# because Vidalia doesn't re-connect to Tor automatically, so the user
# has to restart it to be able to control Tor again. Also, any options
# set by Vidalia will be lost since they weren't written to torrc.
if pgrep "\<vidalia\>" >/dev/null; then
restart-vidalia
fi
#!/bin/sh
set -e
# Get LIVE_USERNAME, whose instance we want to restart
. /etc/live/config.d/username.conf
if killall vidalia 2> /dev/null; then
sleep 2 # give lckdo a chance to release the lockfile
fi
export DISPLAY=':0.0'
export XAUTHORITY="`echo /var/run/gdm3/auth-for-${LIVE_USERNAME}-*/database`"
exec /bin/su -c /usr/local/bin/vidalia-wrapper "${LIVE_USERNAME}" &
...@@ -203,15 +203,10 @@ maybe_restart_tor () { ...@@ -203,15 +203,10 @@ maybe_restart_tor () {
# wheels turning) # wheels turning)
if ! tor_is_working; then if ! tor_is_working; then
echo "* Restarting Tor" echo "* Restarting Tor"
if ! service tor restart; then restart-tor
if ! service tor status >/dev/null; then
error "`gettext \"Failed to restart Tor.\"`" error "`gettext \"Failed to restart Tor.\"`"
fi fi
local counter=0
until [ "${counter}" -ge 10 ] || nc -z localhost 9051 2>/dev/null; do
sleep 1
counter=$((${counter}+1))
done
/etc/NetworkManager/dispatcher.d/60-vidalia.sh clearnet up 2>/dev/null
fi fi
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment