From 6d64ef869dfbcb7aaa802b80ed648393147e40d8 Mon Sep 17 00:00:00 2001 From: Justus Winter Date: Fri, 4 Dec 2015 12:32:20 +0100 Subject: dirmngr: Stricter handling of http error codes. * dirmngr/ks-action.c (ks_action_search): Only retry if the keyserver responded with a '404 Not Found'. * dirmngr/ks-engine-hkp.c (send_request): Return http status code. (ks_hkp_search): Likewise. (ks_hkp_{get,put}): Adapt call to 'send_request'. * dirmngr/ks-engine.h (ks_hkp_search): Update prototype. Signed-off-by: Justus Winter --- dirmngr/ks-action.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'dirmngr/ks-action.c') diff --git a/dirmngr/ks-action.c b/dirmngr/ks-action.c index 285167a17..1da91cccf 100644 --- a/dirmngr/ks-action.c +++ b/dirmngr/ks-action.c @@ -156,13 +156,13 @@ ks_action_search (ctrl_t ctrl, uri_item_t keyservers, parallel and merge them. We also need to decide what to do with errors - it might not be the best idea to ignore an error from one server and silently continue with another server. For now we - stop at the first error, unless it is GPG_ERR_NO_DATA, in which - case we try the next server. Unfortunately, 'send_requests' - broadly maps all kinds of http errors to GPG_ERR_NO_DATA. */ + stop at the first error, unless the server responds with '404 Not + Found', in which case we try the next server. */ for (uri = keyservers; !err && uri; uri = uri->next) { int is_http = uri->parsed_uri->is_http; int is_ldap = 0; + unsigned int http_status; #if USE_LDAP is_ldap = (strcmp (uri->parsed_uri->scheme, "ldap") == 0 || strcmp (uri->parsed_uri->scheme, "ldaps") == 0 @@ -177,10 +177,12 @@ ks_action_search (ctrl_t ctrl, uri_item_t keyservers, else #endif { - err = ks_hkp_search (ctrl, uri->parsed_uri, patterns->d, &infp); + err = ks_hkp_search (ctrl, uri->parsed_uri, patterns->d, + &infp, &http_status); } - if (err == gpg_error (GPG_ERR_NO_DATA)) + if (err == gpg_error (GPG_ERR_NO_DATA) + && http_status == 404 /* not found */) { /* No record found. Clear error and try next server. */ err = 0; -- cgit v1.2.3