1
0
mirror of git://git.gnupg.org/gnupg.git synced 2025-03-21 21:39:58 +01:00

* options.h, keyserver.c (parse_keyserver_options): Remove duplicate code

from parse_keyserver_options by calling the generic parse_options.

* keyserver.c (keyserver_spawn, keyserver_refresh), g10.c (main), gpgv.c
(main), mainproc.c (check_sig_and_print), import.c (revocation_present):
Change all callers.
This commit is contained in:
David Shaw 2004-04-15 18:16:17 +00:00
parent 8c4607568d
commit d20a79dd07
7 changed files with 90 additions and 95 deletions

View File

@ -1,3 +1,13 @@
2004-04-15 David Shaw <dshaw@jabberwocky.com>
* options.h, keyserver.c (parse_keyserver_options): Remove
duplicate code from parse_keyserver_options by calling the generic
parse_options.
* keyserver.c (keyserver_spawn, keyserver_refresh), g10.c (main),
gpgv.c (main), mainproc.c (check_sig_and_print), import.c
(revocation_present): Change all callers.
2004-04-14 David Shaw <dshaw@jabberwocky.com> 2004-04-14 David Shaw <dshaw@jabberwocky.com>
* packet.h, getkey.c (fixup_uidnode, merge_selfsigs_subkey): Keep * packet.h, getkey.c (fixup_uidnode, merge_selfsigs_subkey): Keep

View File

@ -1436,9 +1436,8 @@ main( int argc, char **argv )
opt.export_options=EXPORT_INCLUDE_ATTRIBUTES; opt.export_options=EXPORT_INCLUDE_ATTRIBUTES;
opt.keyserver_options.import_options=IMPORT_REPAIR_PKS_SUBKEY_BUG; opt.keyserver_options.import_options=IMPORT_REPAIR_PKS_SUBKEY_BUG;
opt.keyserver_options.export_options=EXPORT_INCLUDE_ATTRIBUTES; opt.keyserver_options.export_options=EXPORT_INCLUDE_ATTRIBUTES;
opt.keyserver_options.include_subkeys=1; opt.keyserver_options.options=
opt.keyserver_options.include_revoked=1; KEYSERVER_INCLUDE_SUBKEYS|KEYSERVER_INCLUDE_REVOKED|KEYSERVER_TRY_DNS_SRV;
opt.keyserver_options.try_dns_srv=1;
opt.verify_options= opt.verify_options=
VERIFY_SHOW_POLICY_URLS|VERIFY_SHOW_NOTATIONS|VERIFY_SHOW_KEYSERVER_URLS; VERIFY_SHOW_POLICY_URLS|VERIFY_SHOW_NOTATIONS|VERIFY_SHOW_KEYSERVER_URLS;
opt.trust_model=TM_AUTO; opt.trust_model=TM_AUTO;
@ -2212,8 +2211,11 @@ main( int argc, char **argv )
case oNoRandomSeedFile: use_random_seed = 0; break; case oNoRandomSeedFile: use_random_seed = 0; break;
case oAutoKeyRetrieve: case oAutoKeyRetrieve:
case oNoAutoKeyRetrieve: case oNoAutoKeyRetrieve:
opt.keyserver_options.auto_key_retrieve= if(pargs.r_opt==oAutoKeyRetrieve)
(pargs.r_opt==oAutoKeyRetrieve); opt.keyserver_options.options|=KEYSERVER_AUTO_KEY_RETRIEVE;
else
opt.keyserver_options.options&=~KEYSERVER_AUTO_KEY_RETRIEVE;
deprecated_warning(configname,configlineno, deprecated_warning(configname,configlineno,
pargs.r_opt==oAutoKeyRetrieve?"--auto-key-retrieve": pargs.r_opt==oAutoKeyRetrieve?"--auto-key-retrieve":
"--no-auto-key-retrieve","--keyserver-options ", "--no-auto-key-retrieve","--keyserver-options ",

View File

@ -141,7 +141,7 @@ main( int argc, char **argv )
i18n_init(); i18n_init();
opt.command_fd = -1; /* no command fd */ opt.command_fd = -1; /* no command fd */
opt.pgp2_workarounds = 1; opt.pgp2_workarounds = 1;
opt.keyserver_options.auto_key_retrieve = 1; opt.keyserver_options.options|=KEYSERVER_AUTO_KEY_RETRIEVE;
opt.trust_model = TM_ALWAYS; opt.trust_model = TM_ALWAYS;
opt.batch = 1; opt.batch = 1;

View File

@ -1692,7 +1692,8 @@ revocation_present(KBNODE keyblock)
/* No, so try and get it */ /* No, so try and get it */
if(opt.keyserver if(opt.keyserver
&& opt.keyserver_options.auto_key_retrieve) && (opt.keyserver_options.options
& KEYSERVER_AUTO_KEY_RETRIEVE))
{ {
log_info(_("WARNING: key %s may be revoked:" log_info(_("WARNING: key %s may be revoked:"
" fetching revocation key %s\n"), " fetching revocation key %s\n"),

View File

@ -52,22 +52,20 @@ struct keyrec
int lines; int lines;
}; };
struct kopts /* Tell remote processes about these options */
{ #define REMOTE_TELL (KEYSERVER_INCLUDE_REVOKED|KEYSERVER_INCLUDE_DISABLED|KEYSERVER_INCLUDE_SUBKEYS|KEYSERVER_TRY_DNS_SRV)
char *name;
int tell; /* tell remote process about this one */ static struct parse_options keyserver_opts[]=
int *flag; {
} keyserver_opts[]= {"include-revoked",KEYSERVER_INCLUDE_REVOKED,NULL},
{ {"include-disabled",KEYSERVER_INCLUDE_DISABLED,NULL},
{"include-revoked",1,&opt.keyserver_options.include_revoked}, {"include-subkeys",KEYSERVER_INCLUDE_SUBKEYS,NULL},
{"include-disabled",1,&opt.keyserver_options.include_disabled}, {"keep-temp-files",KEYSERVER_KEEP_TEMP_FILES,NULL},
{"include-subkeys",1,&opt.keyserver_options.include_subkeys}, {"refresh-add-fake-v3-keyids",KEYSERVER_ADD_FAKE_V3,NULL},
{"keep-temp-files",0,&opt.keyserver_options.keep_temp_files}, {"auto-key-retrieve",KEYSERVER_AUTO_KEY_RETRIEVE,NULL},
{"refresh-add-fake-v3-keyids",0,&opt.keyserver_options.fake_v3_keyids}, {"try-dns-srv",KEYSERVER_TRY_DNS_SRV,NULL},
{"auto-key-retrieve",0,&opt.keyserver_options.auto_key_retrieve}, {NULL,0,NULL}
{"try-dns-srv",1,&opt.keyserver_options.try_dns_srv}, };
{NULL}
};
static int keyserver_work(int action,STRLIST list, static int keyserver_work(int action,STRLIST list,
KEYDB_SEARCH_DESC *desc,int count); KEYDB_SEARCH_DESC *desc,int count);
@ -79,69 +77,53 @@ parse_keyserver_options(char *options)
while((tok=argsep(&options,&arg))) while((tok=argsep(&options,&arg)))
{ {
int i,hit=0;
if(tok[0]=='\0') if(tok[0]=='\0')
continue; continue;
for(i=0;keyserver_opts[i].name;i++) /* We accept quite a few possible options here - some options to
{ handle specially, the keyserver_options list, and import and
if(ascii_strcasecmp(tok,keyserver_opts[i].name)==0) export options that pertain to keyserver operations. */
{
*(keyserver_opts[i].flag)=1;
hit=1;
break;
}
else if(ascii_strncasecmp("no-",tok,3)==0 &&
ascii_strcasecmp(&tok[3],keyserver_opts[i].name)==0)
{
*(keyserver_opts[i].flag)=0;
hit=1;
break;
}
}
/* These options need more than just a flag */ if(ascii_strcasecmp(tok,"verbose")==0)
if(!hit) opt.keyserver_options.verbose++;
{ else if(ascii_strcasecmp(tok,"no-verbose")==0)
if(ascii_strcasecmp(tok,"verbose")==0) opt.keyserver_options.verbose--;
opt.keyserver_options.verbose++;
else if(ascii_strcasecmp(tok,"no-verbose")==0)
opt.keyserver_options.verbose--;
#ifdef EXEC_TEMPFILE_ONLY #ifdef EXEC_TEMPFILE_ONLY
else if(ascii_strcasecmp(tok,"use-temp-files")==0 || else if(ascii_strcasecmp(tok,"use-temp-files")==0 ||
ascii_strcasecmp(tok,"no-use-temp-files")==0) ascii_strcasecmp(tok,"no-use-temp-files")==0)
log_info(_("WARNING: keyserver option \"%s\" is not used " log_info(_("WARNING: keyserver option \"%s\" is not used "
"on this platform\n"),tok); "on this platform\n"),tok);
#else #else
else if(ascii_strcasecmp(tok,"use-temp-files")==0) else if(ascii_strcasecmp(tok,"use-temp-files")==0)
opt.keyserver_options.use_temp_files=1; opt.keyserver_options.options|=KEYSERVER_USE_TEMP_FILES;
else if(ascii_strcasecmp(tok,"no-use-temp-files")==0) else if(ascii_strcasecmp(tok,"no-use-temp-files")==0)
opt.keyserver_options.use_temp_files=0; opt.keyserver_options.options&=~KEYSERVER_USE_TEMP_FILES;
#endif #endif
else else if(!parse_options(tok,&opt.keyserver_options.options,
if(!parse_import_options(tok, keyserver_opts,0)
&opt.keyserver_options.import_options,0) && !parse_import_options(tok,
&& &opt.keyserver_options.import_options,0)
!parse_export_options(tok, && !parse_export_options(tok,
&opt.keyserver_options.export_options,0)) &opt.keyserver_options.export_options,0))
{ {
if(arg) /* All of the standard options have failed, so the option is
{ destined for a keyserver plugin. */
char *joined;
joined=m_alloc(strlen(tok)+1+strlen(arg)+1); if(arg)
/* Make a canonical name=value form with no {
spaces */ char *joined;
strcpy(joined,tok);
strcat(joined,"="); joined=m_alloc(strlen(tok)+1+strlen(arg)+1);
strcat(joined,arg); /* Make a canonical name=value form with no
add_to_strlist(&opt.keyserver_options.other,joined); spaces */
m_free(joined); strcpy(joined,tok);
} strcat(joined,"=");
else strcat(joined,arg);
add_to_strlist(&opt.keyserver_options.other,tok); add_to_strlist(&opt.keyserver_options.other,joined);
} m_free(joined);
}
else
add_to_strlist(&opt.keyserver_options.other,tok);
} }
} }
} }
@ -720,7 +702,7 @@ keyserver_spawn(int action,STRLIST list,
unsigned int maxlen,buflen; unsigned int maxlen,buflen;
char *command=NULL,*searchstr=NULL; char *command=NULL,*searchstr=NULL;
byte *line=NULL; byte *line=NULL;
struct kopts *kopts; struct parse_options *kopts;
struct exec_info *spawn; struct exec_info *spawn;
assert(opt.keyserver); assert(opt.keyserver);
@ -742,9 +724,9 @@ keyserver_spawn(int action,STRLIST list,
strcpy(command,"gpgkeys_"); strcpy(command,"gpgkeys_");
strcat(command,opt.keyserver->scheme); strcat(command,opt.keyserver->scheme);
if(opt.keyserver_options.use_temp_files) if(opt.keyserver_options.options&KEYSERVER_USE_TEMP_FILES)
{ {
if(opt.keyserver_options.keep_temp_files) if(opt.keyserver_options.options&KEYSERVER_KEEP_TEMP_FILES)
{ {
command=m_realloc(command,strlen(command)+ command=m_realloc(command,strlen(command)+
strlen(KEYSERVER_ARGS_KEEP)+1); strlen(KEYSERVER_ARGS_KEEP)+1);
@ -784,15 +766,13 @@ keyserver_spawn(int action,STRLIST list,
/* Write options */ /* Write options */
for(i=0,kopts=keyserver_opts;kopts[i].name;i++) for(i=0,kopts=keyserver_opts;kopts[i].name;i++)
if(*(kopts[i].flag) && kopts[i].tell) if(opt.keyserver_options.options & kopts[i].bit & REMOTE_TELL)
fprintf(spawn->tochild,"OPTION %s\n",kopts[i].name); fprintf(spawn->tochild,"OPTION %s\n",kopts[i].name);
for(i=0;i<opt.keyserver_options.verbose;i++) for(i=0;i<opt.keyserver_options.verbose;i++)
fprintf(spawn->tochild,"OPTION verbose\n"); fprintf(spawn->tochild,"OPTION verbose\n");
temp=opt.keyserver_options.other; for(temp=opt.keyserver_options.other;temp;temp=temp->next)
for(;temp;temp=temp->next)
fprintf(spawn->tochild,"OPTION %s\n",temp->d); fprintf(spawn->tochild,"OPTION %s\n",temp->d);
switch(action) switch(action)
@ -1423,7 +1403,7 @@ keyserver_refresh(STRLIST users)
/* If refresh_add_fake_v3_keyids is on and it's a HKP or MAILTO /* If refresh_add_fake_v3_keyids is on and it's a HKP or MAILTO
scheme, then enable fake v3 keyid generation. */ scheme, then enable fake v3 keyid generation. */
if(opt.keyserver_options.fake_v3_keyids && opt.keyserver if((opt.keyserver_options.options&KEYSERVER_ADD_FAKE_V3) && opt.keyserver
&& (ascii_strcasecmp(opt.keyserver->scheme,"hkp")==0 || && (ascii_strcasecmp(opt.keyserver->scheme,"hkp")==0 ||
ascii_strcasecmp(opt.keyserver->scheme,"mailto")==0)) ascii_strcasecmp(opt.keyserver->scheme,"mailto")==0))
fakev3=1; fakev3=1;

View File

@ -1346,7 +1346,7 @@ check_sig_and_print( CTX c, KBNODE node )
rc = do_check_sig(c, node, NULL, &is_expkey, &is_revkey ); rc = do_check_sig(c, node, NULL, &is_expkey, &is_revkey );
if( rc == G10ERR_NO_PUBKEY && opt.keyserver if( rc == G10ERR_NO_PUBKEY && opt.keyserver
&& opt.keyserver_options.auto_key_retrieve) && (opt.keyserver_options.options&KEYSERVER_AUTO_KEY_RETRIEVE))
{ {
if( keyserver_import_keyid ( sig->keyid )==0 ) if( keyserver_import_keyid ( sig->keyid )==0 )
rc = do_check_sig(c, node, NULL, &is_expkey, &is_revkey ); rc = do_check_sig(c, node, NULL, &is_expkey, &is_revkey );

View File

@ -136,14 +136,7 @@ struct
struct struct
{ {
int verbose; int verbose;
int include_revoked; unsigned int options;
int include_disabled;
int include_subkeys;
int use_temp_files;
int keep_temp_files;
int fake_v3_keyids;
int auto_key_retrieve;
int try_dns_srv;
unsigned int import_options; unsigned int import_options;
unsigned int export_options; unsigned int export_options;
STRLIST other; STRLIST other;
@ -266,4 +259,13 @@ struct
#define VERIFY_SHOW_VALIDITY (1<<4) #define VERIFY_SHOW_VALIDITY (1<<4)
#define VERIFY_SHOW_UNUSABLE_UIDS (1<<5) #define VERIFY_SHOW_UNUSABLE_UIDS (1<<5)
#define KEYSERVER_INCLUDE_REVOKED (1<<0)
#define KEYSERVER_INCLUDE_DISABLED (1<<1)
#define KEYSERVER_INCLUDE_SUBKEYS (1<<2)
#define KEYSERVER_USE_TEMP_FILES (1<<3)
#define KEYSERVER_KEEP_TEMP_FILES (1<<4)
#define KEYSERVER_ADD_FAKE_V3 (1<<5)
#define KEYSERVER_AUTO_KEY_RETRIEVE (1<<6)
#define KEYSERVER_TRY_DNS_SRV (1<<7)
#endif /*G10_OPTIONS_H*/ #endif /*G10_OPTIONS_H*/