diff options
author | Werner Koch <[email protected]> | 2009-09-03 20:51:55 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2009-09-03 20:51:55 +0000 |
commit | 35ab964c86ffff0125a6ec7c766d021cc9e7db84 (patch) | |
tree | 24f5c3d120069bda22579f16d301d4705060d59c /g10 | |
parent | Updated the german translation (diff) | |
download | gnupg-35ab964c86ffff0125a6ec7c766d021cc9e7db84.tar.gz gnupg-35ab964c86ffff0125a6ec7c766d021cc9e7db84.zip |
Fix bug#1122.
Note that msgmerge 0.17 is completely broken as it always
prepends a fuzzy null entry to all po files.
Diffstat (limited to 'g10')
-rw-r--r-- | g10/ChangeLog | 9 | ||||
-rw-r--r-- | g10/Makefile.am | 2 | ||||
-rw-r--r-- | g10/keyedit.c | 2 | ||||
-rw-r--r-- | g10/keygen.c | 72 | ||||
-rw-r--r-- | g10/packet.h | 2 | ||||
-rw-r--r-- | g10/photoid.c | 3 |
6 files changed, 65 insertions, 25 deletions
diff --git a/g10/ChangeLog b/g10/ChangeLog index 9d77b7d6e..0b151f554 100644 --- a/g10/ChangeLog +++ b/g10/ChangeLog @@ -1,5 +1,14 @@ 2009-09-03 Werner Koch <[email protected]> + * keyedit.c (menu_adduid): Pass keyblock to generate_user_id. + * keygen.c (generate_user_id): Add arg KEYBLOCK. Factor code out + to ... + (uid_from_string): ... new. + (ask_user_id): Add arg KEYBLOCK and check for duplicates. Fix + bug#1122. + + * Makefile.am (uninstall-local): New. + * compress-bz2.c (do_uncompress): Detect unexpected EOF. Fix bug#1011. diff --git a/g10/Makefile.am b/g10/Makefile.am index 9c829fa24..3c85bbe6f 100644 --- a/g10/Makefile.am +++ b/g10/Makefile.am @@ -137,3 +137,5 @@ install-data-local: $(INSTALL_DATA) $(srcdir)/options.skel \ $(DESTDIR)$(pkgdatadir)/gpg-conf.skel +uninstall-local: + -@rm $(DESTDIR)$(pkgdatadir)/gpg-conf.skel diff --git a/g10/keyedit.c b/g10/keyedit.c index 3454189f2..3e6b966b9 100644 --- a/g10/keyedit.c +++ b/g10/keyedit.c @@ -3073,7 +3073,7 @@ menu_adduid( KBNODE pub_keyblock, KBNODE sec_keyblock, uid = generate_photo_id(pk,photo_name); } else - uid = generate_user_id(); + uid = generate_user_id (pub_keyblock); if( !uid ) return 0; diff --git a/g10/keygen.c b/g10/keygen.c index 38d78073f..3abc19bd0 100644 --- a/g10/keygen.c +++ b/g10/keygen.c @@ -2017,8 +2017,28 @@ ask_expiredate() } + +static PKT_user_id * +uid_from_string (const char *string) +{ + size_t n; + PKT_user_id *uid; + + n = strlen (string); + uid = xmalloc_clear (sizeof *uid + n); + uid->len = n; + strcpy (uid->name, string); + uid->ref = 1; + return uid; +} + + +/* Ask for a user ID. With a MODE of 1 an extra help prompt is + printed for use during a new key creation. If KEYBLOCK is not NULL + the function prevents the creation of an already existing user + ID. */ static char * -ask_user_id( int mode ) +ask_user_id (int mode, KBNODE keyblock) { char *answer; char *aname, *acomment, *amail, *uid; @@ -2134,14 +2154,29 @@ ask_user_id( int mode ) } tty_printf(_("You selected this USER-ID:\n \"%s\"\n\n"), uid); - /* fixme: add a warning if this user-id already exists */ + if( !*amail && !opt.allow_freeform_uid && (strchr( aname, '@' ) || strchr( acomment, '@'))) { fail = 1; - tty_printf(_("Please don't put the email address " - "into the real name or the comment\n") ); + tty_printf(_("Please don't put the email address " + "into the real name or the comment\n") ); } + if (!fail && keyblock) + { + PKT_user_id *uidpkt = uid_from_string (uid); + KBNODE node; + + for (node=keyblock; node && !fail; node=node->next) + if (!is_deleted_kbnode (node) + && node->pkt->pkttype == PKT_USER_ID + && !cmp_user_ids (uidpkt, node->pkt->pkt.user_id)) + fail = 1; + if (fail) + tty_printf (_("Such a user ID already exists on this key!\n")); + free_user_id (uidpkt); + } + for(;;) { /* TRANSLATORS: These are the allowed answers in lower and uppercase. Below you will find the matching @@ -2296,25 +2331,18 @@ do_create (int algo, unsigned int nbits, KBNODE pub_root, KBNODE sec_root, } -/**************** - * Generate a new user id packet, or return NULL if canceled - */ +/* Generate a new user id packet or return NULL if canceled. If + KEYBLOCK is not NULL the function prevents the creation of an + already existing user ID. */ PKT_user_id * -generate_user_id() +generate_user_id (KBNODE keyblock) { - PKT_user_id *uid; - char *p; - size_t n; - - p = ask_user_id( 1 ); - if( !p ) - return NULL; - n = strlen(p); - uid = xmalloc_clear( sizeof *uid + n ); - uid->len = n; - strcpy(uid->name, p); - uid->ref = 1; - return uid; + char *p; + + p = ask_user_id (1, keyblock); + if (!p) + return NULL; /* Canceled. */ + return uid_from_string (p); } @@ -3143,7 +3171,7 @@ generate_keypair (const char *fname, const char *card_serialno, r->next = para; para = r; - uid = ask_user_id(0); + uid = ask_user_id (0, NULL); if( !uid ) { log_error(_("Key generation canceled.\n")); diff --git a/g10/packet.h b/g10/packet.h index 9651ba4b0..cb2f0c9f1 100644 --- a/g10/packet.h +++ b/g10/packet.h @@ -509,6 +509,6 @@ int update_keysig_packet( PKT_signature **ret_sig, void *opaque ); /*-- keygen.c --*/ -PKT_user_id *generate_user_id(void); +PKT_user_id *generate_user_id (KBNODE keyblock); #endif /*G10_PACKET_H*/ diff --git a/g10/photoid.c b/g10/photoid.c index 80a60635d..8aa4ad491 100644 --- a/g10/photoid.c +++ b/g10/photoid.c @@ -42,7 +42,8 @@ #include "ttyio.h" #include "trustdb.h" -/* Generate a new photo id packet, or return NULL if canceled */ +/* Generate a new photo id packet, or return NULL if canceled. + FIXME: Should we add a duplicates check similar to generate_user_id? */ PKT_user_id * generate_photo_id(PKT_public_key *pk,const char *photo_name) { |