* ksutil.c (curl_err_to_gpg_err): Add CURLE_OK and CURLE_COULDNT_CONNECT.
authorDavid Shaw <dshaw@jabberwocky.com>
Wed, 7 Dec 2005 22:25:58 +0000 (22:25 +0000)
committerDavid Shaw <dshaw@jabberwocky.com>
Wed, 7 Dec 2005 22:25:58 +0000 (22:25 +0000)
* gpgkeys_curl.c (get_key): Give key-not-found error if no data is found
(or file itself is not found) during a fetch.

keyserver/ChangeLog
keyserver/gpgkeys_curl.c
keyserver/ksutil.c

index 676cc5d..6ac71ab 100644 (file)
@@ -1,3 +1,11 @@
+2005-12-07  David Shaw  <dshaw@jabberwocky.com>
+
+       * ksutil.c (curl_err_to_gpg_err): Add CURLE_OK and
+       CURLE_COULDNT_CONNECT.
+
+       * gpgkeys_curl.c (get_key): Give key-not-found error if no data is
+       found (or file itself is not found) during a fetch.
+
 2005-12-06  David Shaw  <dshaw@jabberwocky.com>
 
        * curl-shim.c (curl_easy_perform): Fix build warning (code before
index c411b23..73f8671 100644 (file)
@@ -50,6 +50,7 @@ get_key(char *getkey)
   char errorbuffer[CURL_ERROR_SIZE];
   char request[MAX_URL];
   struct curl_writer_ctx ctx;
+  int ret=KEYSERVER_OK;
 
   memset(&ctx,0,sizeof(ctx));
 
@@ -70,14 +71,21 @@ get_key(char *getkey)
   res=curl_easy_perform(curl);
   if(res!=CURLE_OK)
     {
-      fprintf(console,"gpgkeys: %s fetch error %d: %s\n",opt->scheme,
-             res,errorbuffer);
-      fprintf(output,"\nKEY 0x%s FAILED %d\n",getkey,curl_err_to_gpg_err(res));
+      fprintf(console,"gpgkeys: unable to fetch %s: %s\n",request,errorbuffer);
+      ret=curl_err_to_gpg_err(res);
     }
+  else if(!ctx.done)
+    {
+      fprintf(console,"gpgkeys: no key data found for %s\n",request);
+      ret=KEYSERVER_KEY_NOT_FOUND;
+    }
+
+  if(ret)
+    fprintf(output,"\nKEY 0x%s FAILED %d\n",getkey,ret);
   else
     fprintf(output,"\nKEY 0x%s END\n",getkey);
 
-  return curl_err_to_gpg_err(res);
+  return ret;
 }
 
 static void 
index 5956377..e858bd4 100644 (file)
@@ -46,6 +46,7 @@ int register_timeout(void) {return 0;}
 static void
 catch_alarm(int foo)
 {
+  (void)foo;
   _exit(KEYSERVER_TIMEOUT);
 }
 
@@ -362,8 +363,10 @@ curl_err_to_gpg_err(CURLcode error)
 {
   switch(error)
     {
-    case CURLE_FTP_COULDNT_RETR_FILE: return KEYSERVER_KEY_NOT_FOUND;
+    case CURLE_OK:                    return KEYSERVER_OK;
     case CURLE_UNSUPPORTED_PROTOCOL:  return KEYSERVER_SCHEME_NOT_FOUND;
+    case CURLE_COULDNT_CONNECT:       return KEYSERVER_UNREACHABLE;
+    case CURLE_FTP_COULDNT_RETR_FILE: return KEYSERVER_KEY_NOT_FOUND;
     default: return KEYSERVER_INTERNAL_ERROR;
     }
 }