[Pkg-gnupg-commit] [gnupg2] 187/241: dirmngr: Allow testing for a running Tor via "getinfo tor".

Daniel Kahn Gillmor dkg at fifthhorseman.net
Wed Dec 9 20:32:15 UTC 2015


This is an automated email from the git hooks/post-receive script.

dkg pushed a commit to branch master
in repository gnupg2.

commit da5a232199ef93be219e933a7eaf4ccfc6d24d61
Author: Werner Koch <wk at gnupg.org>
Date:   Fri Nov 27 12:21:45 2015 +0100

    dirmngr: Allow testing for a running Tor via "getinfo tor".
    
    * dirmngr/server.c (cmd_getinfo): Print an S line if Tor is not
    running.
    
    Signed-off-by: Werner Koch <wk at gnupg.org>
---
 dirmngr/server.c | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/dirmngr/server.c b/dirmngr/server.c
index 8954ba8..e08afd4 100644
--- a/dirmngr/server.c
+++ b/dirmngr/server.c
@@ -2123,8 +2123,25 @@ cmd_getinfo (assuan_context_t ctx, char *line)
     {
       if (opt.use_tor)
         {
-          err = 0;
-          assuan_set_okay_line (ctx, " - Tor mode is enabled");
+#if ASSUAN_VERSION_NUMBER >= 0x020402
+          /* Check whether we can connect to the proxy.  We use a
+             special feature introduced with libassuan 2.4.2.  */
+          int sock = assuan_sock_connect_byname (NULL, 0, 0, NULL,
+                                                 ASSUAN_SOCK_TOR);
+          if (sock == ASSUAN_INVALID_FD)
+            {
+              err = assuan_write_status
+                (ctx, "NO_TOR",
+                 errno == ECONNREFUSED? "Tor not running" : strerror (errno));
+            }
+          else
+            {
+              assuan_sock_close (sock);
+              err = 0;
+            }
+          if (!err)
+#endif /* Libassuan >= 2.4.2 */
+            assuan_set_okay_line (ctx, "- Tor mode is enabled");
         }
       else
         err = set_error (GPG_ERR_FALSE, "Tor mode is NOT enabled");

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-gnupg/gnupg2.git



More information about the Pkg-gnupg-commit mailing list