[Pkg-gnupg-commit] [gnupg2] 142/180: dirmngr: Pass Tor credentials to libdns.

Daniel Kahn Gillmor dkg at fifthhorseman.net
Sat Dec 24 22:29:20 UTC 2016


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

dkg pushed a commit to branch master
in repository gnupg2.

commit ddb48086833f8b86f0f0d69b21a23f245090ea7a
Author: Werner Koch <wk at gnupg.org>
Date:   Fri Dec 16 20:25:02 2016 +0100

    dirmngr: Pass Tor credentials to libdns.
    
    * dirmngr/dns-stuff.c (tor_credentials): Replace by ...
    (tor_socks_user, tor_socks_password): new vars.
    (enable_dns_tormode): Set these new vars.
    (libdns_res_open): Tell libdns the socks credentials.
    
    Signed-off-by: Werner Koch <wk at gnupg.org>
---
 dirmngr/dns-stuff.c | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/dirmngr/dns-stuff.c b/dirmngr/dns-stuff.c
index eec7112..0f1f0ed 100644
--- a/dirmngr/dns-stuff.c
+++ b/dirmngr/dns-stuff.c
@@ -118,8 +118,10 @@ static int tor_mode;
   (40 should be sufficient for v6 but we add some extra for a scope.) */
 static char tor_nameserver[40+20];
 
-/* A string to hold the credentials presented to Tor.  */
-static char tor_credentials[50];
+/* Two strings to hold the credentials presented to Tor.  */
+static char tor_socks_user[30];
+static char tor_socks_password[20];
+
 
 #ifdef USE_LIBDNS
 /* Libdns gobal data.  */
@@ -177,15 +179,14 @@ recursive_resolver_p (void)
 gpg_error_t
 enable_dns_tormode (int new_circuit)
 {
-  /* XXX: dns.c doesn't support SOCKS credentials.  */
-
-  if (!*tor_credentials || new_circuit)
+  if (!*tor_socks_user || new_circuit)
     {
       static unsigned int counter;
 
-      gpgrt_snprintf (tor_credentials, sizeof tor_credentials,
-                      "dirmngr-%lu:p%u",
-                      (unsigned long)getpid (), counter);
+      gpgrt_snprintf (tor_socks_user, sizeof tor_socks_user,
+                      "dirmngr-%lu", (unsigned long)getpid ());
+      gpgrt_snprintf (tor_socks_password, sizeof tor_socks_password,
+                      "p%u", counter);
       counter++;
     }
   tor_mode = 1;
@@ -428,7 +429,10 @@ libdns_res_open (struct dns_resolver **r_res)
     return err;
 
   res = dns_res_open (libdns.resolv_conf, libdns.hosts, libdns.hints, NULL,
-                      dns_opts (.socks_host=&libdns.socks_host), &derr);
+                      dns_opts (.socks_host     = &libdns.socks_host,
+                                .socks_user     = tor_socks_user,
+                                .socks_password = tor_socks_password ),
+                      &derr);
   if (!res)
     return libdns_error_to_gpg_error (derr);
 

-- 
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