[Pkg-gnupg-commit] [gnupg2] 137/159: gpg: Allow new user ids with only the mail address.

Daniel Kahn Gillmor dkg at fifthhorseman.net
Wed Jan 27 13:24:03 UTC 2016


This is an automated email from the git hooks/post-receive script.

dkg pushed a commit to branch master
in repository gnupg2.

commit fc0c71dfe5ea8f1c683101948c23f5d2064ee4cd
Author: Werner Koch <wk at gnupg.org>
Date:   Fri Jan 22 10:35:19 2016 +0100

    gpg: Allow new user ids with only the mail address.
    
    * g10/keygen.c (ask_user_id): Allow empty name.
    --
    
    The --quick-gen-key command allows this and further some mail
    providers require that a key has only the mail address to allow for
    anonymous accounts.
    
    Signed-off-by: Werner Koch <wk at gnupg.org>
---
 g10/keygen.c | 24 ++++++++++++++++++------
 1 file changed, 18 insertions(+), 6 deletions(-)

diff --git a/g10/keygen.c b/g10/keygen.c
index 94ea126..0f7a6a0 100644
--- a/g10/keygen.c
+++ b/g10/keygen.c
@@ -2533,8 +2533,11 @@ ask_user_id (int mode, int full, KBNODE keyblock)
                   }
 		else if( digitp(aname) )
 		    tty_printf(_("Name may not start with a digit\n"));
-		else if( strlen(aname) < 5 )
+		else if (*aname && strlen (aname) < 5)
+                  {
 		    tty_printf(_("Name must be at least 5 characters long\n"));
+                    /* However, we allow an empty name.  */
+                  }
 		else
 		    break;
 	    }
@@ -2577,11 +2580,20 @@ ask_user_id (int mode, int full, KBNODE keyblock)
 
 	xfree(uid);
 	uid = p = xmalloc(strlen(aname)+strlen(amail)+strlen(acomment)+12+10);
-	p = stpcpy(p, aname );
-	if( *acomment )
-	    p = stpcpy(stpcpy(stpcpy(p," ("), acomment),")");
-	if( *amail )
-	    p = stpcpy(stpcpy(stpcpy(p," <"), amail),">");
+        if (!*aname && *amail && !*acomment && !random_is_faked ())
+          { /* Empty name and comment but with mail address.  Use
+               simplified form with only the non-angle-bracketed mail
+               address.  */
+            p = stpcpy (p, amail);
+          }
+        else
+          {
+            p = stpcpy (p, aname );
+            if (*acomment)
+              p = stpcpy(stpcpy(stpcpy(p," ("), acomment),")");
+            if (*amail)
+              p = stpcpy(stpcpy(stpcpy(p," <"), amail),">");
+          }
 
 	/* Append a warning if the RNG is switched into fake mode.  */
         if ( random_is_faked ()  )

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-gnupg/gnupg2.git



More information about the Pkg-gnupg-commit mailing list