aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2019-11-18 16:22:45 +0000
committerWerner Koch <[email protected]>2019-11-18 17:44:33 +0000
commit4dd50991252409eb2023ab8ad11f36a050f421af (patch)
treeb6e5564f27dcc9541a330fec396ce8795e087f47
parentdirmngr: Factor some prototypes out to dirmngr-status.h. (diff)
downloadgnupg-4dd50991252409eb2023ab8ad11f36a050f421af.tar.gz
gnupg-4dd50991252409eb2023ab8ad11f36a050f421af.zip
dirmngr: Forward http redirect warnings to gpg.
* dirmngr/http.c: Include dirmngr-status.h (http_prepare_redirect): Emit WARNING status lines for redirection problems. * dirmngr/http.h: Include fwddecl.h. (struct http_redir_info_s): Add field ctrl. * dirmngr/ks-engine-hkp.c (send_request): Set it. * dirmngr/ks-engine-http.c (ks_http_fetch): Set it. * g10/call-dirmngr.c (ks_status_cb): Detect the two new warnings. -- This should make it easier to diagnose problems with bad WKD servers. Signed-off-by: Werner Koch <[email protected]>
-rw-r--r--dirmngr/http.c17
-rw-r--r--dirmngr/http.h2
-rw-r--r--dirmngr/ks-engine-hkp.c1
-rw-r--r--dirmngr/ks-engine-http.c1
-rw-r--r--g10/call-dirmngr.c6
5 files changed, 26 insertions, 1 deletions
diff --git a/dirmngr/http.c b/dirmngr/http.c
index c5f9f8d70..4a47c9852 100644
--- a/dirmngr/http.c
+++ b/dirmngr/http.c
@@ -101,6 +101,7 @@
#include "../common/i18n.h"
#include "../common/sysutils.h" /* (gnupg_fd_t) */
#include "dns-stuff.h"
+#include "dirmngr-status.h" /* (dirmngr_status_printf) */
#include "http.h"
#include "http-common.h"
@@ -3628,13 +3629,23 @@ http_prepare_redirect (http_redir_info_t *info, unsigned int status_code,
* https address. */
if (info->orig_onion && !locuri->onion)
{
+ dirmngr_status_printf (info->ctrl, "WARNING",
+ "http_redirect %u"
+ " redirect from onion to non-onion address"
+ " rejected",
+ err);
http_release_parsed_uri (locuri);
return gpg_error (GPG_ERR_FORBIDDEN);
}
if (!info->allow_downgrade && info->orig_https && !locuri->use_tls)
{
+ err = gpg_error (GPG_ERR_FORBIDDEN);
+ dirmngr_status_printf (info->ctrl, "WARNING",
+ "http_redirect %u"
+ " redirect '%s' to '%s' rejected",
+ err, info->orig_url, location);
http_release_parsed_uri (locuri);
- return gpg_error (GPG_ERR_FORBIDDEN);
+ return err;
}
if (info->trust_location)
@@ -3714,6 +3725,10 @@ http_prepare_redirect (http_redir_info_t *info, unsigned int status_code,
http_release_parsed_uri (locuri);
if (!info->silent)
log_info (_("redirection changed to '%s'\n"), newurl);
+ dirmngr_status_printf (info->ctrl, "WARNING",
+ "http_redirect_cleanup %u"
+ " changed from '%s' to '%s'",
+ 0, info->orig_url, newurl);
}
*r_url = newurl;
diff --git a/dirmngr/http.h b/dirmngr/http.h
index 2bad63d22..e81aef208 100644
--- a/dirmngr/http.h
+++ b/dirmngr/http.h
@@ -32,6 +32,7 @@
#define GNUPG_COMMON_HTTP_H
#include <gpg-error.h>
+#include "../common/fwddecl.h"
struct uri_tuple_s
{
@@ -106,6 +107,7 @@ typedef struct http_context_s *http_t;
struct http_redir_info_s
{
unsigned int redirects_left; /* Number of still possible redirects. */
+ ctrl_t ctrl; /* The usual connection info or NULL. */
const char *orig_url; /* The original requested URL. */
unsigned int orig_onion:1; /* Original request was an onion address. */
unsigned int orig_https:1; /* Original request was a http address. */
diff --git a/dirmngr/ks-engine-hkp.c b/dirmngr/ks-engine-hkp.c
index a8b1ec271..fef752cd3 100644
--- a/dirmngr/ks-engine-hkp.c
+++ b/dirmngr/ks-engine-hkp.c
@@ -1173,6 +1173,7 @@ send_request (ctrl_t ctrl, const char *request, const char *hostportstr,
err = http_parse_uri (&uri, request, 0);
if (err)
goto leave;
+ redirinfo.ctrl = ctrl;
redirinfo.orig_url = request;
redirinfo.orig_onion = uri->onion;
redirinfo.allow_downgrade = 1;
diff --git a/dirmngr/ks-engine-http.c b/dirmngr/ks-engine-http.c
index a9600dbca..a4ac719dd 100644
--- a/dirmngr/ks-engine-http.c
+++ b/dirmngr/ks-engine-http.c
@@ -82,6 +82,7 @@ ks_http_fetch (ctrl_t ctrl, const char *url, unsigned int flags,
err = http_parse_uri (&uri, url, 0);
if (err)
goto leave;
+ redirinfo.ctrl = ctrl;
redirinfo.orig_url = url;
redirinfo.orig_onion = uri->onion;
redirinfo.orig_https = uri->use_tls;
diff --git a/g10/call-dirmngr.c b/g10/call-dirmngr.c
index 8896f27d0..5b460ff92 100644
--- a/g10/call-dirmngr.c
+++ b/g10/call-dirmngr.c
@@ -412,6 +412,12 @@ ks_status_cb (void *opaque, const char *line)
warn = _("Tor is not running");
else if ((s2 = has_leading_keyword (s, "tor_config_problem")))
warn = _("Tor is not properly configured");
+ else if ((s2 = has_leading_keyword (s, "dns_config_problem")))
+ warn = _("DNS is not properly configured");
+ else if ((s2 = has_leading_keyword (s, "http_redirect")))
+ warn = _("unacceptable HTTP redirect from server");
+ else if ((s2 = has_leading_keyword (s, "http_redirect_cleanup")))
+ warn = _("unacceptable HTTP redirect from server was cleaned up");
else
warn = NULL;