-Mon Mar 13 18:26:03 2000 Dan Harkless <dan-nmh@dilvish.speed.net>
+Mon Mar 13 21:10:16 2000 Dan Harkless <dan-nmh@dilvish.speed.net>
* Applied Sullivan N. Beck <sbeck@cise.ufl.edu>'s mhshow-suffix patch:
believe older versions of lynx lack that option) and added
"mhshow-suffix-text/html: .html".
+ * Modified username_extension masquerading to only use the
+ extended address on generated [Resent-]From: lines and SMTP
+ envelope From:. With Neil's original implementation, nmh's global
+ idea of the username was changed, which would result in inc lying
+ and saying you had no new mail because it was looking for a
+ mailbox called, for instance, "dan-nmh" (where username was "dan"
+ and $USERNAME_EXTENSION was "-nmh").
+
Mon Mar 06 12:20:20 2000 Dan Harkless <dan-nmh@dilvish.speed.net>
* Applied Neil W Rickert <rickert+nmh@cs.niu.edu>'s msh.c patch:
\fB$USERNAME_EXTENSION\fR to "+\fIstring\fR". These MTA features are useful
because they allow one to use different email addresses in different situations
(to aid in automatic mail filtering or in determining where spammers got one's
-address) while only actually having a single account.
+address) while only actually having a single account. Note that
+\fB$USERNAME_EXTENSION\fR is only appended to the username when \fIpost\fR is
+generating "[Resent\-]From:" lines and the SMTP envelope "From:". \fIinc\fR,
+for instance, will not try to read from a maildrop file called "dan\-www" (to
+recall the earlier example).
"draft_from" controls the most powerful type of address masquerading. Normally,
when a user explicitly specifies a "From:" header in a draft, \fInmh\fR uses it
static char err[BUFSIZ];
static char adr[BUFSIZ];
+
+extern boolean username_extension_masquerading; /* defined in mts.c */
+
+
/*
* external prototypes
*/
*/
char *
-adrsprintf (char *local, char *domain)
+adrsprintf (char *username, char *domain)
{
- static char addr[BUFSIZ];
+ int snprintf_return;
+ static char addr[BUFSIZ];
+
+ if (username == NULL)
+ username = getusername();
+
+ if (username_extension_masquerading) {
+ /* mts.conf contains "masquerade:[...]username_extension[...]", so tack
+ on the value of the $USERNAME_EXTENSION environment variable, if set,
+ to username. */
+ char* extension = getenv("USERNAME_EXTENSION");
+ static char username_with_extension[BUFSIZ];
+
+ if (extension != NULL && *extension != '\0') {
+ snprintf_return = snprintf(username_with_extension,
+ sizeof(username_with_extension),
+ "%s%s", username, extension);
+
+ if (snprintf_return < 0 ||
+ snprintf_return >= sizeof(username_with_extension))
+ adios(NULL, "snprintf() error writing username (%d chars) and"
+ " $USERNAME_EXTENSION (%d chars) to array of BUFSIZ (%d)"
+ " chars",
+ strlen(username), strlen(extension), BUFSIZ);
+
+ username = username_with_extension;
+ }
+ }
- if (local == NULL)
#ifdef REALLYDUMB
- return getusername ();
- else
-#endif /* REALLYDUMB */
- local = getusername ();
+ return username;
+#endif
if (domain == NULL)
-#ifdef REALLYDUMB
- return local;
- else
-#endif /* REALLYDUMB */
- domain = LocalName ();
+ domain = LocalName();
#ifndef BANG
- snprintf (addr, sizeof(addr), "%s@%s", local, domain);
+ snprintf_return = snprintf (addr, sizeof(addr), "%s@%s", username, domain);
#else /* BANG */
- snprintf (addr, sizeof(addr), "%s!%s", domain, local);
+ snprintf_return = snprintf (addr, sizeof(addr), "%s!%s", domain, username);
#endif /* BANG */
+ if (snprintf_return < 0 || snprintf_return >= sizeof(addr))
+ adios(NULL, "snprintf() error writing username (%d chars), domain (%d"
+ " chars), and 1 separator char to array of BUFSIZ (%d) chars",
+ strlen(username), strlen(domain), BUFSIZ);
+
return addr;
}
/* Variables for username masquerading: */
boolean draft_from_masquerading = FALSE; /* also used from post.c */
static boolean mmailid_masquerading = FALSE;
-static boolean username_extension_masquerading = FALSE;
+ boolean username_extension_masquerading = FALSE; /* " from addrsbr.c */
static char* masquerade = "";
if (!mmailid_masquerading || *np == '\0')
strncpy (username, pw->pw_name, sizeof(username));
- if (username_extension_masquerading) {
- char* username_extension = getenv("USERNAME_EXTENSION");
-
- if (username_extension != NULL && *username_extension != '\0')
- /* $USERNAME_EXTENSION environment variable has been set, so tack on
- its value to the actual username. This is meant to interact with
- qmail's "user-extension" feature and sendmail's "plussed user"
- feature. */
- snprintf(username, sizeof(username), "%s%s",
- username, username_extension);
- }
-
/* The $SIGNATURE environment variable overrides the GECOS field's idea of
your real name. */
if ((cp = getenv ("SIGNATURE")) && *cp)