Imported Upstream version 2.1.8
[platform/upstream/gpg2.git] / g10 / options.h
1 /* options.h
2  * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
3  *               2007, 2010, 2011 Free Software Foundation, Inc.
4  *
5  * This file is part of GnuPG.
6  *
7  * GnuPG is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * GnuPG is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, see <http://www.gnu.org/licenses/>.
19  */
20 #ifndef G10_OPTIONS_H
21 #define G10_OPTIONS_H
22
23 #include <sys/types.h>
24 #include <types.h>
25 #include "main.h"
26 #include "packet.h"
27 #include "../common/session-env.h"
28
29 #ifndef EXTERN_UNLESS_MAIN_MODULE
30 /* Norcraft can't cope with common symbols */
31 #if defined (__riscos__) && !defined (INCLUDED_BY_MAIN_MODULE)
32 #define EXTERN_UNLESS_MAIN_MODULE extern
33 #else
34 #define EXTERN_UNLESS_MAIN_MODULE
35 #endif
36 #endif
37
38 /* Declaration of a keyserver spec type.  The definition is found in
39    ../common/keyserver.h.  */
40 struct keyserver_spec;
41 typedef struct keyserver_spec *keyserver_spec_t;
42
43
44 /* Global options for GPG.  */
45 EXTERN_UNLESS_MAIN_MODULE
46 struct
47 {
48   int verbose;
49   int quiet;
50   unsigned debug;
51   int armor;
52   char *outfile;
53   estream_t outfp;  /* Hack, sometimes used in place of outfile.  */
54   off_t max_output;
55   int dry_run;
56   int autostart;
57   int list_only;
58   int textmode;
59   int expert;
60   const char *def_sig_expire;
61   int ask_sig_expire;
62   const char *def_cert_expire;
63   int ask_cert_expire;
64   int batch;        /* run in batch mode */
65   int answer_yes; /* answer yes on most questions */
66   int answer_no;  /* answer no on most questions */
67   int check_sigs; /* check key signatures */
68   int with_colons;
69   int with_key_data;
70   int with_icao_spelling; /* Print ICAO spelling with fingerprints.  */
71   int with_fingerprint; /* Option --with-fingerprint active.  */
72   int with_keygrip;     /* Option --with-keygrip active.  */
73   int with_secret;      /* Option --with-secret active.  */
74   int fingerprint; /* list fingerprints */
75   int list_sigs;   /* list signatures */
76   int print_pka_records;
77   int no_armor;
78   int list_packets; /* list-packets mode: 1=normal, 2=invoked by command*/
79   int def_cipher_algo;
80   int force_mdc;
81   int disable_mdc;
82   int def_digest_algo;
83   int cert_digest_algo;
84   int compress_algo;
85   int compress_level;
86   int bz2_compress_level;
87   int bz2_decompress_lowmem;
88   const char *def_secret_key;
89   char *def_recipient;
90   int def_recipient_self;
91   strlist_t secret_keys_to_try;
92
93   int def_cert_level;
94   int min_cert_level;
95   int ask_cert_level;
96   int emit_version;       /* 0 = none,
97                              1 = major only,
98                              2 = major and minor,
99                              3 = full version,
100                              4 = full version plus OS string. */
101   int marginals_needed;
102   int completes_needed;
103   int max_cert_depth;
104   const char *homedir;
105   const char *agent_program;
106   const char *dirmngr_program;
107
108   /* Options to be passed to the gpg-agent */
109   session_env_t session_env;
110   char *lc_ctype;
111   char *lc_messages;
112
113   int skip_verify;
114   int skip_hidden_recipients;
115
116   /* TM_CLASSIC must be zero to accomodate trustdbs generated before
117      we started storing the trust model inside the trustdb. */
118   enum
119     {
120       TM_CLASSIC=0, TM_PGP=1, TM_EXTERNAL=2, TM_ALWAYS, TM_DIRECT, TM_AUTO
121     } trust_model;
122   int force_ownertrust;
123   enum
124     {
125       CO_GNUPG, CO_RFC4880, CO_RFC2440,
126       CO_PGP6, CO_PGP7, CO_PGP8
127     } compliance;
128   enum
129     {
130       KF_SHORT, KF_LONG, KF_0xSHORT, KF_0xLONG
131     } keyid_format;
132   int shm_coprocess;
133   const char *set_filename;
134   strlist_t comments;
135   int throw_keyids;
136   const char *photo_viewer;
137   int s2k_mode;
138   int s2k_digest_algo;
139   int s2k_cipher_algo;
140   unsigned char s2k_count; /* This is the encoded form, not the raw
141                               count */
142   int not_dash_escaped;
143   int escape_from;
144   int lock_once;
145   keyserver_spec_t keyserver;  /* The list of configured keyservers.  */
146   struct
147   {
148     unsigned int options;
149     unsigned int import_options;
150     unsigned int export_options;
151     char *http_proxy;
152   } keyserver_options;
153   int exec_disable;
154   int exec_path_set;
155   unsigned int import_options;
156   unsigned int export_options;
157   unsigned int list_options;
158   unsigned int verify_options;
159   const char *def_preference_list;
160   const char *def_keyserver_url;
161   prefitem_t *personal_cipher_prefs;
162   prefitem_t *personal_digest_prefs;
163   prefitem_t *personal_compress_prefs;
164   int no_perm_warn;
165   int no_mdc_warn;
166   char *temp_dir;
167   int no_encrypt_to;
168   int interactive;
169   struct notation *sig_notations;
170   struct notation *cert_notations;
171   strlist_t sig_policy_url;
172   strlist_t cert_policy_url;
173   strlist_t sig_keyserver_url;
174   strlist_t cert_subpackets;
175   strlist_t sig_subpackets;
176   int allow_non_selfsigned_uid;
177   int allow_freeform_uid;
178   int no_literal;
179   ulong set_filesize;
180   int fast_list_mode;
181   int legacy_list_mode;
182   int ignore_time_conflict;
183   int ignore_valid_from;
184   int ignore_crc_error;
185   int ignore_mdc_error;
186   int command_fd;
187   const char *override_session_key;
188   int show_session_key;
189
190   const char *gpg_agent_info;
191   int try_all_secrets;
192   int no_expensive_trust_checks;
193   int no_sig_cache;
194   int no_auto_check_trustdb;
195   int preserve_permissions;
196   int no_homedir_creation;
197   struct groupitem *grouplist;
198   int mangle_dos_filenames;
199   int enable_progress_filter;
200   unsigned int screen_columns;
201   unsigned int screen_lines;
202   byte *show_subpackets;
203   int rfc2440_text;
204
205   /* If true, let write failures on the status-fd exit the process. */
206   int exit_on_status_write_error;
207
208   /* If > 0, limit the number of card insertion prompts to this
209      value. */
210   int limit_card_insert_tries;
211
212 #ifdef ENABLE_CARD_SUPPORT
213   /* FIXME: We don't needs this here as it is done in scdaemon. */
214   const char *ctapi_driver; /* Library to access the ctAPI. */
215   const char *pcsc_driver;  /* Library to access the PC/SC system. */
216   int disable_ccid;    /* Disable the use of the internal CCID driver. */
217 #endif /*ENABLE_CARD_SUPPORT*/
218
219   struct
220   {
221     /* If set, require an 0x19 backsig to be present on signatures
222        made by signing subkeys.  If not set, a missing backsig is not
223        an error (but an invalid backsig still is). */
224     unsigned int require_cross_cert:1;
225
226     unsigned int use_embedded_filename:1;
227     unsigned int utf8_filename:1;
228     unsigned int dsa2:1;
229     unsigned int allow_multiple_messages:1;
230     unsigned int allow_weak_digest_algos:1;
231     unsigned int large_rsa:1;
232   } flags;
233
234   /* Linked list of ways to find a key if the key isn't on the local
235      keyring. */
236   struct akl
237   {
238     enum {
239       AKL_NODEFAULT,
240       AKL_LOCAL,
241       AKL_CERT,
242       AKL_PKA,
243       AKL_LDAP,
244       AKL_KEYSERVER,
245       AKL_SPEC
246     } type;
247     keyserver_spec_t spec;
248     struct akl *next;
249   } *auto_key_locate;
250
251   int passphrase_repeat;
252   int pinentry_mode;
253 } opt;
254
255 /* CTRL is used to keep some global variables we currently can't
256    avoid.  Future concurrent versions of gpg will put it into a per
257    request structure CTRL. */
258 EXTERN_UNLESS_MAIN_MODULE
259 struct {
260   int in_auto_key_retrieve; /* True if we are doing an
261                                auto_key_retrieve. */
262   /* Hack to store the last error.  We currently need it because the
263      proc_packet machinery is not able to reliabale return error
264      codes.  Thus for the --server purposes we store some of the error
265      codes here.  FIXME! */
266   gpg_error_t lasterr;
267 } glo_ctrl;
268
269 #define DBG_PACKET_VALUE  1     /* debug packet reading/writing */
270 #define DBG_MPI_VALUE     2     /* debug mpi details */
271 #define DBG_CRYPTO_VALUE  4     /* debug crypto handling */
272                                 /* (may reveal sensitive data) */
273 #define DBG_FILTER_VALUE  8     /* debug internal filter handling */
274 #define DBG_IOBUF_VALUE   16    /* debug iobuf stuff */
275 #define DBG_MEMORY_VALUE  32    /* debug memory allocation stuff */
276 #define DBG_CACHE_VALUE   64    /* debug the caching */
277 #define DBG_MEMSTAT_VALUE 128   /* show memory statistics */
278 #define DBG_TRUST_VALUE   256   /* debug the trustdb */
279 #define DBG_HASHING_VALUE 512   /* debug hashing operations */
280 #define DBG_IPC_VALUE     1024  /* debug assuan communication */
281 #define DBG_CARD_IO_VALUE 2048  /* debug smart card I/O.  */
282 #define DBG_CLOCK_VALUE   4096
283 #define DBG_LOOKUP_VALUE  8192  /* debug the kety lookup */
284 #define DBG_EXTPROG_VALUE 16384 /* debug external program calls */
285
286 /* Tests for the debugging flags.  */
287 #define DBG_PACKET (opt.debug & DBG_PACKET_VALUE)
288 #define DBG_CRYPTO (opt.debug & DBG_CRYPTO_VALUE)
289 #define DBG_FILTER (opt.debug & DBG_FILTER_VALUE)
290 #define DBG_CACHE  (opt.debug & DBG_CACHE_VALUE)
291 #define DBG_TRUST  (opt.debug & DBG_TRUST_VALUE)
292 #define DBG_HASHING (opt.debug & DBG_HASHING_VALUE)
293 #define DBG_IPC     (opt.debug & DBG_IPC_VALUE)
294 #define DBG_CARD_IO (opt.debug & DBG_CARD_IO_VALUE)
295 #define DBG_IPC     (opt.debug & DBG_IPC_VALUE)
296 #define DBG_CLOCK   (opt.debug & DBG_CLOCK_VALUE)
297 #define DBG_LOOKUP  (opt.debug & DBG_LOOKUP_VALUE)
298 #define DBG_EXTPROG (opt.debug & DBG_EXTPROG_VALUE)
299
300 /* FIXME: We need to check whey we did not put this into opt. */
301 #define DBG_MEMORY    memory_debug_mode
302 #define DBG_MEMSTAT   memory_stat_debug_mode
303
304 EXTERN_UNLESS_MAIN_MODULE int memory_debug_mode;
305 EXTERN_UNLESS_MAIN_MODULE int memory_stat_debug_mode;
306
307
308 /* Compatibility flags.  */
309 #define GNUPG   (opt.compliance==CO_GNUPG)
310 #define RFC2440 (opt.compliance==CO_RFC2440)
311 #define RFC4880 (opt.compliance==CO_RFC4880)
312 #define PGP6    (opt.compliance==CO_PGP6)
313 #define PGP7    (opt.compliance==CO_PGP7)
314 #define PGP8    (opt.compliance==CO_PGP8)
315 #define PGPX    (PGP6 || PGP7 || PGP8)
316
317 /* Various option flags.  Note that there should be no common string
318    names between the IMPORT_ and EXPORT_ flags as they can be mixed in
319    the keyserver-options option. */
320
321 #define IMPORT_LOCAL_SIGS                (1<<0)
322 #define IMPORT_REPAIR_PKS_SUBKEY_BUG     (1<<1)
323 #define IMPORT_FAST                      (1<<2)
324 #define IMPORT_MERGE_ONLY                (1<<4)
325 #define IMPORT_MINIMAL                   (1<<5)
326 #define IMPORT_CLEAN                     (1<<6)
327 #define IMPORT_NO_SECKEY                 (1<<7)
328 #define IMPORT_KEEP_OWNERTTRUST          (1<<8)
329
330 #define EXPORT_LOCAL_SIGS                (1<<0)
331 #define EXPORT_ATTRIBUTES                (1<<1)
332 #define EXPORT_SENSITIVE_REVKEYS         (1<<2)
333 #define EXPORT_RESET_SUBKEY_PASSWD       (1<<3)
334 #define EXPORT_MINIMAL                   (1<<4)
335 #define EXPORT_CLEAN                     (1<<5)
336 #define EXPORT_SEXP_FORMAT               (1<<6)
337
338 #define LIST_SHOW_PHOTOS                 (1<<0)
339 #define LIST_SHOW_POLICY_URLS            (1<<1)
340 #define LIST_SHOW_STD_NOTATIONS          (1<<2)
341 #define LIST_SHOW_USER_NOTATIONS         (1<<3)
342 #define LIST_SHOW_NOTATIONS (LIST_SHOW_STD_NOTATIONS|LIST_SHOW_USER_NOTATIONS)
343 #define LIST_SHOW_KEYSERVER_URLS         (1<<4)
344 #define LIST_SHOW_UID_VALIDITY           (1<<5)
345 #define LIST_SHOW_UNUSABLE_UIDS          (1<<6)
346 #define LIST_SHOW_UNUSABLE_SUBKEYS       (1<<7)
347 #define LIST_SHOW_KEYRING                (1<<8)
348 #define LIST_SHOW_SIG_EXPIRE             (1<<9)
349 #define LIST_SHOW_SIG_SUBPACKETS         (1<<10)
350 #define LIST_SHOW_USAGE                  (1<<11)
351
352 #define VERIFY_SHOW_PHOTOS               (1<<0)
353 #define VERIFY_SHOW_POLICY_URLS          (1<<1)
354 #define VERIFY_SHOW_STD_NOTATIONS        (1<<2)
355 #define VERIFY_SHOW_USER_NOTATIONS       (1<<3)
356 #define VERIFY_SHOW_NOTATIONS (VERIFY_SHOW_STD_NOTATIONS|VERIFY_SHOW_USER_NOTATIONS)
357 #define VERIFY_SHOW_KEYSERVER_URLS       (1<<4)
358 #define VERIFY_SHOW_UID_VALIDITY         (1<<5)
359 #define VERIFY_SHOW_UNUSABLE_UIDS        (1<<6)
360 #define VERIFY_PKA_LOOKUPS               (1<<7)
361 #define VERIFY_PKA_TRUST_INCREASE        (1<<8)
362 #define VERIFY_SHOW_PRIMARY_UID_ONLY     (1<<9)
363
364 #define KEYSERVER_HTTP_PROXY             (1<<0)
365 #define KEYSERVER_TIMEOUT                (1<<1)
366 #define KEYSERVER_ADD_FAKE_V3            (1<<2)
367 #define KEYSERVER_AUTO_KEY_RETRIEVE      (1<<3)
368 #define KEYSERVER_HONOR_KEYSERVER_URL    (1<<4)
369 #define KEYSERVER_HONOR_PKA_RECORD       (1<<5)
370
371
372 #endif /*G10_OPTIONS_H*/