51
51
#include "call-agent.h"
54
enum cmd_and_opt_values { aNull = 0,
54
enum cmd_and_opt_values {
66
68
static ARGPARSE_OPTS opts[] = {
68
{ 301, NULL, 0, N_("@\nOptions:\n ") },
70
{ oVerbose, "verbose", 0, N_("verbose") },
71
{ oQuiet, "quiet", 0, N_("be somewhat more quiet") },
72
{ oKeyring, "keyring" ,2, N_("take the keys from this keyring")},
73
{ oIgnoreTimeConflict, "ignore-time-conflict", 0,
74
N_("make timestamp conflicts only a warning") },
75
{ oStatusFD, "status-fd" ,1, N_("|FD|write status info to this FD") },
76
{ oLoggerFD, "logger-fd",1, "@" },
77
{ oHomedir, "homedir", 2, "@" }, /* defaults to "~/.gnupg" */
69
ARGPARSE_group (300, N_("@\nOptions:\n ")),
71
ARGPARSE_s_n (oVerbose, "verbose", N_("verbose")),
72
ARGPARSE_s_n (oQuiet, "quiet", N_("be somewhat more quiet")),
73
ARGPARSE_s_s (oKeyring, "keyring",
74
N_("|FILE|take the keys from the keyring FILE")),
75
ARGPARSE_s_n (oIgnoreTimeConflict, "ignore-time-conflict",
76
N_("make timestamp conflicts only a warning")),
77
ARGPARSE_s_i (oStatusFD, "status-fd",
78
N_("|FD|write status info to this FD")),
79
ARGPARSE_s_i (oLoggerFD, "logger-fd", "@"),
80
ARGPARSE_s_s (oHomedir, "homedir", "@"),
83
87
int g10_errors_seen = 0;
91
make_libversion (const char *libname, const char *(*getfnc)(const char*))
97
result = xmalloc (strlen (libname) + 1 + strlen (s) + 1);
98
strcpy (stpcpy (stpcpy (result, libname), " "), s);
85
102
static const char *
86
103
my_strusage( int level )
90
case 11: p = "gpgv (GnuPG)";
92
case 13: p = VERSION; break;
93
case 17: p = PRINTABLE_OS_NAME; break;
95
_("Please report bugs to <gnupg-bugs@gnu.org>.\n");
99
_("Usage: gpgv [options] [files] (-h for help)");
102
_("Syntax: gpg [options] [files]\n"
103
"Check signatures against known trusted keys\n");
105
static char *ver_gcry;
110
case 11: p = "gpgv (GnuPG)";
112
case 13: p = VERSION; break;
113
case 17: p = PRINTABLE_OS_NAME; break;
114
case 19: p = _("Please report bugs to <gnupg-bugs@gnu.org>.\n");
117
case 40: p = _("Usage: gpgv [options] [files] (-h for help)");
119
case 41: p = _("Syntax: gpg [options] [files]\n"
120
"Check signatures against known trusted keys\n");
125
ver_gcry = make_libversion ("libgcrypt", gcry_check_version);
114
138
main( int argc, char **argv )
119
strlist_t nrings=NULL;
120
unsigned configlineno;
122
set_strusage (my_strusage);
123
log_set_prefix ("gpgv", 1);
125
/* Make sure that our subsystems are ready. */
126
init_common_subsystems ();
128
gnupg_init_signals (0, NULL);
131
opt.command_fd = -1; /* no command fd */
132
opt.pgp2_workarounds = 1;
133
opt.keyserver_options.options|=KEYSERVER_AUTO_KEY_RETRIEVE;
134
opt.trust_model = TM_ALWAYS;
137
opt.homedir = default_homedir ();
145
pargs.flags= 1; /* do not remove the args */
146
while( optfile_parse( NULL, NULL, &configlineno, &pargs, opts) ) {
147
switch( pargs.r_opt ) {
148
case oQuiet: opt.quiet = 1; break;
152
gcry_control (GCRYCTL_SET_VERBOSITY, (int)opt.verbose);
154
case oKeyring: append_to_strlist( &nrings, pargs.r.ret_str); break;
155
case oStatusFD: set_status_fd( pargs.r.ret_int ); break;
157
log_set_fd (translate_sys2libc_fd_int (pargs.r.ret_int, 1));
159
case oHomedir: opt.homedir = pargs.r.ret_str; break;
160
case oIgnoreTimeConflict: opt.ignore_time_conflict = 1; break;
161
default : pargs.err = 2; break;
143
strlist_t nrings=NULL;
144
unsigned configlineno;
146
set_strusage (my_strusage);
147
log_set_prefix ("gpgv", 1);
149
/* Make sure that our subsystems are ready. */
151
init_common_subsystems ();
153
gnupg_init_signals (0, NULL);
155
opt.command_fd = -1; /* no command fd */
156
opt.pgp2_workarounds = 1;
157
opt.keyserver_options.options|=KEYSERVER_AUTO_KEY_RETRIEVE;
158
opt.trust_model = TM_ALWAYS;
161
opt.homedir = default_homedir ();
169
pargs.flags= 1; /* do not remove the args */
170
while (optfile_parse( NULL, NULL, &configlineno, &pargs, opts))
174
case oQuiet: opt.quiet = 1; break;
178
gcry_control (GCRYCTL_SET_VERBOSITY, (int)opt.verbose);
180
case oKeyring: append_to_strlist( &nrings, pargs.r.ret_str); break;
181
case oStatusFD: set_status_fd( pargs.r.ret_int ); break;
183
log_set_fd (translate_sys2libc_fd_int (pargs.r.ret_int, 1));
185
case oHomedir: opt.homedir = pargs.r.ret_str; break;
186
case oIgnoreTimeConflict: opt.ignore_time_conflict = 1; break;
187
default : pargs.err = ARGPARSE_PRINT_ERROR; break;
165
if( log_get_errorcount(0) )
168
if( opt.verbose > 1 )
169
set_packet_list_mode(1);
171
if( !nrings ) /* no keyring given: use default one */
172
keydb_add_resource ("trustedkeys" EXTSEP_S "gpg", 0, 0);
173
for(sl = nrings; sl; sl = sl->next )
174
keydb_add_resource (sl->d, 0, 0 );
176
FREE_STRLIST (nrings);
178
if( (rc = verify_signatures( argc, argv ) ))
179
log_error("verify signatures failed: %s\n", g10_errstr(rc) );
183
return 8; /*NEVER REACHED*/
191
if (log_get_errorcount (0))
195
set_packet_list_mode(1);
197
if (!nrings) /* no keyring given: use default one */
198
keydb_add_resource ("trustedkeys" EXTSEP_S "gpg", 0, 0);
199
for (sl = nrings; sl; sl = sl->next)
200
keydb_add_resource (sl->d, 0, 0 );
202
FREE_STRLIST (nrings);
204
if ( (rc = verify_signatures( argc, argv ) ))
205
log_error("verify signatures failed: %s\n", g10_errstr(rc) );
209
return 8; /*NOTREACHED*/
188
214
g10_exit( int rc )
190
rc = rc? rc : log_get_errorcount(0)? 2 :
191
g10_errors_seen? 1 : 0;
216
rc = rc? rc : log_get_errorcount(0)? 2 : g10_errors_seen? 1 : 0;
266
312
struct keyserver_spec *
267
keyserver_match(struct keyserver_spec *spec) { return NULL; }
270
keyserver_import_keyid( u32 *keyid, void *dummy )
276
keyserver_import_cert(const char *name) { return -1; }
279
keyserver_import_pka(const char *name,unsigned char *fpr) { return -1; }
282
keyserver_import_name(const char *name,struct keyserver_spec *spec)
288
keyserver_import_ldap(const char *name) { return -1; }
313
keyserver_match (struct keyserver_spec *spec)
320
keyserver_import_keyid (u32 *keyid, void *dummy)
328
keyserver_import_cert (const char *name)
335
keyserver_import_pka (const char *name,unsigned char *fpr)
343
keyserver_import_name (const char *name,struct keyserver_spec *spec)
351
keyserver_import_ldap (const char *name)
291
358
* No encryption here but mainproc links to these functions.
294
get_session_key( PKT_pubkey_enc *k, DEK *dek )
296
return G10ERR_GENERAL;
300
get_override_session_key( DEK *dek, const char *string )
302
return G10ERR_GENERAL;
306
decrypt_data( void *procctx, PKT_encrypted *ed, DEK *dek )
308
return G10ERR_GENERAL;
361
get_session_key (PKT_pubkey_enc *k, DEK *dek)
365
return G10ERR_GENERAL;
370
get_override_session_key (DEK *dek, const char *string)
374
return G10ERR_GENERAL;
379
decrypt_data (void *procctx, PKT_encrypted *ed, DEK *dek)
384
return G10ERR_GENERAL;
313
* No interactive commnds, so we don't need the helptexts
389
* No interactive commands, so we don't need the helptexts
316
display_online_help( const char *keyword )
392
display_online_help (const char *keyword)
321
398
* We don't use secret keys, but getkey.c links to this
324
check_secret_key( PKT_secret_key *sk, int n )
401
check_secret_key (PKT_secret_key *sk, int n)
326
return G10ERR_GENERAL;
405
return G10ERR_GENERAL;
330
409
* No secret key, so no passphrase needed
333
passphrase_to_dek( u32 *keyid, int pubkey_algo,
334
int cipher_algo, STRING2KEY *s2k, int mode,
412
passphrase_to_dek (u32 *keyid, int pubkey_algo,
413
int cipher_algo, STRING2KEY *s2k, int mode,
335
414
const char *tmp, int *canceled)
342
struct keyserver_spec *parse_preferred_keyserver(PKT_signature *sig) {return NULL;}
343
struct keyserver_spec *parse_keyserver_uri(const char *uri,int require_scheme,
344
const char *configname,
345
unsigned int configlineno)
350
void free_keyserver_spec(struct keyserver_spec *keyserver) {}
428
struct keyserver_spec *
429
parse_preferred_keyserver(PKT_signature *sig)
435
struct keyserver_spec *
436
parse_keyserver_uri (const char *uri, int require_scheme,
437
const char *configname, unsigned int configlineno)
440
(void)require_scheme;
447
free_keyserver_spec (struct keyserver_spec *keyserver)
352
452
/* Stubs to avoid linking to photoid.c */
353
void show_photos(const struct user_attribute *attrs,int count,PKT_public_key *pk) {}
354
int parse_image_header(const struct user_attribute *attr,byte *type,u32 *len) {return 0;}
355
char *image_type_to_string(byte type,int string) {return NULL;}
454
show_photos (const struct user_attribute *attrs, int count, PKT_public_key *pk)
462
parse_image_header (const struct user_attribute *attr, byte *type, u32 *len)
471
image_type_to_string (byte type, int string)
357
478
#ifdef ENABLE_CARD_SUPPORT
358
int agent_scd_getattr (const char *name, struct agent_card_info_s *info) {return 0;}
480
agent_scd_getattr (const char *name, struct agent_card_info_s *info)
359
486
#endif /* ENABLE_CARD_SUPPORT */
361
/* Stubs to void linking to ../cipher/cipher.c */
362
const char *cipher_algo_to_string( int algo ) { return "?";}
363
void disable_cipher_algo( int algo ) {}
364
int check_cipher_algo( int algo ) { return -1;}
365
unsigned int cipher_get_keylen( int algo ) { return 0; }
366
unsigned int cipher_get_blocksize( int algo ) {return 0;}
367
gcry_cipher_hd_t cipher_open( int algo, int mode, int secure ) { return NULL;}
368
void cipher_close( gcry_cipher_hd_t c ) {}
369
int cipher_setkey( gcry_cipher_hd_t c, byte *key, unsigned keylen ) { return -1;}
370
void cipher_setiv( gcry_cipher_hd_t c, const byte *iv, unsigned ivlen ){}
371
void cipher_encrypt( gcry_cipher_hd_t c, byte *outbuf,
372
byte *inbuf, unsigned nbytes ) {}
373
void cipher_decrypt( gcry_cipher_hd_t c, byte *outbuf,
374
byte *inbuf, unsigned nbytes ) {}
375
void cipher_sync( gcry_cipher_hd_t c ) {}
379
488
/* We do not do any locking, so use these stubs here */
380
void disable_dotlock(void) {}
381
DOTLOCK create_dotlock( const char *file_to_lock ) { return NULL; }
382
void destroy_dotlock (DOTLOCK h) {}
383
int make_dotlock( DOTLOCK h, long timeout ) { return 0;}
384
int release_dotlock( DOTLOCK h ) {return 0;}
385
void remove_lockfiles(void) {}
490
disable_dotlock (void)
495
create_dotlock (const char *file_to_lock)
502
destroy_dotlock (DOTLOCK h)
508
make_dotlock (DOTLOCK h, long timeout)
516
release_dotlock (DOTLOCK h)
523
remove_lockfiles (void)