diff options
Diffstat (limited to 'keyserver')
-rw-r--r-- | keyserver/ChangeLog | 17 | ||||
-rw-r--r-- | keyserver/Makefile.am | 55 | ||||
-rw-r--r-- | keyserver/curl-shim.c | 73 | ||||
-rw-r--r-- | keyserver/curl-shim.h | 2 | ||||
-rw-r--r-- | keyserver/gpgkeys_finger.c | 3 |
5 files changed, 96 insertions, 54 deletions
diff --git a/keyserver/ChangeLog b/keyserver/ChangeLog index c427c4778..d52a53d3e 100644 --- a/keyserver/ChangeLog +++ b/keyserver/ChangeLog @@ -1,3 +1,20 @@ +2006-08-16 Werner Koch <[email protected]> + + * Makefile.am: Renamed all binaries to gpg2keys_*. + (gpg2keys_ldap_CPPFLAGS): Add AM_CPPFLAGS. + +2006-08-15 Werner Koch <[email protected]> + + * Makefile.am: Adjusted to the gnupg2 framework. + +2006-08-14 Werner Koch <[email protected]> + + * curl-shil.c, curl-shim.h: Changed to make use of the new http.c + API. + + * curl-shim.c (curl_easy_perform): Add missing http_close to the + POST case. + 2006-07-24 David Shaw <[email protected]> (wk) * curl-shim.c (curl_easy_perform): Minor cleanup of proxy code. diff --git a/keyserver/Makefile.am b/keyserver/Makefile.am index 72572de2c..a61fa3032 100644 --- a/keyserver/Makefile.am +++ b/keyserver/Makefile.am @@ -18,36 +18,47 @@ ## Process this file with automake to produce Makefile.in -INCLUDES = -I$(top_srcdir)/include -I$(top_srcdir)/intl -EXTRA_PROGRAMS = gpgkeys_ldap gpgkeys_hkp gpgkeys_finger gpgkeys_curl -EXTRA_SCRIPTS = gpgkeys_mailto +EXTRA_PROGRAMS = gpg2keys_ldap gpg2keys_hkp gpg2keys_finger gpg2keys_curl +EXTRA_SCRIPTS = gpg2keys_mailto -gpglibexecdir = $(libexecdir)/@PACKAGE@ +AM_CPPFLAGS = -I$(top_srcdir)/gl -I$(top_srcdir)/common -I$(top_srcdir)/intl -gpglibexec_PROGRAMS = @GPGKEYS_LDAP@ @GPGKEYS_HKP@ @GPGKEYS_FINGER@ @GPGKEYS_CURL@ -gpglibexec_SCRIPTS = @GPGKEYS_MAILTO@ -noinst_SCRIPTS = gpgkeys_test +AM_CFLAGS = $(LIBGCRYPT_CFLAGS) + +include $(top_srcdir)/am/cmacros.am -gpgkeys_ldap_SOURCES = gpgkeys_ldap.c ksutil.c ksutil.h -gpgkeys_hkp_SOURCES = gpgkeys_hkp.c ksutil.c ksutil.h -gpgkeys_finger_SOURCES = gpgkeys_finger.c ksutil.c ksutil.h -gpgkeys_curl_SOURCES = gpgkeys_curl.c ksutil.c ksutil.h +libexec_PROGRAMS = $(GPGKEYS_LDAP) $(GPGKEYS_HKP) $(GPGKEYS_FINGER) \ + $(GPGKEYS_CURL) +libexec_SCRIPTS = $(GPGKEYS_MAILTO) +noinst_SCRIPTS = gpgkeys_test +needed_libs = ../gl/libgnu.a ../common/libcommon.a ../jnlib/libjnlib.a other_libs = $(LIBICONV) $(LIBINTL) $(CAPLIBS) -gpgkeys_ldap_CPPFLAGS = @LDAP_CPPFLAGS@ -gpgkeys_ldap_LDADD = ../util/libutil.a @LDAPLIBS@ @NETLIBS@ $(other_libs) @GETOPT@ @W32LIBS@ +gpg2keys_ldap_SOURCES = gpgkeys_ldap.c ksutil.c ksutil.h +gpg2keys_hkp_SOURCES = gpgkeys_hkp.c ksutil.c ksutil.h +gpg2keys_finger_SOURCES = gpgkeys_finger.c ksutil.c ksutil.h +gpg2keys_curl_SOURCES = gpgkeys_curl.c ksutil.c ksutil.h -gpgkeys_finger_LDADD = ../util/libutil.a @NETLIBS@ $(other_libs) @GETOPT@ @W32LIBS@ + +gpg2keys_ldap_CPPFLAGS = $(LDAP_CPPFLAGS) $(AM_CPPFLAGS) +gpg2keys_ldap_LDADD = $(needed_libs) $(LDAPLIBS) $(NETLIBS) \ + $(other_libs) $(W32LIBS) + +gpg2keys_finger_LDADD = $(needed_libs) $(LIBGCRYPT_LIBS) \ + $(NETLIBS) $(other_libs) $(W32LIBS) if FAKE_CURL -gpgkeys_curl_SOURCES += curl-shim.c curl-shim.h -gpgkeys_curl_LDADD = ../util/libutil.a @NETLIBS@ @SRVLIBS@ $(other_libs) @GETOPT@ @W32LIBS@ -gpgkeys_hkp_SOURCES += curl-shim.c curl-shim.h -gpgkeys_hkp_LDADD = ../util/libutil.a @NETLIBS@ @SRVLIBS@ $(other_libs) @GETOPT@ @W32LIBS@ +gpg2keys_curl_SOURCES += curl-shim.c curl-shim.h +gpg2keys_curl_LDADD = $(needed_libs) $(NETLIBS) $(DNSLIBS) \ + $(other_libs) $(W32LIBS) +gpg2keys_hkp_SOURCES += curl-shim.c curl-shim.h +gpg2keys_hkp_LDADD = $(needed_libs) $(NETLIBS) $(DNSLIBS) \ + $(other_libs) $(W32LIBS) else -gpgkeys_curl_CPPFLAGS = @LIBCURL_CPPFLAGS@ -gpgkeys_curl_LDADD = @LIBCURL@ @GETOPT@ -gpgkeys_hkp_CPPFLAGS = @LIBCURL_CPPFLAGS@ -gpgkeys_hkp_LDADD = @LIBCURL@ @GETOPT@ +gpg2keys_curl_CPPFLAGS = $(LIBCURL_CPPFLAGS) $(AM_CPPFLAGS) +gpg2keys_curl_LDADD = $(LIBCURL) $(GETOPT) +gpg2keys_hkp_CPPFLAGS = $(LIBCURL_CPPFLAGS) $(AM_CPPFLAGS) +gpg2keys_hkp_LDADD = $(LIBCURL) $(GETOPT) endif + diff --git a/keyserver/curl-shim.c b/keyserver/curl-shim.c index c71c655b5..12c7afa94 100644 --- a/keyserver/curl-shim.c +++ b/keyserver/curl-shim.c @@ -27,6 +27,7 @@ #include <string.h> #include <stdio.h> #include <errno.h> + #include "http.h" #include "util.h" #include "ksutil.h" @@ -100,7 +101,11 @@ curl_easy_init(void) void curl_easy_cleanup(CURL *curl) { - free(curl); + if (curl) + { + http_close (curl->hd); + free(curl); + } } CURLcode @@ -177,42 +182,46 @@ curl_easy_perform(CURL *curl) if(curl->flags.post) { - rc=http_open(&curl->hd,HTTP_REQ_POST,curl->url,curl->auth,0,proxy); - if(rc==0) + rc = http_open (&curl->hd, HTTP_REQ_POST, curl->url, curl->auth, + 0, proxy, NULL); + if (!rc) { - char content_len[50]; - unsigned int post_len=strlen(curl->postfields); - - iobuf_writestr(curl->hd.fp_write, - "Content-Type: application/x-www-form-urlencoded\r\n"); - sprintf(content_len,"Content-Length: %u\r\n",post_len); - - iobuf_writestr(curl->hd.fp_write,content_len); - - http_start_data(&curl->hd); - iobuf_write(curl->hd.fp_write,curl->postfields,post_len); - rc=http_wait_response(&curl->hd,&curl->status); - if(rc==0 && curl->flags.failonerror && curl->status>=300) - err=CURLE_HTTP_RETURNED_ERROR; + unsigned int post_len = strlen(curl->postfields); + + es_fprintf (http_get_write_ptr (curl->hd), + "Content-Type: application/x-www-form-urlencoded\r\n" + "Content-Length: %u\r\n", post_len); + http_start_data (curl->hd); + es_write (http_get_write_ptr (curl->hd), + curl->postfields, post_len, NULL); + + rc = http_wait_response (curl->hd); + curl->status = http_get_status_code (curl->hd); + if (!rc && curl->flags.failonerror && curl->status>=300) + err = CURLE_HTTP_RETURNED_ERROR; + http_close(curl->hd); + curl->hd = NULL; } } else { - rc=http_open(&curl->hd,HTTP_REQ_GET,curl->url,curl->auth,0,proxy); - if(rc==0) + rc = http_open (&curl->hd, HTTP_REQ_GET, curl->url, curl->auth, + 0, proxy, NULL); + if (!rc) { - rc=http_wait_response(&curl->hd,&curl->status); - if(rc==0) + rc = http_wait_response (curl->hd); + curl->status = http_get_status_code (curl->hd); + if (!rc) { - if(curl->flags.failonerror && curl->status>=300) - err=CURLE_HTTP_RETURNED_ERROR; + if (curl->flags.failonerror && curl->status>=300) + err = CURLE_HTTP_RETURNED_ERROR; else { - unsigned int maxlen=1024,buflen,len; - byte *line=NULL; + unsigned int maxlen = 1024, buflen, len; + unsigned char *line = NULL; - while((len=iobuf_read_line(curl->hd.fp_read, - &line,&buflen,&maxlen))) + while ((len = es_read_line (http_get_read_ptr (curl->hd), + &line, &buflen, &maxlen))) { size_t ret; @@ -226,12 +235,16 @@ curl_easy_perform(CURL *curl) } } - xfree(line); - http_close(&curl->hd); + es_free (line); + http_close(curl->hd); + curl->hd = NULL; } } else - http_close(&curl->hd); + { + http_close (curl->hd); + curl->hd = NULL; + } } } diff --git a/keyserver/curl-shim.h b/keyserver/curl-shim.h index 91eac9d1e..e942ec710 100644 --- a/keyserver/curl-shim.h +++ b/keyserver/curl-shim.h @@ -73,7 +73,7 @@ typedef struct unsigned int failonerror:1; unsigned int verbose:1; } flags; - struct http_context hd; + http_t hd; } CURL; #define CURL_ERROR_SIZE 256 diff --git a/keyserver/gpgkeys_finger.c b/keyserver/gpgkeys_finger.c index 4124ebc72..b4f7b6a78 100644 --- a/keyserver/gpgkeys_finger.c +++ b/keyserver/gpgkeys_finger.c @@ -46,6 +46,7 @@ #include "util.h" #include "keyserver.h" #include "ksutil.h" +#include "iobuf.h" #ifdef _WIN32 #define sock_close(a) closesocket(a) @@ -289,7 +290,7 @@ get_key (char *getkey) { int rc; int sock; - IOBUF fp_read; + iobuf_t fp_read; unsigned int maxlen, buflen, gotit=0; byte *line = NULL; |