Support getting the "fullname" out of the Signature profile setting.
[mmh] / sbr / mts.c
index 451a9b2..868e603 100644 (file)
--- a/sbr/mts.c
+++ b/sbr/mts.c
@@ -267,7 +267,7 @@ LocalName (int flag)
     if (*localname && flag == 0) {
        strncpy (buf, localname, sizeof(buffer0));
     } else {
-       memset(buffer, 0, sizeof(buffer0));
+       memset(buf, 0, sizeof(buffer0));
        /* first get our local name */
        gethostname (buf, sizeof(buffer0) - 1);
        /* now fully qualify our name */
@@ -412,9 +412,12 @@ getuserinfo (void)
        strncpy (username, pw->pw_name, sizeof(username));
 
     /* The $SIGNATURE environment variable overrides the GECOS field's idea of
-       your real name. */
+       your real name. If SIGNATURE isn't set, use the Signature profile
+       setting if it exists. */
     if ((cp = getenv ("SIGNATURE")) && *cp)
        strncpy (fullname, cp, sizeof(fullname));
+    else if ((cp = context_find("Signature")))
+       strncpy (fullname, cp, sizeof(fullname));
 
     if (strchr(fullname, '.')) {               /*  quote any .'s */
        char tmp[BUFSIZ];
@@ -424,13 +427,15 @@ getuserinfo (void)
        strncpy (fullname, tmp, sizeof(fullname));
     }
 
+    fullname[sizeof(fullname) - 1] = '\0';
+
     return;
 }
 
 static const char*
 get_mtsconf_pathname (void)
 {
-    const char *cp = getenv ( "MHMTSCONF ");
+    const char *cp = getenv ( "MHMTSCONF" );
     if (cp != NULL && *cp != '\0') {
         return cp;
     }