diff options
author | David Shaw <dshaw@jabberwocky.com> | 2007-03-14 05:24:55 +0100 |
---|---|---|
committer | David Shaw <dshaw@jabberwocky.com> | 2007-03-14 05:24:55 +0100 |
commit | 458efc1d6f84262f72471de173e5f8bb065cbec8 (patch) | |
tree | 351d476109019708aadab0ad6140802310217a62 /keyserver/gpgkeys_curl.c | |
parent | From STABLE-BRANCH-1-4 (diff) | |
download | gnupg2-458efc1d6f84262f72471de173e5f8bb065cbec8.tar.xz gnupg2-458efc1d6f84262f72471de173e5f8bb065cbec8.zip |
From STABLE-BRANCH-1-4
* gpgkeys_curl.c (main): Use curl_version_info to verify that the
protocol we're about to use is actually available.
* curl-shim.h, curl-shim.c (curl_free): Make into a macro.
(curl_version_info): New. Only advertises "http" for our shim, of
course.
Diffstat (limited to '')
-rw-r--r-- | keyserver/gpgkeys_curl.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/keyserver/gpgkeys_curl.c b/keyserver/gpgkeys_curl.c index 192f9ba66..e326df63c 100644 --- a/keyserver/gpgkeys_curl.c +++ b/keyserver/gpgkeys_curl.c @@ -1,5 +1,5 @@ /* gpgkeys_curl.c - fetch a key via libcurl - * Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc. + * Copyright (C) 2004, 2005, 2006, 2007 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -112,11 +112,12 @@ show_help (FILE *fp) int main(int argc,char *argv[]) { - int arg,ret=KEYSERVER_INTERNAL_ERROR; + int arg,ret=KEYSERVER_INTERNAL_ERROR,i; char line[MAX_LINE]; char *thekey=NULL; long follow_redirects=5; char *proxy=NULL; + curl_version_info_data *curldata; console=stderr; @@ -261,6 +262,7 @@ main(int argc,char *argv[]) } curl_global_init(CURL_GLOBAL_DEFAULT); + curl=curl_easy_init(); if(!curl) { @@ -269,6 +271,20 @@ main(int argc,char *argv[]) goto fail; } + /* Make sure we have the protocol the user is asking for so we can + print a nicer error message. */ + curldata=curl_version_info(CURLVERSION_NOW); + for(i=0;curldata->protocols[i];i++) + if(strcasecmp(curldata->protocols[i],opt->scheme)==0) + break; + + if(curldata->protocols[i]==NULL) + { + fprintf(console,"gpgkeys: protocol `%s' not supported\n",opt->scheme); + ret=KEYSERVER_SCHEME_NOT_FOUND; + goto fail; + } + if(follow_redirects) { curl_easy_setopt(curl,CURLOPT_FOLLOWLOCATION,1); |