~ubuntu-branches/ubuntu/karmic/gnupg2/karmic-security

« back to all changes in this revision

Viewing changes to keyserver/ksutil.h

  • Committer: Bazaar Package Importer
  • Author(s): Thomas Viehmann
  • Date: 2008-10-04 10:25:53 UTC
  • mfrom: (5.1.15 intrepid)
  • Revision ID: james.westby@ubuntu.com-20081004102553-fv62pp8dsitxli47
Tags: 2.0.9-3.1
* Non-maintainer upload.
* agent/gpg-agent.c: Deinit the threading library before exec'ing
  the command to run in --daemon mode. And because that still doesn't
  restore the sigprocmask, do that manually. Closes: #499569

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* ksutil.h
2
 
 * Copyright (C) 2004 Free Software Foundation, Inc.
3
 
 *
4
 
 * This file is part of GNUPG.
5
 
 *
6
 
 * GNUPG is free software; you can redistribute it and/or modify
 
2
 * Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
 
3
 *
 
4
 * This file is part of GnuPG.
 
5
 *
 
6
 * GnuPG is free software; you can redistribute it and/or modify
7
7
 * it under the terms of the GNU General Public License as published by
8
 
 * the Free Software Foundation; either version 2 of the License, or
 
8
 * the Free Software Foundation; either version 3 of the License, or
9
9
 * (at your option) any later version.
10
10
 *
11
 
 * GNUPG is distributed in the hope that it will be useful,
 
11
 * GnuPG is distributed in the hope that it will be useful,
12
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
14
 * GNU General Public License for more details.
15
15
 *
16
16
 * You should have received a copy of the GNU General Public License
17
 
 * along with this program; if not, write to the Free Software
18
 
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
 
17
 * along with this program; if not, see <http://www.gnu.org/licenses/>.
 
18
 *
 
19
 * In addition, as a special exception, the Free Software Foundation
 
20
 * gives permission to link the code of the keyserver helper tools:
 
21
 * gpgkeys_ldap, gpgkeys_curl and gpgkeys_hkp with the OpenSSL
 
22
 * project's "OpenSSL" library (or with modified versions of it that
 
23
 * use the same license as the "OpenSSL" library), and distribute the
 
24
 * linked executables.  You must obey the GNU General Public License
 
25
 * in all respects for all of the code used other than "OpenSSL".  If
 
26
 * you modify this file, you may extend this exception to your version
 
27
 * of the file, but you are not obligated to do so.  If you do not
 
28
 * wish to do so, delete this exception statement from your version.
19
29
 */
20
30
 
21
31
#ifndef _KSUTIL_H_
22
32
#define _KSUTIL_H_
23
33
 
24
 
/* 30 seconds seems reasonable */
25
 
#define DEFAULT_KEYSERVER_TIMEOUT 30
 
34
#ifdef HAVE_LIBCURL
 
35
#include <curl/curl.h>
 
36
#else
 
37
#include "curl-shim.h"
 
38
#endif
 
39
 
 
40
/* MAX_LINE must be at least 1 larger than the largest item we expect
 
41
   to receive, including the name tag ("COMMAND", "PORT", etc) and
 
42
   space between.  In practice, that means it should be
 
43
   strlen("OPAQUE")+1+sizeof_opaque+1 */
 
44
#define MAX_LINE       (6+1+1024+1)
 
45
 
 
46
#define MAX_COMMAND    7
 
47
#define MAX_OPTION   256
 
48
#define MAX_SCHEME    20
 
49
#define MAX_OPAQUE  1024
 
50
#define MAX_AUTH     128
 
51
#define MAX_HOST      80
 
52
#define MAX_PORT      10
 
53
#define URLMAX_PATH 1024
 
54
#define MAX_PROXY    128
 
55
#define MAX_URL     (MAX_SCHEME+1+3+MAX_AUTH+1+1+MAX_HOST+1+1 \
 
56
                     +MAX_PORT+1+1+URLMAX_PATH+1+50)
 
57
 
 
58
#define STRINGIFY(x) #x
 
59
#define MKSTRING(x) STRINGIFY(x)
 
60
 
 
61
#define BEGIN "-----BEGIN PGP PUBLIC KEY BLOCK-----"
 
62
#define END   "-----END PGP PUBLIC KEY BLOCK-----"
 
63
 
 
64
#ifdef __riscos__
 
65
#define HTTP_PROXY_ENV           "GnuPG$HttpProxy"
 
66
#else
 
67
#define HTTP_PROXY_ENV           "http_proxy"
 
68
#endif
 
69
 
 
70
struct keylist
 
71
{
 
72
  char str[MAX_LINE];
 
73
  struct keylist *next;
 
74
};
 
75
 
 
76
/* 2 minutes seems reasonable */
 
77
#define DEFAULT_KEYSERVER_TIMEOUT 120
26
78
 
27
79
unsigned int set_timeout(unsigned int seconds);
28
80
int register_timeout(void);
29
81
 
 
82
enum ks_action {KS_UNKNOWN=0,KS_GET,KS_GETNAME,KS_SEND,KS_SEARCH};
 
83
 
 
84
enum ks_search_type {KS_SEARCH_SUBSTR,KS_SEARCH_EXACT,
 
85
                     KS_SEARCH_MAIL,KS_SEARCH_MAILSUB,
 
86
                     KS_SEARCH_KEYID_LONG,KS_SEARCH_KEYID_SHORT};
 
87
 
 
88
struct ks_options
 
89
{
 
90
  enum ks_action action;
 
91
  char *host;
 
92
  char *port;
 
93
  char *scheme;
 
94
  char *auth;
 
95
  char *path;
 
96
  char *opaque;
 
97
  struct
 
98
  {
 
99
    unsigned int include_disabled:1;
 
100
    unsigned int include_revoked:1;
 
101
    unsigned int include_subkeys:1;
 
102
    unsigned int check_cert:1;
 
103
  } flags;
 
104
  unsigned int verbose;
 
105
  unsigned int debug;
 
106
  unsigned int timeout;
 
107
  char *ca_cert_file;
 
108
};
 
109
 
 
110
struct ks_options *init_ks_options(void);
 
111
void free_ks_options(struct ks_options *opt);
 
112
int parse_ks_options(char *line,struct ks_options *opt);
 
113
const char *ks_action_to_string(enum ks_action action);
 
114
void print_nocr(FILE *stream,const char *str);
 
115
enum ks_search_type classify_ks_search(const char **search);
 
116
 
 
117
int curl_err_to_gpg_err(CURLcode error);
 
118
 
 
119
struct curl_writer_ctx
 
120
{
 
121
  struct
 
122
  {
 
123
    unsigned int initialized:1;
 
124
    unsigned int begun:1;
 
125
    unsigned int done:1;
 
126
    unsigned int armor:1;
 
127
  } flags;
 
128
 
 
129
  int armor_remaining;
 
130
  unsigned char armor_ctx[3];
 
131
  int markeridx,linelen;
 
132
  const char *marker;
 
133
  FILE *stream;
 
134
};
 
135
 
 
136
size_t curl_writer(const void *ptr,size_t size,size_t nmemb,void *cw_ctx);
 
137
void curl_writer_finalize(struct curl_writer_ctx *ctx);
 
138
 
 
139
int ks_hextobyte (const char *s);
 
140
int ks_toupper (int c);
 
141
int ks_strcasecmp (const char *a, const char *b);
 
142
 
 
143
 
30
144
#endif /* !_KSUTIL_H_ */