[git] GnuPG - branch, STABLE-BRANCH-2-0, updated. gnupg-2.0.19-90-g6d0e418

by David Shaw cvs at cvs.gnupg.org
Sun Mar 3 03:08:00 CET 2013


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "The GNU Privacy Guard".

The branch, STABLE-BRANCH-2-0 has been updated
       via  6d0e41815a726ad4b170ed18cc772a1817559299 (commit)
       via  7808e4a763692b8bcd95264d39caf85fad32f0bd (commit)
      from  fe85638284880805b80778fe87ae551d3de0ca32 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 6d0e41815a726ad4b170ed18cc772a1817559299
Author: David Shaw <dshaw at jabberwocky.com>
Date:   Sat Mar 2 20:39:48 2013 -0500

    Differentiate between success (full or partial), not-found, and failure.
    
    * keyserver/gpgkeys_hkp.c (get_key): Use curl_easy_setinfo to get the
      HTTP status code so we can tell the difference between a successful
      retrieval, a partial retrieval, a not-found, or a server failed.

diff --git a/keyserver/gpgkeys_hkp.c b/keyserver/gpgkeys_hkp.c
index d90027a..f0647d7 100644
--- a/keyserver/gpgkeys_hkp.c
+++ b/keyserver/gpgkeys_hkp.c
@@ -1,6 +1,6 @@
 /* gpgkeys_hkp.c - talk to an HKP keyserver
  * Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
- *               2009, 2012 Free Software Foundation, Inc.
+ *               2009, 2012, 2013 Free Software Foundation, Inc.
  *
  * This file is part of GnuPG.
  *
@@ -319,15 +319,49 @@ get_key(char *getkey)
     }
   else
     {
+      long status = 0;
+
       curl_writer_finalize(&ctx);
-      if(!ctx.flags.done)
+
+      curl_easy_getinfo (curl, CURLINFO_RESPONSE_CODE, &status);
+
+      if (opt->verbose > 2)
+	fprintf (console, "gpgkeys: HTTP response code is %ld\n", status);
+
+      if (status == 200)
+	{
+	  if (!ctx.flags.done)
+	    {
+	      if (ctx.flags.begun)
+		{
+		  fprintf (console, "gpgkeys: key %s partially retrieved"
+			   " (probably corrupt)\n", getkey);
+		  fprintf (output, "\nKEY 0x%s FAILED %d\n",
+			   getkey, KEYSERVER_KEY_INCOMPLETE);
+		}
+	      else
+		{
+		  fprintf (console, "gpgkeys: key %s can't be retrieved\n",
+			   getkey);
+		  fprintf (output, "\nKEY 0x%s FAILED %d\n",
+			   getkey, KEYSERVER_GENERAL_ERROR);
+		}
+	    }
+	  else
+	    fprintf (output, "\nKEY 0x%s END\n", getkey);
+	}
+      else if (status == 404)
 	{
-	  fprintf(console,"gpgkeys: key %s not found on keyserver\n",getkey);
-	  fprintf(output,"\nKEY 0x%s FAILED %d\n",
-		  getkey,KEYSERVER_KEY_NOT_FOUND);
+	  fprintf (console, "gpgkeys: key %s not found on keyserver\n", getkey);
+	  fprintf (output, "\nKEY 0x%s FAILED %d\n",
+		  getkey, KEYSERVER_KEY_NOT_FOUND);
 	}
       else
-	fprintf(output,"\nKEY 0x%s END\n",getkey);
+	{
+	  fprintf (console, "gpgkeys: key %s can't be retrieved\n", getkey);
+	  fprintf (output, "\nKEY 0x%s FAILED %d\n",
+		  getkey, KEYSERVER_GENERAL_ERROR);
+	}
     }
 
   return KEYSERVER_OK;
@@ -388,16 +422,47 @@ get_name(const char *getkey)
     }
   else
     {
+      long status = 0;
+
       curl_writer_finalize(&ctx);
-      if(!ctx.flags.done)
+
+      curl_easy_getinfo (curl, CURLINFO_RESPONSE_CODE, &status);
+
+      if (opt->verbose > 2)
+	fprintf (console, "gpgkeys: HTTP response code is %ld\n", status);
+
+      if (status == 200)
+	{
+	  if (!ctx.flags.done)
+	    {
+	      if (ctx.flags.begun)
+		{
+		  fprintf (console, "gpgkeys: key %s partially retrieved"
+			   " (probably corrupt)\n", getkey);
+		  ret = KEYSERVER_KEY_INCOMPLETE;
+		}
+	      else
+		{
+		  fprintf (console, "gpgkeys: key %s can't be retrieved\n",
+			   getkey);
+		  ret = KEYSERVER_GENERAL_ERROR;
+		}
+	    }
+	  else
+	    {
+	      fprintf (output, "\nNAME %s END\n", getkey);
+	      ret = KEYSERVER_OK;
+	    }
+	}
+      else if (status == 404)
 	{
-	  fprintf(console,"gpgkeys: key %s not found on keyserver\n",getkey);
-	  ret=KEYSERVER_KEY_NOT_FOUND;
+	  fprintf (console, "gpgkeys: key %s not found on keyserver\n", getkey);
+	  ret = KEYSERVER_KEY_NOT_FOUND;
 	}
       else
 	{
-	  fprintf(output,"\nNAME %s END\n",getkey);
-	  ret=KEYSERVER_OK;
+	  fprintf (console, "gpgkeys: key %s can't be retrieved\n", getkey);
+	  ret = KEYSERVER_GENERAL_ERROR;
 	}
     }
 

commit 7808e4a763692b8bcd95264d39caf85fad32f0bd
Author: David Shaw <dshaw at jabberwocky.com>
Date:   Sat Mar 2 20:07:27 2013 -0500

    Emulate curl_easy_getinfo and CURLINFO_RESPONSE_CODE in curl-shim.
    
    * keyserver/curl-shim.h, keyserver/curl-shim.c (curl_easy_getinfo):
      New. Return the HTTP status code for the last transfer.

diff --git a/keyserver/curl-shim.c b/keyserver/curl-shim.c
index 136436a..be87780 100644
--- a/keyserver/curl-shim.c
+++ b/keyserver/curl-shim.c
@@ -1,8 +1,8 @@
 /* curl-shim.c - Implement a small subset of the curl API in terms of
  * the iobuf HTTP API
  *
- * Copyright (C) 2005, 2006, 2007, 2008, 2009,
- *               2012 Free Software Foundation, Inc.
+ * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2012,
+ *               2013 Free Software Foundation, Inc.
  *
  * This file is part of GnuPG.
  *
@@ -307,6 +307,27 @@ curl_easy_perform(CURL *curl)
   return handle_error(curl,err,errstr);
 }
 
+CURLcode
+curl_easy_getinfo(CURL *curl, CURLINFO info, ... )
+{
+  va_list ap;
+  long *var;
+
+  va_start(ap,info);
+
+  switch(info)
+    {
+    case CURLINFO_RESPONSE_CODE:
+      var=va_arg(ap,long *);
+      *var=curl->status;
+      break;
+    default:
+      break;
+    }
+
+  return handle_error(curl,CURLE_OK,NULL);
+}
+
 /* This is not the same exact set that is allowed according to
    RFC-2396, but it is what the real curl uses. */
 #define VALID_URI_CHARS "abcdefghijklmnopqrstuvwxyz" \
diff --git a/keyserver/curl-shim.h b/keyserver/curl-shim.h
index e37d816..df28fcc 100644
--- a/keyserver/curl-shim.h
+++ b/keyserver/curl-shim.h
@@ -1,5 +1,6 @@
 /* curl-shim.h
- * Copyright (C) 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
+ * Copyright (C) 2005, 2006, 2007, 2008, 2009,
+ *               2013 Free Software Foundation, Inc.
  *
  * This file is part of GNUPG.
  *
@@ -54,6 +55,11 @@ typedef enum
     CURLOPT_SRVTAG_GPG_HACK
   } CURLoption;
 
+typedef enum
+  {
+    CURLINFO_RESPONSE_CODE
+  } CURLINFO;
+
 typedef size_t (*write_func)(char *buffer,size_t size,
 			     size_t nitems,void *outstream);
 
@@ -93,6 +99,7 @@ void curl_global_cleanup(void);
 CURL *curl_easy_init(void);
 CURLcode curl_easy_setopt(CURL *curl,CURLoption option,...);
 CURLcode curl_easy_perform(CURL *curl);
+CURLcode curl_easy_getinfo(CURL *curl, CURLINFO info, ... );
 void curl_easy_cleanup(CURL *curl);
 char *curl_escape(char *str,int len);
 #define curl_free(x) free(x)

-----------------------------------------------------------------------

Summary of changes:
 keyserver/curl-shim.c   |   25 ++++++++++++-
 keyserver/curl-shim.h   |    9 ++++-
 keyserver/gpgkeys_hkp.c |   87 +++++++++++++++++++++++++++++++++++++++++------
 3 files changed, 107 insertions(+), 14 deletions(-)


hooks/post-receive
-- 
The GNU Privacy Guard
http://git.gnupg.org




More information about the Gnupg-commits mailing list