diff options
author | David Shaw <[email protected]> | 2002-06-14 19:47:11 +0000 |
---|---|---|
committer | David Shaw <[email protected]> | 2002-06-14 19:47:11 +0000 |
commit | c5a82f99dc17687d9078e82a8960c8f4b85e6fe0 (patch) | |
tree | 86778ae0dea1a930eacf209b96716457b3080801 | |
parent | * util.h: Add pop_strlist() from strgutil.c. (diff) | |
download | gnupg-c5a82f99dc17687d9078e82a8960c8f4b85e6fe0.tar.gz gnupg-c5a82f99dc17687d9078e82a8960c8f4b85e6fe0.zip |
* pkclist.c (expand_id, expand_group, build_pk_list): Groups now work
properly when used in the "Enter the user ID" prompt.
-rw-r--r-- | g10/ChangeLog | 5 | ||||
-rw-r--r-- | g10/pkclist.c | 66 |
2 files changed, 44 insertions, 27 deletions
diff --git a/g10/ChangeLog b/g10/ChangeLog index 70d3392dc..6af94beb7 100644 --- a/g10/ChangeLog +++ b/g10/ChangeLog @@ -1,5 +1,10 @@ 2002-06-14 David Shaw <[email protected]> + * pkclist.c (expand_id, expand_group, build_pk_list): Groups now + work properly when used in the "Enter the user ID" prompt. + +2002-06-14 David Shaw <[email protected]> + * keyedit.c (show_key_with_all_names): Display warning if a user tries to show prefs on a v3 key with a v3 selfsig. diff --git a/g10/pkclist.c b/g10/pkclist.c index c56dc3cda..83cca6684 100644 --- a/g10/pkclist.c +++ b/g10/pkclist.c @@ -690,43 +690,49 @@ default_recipient(void) return p; } -/* For simplicity, and to avoid potential loops, we only expand once - - you can't make an alias that points to an alias. */ -static STRLIST -expand_groups(STRLIST input) +static int +expand_id(const char *id,STRLIST *into) { - STRLIST sl,output=NULL,rover; struct groupitem *groups; + int count=0; - for(rover=input;rover;rover=rover->next) + for(groups=opt.grouplist;groups;groups=groups->next) { - for(groups=opt.grouplist;groups;groups=groups->next) + /* need strcasecmp() here, as this should be localized */ + if(strcasecmp(groups->name,id)==0) { - /* need strcasecmp() here, as this should be localized */ - if(strcasecmp(groups->name,rover->d)==0) - { - STRLIST each; - - /* maintain current utf8-ness */ - for(each=groups->values;each;each=each->next) - { - sl=add_to_strlist(&output,each->d); - /* maintain the flags from the original */ - sl->flags=each->flags; - } + STRLIST each,sl; - break; + /* this maintains the current utf8-ness */ + for(each=groups->values;each;each=each->next) + { + sl=add_to_strlist(into,each->d); + sl->flags=each->flags; + count++; } - } - /* Didn't find any groups, so use the existing string */ - if(!groups) - { - sl=add_to_strlist(&output,rover->d); - sl->flags=rover->flags; + break; } } + return count; +} + +/* For simplicity, and to avoid potential loops, we only expand once - + you can't make an alias that points to an alias. */ +static STRLIST +expand_group(STRLIST input) +{ + STRLIST sl,output=NULL,rover; + + for(rover=input;rover;rover=rover->next) + if(expand_id(rover->d,&output)==0) + { + /* Didn't find any groups, so use the existing string */ + sl=add_to_strlist(&output,rover->d); + sl->flags=rover->flags; + } + return output; } @@ -741,7 +747,7 @@ build_pk_list( STRLIST rcpts, PK_LIST *ret_pk_list, unsigned use ) char *def_rec = NULL; if(opt.grouplist) - remusr=expand_groups(rcpts); + remusr=expand_group(rcpts); else remusr=rcpts; @@ -788,6 +794,7 @@ build_pk_list( STRLIST rcpts, PK_LIST *ret_pk_list, unsigned use ) if( !any_recipients && !opt.batch ) { /* ask */ int have_def_rec; char *answer=NULL; + STRLIST backlog=NULL; def_rec = default_recipient(); have_def_rec = !!def_rec; @@ -801,6 +808,9 @@ build_pk_list( STRLIST rcpts, PK_LIST *ret_pk_list, unsigned use ) answer = def_rec; def_rec = NULL; } + else if(backlog) { + answer=pop_strlist(&backlog); + } else { answer = cpr_get_utf8("pklist.user_id.enter", _("\nEnter the user ID. End with an empty line: ")); @@ -811,6 +821,8 @@ build_pk_list( STRLIST rcpts, PK_LIST *ret_pk_list, unsigned use ) m_free(answer); break; } + if(expand_id(answer,&backlog)) + continue; if( pk ) free_public_key( pk ); pk = m_alloc_clear( sizeof *pk ); |