Article View: comp.bugs.4bsd
Article #455Re: sendmail problem in expanding macros in headers
From: Lennart Lovstrand
Date: Sun, 28 Dec 1986 02:26
Date: Sun, 28 Dec 1986 02:26
232 lines
7512 bytes
7512 bytes
In article <1598@oddjob.UChicago.EDU> matt@oddjob.UChicago.EDU
(Matt Crawford) writes:
> Why won't the sending hostname from the SMTP HELO command
> appear in the "Received:" header? Running with debugging
> shows that macro 's' is defined correctly upon receipt of
> HELO. Starting sendmail with a flag "-oMsfakehost" gets
> " from fakehost" into the header, but a $s from HELO gets
> lost somewhere.
Don't know if you have gotten help with this one already, but anyway,
here it is...
Index: sendmail/src/srvrsmtp.c
Description:
When the SMTP code receives the HELO command, it immediately
defines the 's' macro to that name. When it shortly after
receives the MAIL FROM:-command, it spawns a child to process
the letter and clears the envelope unless only one transaction
has been specified (ONEX). Oops, that included clearing all
macros and especially the 's' macro!
Repeat-By:
Define the Received: header line to contain the name of the
remote system. Then receive a message over an SMTP connection
from either a non-sendmail sender or a sendmail sender that
hasn't got the 'I' (M_INTERNAL) mailer flag set. Watch the
the missing remote system name in the Received: line.
Fix:
Don't define the 's' macro until the envelope has been
cleared.
(Also included in the following patch is:
Description:
SMTP server won't recognize nicknames.
Repeat-By:
Define the 'j' macro to be a nickname of your system. Let it
talk to itself over an SMTP connection. Watch it not reject
its looping connection.
--or--
Let a remote system talk to your node over a SMTP connection
and identify itself using a nickname (or any name not equal to
the "official" name you have in your /etc/hosts). Watch it
claim that the remote system is using a faked hostname.
Fix:
Do hostname comparisons on the received remote name filtered
through maphostname().
)
*** srvrsmtp.c.orig Sun Dec 28 02:09:17 1986
--- srvrsmtp.c Sun Dec 28 02:30:44 1986
***************
*** 107,112
ADDRESS *a;
char inp[MAXLINE];
char cmdbuf[100];
extern char Version[];
extern tick();
extern bool iswiz();
--- 107,113 -----
ADDRESS *a;
char inp[MAXLINE];
char cmdbuf[100];
+ char hostbuf[MAXNAME]; /* for host name transformations */
extern char Version[];
extern tick();
extern bool iswiz();
***************
*** 176,181
for (cmd = cmdbuf; *p != '\0' && !isspace(*p); )
*cmd++ = *p++;
*cmd = '\0';
/* decode command */
for (c = CmdTab; c->cmdname != NULL; c++)
--- 177,184 -----
for (cmd = cmdbuf; *p != '\0' && !isspace(*p); )
*cmd++ = *p++;
*cmd = '\0';
+ while (*p != '\0' && isspace(*p))
+ p++;
/* decode command */
for (c = CmdTab; c->cmdname != NULL; c++)
***************
*** 190,196
case CMDHELO: /* hello -- introduce yourself */
SmtpPhase = "HELO";
setproctitle("%s: %s", CurHostName, inp);
! if (sameword(p, MyHostName))
{
/* connected to an echo server */
message("553", "%s I refuse to talk to myself",
--- 193,202 -----
case CMDHELO: /* hello -- introduce yourself */
SmtpPhase = "HELO";
setproctitle("%s: %s", CurHostName, inp);
! /* find canonical name */
! strcpy(hostbuf, p);
! maphostname(hostbuf, sizeof(hostbuf));
! if (sameword(hostbuf, MyHostName))
{
/* connected to an echo server */
message("553", "%s I refuse to talk to myself",
***************
*** 197,203
MyHostName);
break;
}
! if (RealHostName != NULL && !sameword(p, RealHostName))
{
char hostbuf[MAXNAME];
--- 203,209 -----
MyHostName);
break;
}
! if (RealHostName != NULL && !sameword(hostbuf, RealHostName))
{
(void) sprintf(hostbuf, "%s (%s)", p, RealHostName);
CurHostName = newstr(hostbuf);
***************
*** 199,206
}
if (RealHostName != NULL && !sameword(p, RealHostName))
{
- char hostbuf[MAXNAME];
-
(void) sprintf(hostbuf, "%s (%s)", p, RealHostName);
define('s', newstr(hostbuf), CurEnv);
}
--- 205,210 -----
}
if (RealHostName != NULL && !sameword(hostbuf, RealHostName))
{
(void) sprintf(hostbuf, "%s (%s)", p, RealHostName);
CurHostName = newstr(hostbuf);
message("250", "%s Hello %s, why do you call yourself %s?",
***************
*** 202,208
char hostbuf[MAXNAME];
(void) sprintf(hostbuf, "%s (%s)", p, RealHostName);
! define('s', newstr(hostbuf), CurEnv);
}
else
define('s', newstr(p), CurEnv);
--- 206,218 -----
if (RealHostName != NULL && !sameword(hostbuf, RealHostName))
{
(void) sprintf(hostbuf, "%s (%s)", p, RealHostName);
! CurHostName = newstr(hostbuf);
! message("250", "%s Hello %s, why do you call yourself %s?",
! MyHostName, RealHostName, p);
! } else {
! CurHostName = newstr(p);
! message("250", "%s Hello %s, pleased to meet you",
! MyHostName, p);
}
break;
***************
*** 204,213
(void) sprintf(hostbuf, "%s (%s)", p, RealHostName);
define('s', newstr(hostbuf), CurEnv);
}
- else
- define('s', newstr(p), CurEnv);
- message("250", "%s Hello %s, pleased to meet you",
- MyHostName, p);
break;
case CMDMAIL: /* mail -- designate sender */
--- 214,219 -----
message("250", "%s Hello %s, pleased to meet you",
MyHostName, p);
}
break;
case CMDMAIL: /* mail -- designate sender */
***************
*** 213,222
case CMDMAIL: /* mail -- designate sender */
SmtpPhase = "MAIL";
- /* force a sending host even if no HELO given */
- if (RealHostName != NULL && macvalue('s', CurEnv) == NULL)
- define('s', RealHostName, CurEnv);
-
/* check for validity of this command */
if (hasmail)
{
--- 219,224 -----
case CMDMAIL: /* mail -- designate sender */
SmtpPhase = "MAIL";
/* check for validity of this command */
if (hasmail)
{
***************
*** 233,238
if (runinchild("SMTP-MAIL") > 0)
break;
initsys();
setproctitle("%s %s: %s", CurEnv->e_id,
CurHostName, inp);
--- 235,241 -----
if (runinchild("SMTP-MAIL") > 0)
break;
initsys();
+ define('s', CurHostName, CurEnv);
setproctitle("%s %s: %s", CurEnv->e_id,
CurHostName, inp);
--
Dept of Computer and Information Science, University of Linkoping, Sweden
UUCP: {seismo, mcvax}!enea!liuida!lel EARN/BITNET: LEL@SELIUI51
ARPA: lel%ida.liu.se@seismo.CSS.GOV EAN/X.400: lel@ida.liu.sunet
SUNET-bis: L-LOVSTRAND@LISBET PSI/X.25: PSI%240200100403::LEL
Technical Details
Message-ID:
<377@majestix.liuida.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!mnetor!seismo!mcvax!enea!liuida!lenloReferences:
<1598@oddjob.UChicago.EDU>Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: arc1-ca.pugleaf.net!utzoo!mnetor!seismo!mcvax!enea!liuida!lenlo From: lenlo@liuida.UUCP (Lennart Lovstrand) Newsgroups: comp.bugs.4bsd Subject: Re: sendmail problem in expanding macros in headers Message-ID: <377@majestix.liuida.UUCP> Date: Sat, 27-Dec-86 21:26:12 EST Article-I.D.: majestix.377 Posted: Sat Dec 27 21:26:12 1986 Date-Received: Sun, 28-Dec-86 21:43:16 EST References: <1598@oddjob.UChicago.EDU> Reply-To: lenlo@liuida.UUCP (Lennart Lovstrand) Organization: CS Dept, Univ of Linkoping, Sweden Lines: 232 Summary: Fix to srvrsmtp.c enclosed.