sendmail problem in expanding macros in headers
Lennart Lovstrand
lenlo at liuida.UUCP
Sun Dec 28 12:26:12 AEST 1986
In article <1598 at oddjob.UChicago.EDU> matt at 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 at SELIUI51
ARPA: lel%ida.liu.se at seismo.CSS.GOV EAN/X.400: lel at ida.liu.sunet
SUNET-bis: L-LOVSTRAND at LISBET PSI/X.25: PSI%240200100403::LEL
More information about the Comp.bugs.4bsd.ucb-fixes
mailing list