[Raw Msg Headers][Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Problem with smtpserver.conf
> Hello,
> there is still another glitch in smtpserver revealing if you have
> smtpserver.conf file. If you have a line:
>
> ariel 999 ftveR
>
> then smtpserver stops accepting "mail from:" command:
With the diffs attached at the end, it will work.
(... and I should have done it this way the first time
around -- this is much cleaner logic..)
/Matti Aarnio <mea@nic.funet.fi>
----------------------------------------------------------------
$ telnet mea smtp
Trying 194.251.252.33...
Connected to mea.tmt.tele.fi.
Escape character is '^]'.
220 mea.tmt.tele.fi ZMailer Server 2.99.43 #1 ESMTP+IDENT ready at Wed, 4 Dec 1996 20:41:18 +0200
helo test-test
250 mea.tmt.tele.fi expected "HELO mea.tmt.tele.fi"
expn mea@mea
250 Matti Aarnio <mea>
vrfy mea@mea
250 Matti Aarnio <mea>
mail from:<mea@mea.tmt.tele.fi>
250 Ok (verified) Ok
rcpt to:<mea@mea.tmt.tele.fi>
250 Ok (verified) Ok
----------------------------------------------------------------
--- smtpserver/smtpserver.c~ Mon Dec 2 20:27:34 1996
+++ smtpserver/smtpserver.c Wed Dec 4 20:36:09 1996
@@ -1770,6 +1770,78 @@
return 0;
}
+static void
+smtp_verify(buf,cp,cfinfo)
+ char *buf, *cp;
+ struct smtpconf *cfinfo;
+{
+ char *s;
+ int cfi;
+
+ if (state == Hello) {
+ type(503, m551, "Waiting for HELO/EHLO command");
+ return;
+ }
+ while (*cp == ' ' || *cp == '\t') ++cp;
+ if (*cp == '<')
+ s = rfc821_path(cp,cfi); /* with < > */
+ else
+ s = rfc821_path2(cp,cfi); /* Without < > */
+ if (s == cp) {
+ type821err(501,m552, buf,"Path data: %s",rfc821_error);
+ return;
+ }
+ while (*s == ' ' || *s == '\t') ++s;
+ if (*s != 0) {
+ type(501, m552, "Growl! Extra junk after the VRFY argument!");
+ return;
+ }
+ if ((cfi = STYLE(cfinfo, 'v'))) {
+ if ((s = router(RKEY_VERIFY, 0, cp)) != NULL) {
+ /* printf("%s\r\n", s);
+ free(s); */
+ } else
+ type(501,m540, "Unable to verify that address");
+ } else
+ type(252, "2.5.2", (char *)NULL); /* Syntax ok */
+}
+
+static void
+smtp_expand(buf,cp,cfinfo)
+ char *buf, *cp;
+ struct smtpconf *cfinfo;
+{
+ char *s;
+ int cfi;
+
+ if (state == Hello) {
+ type(503, m551, "Waiting for HELO/EHLO command");
+ return;
+ }
+ if ((cfi = STYLE(cfinfo, 'e'))) {
+ while (*cp == ' ' || *cp == '\t') ++cp;
+ if (*cp == '<')
+ s = rfc821_path(cp,cfi); /* with < > */
+ else
+ s = rfc821_path2(cp,cfi); /* Without < > */
+ if (s == cp) {
+ type821err(501,m552,buf,"Path data: %s",rfc821_error);
+ return;
+ }
+ while (*s == ' ' || *s == '\t') ++s;
+ if (*s != 0) {
+ type(501, m552, "Growl! Extra junk after the EXPN argument!");
+ return;
+ }
+ if ((s = router(RKEY_EXPAND, 0, cp)) != NULL) {
+ /* printf("%s\r\n", s);
+ free(s); */
+ } else
+ type(501,m540, "Unable to verify that address");
+ } else
+ type(502,m540, (char *)NULL);
+}
+
/* The SMTP-server itself */
static void
@@ -2006,69 +2078,11 @@
break;
case Verify:
case Verify2:
- if (state == Hello) {
- type(503, m551, "Waiting for HELO/EHLO command");
- fflush(stdout);
- break;
- }
- {
- char *s;
- while (*cp == ' ' || *cp == '\t') ++cp;
- if (*cp == '<')
- s = rfc821_path(cp,cfi); /* with < > */
- else
- s = rfc821_path2(cp,cfi); /* Without < > */
- if (s == cp) {
- type821err(501,m552, buf,"Path data: %s",rfc821_error);
- break;
- }
- while (*s == ' ' || *s == '\t') ++s;
- if (*s != 0) {
- type(501, m552, "Growl! Extra junk after the VRFY argument!");
- break;
- }
- }
- if ((cfi = STYLE(cfinfo, 'v'))) {
- char *s;
- if ((s = router(RKEY_VERIFY, 0, cp)) != NULL) {
- /* printf("%s\r\n", s);
- free(s); */
- } else
- type(501,m540, "Unable to verify that address");
- } else
- type(252, "2.5.2", (char *)NULL); /* Syntax ok */
-
+ smtp_verify(buf,cp,cfinfo);
fflush(stdout);
break;
case Expand:
- if (state == Hello) {
- type(503, m551, "Waiting for HELO/EHLO command");
- fflush(stdout);
- break;
- }
- if ((cfi = STYLE(cfinfo, 'e'))) {
- char *s;
- while (*cp == ' ' || *cp == '\t') ++cp;
- if (*cp == '<')
- s = rfc821_path(cp,cfi); /* with < > */
- else
- s = rfc821_path2(cp,cfi); /* Without < > */
- if (s == cp) {
- type821err(501,m552,buf,"Path data: %s",rfc821_error);
- break;
- }
- while (*s == ' ' || *s == '\t') ++s;
- if (*s != 0) {
- type(501, m552, "Growl! Extra junk after the EXPN argument!");
- break;
- }
- if ((s = router(RKEY_EXPAND, 0, cp)) != NULL) {
- /* printf("%s\r\n", s);
- free(s); */
- } else
- type(501,m540, "Unable to verify that address");
- } else
- type(502,m540, (char *)NULL);
+ smtp_expand(buf,cp,cfinfo);
fflush(stdout);
break;
case Turnme:
@@ -2091,6 +2105,7 @@
VerboseCommand = 1;
break;
case DebugMode:
+ ++debug;
debug_report(VerboseCommand,rhostname,buf);
fflush(stdout);
break;
@@ -2378,10 +2393,8 @@
int promptlen;
FILE *tofp, *fromfp;
-extern char *mgets __((char **, int *, FILE *));
-char *
-mgets(bufp, flagp, fp)
- char **bufp; /* this is what I returned earlier, if non-null */
+extern char *mgets __((int *, FILE *));
+char *mgets(flagp, fp)
int *flagp;
FILE *fp;
{
@@ -2390,10 +2403,6 @@
char *buf;
int ccnt = 0;
- if (*bufp != NULL)
- free(*bufp);
- *bufp = NULL;
-
if (*flagp) {
*flagp = 0;
return NULL;
@@ -2434,7 +2443,6 @@
return NULL;
}
- *bufp = buf;
return buf;
}
@@ -2504,18 +2512,16 @@
ROUTER_SERVER, RKEY_INIT, rhostname, ihostaddr);
fflush(tofp);
- bufp = NULL;
sawend = 0;
- while ((cp = mgets(&bufp, &sawend, fromfp)) != NULL) {
+ while ((bufp = mgets(&sawend, fromfp)) != NULL) {
if (strncmp(cp, BADEXEC, strlen(BADEXEC)-2) == 0) {
free(cp);
killr(pid);
return -1;
}
/*printf("241%c%s\n", sawend == 1 ? ' ' : '-', buf);*/
- }
- if (bufp)
free(bufp);
+ }
return pid;
}
@@ -2541,8 +2547,8 @@
char *function, *args;
int holdlast;
{
- char *bufp, *holdcp, *prevb = NULL;
- int sawend, anyresult = 0;
+ char *bufp, *prevb = NULL;
+ int sawend = 0;
if (args == NULL) {
type(501,NULL,NULL);
@@ -2567,9 +2573,6 @@
fprintf(tofp, "\"\n");
fflush(tofp);
- bufp = NULL;
- holdcp = NULL;
- sawend = 0;
for (;;) {
/*
* We want to give the router the opportunity to report
@@ -2577,42 +2580,46 @@
* three characters are digits and the 4th a space or '-',
* then pass through.
*/
- char *buf = mgets(&bufp, &sawend, fromfp);
+ bufp = mgets(&sawend, fromfp);
+ if (!bufp) break;
- if (buf && strlen(buf) > 4 &&
- isdigit(buf[0]) && isdigit(buf[1]) && isdigit(buf[2])
- && (buf[3] == ' ' || buf[3] == '-')) {
- if (holdlast && buf[3] == ' ')
- holdcp = buf;
- else
- printf("%s\r\n", buf);
- anyresult = 1;
+ if (debug) {
+ fprintf(stdout,"001 Got string: '%s'\r\n", bufp);
+ fflush(stdout);
+ }
+
+ if (prevb != NULL) {
+ if (strlen(prevb) > 4 &&
+ isdigit(prevb[0]) && isdigit(prevb[1]) && isdigit(prevb[2])
+ && (prevb[3] == ' ' || prevb[3] == '-')) {
+ printf("%s\r\n", prevb);
+ } else {
+ printf("250-%s\r\n", prevb);
+ }
+ free(prevb);
+ }
+ prevb = bufp;
+ }
+
+ if (!holdlast) {
+ /* -------- Print the last line too -------- */
+ if (strlen(prevb) > 4 &&
+ isdigit(prevb[0]) && isdigit(prevb[1]) && isdigit(prevb[2])
+ && (prevb[3] == ' ')) {
+ printf("%s\r\n", prevb);
} else {
- if (holdlast && sawend) {
- holdcp = prevb;
- anyresult = 1;
- } else
- if (prevb && !sawend) {
- printf("250-%s\r\n", prevb);
- anyresult = 1;
- } else if (prevb && sawend) {
- printf("250 %s\r\n", prevb);
- anyresult = 1;
- }
-
- if (prevb != holdcp)
- free(prevb);
- prevb = bufp;
- bufp = NULL;
+ printf("250 %s\r\n", prevb);
}
- if (!buf) break;
+ free(prevb);
+ prevb = "<any-pointer>";
+ } else {
+ /* Uhhh.... No output! */
+ if (!prevb)
+ fprintf("500 **INTERNAL*ERROR**\r\n");
}
- if (bufp && bufp != holdcp)
- free(bufp);
fflush(stdout);
- if (!holdlast && anyresult)
- return "*any*result*"; /* Flag */
- return holdcp;
+
+ return prevb; /* It may be unfreeable pointer... */
}