Commit d9dd9d35 authored by segfault's avatar segfault

tailslib: Add tor_has_boostrapped()

I add this function to a new file systemd.sh instead of tor.sh, to make
it clear that this uses the systemd unit instead of communicating with
the Tor control socket (which is what tor.sh does).

This function should be used over tor_is_working() from tor.sh in
scripts which don't already communicate with the Tor control socket.
parent 65db984e
......@@ -10,6 +10,9 @@ if [ "$2" != "up" ]; then
exit 0
fi
# Import tor_has_bootstrapped()
. /usr/local/lib/tails-shell-library/systemd.sh
# Get LANG
. /etc/default/locale
export LANG
......@@ -19,7 +22,7 @@ export LANG
TEXTDOMAIN="tails"
export TEXTDOMAIN
while ! /bin/systemctl --quiet is-active tails-tor-has-bootstrapped.target; do
while ! tor_has_bootstrapped; do
sleep 1
done
......
......@@ -22,6 +22,9 @@ PROFILE="${HOME}/.tor-browser/profile.default"
# Get LIVE_USERNAME
. /etc/live/config.d/username.conf
# Import tor_has_bootstrapped()
. /usr/local/lib/tails-shell-library/systemd.sh
# Allow Torbutton access to the control port filter (for new identity).
# Setting a password is required, otherwise Torbutton attempts to
# read the authentication cookie file instead, which fails.
......@@ -68,7 +71,7 @@ start_browser() {
}
if /bin/systemctl --quiet is-active tails-tor-has-bootstrapped.target || ask_for_confirmation; then
if tor_has_bootstrapped || ask_for_confirmation; then
# Torbutton 1.5.1+ uses those environment variables
export TOR_SOCKS_HOST='127.0.0.1'
export TOR_SOCKS_PORT='9150'
......
#!/bin/sh
tor_has_bootstrapped() {
/bin/systemctl --quiet is-active tails-tor-has-bootstrapped.target
}
......@@ -7,8 +7,8 @@ set -u
TEXTDOMAIN="tails"
export TEXTDOMAIN
# Import tor_is_working()
. /usr/local/lib/tails-shell-library/tor.sh
# Import tor_has_bootstrapped()
. /usr/local/lib/tails-shell-library/systemd.sh
# Import the TBB_EXT variable, and guess_best_tor_browser_locale().
. /usr/local/lib/tails-shell-library/tor-browser.sh
......@@ -63,7 +63,7 @@ maybe_restart_tor () {
# Restart Tor if it's not working (a captive portal may have prevented
# Tor from bootstrapping, and a restart is the fastest way to get
# wheels turning)
if ! tor_is_working; then
if ! tor_has_bootstrapped; then
echo "* Restarting Tor"
restart-tor
if ! systemctl --quiet is-active tor@default.service; then
......
Markdown is supported
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