From 97b8f41b08c378ab20dbd00be1ab23453c8d3670 Mon Sep 17 00:00:00 2001 From: David Shaw Date: Wed, 22 Dec 2004 19:19:10 +0000 Subject: [PATCH] * gpgkeys_curl.c (main): New "follow-redirects" option. Takes an optional numeric value for the maximum number of redirects to allow. Defaults to 5. * gpgkeys_curl.c (main), gpgkeys_finger.c (main), gpgkeys_hkp.c (main), gpgkeys_http.c (main), gpgkeys_ldap.c (main): Make sure that a "timeout" option passed with no arguments is properly handled. --- keyserver/ChangeLog | 9 +++++++++ keyserver/gpgkeys_curl.c | 22 +++++++++++++++++++++- keyserver/gpgkeys_finger.c | 4 +++- keyserver/gpgkeys_hkp.c | 4 +++- keyserver/gpgkeys_http.c | 4 +++- keyserver/gpgkeys_ldap.c | 4 +++- 6 files changed, 42 insertions(+), 5 deletions(-) diff --git a/keyserver/ChangeLog b/keyserver/ChangeLog index de8516dcf..deee410ef 100644 --- a/keyserver/ChangeLog +++ b/keyserver/ChangeLog @@ -1,5 +1,14 @@ 2004-12-22 David Shaw + * gpgkeys_curl.c (main): New "follow-redirects" option. Takes an + optional numeric value for the maximum number of redirects to + allow. Defaults to 5. + + * gpgkeys_curl.c (main), gpgkeys_finger.c (main), gpgkeys_hkp.c + (main), gpgkeys_http.c (main), gpgkeys_ldap.c (main): Make sure + that a "timeout" option passed with no arguments is properly + handled. + * gpgkeys_curl.c (get_key, writer): New function to wrap around fwrite to avoid DLL access problem on win32. diff --git a/keyserver/gpgkeys_curl.c b/keyserver/gpgkeys_curl.c index 1d206e0c5..1d7544550 100644 --- a/keyserver/gpgkeys_curl.c +++ b/keyserver/gpgkeys_curl.c @@ -123,6 +123,7 @@ main(int argc,char *argv[]) char line[MAX_LINE]; char *thekey=NULL; unsigned int timeout=DEFAULT_KEYSERVER_TIMEOUT; + long follow_redirects=5; console=stderr; @@ -269,8 +270,19 @@ main(int argc,char *argv[]) { if(no) timeout=0; - else + else if(start[7]=='=') timeout=atoi(&start[8]); + else if(start[7]=='\0') + timeout=DEFAULT_KEYSERVER_TIMEOUT; + } + else if(strncasecmp(start,"follow-redirects",16)==0) + { + if(no) + follow_redirects=0; + else if(start[16]=='=') + follow_redirects=atoi(&start[17]); + else if(start[16]=='\0') + follow_redirects=-1; } continue; @@ -312,6 +324,14 @@ main(int argc,char *argv[]) goto fail; } + if(follow_redirects) + { + curl_easy_setopt(curl,CURLOPT_FOLLOWLOCATION,1); + if(follow_redirects>0) + curl_easy_setopt(curl,CURLOPT_MAXREDIRS,follow_redirects); + } + + /* If it's a GET or a SEARCH, the next thing to come in is the keyids. If it's a SEND, then there are no keyids. */ diff --git a/keyserver/gpgkeys_finger.c b/keyserver/gpgkeys_finger.c index 4467362b0..303e636eb 100644 --- a/keyserver/gpgkeys_finger.c +++ b/keyserver/gpgkeys_finger.c @@ -502,8 +502,10 @@ main(int argc,char *argv[]) { if(no) timeout=0; - else + else if(start[7]=='=') timeout=atoi(&start[8]); + else if(start[7]=='\0') + timeout=DEFAULT_KEYSERVER_TIMEOUT; } continue; diff --git a/keyserver/gpgkeys_hkp.c b/keyserver/gpgkeys_hkp.c index 506513835..db1e7ea0e 100644 --- a/keyserver/gpgkeys_hkp.c +++ b/keyserver/gpgkeys_hkp.c @@ -949,8 +949,10 @@ main(int argc,char *argv[]) { if(no) timeout=0; - else + else if(start[7]=='=') timeout=atoi(&start[8]); + else if(start[7]=='\0') + timeout=DEFAULT_KEYSERVER_TIMEOUT; } continue; diff --git a/keyserver/gpgkeys_http.c b/keyserver/gpgkeys_http.c index dad141fd6..76da9e00c 100644 --- a/keyserver/gpgkeys_http.c +++ b/keyserver/gpgkeys_http.c @@ -311,8 +311,10 @@ main(int argc,char *argv[]) { if(no) timeout=0; - else + else if(start[7]=='=') timeout=atoi(&start[8]); + else if(start[7]=='\0') + timeout=DEFAULT_KEYSERVER_TIMEOUT; } continue; diff --git a/keyserver/gpgkeys_ldap.c b/keyserver/gpgkeys_ldap.c index 97f3911f7..bc603e725 100644 --- a/keyserver/gpgkeys_ldap.c +++ b/keyserver/gpgkeys_ldap.c @@ -1763,8 +1763,10 @@ main(int argc,char *argv[]) { if(no) timeout=0; - else + else if(start[7]=='=') timeout=atoi(&start[8]); + else if(start[7]=='\0') + timeout=DEFAULT_KEYSERVER_TIMEOUT; } continue;