~ubuntu-branches/ubuntu/natty/gnupg/natty-security

« back to all changes in this revision

Viewing changes to keyserver/gpgkeys_curl.c

  • Committer: Bazaar Package Importer
  • Author(s): Michael Bienia
  • Date: 2010-01-04 20:06:01 UTC
  • mfrom: (1.1.11 squeeze)
  • Revision ID: james.westby@ubuntu.com-20100104200601-0rble341i2xns9xw
Tags: 1.4.10-2ubuntu1
* Merge from Debian testing (lp: #503064, #477818). Remaining changes:
  - Add 'debian/patches/50_disable_mlock_test.dpatch': Disable mlock() test
    since it fails with ulimit 0 (on buildds).
  - Add 'debian/patches/61_use_agent_default.dpatch': Patch to set gpg
    (or gpg2) and gpgsm to use a passphrase agent by default (lp: 15485)
  - Fix udeb build failure on powerpc, building with -O2 instead of -Os.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* gpgkeys_curl.c - fetch a key via libcurl
2
 
 * Copyright (C) 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
 
2
 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
3
3
 *
4
4
 * This file is part of GnuPG.
5
5
 *
103
103
static void 
104
104
show_help (FILE *fp)
105
105
{
106
 
  fprintf (fp,"-h\thelp\n");
107
 
  fprintf (fp,"-V\tversion\n");
108
 
  fprintf (fp,"-o\toutput to this file\n");
 
106
  fprintf (fp,"-h, --help\thelp\n");
 
107
  fprintf (fp,"-V\t\tmachine readable version\n");
 
108
  fprintf (fp,"--version\thuman readable version\n");
 
109
  fprintf (fp,"-o\t\toutput to this file\n");
109
110
}
110
111
 
111
112
int
117
118
  long follow_redirects=5;
118
119
  char *proxy=NULL;
119
120
  curl_version_info_data *curldata;
 
121
  struct curl_slist *headers=NULL;
120
122
 
121
123
  console=stderr;
122
124
 
123
125
  /* Kludge to implement standard GNU options.  */
124
126
  if (argc > 1 && !strcmp (argv[1], "--version"))
125
127
    {
126
 
      fputs ("gpgkeys_curl (GnuPG) " VERSION"\n", stdout);
 
128
      printf ("gpgkeys_curl (GnuPG) %s\n", VERSION);
 
129
      printf ("Uses: %s\n", curl_version());
127
130
      return 0;
128
131
    }
129
132
  else if (argc > 1 && !strcmp (argv[1], "--help"))
286
289
 
287
290
  if(follow_redirects)
288
291
    {
289
 
      curl_easy_setopt(curl,CURLOPT_FOLLOWLOCATION,1);
 
292
      curl_easy_setopt(curl,CURLOPT_FOLLOWLOCATION,1L);
290
293
      if(follow_redirects>0)
291
294
        curl_easy_setopt(curl,CURLOPT_MAXREDIRS,follow_redirects);
292
295
    }
298
301
    {
299
302
      fprintf(console,"gpgkeys: curl version = %s\n",curl_version());
300
303
      curl_easy_setopt(curl,CURLOPT_STDERR,console);
301
 
      curl_easy_setopt(curl,CURLOPT_VERBOSE,1);
 
304
      curl_easy_setopt(curl,CURLOPT_VERBOSE,1L);
302
305
    }
303
306
 
304
 
  curl_easy_setopt(curl,CURLOPT_SSL_VERIFYPEER,opt->flags.check_cert);
 
307
  curl_easy_setopt(curl,CURLOPT_SSL_VERIFYPEER,(long)opt->flags.check_cert);
305
308
  curl_easy_setopt(curl,CURLOPT_CAINFO,opt->ca_cert_file);
306
309
 
 
310
  /* Avoid caches to get the most recent copy of the key.  This is bug
 
311
     #1061.  In pre-curl versions of the code, we didn't do it.  Then
 
312
     we did do it (as a curl default) until curl changed the default.
 
313
     Now we're doing it again, but in such a way that changing
 
314
     defaults in the future won't impact us.  We set both the Pragma
 
315
     and Cache-Control versions of the header, so we're good with both
 
316
     HTTP 1.0 and 1.1. */
 
317
  headers=curl_slist_append(headers,"Pragma: no-cache");
 
318
  if(headers)
 
319
    headers=curl_slist_append(headers,"Cache-Control: no-cache");
 
320
 
 
321
  if(!headers)
 
322
    {
 
323
      fprintf(console,"gpgkeys: out of memory when building HTTP headers\n");
 
324
      ret=KEYSERVER_NO_MEMORY;
 
325
      goto fail;
 
326
    }
 
327
 
 
328
  curl_easy_setopt(curl,CURLOPT_HTTPHEADER,headers);
 
329
 
307
330
  if(proxy)
308
331
    curl_easy_setopt(curl,CURLOPT_PROXY,proxy);
309
332
 
384
407
 
385
408
  free_ks_options(opt);
386
409
 
 
410
  curl_slist_free_all(headers);
 
411
 
387
412
  if(curl)
388
413
    curl_easy_cleanup(curl);
389
414