1
0
mirror of git://git.gnupg.org/gnupg.git synced 2025-03-12 23:01:14 +01:00

* 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.
This commit is contained in:
David Shaw 2005-01-24 18:23:56 +00:00
parent 1f057ff498
commit 5d257ee60e
3 changed files with 77 additions and 9 deletions

View File

@ -1,4 +1,13 @@
2005-01-21 David Shaw <dshaw@grover.jabberwocky.com>
2005-01-24 David Shaw <dshaw@jabberwocky.com>
* 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 <dshaw@jabberwocky.com>
* 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 <dshaw@grover.jabberwocky.com>
2005-01-18 David Shaw <dshaw@jabberwocky.com>
* 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 <dshaw@grover.jabberwocky.com>
2005-01-17 David Shaw <dshaw@jabberwocky.com>
* gpgkeys_curl.c (main): Only allow specified protocols to use the
curl handler.

View File

@ -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);

View File

@ -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);
}