1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-12-23 10:29:58 +01:00

* options.h, keyserver.c (keyserver_opts), g10.c (main): New keyserver

option "include-subkeys".  This feature already existed, but now can be
turned off.  It defaults to on.

* options.h, keyserver.c (parse_keyserver_options, keyserver_spawn): There
are now enough options to justify making a structure for the keyserver
options rather than a page of if-then-else-if-then-etc.

* getkey.c (merge_keys_and_selfsig, merge_selfsigs_main): Fix bug in
calculating key expiration dates.
This commit is contained in:
David Shaw 2002-06-10 21:32:07 +00:00
parent 3bff7c1d60
commit 6ae955f451
5 changed files with 93 additions and 63 deletions

View File

@ -1,3 +1,17 @@
2002-06-10 David Shaw <dshaw@jabberwocky.com>
* options.h, keyserver.c (keyserver_opts), g10.c (main): New
keyserver option "include-subkeys". This feature already existed,
but now can be turned off. It defaults to on.
* options.h, keyserver.c (parse_keyserver_options,
keyserver_spawn): There are now enough options to justify making a
structure for the keyserver options rather than a page of
if-then-else-if-then-etc.
* getkey.c (merge_keys_and_selfsig, merge_selfsigs_main): Fix bug
in calculating key expiration dates.
2002-06-09 David Shaw <dshaw@jabberwocky.com> 2002-06-09 David Shaw <dshaw@jabberwocky.com>
* keydb.h, getkey.c (get_user_id_native), import.c (import_one): * keydb.h, getkey.c (get_user_id_native), import.c (import_one):

View File

@ -907,6 +907,7 @@ main( int argc, char **argv )
opt.pgp2_workarounds = 1; opt.pgp2_workarounds = 1;
opt.force_v3_sigs = 1; opt.force_v3_sigs = 1;
opt.escape_from = 1; opt.escape_from = 1;
opt.keyserver_options.include_subkeys=1;
#if defined (__MINGW32__) || defined (__CYGWIN32__) #if defined (__MINGW32__) || defined (__CYGWIN32__)
opt.homedir = read_w32_registry_string( NULL, "Software\\GNU\\GnuPG", "HomeDir" ); opt.homedir = read_w32_registry_string( NULL, "Software\\GNU\\GnuPG", "HomeDir" );
#else #else

View File

@ -1084,10 +1084,12 @@ merge_keys_and_selfsig( KBNODE keyblock )
} }
} }
if(pk && (pk->expiredate==0 || pk->expiredate>pk->max_expiredate)) if(pk && (pk->expiredate==0 ||
(pk->max_expiredate && pk->expiredate>pk->max_expiredate)))
pk->expiredate=pk->max_expiredate; pk->expiredate=pk->max_expiredate;
if(sk && (sk->expiredate==0 || sk->expiredate>sk->max_expiredate)) if(sk && (sk->expiredate==0 ||
(sk->max_expiredate && sk->expiredate>sk->max_expiredate)))
sk->expiredate=sk->max_expiredate; sk->expiredate=sk->max_expiredate;
} }
} }
@ -1527,7 +1529,7 @@ merge_selfsigs_main( KBNODE keyblock, int *r_revoked )
/* Currently only v3 keys have a maximum expiration date, but I'll /* Currently only v3 keys have a maximum expiration date, but I'll
bet v5 keys get this feature again. */ bet v5 keys get this feature again. */
if(key_expire==0 || key_expire>pk->max_expiredate) if(key_expire==0 || (pk->max_expiredate && key_expire>pk->max_expiredate))
key_expire=pk->max_expiredate; key_expire=pk->max_expiredate;
pk->has_expired = key_expire >= curtime? 0 : key_expire; pk->has_expired = key_expire >= curtime? 0 : key_expire;

View File

@ -44,6 +44,24 @@
#define SEND 1 #define SEND 1
#define SEARCH 2 #define SEARCH 2
struct kopts
{
char *name;
int tell; /* tell remote process about this one */
int *flag;
} keyserver_opts[]=
{
{"include-revoked",1,&opt.keyserver_options.include_revoked},
{"include-disabled",1,&opt.keyserver_options.include_disabled},
{"include-subkeys",1,&opt.keyserver_options.include_subkeys},
{"keep-temp-files",0,&opt.keyserver_options.keep_temp_files},
{"honor-http-proxy",1,&opt.keyserver_options.honor_http_proxy},
{"broken-http-proxy",1,&opt.keyserver_options.broken_http_proxy},
{"refresh-add-fake-v3-keyids",0,&opt.keyserver_options.fake_v3_keyids},
{"auto-key-retrieve",0,&opt.keyserver_options.auto_key_retrieve},
{NULL}
};
void void
parse_keyserver_options(char *options) parse_keyserver_options(char *options)
{ {
@ -51,14 +69,33 @@ parse_keyserver_options(char *options)
do do
{ {
if(ascii_strcasecmp(tok,"include-revoked")==0) struct kopts *kopts=keyserver_opts;
opt.keyserver_options.include_revoked=1; int i,hit=0;
else if(ascii_strcasecmp(tok,"no-include-revoked")==0)
opt.keyserver_options.include_revoked=0; for(i=0,kopts=keyserver_opts;kopts[i].name;i++)
else if(ascii_strcasecmp(tok,"include-disabled")==0) {
opt.keyserver_options.include_disabled=1; if(ascii_strcasecmp(tok,kopts[i].name)==0)
else if(ascii_strcasecmp(tok,"no-include-disabled")==0) {
opt.keyserver_options.include_disabled=0; *(kopts[i].flag)=1;
hit=1;
break;
}
else if(ascii_memcasecmp("no-",tok,3)==0 && strlen(tok)>3 &&
ascii_strcasecmp(&tok[3],kopts[i].name)==0)
{
*(kopts[i].flag)=0;
hit=1;
break;
}
}
/* These options need more than just a flag */
if(!hit)
{
if(ascii_strcasecmp(tok,"verbose")==0)
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)
@ -70,32 +107,9 @@ parse_keyserver_options(char *options)
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.use_temp_files=0;
#endif #endif
else if(ascii_strcasecmp(tok,"keep-temp-files")==0)
opt.keyserver_options.keep_temp_files=1;
else if(ascii_strcasecmp(tok,"no-keep-temp-files")==0)
opt.keyserver_options.keep_temp_files=0;
else if(ascii_strcasecmp(tok,"verbose")==0)
opt.keyserver_options.verbose++;
else if(ascii_strcasecmp(tok,"no-verbose")==0)
opt.keyserver_options.verbose--;
else if(ascii_strcasecmp(tok,"honor-http-proxy")==0)
opt.keyserver_options.honor_http_proxy=1;
else if(ascii_strcasecmp(tok,"no-honor-http-proxy")==0)
opt.keyserver_options.honor_http_proxy=0;
else if(ascii_strcasecmp(tok,"refresh-add-fake-v3-keyids")==0)
opt.keyserver_options.refresh_add_fake_v3_keyids=1;
else if(ascii_strcasecmp(tok,"no-refresh-add-fake-v3-keyids")==0)
opt.keyserver_options.refresh_add_fake_v3_keyids=0;
else if(ascii_strcasecmp(tok,"auto-key-retrieve")==0)
opt.keyserver_options.auto_key_retrieve=1;
else if(ascii_strcasecmp(tok,"no-auto-key-retrieve")==0)
opt.keyserver_options.auto_key_retrieve=0;
else if(ascii_strcasecmp(tok,"broken-http-proxy")==0)
opt.keyserver_options.broken_http_proxy=1;
else if(ascii_strcasecmp(tok,"no-broken-http-proxy")==0)
opt.keyserver_options.broken_http_proxy=0;
else if(strlen(tok)>0) else if(strlen(tok)>0)
add_to_strlist(&opt.keyserver_options.other,tok); add_to_strlist(&opt.keyserver_options.other,tok);
}
tok=strsep(&options," ,"); tok=strsep(&options," ,");
} }
@ -290,6 +304,7 @@ keyserver_spawn(int action,STRLIST list,
unsigned int maxlen=256,buflen; unsigned int maxlen=256,buflen;
char *command=NULL,*searchstr=NULL; char *command=NULL,*searchstr=NULL;
byte *line=NULL; byte *line=NULL;
struct kopts *kopts;
struct exec_info *spawn; struct exec_info *spawn;
#ifdef EXEC_TEMPFILE_ONLY #ifdef EXEC_TEMPFILE_ONLY
@ -335,11 +350,9 @@ keyserver_spawn(int action,STRLIST list,
/* Write options */ /* Write options */
fprintf(spawn->tochild,"OPTION %sinclude-revoked\n", for(i=0,kopts=keyserver_opts;kopts[i].name;i++)
opt.keyserver_options.include_revoked?"":"no-"); if(*(kopts[i].flag) && kopts[i].tell)
fprintf(spawn->tochild,"OPTION %s\n",kopts[i].name);
fprintf(spawn->tochild,"OPTION %sinclude-disabled\n",
opt.keyserver_options.include_disabled?"":"no-");
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");
@ -874,8 +887,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.refresh_add_fake_v3_keyids && if(opt.keyserver_options.fake_v3_keyids && opt.keyserver_scheme &&
opt.keyserver_scheme &&
(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

@ -117,14 +117,15 @@ struct {
struct struct
{ {
int verbose; int verbose;
int include_revoked:1; int include_revoked;
int include_disabled:1; int include_disabled;
int use_temp_files:1; int include_subkeys;
int keep_temp_files:1; int honor_http_proxy;
int refresh_add_fake_v3_keyids:1; int broken_http_proxy;
int auto_key_retrieve:1; int use_temp_files;
int honor_http_proxy:1; int keep_temp_files;
int broken_http_proxy:1; int fake_v3_keyids;
int auto_key_retrieve;
STRLIST other; STRLIST other;
} keyserver_options; } keyserver_options;
int exec_disable; int exec_disable;