[tbb-bugs] #26653 [Applications/Tor Browser]: Evaluate Tor's Embedding API when integrating Tor Launcher
Tor Bug Tracker & Wiki
blackhole at torproject.org
Tue Sep 18 20:35:34 UTC 2018
#26653: Evaluate Tor's Embedding API when integrating Tor Launcher
-------------------------------------------------+-------------------------
Reporter: sysrqb | Owner: tbb-
| team
Type: task | Status: new
Priority: Medium | Milestone:
Component: Applications/Tor Browser | Version:
Severity: Normal | Resolution:
Keywords: tbb-mobile, TBA-a2, | Actual Points:
TorBrowserTeam201809 |
Parent ID: #24856 | Points:
Reviewer: | Sponsor:
-------------------------------------------------+-------------------------
Comment (by sysrqb):
Okay, this is looking good. #24204 is really nice.
I created a test program that takes the standard tor command line as its
own command line arguments, but it runs `tor_run_main()` twice, and calls
`tor_configuration_set_command_line()` twice, too.
First, it begins by taking the provided command line arguments and
injecting `--verify-config` as the second argument (in a newly allocate
argv). It then creates a control fd, and calls `tor_run_main()` using the
modified command line for verifying the config is valid.
After that returns, it resets the configuration using the original
provided command line and calls `tor_run_main()` again using the original
arguments. After tor starts, `SIGNAL TERM` is sent on the control FD.
{{{
$ ./threaded_verify_config --Log "notice stdout" --AvoidDiskWrites 1
--SocksPort unix:${HOME}/test_socks --DisableNetwork 1
Running with 'tor 0.3.5.0-alpha-dev'
Sep 18 19:12:57.516 [notice] Tor 0.3.5.0-alpha-dev (git-b729bc202c74113c)
running on Linux with Libevent 2.0.22-stable, NSS 3.36.1, Zlib 1.2.11,
Liblzma N/A, and Libzstd N/A.
Sep 18 19:12:57.516 [notice] Tor can't help you if you use it wrong! Learn
how to be safe at https://www.torproject.org/download/download#warning
Sep 18 19:12:57.516 [notice] This version is not a stable Tor release.
Expect more bugs than usual.
Sep 18 19:12:57.516 [notice] Configuration file "/usr/local/etc/tor/torrc"
not present, using reasonable defaults.
Configuration was valid
Tor returned successfully
Sep 18 19:12:57.572 [notice] Tor 0.3.5.0-alpha-dev (git-b729bc202c74113c)
running on Linux with Libevent 2.0.22-stable, NSS 3.36.1, Zlib 1.2.11,
Liblzma N/A, and Libzstd N/A.
Sep 18 19:12:57.572 [notice] Tor can't help you if you use it wrong! Learn
how to be safe at https://www.torproject.org/download/download#warning
Sep 18 19:12:57.572 [notice] This version is not a stable Tor release.
Expect more bugs than usual.
Sep 18 19:12:57.572 [notice] Configuration file "/usr/local/etc/tor/torrc"
not present, using reasonable defaults.
Sep 18 19:12:57.575 [notice] DisableNetwork is set. Tor will not make or
accept non-control network connections. Shutting down all existing
connections.
Sep 18 19:12:57.000 [notice] Bootstrapped 0%: Starting
Sep 18 19:12:57.000 [notice] Starting with guard context "default"
Sep 18 19:12:57.000 [notice] Delaying directory fetches: DisableNetwork is
set.
Sep 18 19:12:57.000 [notice] Catching signal TERM, exiting cleanly.
Tor returned successfully
}}}
I compiled tor (with and without `--enable-restart-debugging`) with
openssl:
{{{
$ ./configure --disable-asciidoc --enable-pic --enable-android --enable-
fatal-warnings
}}}
and for fun, with NSS:
{{{
$ ./configure --disable-asciidoc --enable-pic --enable-android --enable-
fatal-warnings --enable-nss
}}}
and I compiled the program using:
{{{
gcc -Wall -Werror -g -o threaded_verify_config -Isrc/feature/api
src/tools/threaded_verify_config.c -lpthread -lz -lm -levent -lssl
-lcrypto -ldl `make show-libs`
}}}
and with NSS:
{{{
gcc -Wall -Werror -g -o threaded_verify_config -Isrc/feature/api
src/tools/threaded_verify_config.c -lpthread -lz -lm -levent -lssl3
-lsmime3 -lnss3 -lnssutil3 -lplds4 -lplc4 -lnspr4 -lcrypto -ldl `make
show-libs`
}}}
I put the program in src/tool/threaded_verify_config.c simply because it
was easy.
The test programs are available in branch `testing_26653` in my tor user
repo. These don't fully bootstrap because `SIGNAL TERM` is sent as soon as
the control fd is writable. I confirmed tor does fully bootstrap if it is
not terminated immediately, though.
Ex.
{{{
diff --git a/src/tools/threaded_verify_config.c
b/src/tools/threaded_verify_config.c
index 9ba637888..48b7249d8 100644
--- a/src/tools/threaded_verify_config.c
+++ b/src/tools/threaded_verify_config.c
@@ -121,6 +121,7 @@ int main(const int argc, char *argv[]) {
pfd[0].events = POLLIN;
if (poll(pfd, 1, -1)) {
+ sleep(60);
read(ctx.control_fd, buf, 100);
printf("%s", buf);
}
}}}
https://gitweb.torproject.org/user/sysrqb/tor.git/commit/?h=testing_26653&id=621ef35eb5464bcf63857deebd2be6728483e8b6
--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/26653#comment:4>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online
More information about the tbb-bugs
mailing list