aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--keyserver/ChangeLog15
-rw-r--r--keyserver/gpgkeys_curl.c57
-rw-r--r--keyserver/gpgkeys_ldap.c14
3 files changed, 77 insertions, 9 deletions
diff --git a/keyserver/ChangeLog b/keyserver/ChangeLog
index 4917f6e69..b5892ad01 100644
--- a/keyserver/ChangeLog
+++ b/keyserver/ChangeLog
@@ -1,4 +1,13 @@
-2005-01-21 David Shaw <[email protected]>
+2005-01-24 David Shaw <[email protected]>
+
+ * gpgkeys_ldap.c (print_nocr): New.
+ (get_key): Call it here to canonicalize line endings.
+
+ * gpgkeys_curl.c (writer): Discard everything outside the BEGIN
+ and END lines when retrieving keys. Canonicalize line endings.
+ (main): Accept FTPS.
+
+2005-01-21 David Shaw <[email protected]>
* gpgkeys_ldap.c (main): Add "check-cert" option to disable SSL
certificate checking (which is on by default).
@@ -7,7 +16,7 @@
helper. Add "check-cert" option to disable SSL certificate
checking (which is on by default).
-2005-01-18 David Shaw <[email protected]>
+2005-01-18 David Shaw <[email protected]>
* gpgkeys_curl.c: Fix typo.
@@ -19,7 +28,7 @@
* gpgkeys_http.c: Ditto.
* ksutil.h: s/MAX_PATH/URLMAX_PATH/.
-2005-01-17 David Shaw <[email protected]>
+2005-01-17 David Shaw <[email protected]>
* gpgkeys_curl.c (main): Only allow specified protocols to use the
curl handler.
diff --git a/keyserver/gpgkeys_curl.c b/keyserver/gpgkeys_curl.c
index cac65c4e8..7d8fcd175 100644
--- a/keyserver/gpgkeys_curl.c
+++ b/keyserver/gpgkeys_curl.c
@@ -55,12 +55,55 @@ curl_err_to_gpg_err(CURLcode error)
}
}
-/* We wrap fwrite so to avoid DLL problems on Win32 (see curl faq for
- more). */
static size_t
writer(const void *ptr,size_t size,size_t nmemb,void *stream)
{
- return fwrite(ptr,size,nmemb,stream);
+ const char *buf=ptr;
+ size_t i;
+ static int markeridx=0,begun=0,done=0;
+ static const char *marker=BEGIN;
+
+ /* scan the incoming data for our marker */
+ for(i=0;!done && i<(size*nmemb);i++)
+ {
+ if(buf[i]==marker[markeridx])
+ {
+ markeridx++;
+ if(marker[markeridx]=='\0')
+ {
+ if(begun)
+ done=1;
+ else
+ {
+ /* We've found the BEGIN marker, so now we're looking
+ for the END marker. */
+ begun=1;
+ marker=END;
+ markeridx=0;
+ fprintf(output,BEGIN);
+ continue;
+ }
+ }
+ }
+ else
+ markeridx=0;
+
+ if(begun)
+ {
+ /* Canonicalize CRLF to just LF by stripping CRs. This
+ actually makes sense, since on Unix-like machines LF is
+ correct, and on win32-like machines, our output buffer is
+ opened in textmode and will re-canonicalize line endings
+ back to CRLF. Since we only need to handle armored keys,
+ we don't have to worry about odd cases like CRCRCR and
+ the like. */
+
+ if(buf[i]!='\r')
+ fputc(buf[i],output);
+ }
+ }
+
+ return size*nmemb;
}
static int
@@ -87,10 +130,10 @@ get_key(char *getkey)
{
fprintf(console,"gpgkeys: %s fetch error %d: %s\n",scheme,
res,errorbuffer);
- fprintf(output,"KEY 0x%s FAILED %d\n",getkey,curl_err_to_gpg_err(res));
+ fprintf(output,"\nKEY 0x%s FAILED %d\n",getkey,curl_err_to_gpg_err(res));
}
else
- fprintf(output,"KEY 0x%s END\n",getkey);
+ fprintf(output,"\nKEY 0x%s END\n",getkey);
return KEYSERVER_OK;
}
@@ -319,6 +362,10 @@ main(int argc,char *argv[])
else if(strcasecmp(scheme,"ftp")==0)
;
#endif /* FTP_VIA_LIBCURL */
+#ifdef FTPS_VIA_LIBCURL
+ else if(strcasecmp(scheme,"ftps")==0)
+ ;
+#endif /* FTPS_VIA_LIBCURL */
else
{
fprintf(console,"gpgkeys: scheme `%s' not supported\n",scheme);
diff --git a/keyserver/gpgkeys_ldap.c b/keyserver/gpgkeys_ldap.c
index 8ca1d1d2c..d6b280a62 100644
--- a/keyserver/gpgkeys_ldap.c
+++ b/keyserver/gpgkeys_ldap.c
@@ -952,6 +952,17 @@ build_info(const char *certid,LDAPMessage *each)
fprintf(output,"INFO %s END\n",certid);
}
+static void
+print_nocr(FILE *stream,const char *str)
+{
+ while(*str)
+ {
+ if(*str!='\r')
+ fputc(*str,stream);
+ str++;
+ }
+}
+
/* Note that key-not-found is not a fatal error */
static int
get_key(char *getkey)
@@ -1091,7 +1102,8 @@ get_key(char *getkey)
}
else
{
- fprintf(output,"%sKEY 0x%s END\n",vals[0],getkey);
+ print_nocr(output,vals[0]);
+ fprintf(output,"\nKEY 0x%s END\n",getkey);
ldap_value_free(vals);
}