dirmngr: Auto-enable Tor on startup or reload.

* dirmngr/dirmngr.c (dirmngr_use_tor): Test for Tor availibility.
--

GnuPG-bug-id: 2935
Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
Werner Koch 2017-07-26 10:58:15 +02:00
parent d50c2eff8d
commit fd68bdb61e
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B
3 changed files with 22 additions and 6 deletions

View File

@ -532,7 +532,17 @@ dirmngr_use_tor (void)
{ {
if (tor_mode == TOR_MODE_AUTO) if (tor_mode == TOR_MODE_AUTO)
{ {
/* FIXME: Figure out whether Tor is running. */ /* Figure out whether Tor is running. */
assuan_fd_t sock;
sock = assuan_sock_connect_byname (NULL, 0, 0, NULL, ASSUAN_SOCK_TOR);
if (sock == ASSUAN_INVALID_FD)
tor_mode = TOR_MODE_NO;
else
{
tor_mode = TOR_MODE_YES;
assuan_sock_close (sock);
}
} }
if (tor_mode == TOR_MODE_FORCE) if (tor_mode == TOR_MODE_FORCE)

View File

@ -308,8 +308,8 @@ strcpy_escaped_plus (char *d, const unsigned char *s)
} }
/* This function returns true if a Tor server is running. The sattus /* This function returns true if a Tor server is running. The status
is cached for the current connection. */ * is cached for the current connection. */
static int static int
is_tor_running (ctrl_t ctrl) is_tor_running (ctrl_t ctrl)
{ {

View File

@ -243,10 +243,16 @@ Enabling this option forces loading of expired CRLs; this is only
useful for debugging. useful for debugging.
@item --use-tor @item --use-tor
@itemx --no-use-tor
@opindex use-tor @opindex use-tor
This option switches Dirmngr and thus GnuPG into ``Tor mode'' to route @opindex no-use-tor
all network access via Tor (an anonymity network). Certain other The option @option{--use-tor} switches Dirmngr and thus GnuPG into
features are disabled if this mode is active. ``Tor mode'' to route all network access via Tor (an anonymity
network). Certain other features are disabled in this mode. The
effect of @option{--use-tor} cannot be overridden by any other command
or even be reloading gpg-agent. The use of @option{--no-use-tor}
disables the use of Tor. The default is to use Tor if it is available
on startup or after reloading dirmngr.
@item --standard-resolver @item --standard-resolver
@opindex standard-resolver @opindex standard-resolver