[git] GnuPG - branch, STABLE-BRANCH-1-4, updated. gnupg-1.4.13-7-g6f0ec6a

by David Shaw cvs at cvs.gnupg.org
Sun Mar 3 02:51:44 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-1-4 has been updated
       via  6f0ec6ab485f48c8079ab2a16ed41ee7859f88ab (commit)
       via  ca0b94d4d41c81045ed97fad0569ff4b64e5a6fe (commit)
      from  1edc1b3751496885b236f5ab1194ad667c96b174 (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 6f0ec6ab485f48c8079ab2a16ed41ee7859f88ab
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 bc2f044..309e728 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.
  *
@@ -312,15 +312,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;
@@ -383,16 +417,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 ca0b94d4d41c81045ed97fad0569ff4b64e5a6fe
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 857b5c1..ce510cb 100644
--- a/keyserver/curl-shim.c
+++ b/keyserver/curl-shim.c
@@ -1,7 +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.
  *
@@ -291,6 +292,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 0d378e8..a8609df 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.
  *
@@ -53,6 +54,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);
 
@@ -92,6 +98,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_easy_escape(CURL *curl,char *str,int len);
 #define curl_free(x) free(x)

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

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


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




More information about the Gnupg-commits mailing list