seeger@helios.iec.ufl.edu (F. L. Charles Seeger III) (08/24/89)
Problem: When sendmail is started in daemon mode from the command line, it reads the "NAME" environment variable to be used as the sender's Full Name. When mail was forwarded by a machine running such a sendmail, full names would be incorrectly altered when the addresses were rewritten. If NAME isn't set there is no problem. Solution: Don't read NAME when starting in daemon mode. Fix: The context diffs included below inlcude a test for daemon mode operation before reading NAME. Notes: The "NAME" enviroment variable is not properly used when mail is sent from a host that doesn't run its own sendmail daemon and just forwards outgoing mail to a server. This is probably a continuing bug. A better fix, which addresses this problem as well, is probably possible, if someone wishes to look into it. These diffs also include the definition of the m macro (a la Sun's sendmail) to be the domain name, obtained by getdomainname(). The use of the {GET,DEF}_DOMAIN macros (definitions added to conf.h) is quite clear. Sorry for mixing the two in one set of diffs. The definition of YELLOW_PAGES in conf.h comes from Stanley Barber's patches for SunOS-4 with YP support. The default cf file is redefined to "/etc/sendmail.cf". I've also upped the limits for MAXHOP, MAXMXHOSTS and jbuf[] size. Tomorrow is my last day at my current job, and I don't know what my net access will be like in the near future. Use of this Email address should get to me for a while, though. Regards, Chuck -- Charles Seeger 216 Larsen Hall +1 904 392 8935 Electrical Engineering University of Florida "Bye, Opus. seeger@iec.ufl.edu Gainesville, FL 32611 It's been fun." -- ============================ conf.h.diff ================================= *** conf.h.orig Wed Aug 23 17:43:50 1989 --- conf.h Wed Aug 23 18:33:27 1989 *************** *** 31,37 **** # define MAXNAME 256 /* max length of a name */ # define MAXFIELD 2500 /* max total length of a hdr field */ # define MAXPV 40 /* max # of parms to mailers */ ! # define MAXHOP 17 /* max value of HopCount */ # define MAXATOM 100 /* max atoms per address */ # define MAXMAILERS 25 /* maximum mailers known to system */ # define MAXRWSETS 30 /* max # of sets of rewriting rules */ --- 31,37 ---- # define MAXNAME 256 /* max length of a name */ # define MAXFIELD 2500 /* max total length of a hdr field */ # define MAXPV 40 /* max # of parms to mailers */ ! # define MAXHOP 32 /* max value of HopCount */ # define MAXATOM 100 /* max atoms per address */ # define MAXMAILERS 25 /* maximum mailers known to system */ # define MAXRWSETS 30 /* max # of sets of rewriting rules */ *************** *** 39,45 **** # define MAXTRUST 30 /* maximum number of trusted users */ # define MAXUSERENVIRON 40 /* max # of items in user environ */ # define QUEUESIZE 600 /* max # of jobs per queue run */ ! # define MAXMXHOSTS 10 /* max # of MX records */ /* ** Compilation options. --- 39,45 ---- # define MAXTRUST 30 /* maximum number of trusted users */ # define MAXUSERENVIRON 40 /* max # of items in user environ */ # define QUEUESIZE 600 /* max # of jobs per queue run */ ! # define MAXMXHOSTS 16 /* max # of MX records */ /* ** Compilation options. *************** *** 56,61 **** --- 56,64 ---- # define DAEMON 1 /* include the daemon (requires IPC & SMTP) */ # define SETPROCTITLE 1 /* munge argv to display current status */ # define NAMED_BIND 1 /* use Berkeley Internet Domain Server */ + # define YELLOW_PAGES 1 /* use Yellow Pages for aliases lookup */ + # define GET_DOMAIN 1 /* use getdomainname() to define m macro */ + # define DEF_DOMAIN "iec.ufl.edu" /* default domain name */ /* * Use query type of ANY if possible (NO_WILDCARD_MX), which will *************** *** 65,68 **** * searched, we can't use ANY; it would cause fully-qualified names * to match as names in a local domain. */ ! # define NO_WILDCARD_MX 1 --- 68,71 ---- * searched, we can't use ANY; it would cause fully-qualified names * to match as names in a local domain. */ ! /* # define NO_WILDCARD_MX 1 */ ============================ daemon.c.diff ================================= *** daemon.c.orig Wed Aug 23 17:22:01 1989 --- daemon.c Wed Aug 23 18:37:33 1989 *************** *** 484,489 **** --- 484,502 ---- return (NULL); } + #ifdef DEF_DOMAIN + mydomainname(hostbuf, size) + char hostbuf[]; + int size; + { + #ifdef GET_DOMAIN + if (getdomainname(hostbuf, size) < 0) + #endif + (void) strcpy(hostbuf, DEF_DOMAIN); + return (NULL); + } + #endif DEF_DOMAIN + /* * MAPHOSTNAME -- turn a hostname into canonical form * ============================ main.c.diff ================================= *** main.c.orig Wed Aug 23 17:07:11 1989 --- main.c Wed Aug 23 18:38:15 1989 *************** *** 112,119 **** bool readconfig = TRUE; bool queuemode = FALSE; /* process queue requests */ bool nothaw; static bool reenter = FALSE; ! char jbuf[30]; /* holds MyHostName */ extern bool safefile(); extern time_t convtime(); extern putheader(), putbody(); --- 112,120 ---- bool readconfig = TRUE; bool queuemode = FALSE; /* process queue requests */ bool nothaw; + bool daemonmode = FALSE; static bool reenter = FALSE; ! char jbuf[64]; /* holds MyHostName */ extern bool safefile(); extern time_t convtime(); extern putheader(), putbody(); *************** *** 183,189 **** { ConfFile = &p[2]; if (ConfFile[0] == '\0') ! ConfFile = "sendmail.cf"; (void) setgid(getrgid()); (void) setuid(getruid()); nothaw = TRUE; --- 184,190 ---- { ConfFile = &p[2]; if (ConfFile[0] == '\0') ! ConfFile = "/etc/sendmail.cf"; (void) setgid(getrgid()); (void) setuid(getruid()); nothaw = TRUE; *************** *** 190,195 **** --- 191,198 ---- } else if (strncmp(p, "-bz", 3) == 0) nothaw = TRUE; + else if (strncmp(p, "-bd", 3) == 0) + daemonmode = TRUE; else if (strncmp(p, "-d", 2) == 0) { tTsetup(tTdvect, sizeof tTdvect, "0-99.1"); *************** *** 234,240 **** OldUmask = umask(0); OpMode = MD_DELIVER; MotherPid = getpid(); ! FullName = getenv("NAME"); #ifdef LOG_MAIL openlog("sendmail", LOG_PID, LOG_MAIL); --- 237,246 ---- OldUmask = umask(0); OpMode = MD_DELIVER; MotherPid = getpid(); ! if (daemonmode) ! FullName = NULL; ! else ! FullName = getenv("NAME"); #ifdef LOG_MAIL openlog("sendmail", LOG_PID, LOG_MAIL); *************** *** 266,271 **** --- 272,289 ---- setclass('w', *av++); } + #ifdef DEF_DOMAIN + /* domainname */ + (void) mydomainname(jbuf, sizeof jbuf); + if (jbuf[0] != '\0') + { + if (tTd(0, 4)) + printf("domain name: %s\n", jbuf); + p = newstr(jbuf); + define('m', p, CurEnv); + } + #endif + /* version */ define('v', Version, CurEnv); } -- Charles Seeger 216 Larsen Hall +1 904 392 8935 Electrical Engineering University of Florida "Bye, Opus. seeger@iec.ufl.edu Gainesville, FL 32611 It's been fun."