X-Git-Url: http://git.marmaro.de/?p=mmh;a=blobdiff_plain;f=zotnet%2Fmts%2Fmts.c;h=26e480779f286b1102734921dbad35325d6a695d;hp=31d96bdd92a8d43985c5e78bd5a139d3856042ba;hb=84b98d0484fe61d4ebe205016e35a06da194f525;hpb=1691e80890e5d8ba258c51c214a3e91880e1db2b diff --git a/zotnet/mts/mts.c b/zotnet/mts/mts.c index 31d96bd..26e4807 100644 --- a/zotnet/mts/mts.c +++ b/zotnet/mts/mts.c @@ -5,6 +5,7 @@ * $Id$ */ +#include "h/mh.h" /* for snprintf() */ #include #define nmhetcdir(file) NMHETCDIR#file @@ -60,7 +61,7 @@ static char username[BUFSIZ]; static char fullname[BUFSIZ]; /* variables for username masquerading */ -static int MMailids = 0; +int MMailids = 0; /* used from post.c as well as here */ static char *mmailid = "0"; @@ -285,9 +286,9 @@ LocalName (void) /* first get our local name */ gethostname (buffer, sizeof(buffer)); #endif -#ifndef BIND +#ifdef HAVE_SETHOSTENT sethostent (1); -#endif +#endif /* now fully qualify our name */ if ((hp = gethostbyname (buffer))) strncpy (buffer, hp->h_name, sizeof(buffer)); @@ -374,7 +375,8 @@ getfullname (void) /* * Find the user's username and full name, and cache them. - * It also handles mmailid processing (username masquerading) + * Also, handle "mmailid" username masquerading controlled from the GECOS field + * of the passwd file. */ static void @@ -409,12 +411,20 @@ getuserinfo (void) /* * Do mmailid (username masquerading) processing. The GECOS - * field should have the form "Full Name ". + * field should have the form "Full Name ". For instance, + * "Dan Harkless ". Naturally, you'll want your MTA to have + * an alias (e.g. in /etc/aliases) from "fakeusername" to your account name. */ -#ifndef GCOS_HACK +#ifndef BSD42 for (cp = fullname; *np && *np != (MMailids ? '<' : ','); *cp++ = *np++) continue; -#else +#else /* BSD42 */ + /* On BSD(-derived) systems, the system utilities that deal with the GECOS + field (finger, mail, sendmail, etc.) translate any '&' character in it to + the login name, with the first letter capitalized. So, for instance, + fingering a user "bob" with the GECOS field "& Jones" would reveal him to + be "In real life: Bob Jones". Surprisingly, though, the OS doesn't do + the translation for you, so we have to do it manually here. */ for (cp = fullname; *np && *np != (MMailids ? '<' : ','); ) { if (*np == '&') { /* blech! */ strcpy (cp, pw->pw_name); @@ -426,7 +436,7 @@ getuserinfo (void) *cp++ = *np++; } } -#endif +#endif /* BSD42 */ *cp = '\0'; if (MMailids) {