From: Dan Harkless Date: Tue, 14 Mar 2000 05:05:49 +0000 (+0000) Subject: Modified username_extension masquerading to only use the extended address on X-Git-Tag: nmh-1_0~64 X-Git-Url: http://git.marmaro.de/?a=commitdiff_plain;h=34ec62af8fc74c3c9d143328f485c82ef7aad327;p=mmh 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"). While in there (adrsprintf()), added checking of snprintf()'s return code and added calls to adios() when things are not kosher. Also simplfied the really confusing REALLYDUMB #ifdef'ing, which didn't even jibe with the comment explaining REALLYDUMB in acconfig.h. Now adrsprintf() will always return just the username, even if an explicit domain is passed in (which currently doesn't happen anywhere in nmh). --- diff --git a/ChangeLog b/ChangeLog index dc73246..ba38c6b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,4 @@ -Mon Mar 13 18:26:03 2000 Dan Harkless +Mon Mar 13 21:10:16 2000 Dan Harkless * Applied Sullivan N. Beck 's mhshow-suffix patch: @@ -15,6 +15,14 @@ Mon Mar 13 18:26:03 2000 Dan Harkless 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 * Applied Neil W Rickert 's msh.c patch: diff --git a/man/mh-tailor.man b/man/mh-tailor.man index 53c0875..611b66d 100644 --- a/man/mh-tailor.man +++ b/man/mh-tailor.man @@ -136,7 +136,11 @@ versions of sendmail for which "plussed user" processing is active can set \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 diff --git a/sbr/addrsbr.c b/sbr/addrsbr.c index d1fd730..4f734b4 100644 --- a/sbr/addrsbr.c +++ b/sbr/addrsbr.c @@ -70,6 +70,10 @@ static char *note = NULL; static char err[BUFSIZ]; static char adr[BUFSIZ]; + +extern boolean username_extension_masquerading; /* defined in mts.c */ + + /* * external prototypes */ @@ -310,30 +314,55 @@ auxformat (struct mailname *mp, int extras) */ 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; } diff --git a/zotnet/mts/mts.c b/zotnet/mts/mts.c index 9194404..3b0b180 100644 --- a/zotnet/mts/mts.c +++ b/zotnet/mts/mts.c @@ -63,7 +63,7 @@ static char fullname[BUFSIZ]; /* 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 = ""; @@ -496,18 +496,6 @@ getuserinfo (void) 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)