]> diplodocus.org Git - nmh/commitdiff
Fix handling of fullname
authorKen Hornstein <kenh@pobox.com>
Mon, 15 Jul 2019 18:25:53 +0000 (14:25 -0400)
committerKen Hornstein <kenh@pobox.com>
Mon, 15 Jul 2019 18:30:08 +0000 (14:30 -0400)
Make it that if a Local-Mailbox profile entry was NOT specified
that the fullname would be generated BEFORE the local mailbox was
generated, so the user's name ended up in the email address properly.

sbr/mts.c

index b7e6571..a8c8b89 100644 (file)
--- a/sbr/mts.c
+++ b/sbr/mts.c
@@ -365,6 +365,28 @@ getuserinfo (void)
     }
     username[sizeof(username) - 1] = '\0';
 
+    /* fullname */
+    np = pw->pw_gecos;
+
+    /* Get the user's real name from the GECOS field.  Stop once we hit a ',',
+       which some OSes use to separate other 'finger' information in the GECOS
+       field, like phone number. */
+    for (cp = fullname; *np != '\0' && *np != ','; *cp++ = *np++)
+       continue;
+    *cp = '\0';
+
+    /* The $SIGNATURE environment variable overrides the GECOS field's idea of
+       your real name. If SIGNATURE isn't set, use the Signature profile
+       setting if it exists.
+       Note that post(8) uses context_foil(), so it won't see the profile
+       component. */
+    if ((cp = getenv ("SIGNATURE")) && *cp)
+       strncpy (fullname, cp, sizeof(fullname));
+    else if ((cp = context_find("Signature")))
+       strncpy (fullname, cp, sizeof(fullname));
+    fullname[sizeof(fullname) - 1] = '\0';
+    escape_display_name(fullname, sizeof(fullname));
+
     /* localmbox and mboxname */
     /* If there's a Local-Mailbox profile component, try to extract
        the username from it.  But don't try very hard, this assumes
@@ -395,28 +417,6 @@ getuserinfo (void)
     }
     mboxname[sizeof(mboxname) - 1] = '\0';
     escape_local_part(mboxname, sizeof(mboxname));
-
-    /* fullname */
-    np = pw->pw_gecos;
-
-    /* Get the user's real name from the GECOS field.  Stop once we hit a ',',
-       which some OSes use to separate other 'finger' information in the GECOS
-       field, like phone number. */
-    for (cp = fullname; *np != '\0' && *np != ','; *cp++ = *np++)
-       continue;
-    *cp = '\0';
-
-    /* The $SIGNATURE environment variable overrides the GECOS field's idea of
-       your real name. If SIGNATURE isn't set, use the Signature profile
-       setting if it exists.
-       Note that post(8) uses context_foil(), so it won't see the profile
-       component. */
-    if ((cp = getenv ("SIGNATURE")) && *cp)
-       strncpy (fullname, cp, sizeof(fullname));
-    else if ((cp = context_find("Signature")))
-       strncpy (fullname, cp, sizeof(fullname));
-    fullname[sizeof(fullname) - 1] = '\0';
-    escape_display_name(fullname, sizeof(fullname));
 }
 
 static const char*