pkgsrc/mail/smtpfeed/patches/patch-al

968 lines
27 KiB
Text
Raw Normal View History

$NetBSD: patch-al,v 1.1 2006/07/23 15:00:41 taca Exp $
--- smtp.c.orig 2002-02-23 19:20:05.000000000 +0900
+++ smtp.c
@@ -49,32 +49,42 @@
static int FirstRead, FirstWrite;
static int Terminate, NewTransCheck, NeedTrimDomain, MoreFreeSlot;
+static void sig_alarm P((int));
+static void sig_int P((int));
+static void sig_hup P((int));
+static void sig_term P((int));
+static void smtp P((void));
+
static void
-sig_alarm()
+sig_alarm(dummy)
+ int dummy;
{
errno = ETIMEDOUT;
if (cnf.debug & DEBUG_EVENT)
- log(LOG_DEBUG, "alarm clock");
+ mylog(LOG_DEBUG, "alarm clock");
}
static void
-sig_int()
+sig_int(dummy)
+ int dummy;
{
- log(LOG_INFO, "SIGINT received: internal states dumped");
+ mylog(LOG_INFO, "SIGINT received: internal states dumped");
dump_internal();
}
static void
-sig_hup()
+sig_hup(dummy)
+ int dummy;
{
- log(LOG_INFO, "SIGHUP received: graceful termination");
+ mylog(LOG_INFO, "SIGHUP received: graceful termination");
forced_terminate();
}
static void
-sig_term()
+sig_term(dummy)
+ int dummy;
{
- log(LOG_INFO, "SIGTERM received: semi graceful termination");
+ mylog(LOG_INFO, "SIGTERM received: semi graceful termination");
markstatus(env.rcpt_list, SMTP_TEMPFAIL(51),
"Aborted by INT signal", 1);
longjmp(jmp_env, 1);
@@ -87,10 +97,10 @@
int s;
while((s = dup(0)) < 253);
- log(LOG_DEBUG, "descriptor reserved till %d", s);
+ mylog(LOG_DEBUG, "descriptor reserved till %d", s);
#endif
- log(LOG_INFO, "from=%s size=%d nrcpt=%d msgid=%s",
+ mylog(LOG_INFO, "from=%s size=%d nrcpt=%d msgid=%s",
env.sender, env.realsize, sti.nrcpt,
(env.mid == NULL)?"none":env.mid);
@@ -99,7 +109,7 @@
FILE *fp;
if (cnf.debug & DEBUG_TRANS)
- log(LOG_DEBUG, "searching sender address %s in %s",
+ mylog(LOG_DEBUG, "searching sender address %s in %s",
env.sender, cnf.src_mod_path);
if ((fp = fopen(cnf.src_mod_path, "r")) == NULL)
{
@@ -127,7 +137,7 @@
fclose(fp);
if (found)
{
- log(LOG_INFO,
+ mylog(LOG_INFO,
"recipients/transaction changed to 1");
cnf.rcpts_trans == 1;
}
@@ -207,15 +217,53 @@
resource_usage("finalstatus done");
}
-static int smtp_connected(), smtp_greeted(), smtp_flush();
-static int smtp_helo_r(), smtp_helo_r();
-static int smtp_mail_r(), smtp_rcpt_r(), smtp_rcpt_s();
-static int smtp_data_r(), smtp_data_body(), smtp_data_t();
-static int smtp_rset_r(), smtp_quit_r();
+static int smtp_connected P((struct connection *));
+static int smtp_flush P((struct connection *));
+static int smtp_greeted P((struct connection *));
+static int smtp_helo_r P((struct connection *));
+static int smtp_mail_r P((struct connection *));
+static int smtp_rcpt_r P((struct connection *));
+static int smtp_data_r P((struct connection *));
+static int smtp_data_body P((struct connection *));
+static int smtp_data_t P((struct connection *));
+static int smtp_rset_r P((struct connection *));
+static int smtp_quit_r P((struct connection *));
+
+static int smtp_helo_s P((struct connection *));
+static int smtp_mail_s P((struct connection *));
+static int smtp_rcpt_s P((struct connection *));
+static int smtp_data_s P((struct connection *));
+static int smtp_rset_s P((struct connection *));
+static int smtp_quit_s P((struct connection *));
+
+static int new_transaction P((void));
+static void process_connection P((fd_set *, fd_set *, int, int));
+static void markstatus P((struct recipient *, int, char *, int));
+static struct connection *open_transaction P((struct recipient *));
+static void close_transaction P((struct connection *, int));
+static void trim_rcpts P((struct domain *));
+static int trim_domain P((void));
+static void forced_terminate P((void));
+
+static int smtp_connect P((struct connection *));
+void smtp_close P((int));
+static int smtp_read P((struct connection *, char *, int, int *));
+static int smtp_write P((struct connection *, char *, int, int));
+static int smtp_get_reply P((struct connection *,
+ void (*) P((struct connection *, char *)),
+ char *, int, int *));
+static int smtp_send_command P((struct connection *, char *, int, int));
+static void esmtp_check P((struct connection *, char *));
+static void ehlo_opt P((struct connection *, char *));
+static char *skipaddr P((char *, char *addr));
+static int may_be_reused P((struct connection *));
+static int smtp_timeout P((struct connection *));
+static void dump_internal P((void));
+static char *smtpstrerror P((int));
static struct {
- int (*recv)();
- int (*send)();
+ int (*recv) P((struct connection *));
+ int (*send) P((struct connection *));
time_t tout;
char *name;
} state_tbl[] = {
@@ -356,13 +404,13 @@
if (rcptp->domain == NULL)
{
rcptp->stat = RCPT_DONE;
- log(LOG_NOTICE, "no domain for %s", rcptp->address);
+ mylog(LOG_NOTICE, "no domain for %s", rcptp->address);
continue;
}
if (rcptp->domain->firstmx == NULL)
{
rcptp->stat = RCPT_DONE;
- log(LOG_NOTICE, "no MX for %s", rcptp->address);
+ mylog(LOG_NOTICE, "no MX for %s", rcptp->address);
continue;
}
}
@@ -375,7 +423,7 @@
if (domp->rcpt_top == NULL)
continue;
if (cnf.debug & DEBUG_TRANS)
- log(LOG_DEBUG, "pick up domain: %s", domp->name);
+ mylog(LOG_DEBUG, "pick up domain: %s", domp->name);
if (wdomp == NULL)
env.work_domain = domp;
else
@@ -395,7 +443,7 @@
{
/* all recipients had been processed */
if (cnf.debug & DEBUG_CONNECT)
- log(LOG_DEBUG, "closing all sockets");
+ mylog(LOG_DEBUG, "closing all sockets");
all_done = 1;
for (i = 0; i < cnf.sd_max; i++)
{
@@ -424,7 +472,7 @@
}
if (cnf.debug & DEBUG_TRANS)
- log(LOG_DEBUG, "in_use=%d, max_sock=%d, min_sock=%d",
+ mylog(LOG_DEBUG, "in_use=%d, max_sock=%d, min_sock=%d",
in_use, max_sock, sti.minsock);
if (in_use > (max_sock - sti.minsock))
@@ -439,7 +487,7 @@
if (connwork[i].host->state != STAT_SENT)
continue;
if (cnf.debug & DEBUG_CONNECT)
- log(LOG_DEBUG, "%d/%d: closing idle socket",
+ mylog(LOG_DEBUG, "%d/%d: closing idle socket",
connwork[i].seq,
connwork[i].socket);
smtp_quit_s(&connwork[i]);
@@ -458,7 +506,7 @@
if (!connwork[i].reuse)
break;
if (cnf.debug & DEBUG_CONNECT)
- log(LOG_DEBUG, "%d/%d: closing idle socket",
+ mylog(LOG_DEBUG, "%d/%d: closing idle socket",
connwork[i].seq,
connwork[i].socket);
smtp_quit_s(&connwork[i]);
@@ -479,7 +527,7 @@
}
#if 1
if (cnf.debug & DEBUG_TRANS)
- log(LOG_DEBUG, "new transaction: trans=%d, sock=%d",
+ mylog(LOG_DEBUG, "new transaction: trans=%d, sock=%d",
num_trans, num_sock);
#endif
if (new_transaction() < 0)
@@ -514,7 +562,7 @@
if (all_done && fds < 0)
{
if (cnf.debug & DEBUG_CONNECT)
- log(LOG_DEBUG, "all sockets are closed");
+ mylog(LOG_DEBUG, "all sockets are closed");
#if 0
dump_internal();
#endif
@@ -523,7 +571,7 @@
if (fds < 0) /* XXX */
{
- log(LOG_INFO, "No active sockets");
+ mylog(LOG_INFO, "No active sockets");
if (bad_state++ > 5)
{
markstatus(env.rcpt_list, SMTP_TEMPFAIL(51),
@@ -561,12 +609,12 @@
{
/* time up */
forced_terminate();
- log(LOG_INFO, "total processing timed out (%d sec)",
+ mylog(LOG_INFO, "total processing timed out (%d sec)",
cnf.t_timeout);
}
if (rc < 0)
{
- log(LOG_INFO, "select returns %d (fds=%d, errno=%d)",
+ mylog(LOG_INFO, "select returns %d (fds=%d, errno=%d)",
rc, fds, errno);
sleep(1);
}
@@ -594,7 +642,7 @@
{
#if 1
if (cnf.debug & DEBUG_TRANS)
- log(LOG_DEBUG, "checking domain: %s", domp->name);
+ mylog(LOG_DEBUG, "checking domain: %s", domp->name);
#endif
/* first time for the domain? */
#if 1
@@ -615,7 +663,7 @@
|| domp->curmx->host->addr == NULL))))
{
if (domp->curmx->host == NULL)
- log(LOG_INFO, "skipping bad MX: %s for %s",
+ mylog(LOG_INFO, "skipping bad MX: %s for %s",
domp->curmx->name, domp->name);
else
{
@@ -697,7 +745,7 @@
}
#if 1
if (cnf.debug & DEBUG_TRANS)
- log(LOG_DEBUG, "no new transaction");
+ mylog(LOG_DEBUG, "no new transaction");
#endif
NewTransCheck = 0;
return -1; /* no new transaction */
@@ -721,7 +769,7 @@
snprintf(msgbuf, sizeof(msgbuf),
"No address known for %s", conn->host->name);
- log(LOG_INFO, msgbuf, conn->host->name);
+ mylog(LOG_INFO, msgbuf, conn->host->name);
rcode = SMTP_TEMPFAIL(52);
if (cnf.absentAok)
@@ -798,7 +846,7 @@
/* timeout! */
sti.ntimeout++;
if (cnf.debug & DEBUG_CONNECT)
- log(LOG_DEBUG, "%d/%d: timeout (%s)", conn->seq,
+ mylog(LOG_DEBUG, "%d/%d: timeout (%s)", conn->seq,
conn->socket, STATE(st));
if (st == STAT_DTERMSENT)
{
@@ -814,7 +862,7 @@
if (FD_ISSET(conn->socket, w_fds))
{
if (cnf.debug & DEBUG_EVENT)
- log(LOG_DEBUG, "%d/%d: writable (%s)",
+ mylog(LOG_DEBUG, "%d/%d: writable (%s)",
conn->seq, conn->socket, STATE(st));
if (state_tbl[st].send != NULL)
{
@@ -825,14 +873,14 @@
if (conn->host == NULL)
{
if (cnf.debug & DEBUG_EVENT)
- log(LOG_DEBUG, "%d/%d: state %s -> NULL",
+ mylog(LOG_DEBUG, "%d/%d: state %s -> NULL",
conn->seq, conn->socket, STATE(st));
}
else if (st != conn->host->state)
{
conn->host->time = Now;
if (cnf.debug & DEBUG_EVENT)
- log(LOG_DEBUG, "%d/%d: state %s -> %s",
+ mylog(LOG_DEBUG, "%d/%d: state %s -> %s",
conn->seq, conn->socket, STATE(st),
STATE(conn->host->state));
}
@@ -841,7 +889,7 @@
if (FD_ISSET(conn->socket, r_fds))
{
if (cnf.debug & DEBUG_EVENT)
- log(LOG_DEBUG, "%d/%d: readable (%s)",
+ mylog(LOG_DEBUG, "%d/%d: readable (%s)",
conn->seq, conn->socket, STATE(st));
if (state_tbl[st].recv != NULL)
{
@@ -852,14 +900,14 @@
if (conn->host == NULL)
{
if (cnf.debug & DEBUG_EVENT)
- log(LOG_DEBUG, "%d/%d: state %s -> NULL",
+ mylog(LOG_DEBUG, "%d/%d: state %s -> NULL",
conn->seq, conn->socket, STATE(st));
}
else if (st != conn->host->state)
{
conn->host->time = Now;
if (cnf.debug & DEBUG_EVENT)
- log(LOG_DEBUG, "%d/%d: state %s -> %s",
+ mylog(LOG_DEBUG, "%d/%d: state %s -> %s",
conn->seq, conn->socket, STATE(st),
STATE(conn->host->state));
}
@@ -1041,7 +1089,7 @@
{
/* buffer may be full */
strcat(addrbuf+addrlen, ",(more...)");
- log(LOG_INFO, "(%d+%d+%d+%d/%d) relay=%s to=%s proto=%s delay=%d code=%d (%s)",
+ mylog(LOG_INFO, "(%d+%d+%d+%d/%d) relay=%s to=%s proto=%s delay=%d code=%d (%s)",
sti.nsent, sti.ndeferred, sti.nnsfailed,
sti.nsmtpfailed, sti.nrcpt, hostname,
addrbuf, proto, delay, rcode,
@@ -1066,7 +1114,7 @@
{
rcptp->stat = RCPT_RETRY;
if (cnf.debug & DEBUG_TRANS)
- log(LOG_DEBUG, "tempfail; next avail: %s",
+ mylog(LOG_DEBUG, "tempfail; next avail: %s",
rcptp->address);
}
else
@@ -1074,7 +1122,7 @@
sti.ndeferred++;
rcptp->stat = RCPT_DONE;
if (cnf.debug & DEBUG_TRANS)
- log(LOG_DEBUG, "tempfail; done: %s",
+ mylog(LOG_DEBUG, "tempfail; done: %s",
rcptp->address);
}
}
@@ -1103,7 +1151,7 @@
}
if (addrlen > 0)
{
- log(LOG_INFO, "(%d+%d+%d+%d/%d) relay=%s to=%s proto=%s delay=%d code=%d (%s)",
+ mylog(LOG_INFO, "(%d+%d+%d+%d/%d) relay=%s to=%s proto=%s delay=%d code=%d (%s)",
sti.nsent, sti.ndeferred, sti.nnsfailed,
sti.nsmtpfailed, sti.nrcpt, hostname,
addrbuf, proto, delay, rcode,
@@ -1143,7 +1191,7 @@
#if 1
if (cnf.debug & DEBUG_TRANS)
- log(LOG_DEBUG, "num_trans=%d, num_sock=%d, max_sock=%d, min_sock=%d",
+ mylog(LOG_DEBUG, "num_trans=%d, num_sock=%d, max_sock=%d, min_sock=%d",
num_trans, num_sock, max_sock, sti.minsock);
#endif
if (num_trans > (max_sock - sti.minsock))
@@ -1158,7 +1206,7 @@
#if 1
if (cnf.debug & DEBUG_TRANS)
- log(LOG_DEBUG, "open transaction for %s", rcptp->address);
+ mylog(LOG_DEBUG, "open transaction for %s", rcptp->address);
#endif
if (rcptp->domain->curmx->host->state == STAT_SENT)
@@ -1170,7 +1218,7 @@
break;
}
if (cnf.debug & DEBUG_TRANS)
- log(LOG_DEBUG, "reusing: slot=%d", i);
+ mylog(LOG_DEBUG, "reusing: slot=%d", i);
}
else
{
@@ -1190,7 +1238,7 @@
{
#if 0
if (cnf.debug & DEBUG_TRANS)
- log(LOG_DEBUG, "no free slot");
+ mylog(LOG_DEBUG, "no free slot");
#endif
/* sleep (1); */
return NULL; /* XXX socket slot is full */
@@ -1199,7 +1247,7 @@
sti.ntrans++;
if (cnf.debug & DEBUG_TRANS)
- log(LOG_DEBUG, "%d/-: open transaction for %s, slot=%d",
+ mylog(LOG_DEBUG, "%d/-: open transaction for %s, slot=%d",
sti.ntrans, rcptp->address, i);
/* initialize transaction */
@@ -1230,7 +1278,7 @@
domp = mxp->domain;
if (domp == NULL)
{
- log(LOG_NOTICE, "Oops, mxp->domain for %s is NULL",
+ mylog(LOG_NOTICE, "Oops, mxp->domain for %s is NULL",
mxp->name);
goto next_domain;
}
@@ -1253,7 +1301,7 @@
if (rcpts + 1 > cnf.rcpts_trans)
#else
if (cnf.debug & DEBUG_TRANS)
- log(LOG_DEBUG, "check count of rcpts (domain:%s, max rcpts:%d, count:%d)",
+ mylog(LOG_DEBUG, "check count of rcpts (domain:%s, max rcpts:%d, count:%d)",
rcptp2->domain->name,
rcptp2->domain->rcpts,
rcpts);
@@ -1266,7 +1314,7 @@
}
rcpts++;
if (cnf.debug & DEBUG_TRANS)
- log(LOG_DEBUG, "%d/-: with %s",
+ mylog(LOG_DEBUG, "%d/-: with %s",
sti.ntrans, rcptp2->address);
rcptp2->stat = RCPT_WORK;
rcptp2->chain = NULL;
@@ -1306,7 +1354,7 @@
#endif
if (cnf.debug & DEBUG_TRANS)
- log(LOG_DEBUG, "%d/%d: close transaction", conn->seq, conn->socket);
+ mylog(LOG_DEBUG, "%d/%d: close transaction", conn->seq, conn->socket);
NewTransCheck = 1; /* do not skip new_transaction() */
env.work_dom_ptr = NULL; /* retry from the top of list */
@@ -1369,7 +1417,7 @@
if (domp->curmx != NULL)
{
if (cnf.debug & DEBUG_TRANS)
- log(LOG_DEBUG, "%d/-: switching to next MX: %s",
+ mylog(LOG_DEBUG, "%d/-: switching to next MX: %s",
conn->seq, domp->curmx->name);
}
}
@@ -1410,7 +1458,7 @@
num_trans--;
}
-void
+static void
trim_rcpts(domp)
struct domain *domp;
{
@@ -1427,7 +1475,7 @@
{
/* remove recipient from working chain */
if (cnf.debug & DEBUG_TRANS)
- log(LOG_DEBUG, "removing recipient: %s",
+ mylog(LOG_DEBUG, "removing recipient: %s",
rcptp->address);
if (rcptp == domp->rcpt_top)
{
@@ -1449,7 +1497,7 @@
NeedTrimDomain = 1;
}
-int
+static int
trim_domain()
{
struct domain *domp, *domtmp;
@@ -1463,7 +1511,7 @@
{
/* remove from working domain chain */
if (cnf.debug & DEBUG_TRANS)
- log(LOG_DEBUG, "removing domain: %s",
+ mylog(LOG_DEBUG, "removing domain: %s",
domp->name);
if (domp == env.work_domain)
{
@@ -1490,7 +1538,7 @@
return 0;
}
-void
+static void
forced_terminate()
{
struct recipient *rcptp;
@@ -1518,7 +1566,7 @@
if (conn->host == NULL)
{
- log(LOG_NOTICE, "smtp_connect called with NULL host");
+ mylog(LOG_NOTICE, "smtp_connect called with NULL host");
return -1;
}
@@ -1532,7 +1580,7 @@
}
if (cnf.debug & DEBUG_CONNECT)
- log(LOG_DEBUG, "%d/-: connecting to %s",
+ mylog(LOG_DEBUG, "%d/-: connecting to %s",
conn->seq, conn->host->name);
bzero((char *)&rsin, sizeof(rsin));
@@ -1569,7 +1617,7 @@
socksize = sizeof(struct sockaddr_in);
if (cnf.debug & DEBUG_CONNECT)
- log(LOG_DEBUG, "%d/-: destination=%s/%d", conn->seq,
+ mylog(LOG_DEBUG, "%d/-: destination=%s/%d", conn->seq,
inet_ntoa(rsin.in.sin_addr), cnf.dst_port);
found = 1;
break;
@@ -1599,7 +1647,7 @@
inet_ntop(AF_INET6, &rsin.in6.sin6_addr,
buf, sizeof(buf));
- log(LOG_DEBUG, "%d/-: destination=%s/%d",
+ mylog(LOG_DEBUG, "%d/-: destination=%s/%d",
conn->seq, buf, cnf.dst_port);
}
found = 1;
@@ -1637,7 +1685,7 @@
if (sd > MAX_SOCK)
{
- log(LOG_NOTICE, "%d/%d: can not manage such a big file descriptor number with select()",
+ mylog(LOG_NOTICE, "%d/%d: can not manage such a big file descriptor number with select()",
conn->seq, sd);
close(sd);
if (max_sock > MAX_SOCK)
@@ -1650,7 +1698,7 @@
if (sd < 0){
/* no more socket resource */
- log(LOG_NOTICE, "socket allocation failed for %s: %s (may be max=%d, current=%d/%d/%d)",
+ mylog(LOG_NOTICE, "socket allocation failed for %s: %s (may be max=%d, current=%d/%d/%d)",
conn->host->name, smtpstrerror(errno), sti.maxsock,
max_sock, num_sock, sti.minsock);
if (max_sock > NOFILE)
@@ -1669,14 +1717,14 @@
}
if (cnf.debug & DEBUG_CONNECT)
- log(LOG_DEBUG, "%d/%d: socket allocated", conn->seq, sd);
+ mylog(LOG_DEBUG, "%d/%d: socket allocated", conn->seq, sd);
#ifdef SO_SNDBUF
if (cnf.sendbufsize > 0)
{
if (setsockopt(sd, SOL_SOCKET, SO_SNDBUF,
(char *)&cnf.sendbufsize, sizeof(cnf.sendbufsize)) < 0)
- log(LOG_NOTICE, "%d/%d: setsockopt(SO_SNDBUF) failed for %s: %s",
+ mylog(LOG_NOTICE, "%d/%d: setsockopt(SO_SNDBUF) failed for %s: %s",
conn->seq, sd, conn->host->name,
smtpstrerror(errno));
/* ignore error */
@@ -1741,7 +1789,7 @@
case AF_INET:
bcopy(addrp->address,
&lsin.in.sin_addr, addrp->len);
- log(LOG_INFO,
+ mylog(LOG_INFO,
"using %s as source IP address",
inet_ntoa(lsin.in.sin_addr));
break;
@@ -1753,7 +1801,7 @@
inet_ntop(AF_INET6, &lsin.in6.sin6_addr,
buf, sizeof(buf));
- log(LOG_INFO, "using %s as source IP address", buf);
+ mylog(LOG_INFO, "using %s as source IP address", buf);
break;
#endif
}
@@ -1771,7 +1819,7 @@
p = NULL;
}
if (!found)
- log(LOG_INFO, "sourceIP (%s) ignored", cnf.sourceIP);
+ mylog(LOG_INFO, "sourceIP (%s) ignored", cnf.sourceIP);
}
if (!found)
{
@@ -1820,7 +1868,7 @@
{
if (bind(sd, (struct sockaddr *)&lsin, socksize) < 0)
{
- log(LOG_NOTICE, "%d/%d: bind failed for %s: %s",
+ mylog(LOG_NOTICE, "%d/%d: bind failed for %s: %s",
conn->seq, sd, conn->host->name,
smtpstrerror(errno));
conn->host->state = STAT_FAIL;
@@ -1837,7 +1885,7 @@
if (ioctl (sd, FIONBIO, &res) < 0)
{
- log(LOG_NOTICE, "%d/%d: FIONBIO failed for %s: %s",
+ mylog(LOG_NOTICE, "%d/%d: FIONBIO failed for %s: %s",
conn->seq, sd, conn->host->name, smtpstrerror(errno));
conn->host->state = STAT_FAIL;
close (sd);
@@ -1848,7 +1896,7 @@
#else
if ((res = fcntl(sd, F_GETFL, 0)) == -1)
{
- log(LOG_NOTICE, "%d/%d: F_GETFL failed for %s: %s",
+ mylog(LOG_NOTICE, "%d/%d: F_GETFL failed for %s: %s",
conn->seq, sd, conn->host->name, smtpstrerror(errno));
conn->host->state = STAT_FAIL;
close (sd);
@@ -1863,7 +1911,7 @@
# endif
if (fcntl(sd, F_SETFL, res) == -1)
{
- log(LOG_NOTICE, "%d/%d: F_SETFL failed for %s: %s",
+ mylog(LOG_NOTICE, "%d/%d: F_SETFL failed for %s: %s",
conn->seq, sd, conn->host->name, smtpstrerror(errno));
conn->host->state = STAT_FAIL;
close (sd);
@@ -1879,7 +1927,7 @@
&& errno != EINPROGRESS && errno != EINTR) /* XXX */
{
alarm(0);
- log(LOG_DEBUG, "%d/%d: connect failed for %s: %s",
+ mylog(LOG_DEBUG, "%d/%d: connect failed for %s: %s",
conn->seq, sd, conn->host->name, smtpstrerror(errno));
conn->host->current->stat = EX_TEMPFAIL;
close (sd);
@@ -1911,7 +1959,7 @@
}
sti.minsock = sd;
if (cnf.debug & DEBUG_CONNECT)
- log(LOG_DEBUG, "minsock=%d", sti.minsock);
+ mylog(LOG_DEBUG, "minsock=%d", sti.minsock);
}
num_sock++;
return 0;
@@ -1931,11 +1979,11 @@
{
SockAddr cin;
int len = sizeof(SockAddr);
- const char *errmsg;
+ char *errmsg;
if (getpeername(conn->socket, (struct sockaddr *)&cin, &len) < 0)
{
- log(LOG_INFO, "%d/%d: getpeername failed for %s: %s",
+ mylog(LOG_INFO, "%d/%d: getpeername failed for %s: %s",
conn->seq, conn->socket, conn->host->name,
smtpstrerror(errno));
if (conn->host->current != NULL) /* XXX for safe access */
@@ -1984,7 +2032,7 @@
conn->outlen = 0;
if (conn->inbuf == NULL || conn->outbuf == NULL)
{
- log(LOG_NOTICE, "out of memory (SMTP buffer allocation)");
+ mylog(LOG_NOTICE, "out of memory (SMTP buffer allocation)");
if (conn->host->current != NULL) /* XXX for safe access */
{
conn->host->current->stat = EX_TEMPFAIL;
@@ -2028,7 +2076,7 @@
if (n == 0)
{
if (cnf.debug & DEBUG_CONNECT)
- log(LOG_DEBUG, "%d/%d: closed by foreign host",
+ mylog(LOG_DEBUG, "%d/%d: closed by foreign host",
conn->seq, conn->socket);
errno = E_SF_IO;
return -1;
@@ -2046,7 +2094,7 @@
#endif
return 0;
default:
- log(LOG_DEBUG, "%d/%d: read failed for %s: ret=%d, errno=%d",
+ mylog(LOG_DEBUG, "%d/%d: read failed for %s: ret=%d, errno=%d",
conn->seq, conn->socket,
conn->host->name, n, errno);
return n;
@@ -2112,7 +2160,7 @@
if (n == 0)
{
if (cnf.debug & DEBUG_CONNECT)
- log(LOG_DEBUG,
+ mylog(LOG_DEBUG,
"%d/%d: closed by foreign host (%s)",
conn->seq, conn->socket,
conn->host->name);
@@ -2132,7 +2180,7 @@
#endif
return 0;
default:
- log(LOG_DEBUG,
+ mylog(LOG_DEBUG,
"%d/%d: write failed for %s: ret=%d, errno=%d",
conn->seq, conn->socket,
conn->host->name, n, errno);
@@ -2167,7 +2215,7 @@
if (n == 0)
{
if (cnf.debug & DEBUG_CONNECT)
- log(LOG_DEBUG,
+ mylog(LOG_DEBUG,
"%d/%d: closed by foreign host (%s)",
conn->seq, conn->socket,
conn->host->name);
@@ -2185,7 +2233,7 @@
#endif
return size;
default:
- log(LOG_DEBUG,
+ mylog(LOG_DEBUG,
"%d/%d: write failed for %s: ret=%d, errno=%d",
conn->seq, conn->socket,
conn->host->name, n, errno);
@@ -2236,7 +2284,7 @@
static int
smtp_get_reply(conn, func, firstline, size, rest)
struct connection *conn;
-void (*func)();
+void (*func) P((struct connection *, char *));
char firstline[];
int size;
int *rest;
@@ -2281,7 +2329,7 @@
cbuf[--len] = '\0';
}
if (cnf.debug & DEBUG_SMTP)
- log(LOG_DEBUG, "%d/%d: >>> %s", conn->seq, conn->socket, cbuf);
+ mylog(LOG_DEBUG, "%d/%d: >>> %s", conn->seq, conn->socket, cbuf);
if (func != NULL)
(*func)(conn, cbuf);
if (!isdigit(cbuf[0]) || !isdigit(cbuf[1]) || !isdigit(cbuf[2])
@@ -2338,7 +2386,7 @@
int len = strlen(buf);
if (cnf.debug & DEBUG_SMTP)
- log(LOG_DEBUG, "%d/%d: <<< %s", conn->seq, conn->socket, buf);
+ mylog(LOG_DEBUG, "%d/%d: <<< %s", conn->seq, conn->socket, buf);
if (len + 2 < size)
{
strcat(buf, CRLF);
@@ -2412,7 +2460,7 @@
{
char buf[MAXLINE];
int rcode, savestate;
- const char *errmsg;
+ char *errmsg;
errno = 0;
savestate = conn->host->state;
@@ -2453,7 +2501,7 @@
errmsg = "Unexpected Error";
break;
}
- log(LOG_INFO, "%d/%d: failed for %s: %s (%s)",
+ mylog(LOG_INFO, "%d/%d: failed for %s: %s (%s)",
conn->seq, conn->socket, conn->host->name,
smtpstrerror(errno), STATE(savestate));
if (conn->host->current != NULL) /* XXX for safe access */
@@ -2600,7 +2648,7 @@
{
if (errno > 0)
{
- log(LOG_INFO, "%d/%d: failed for %s: %s (%s)",
+ mylog(LOG_INFO, "%d/%d: failed for %s: %s (%s)",
conn->seq, conn->socket, smtpstrerror(errno),
conn->host->name, STATE(savestate));
}
@@ -2854,7 +2902,7 @@
{
if (errno > 0)
{
- log(LOG_INFO, "%d/%d: failed for %s: %s (%s)",
+ mylog(LOG_INFO, "%d/%d: failed for %s: %s (%s)",
conn->seq, conn->socket, conn->host->name,
smtpstrerror(errno), STATE(savestate));
}
@@ -3032,7 +3080,7 @@
{
if (errno > 0)
{
- log(LOG_INFO, "%d/%d: failed for %s: %s (%s)",
+ mylog(LOG_INFO, "%d/%d: failed for %s: %s (%s)",
conn->seq, conn->socket, conn->host->name,
smtpstrerror(errno), STATE(savestate));
}
@@ -3149,7 +3197,7 @@
{
if (errno > 0)
{
- log(LOG_INFO, "%d/%d: failed for %s: %s (%s)",
+ mylog(LOG_INFO, "%d/%d: failed for %s: %s (%s)",
conn->seq, conn->socket, conn->host->name,
smtpstrerror(errno), STATE(savestate));
}
@@ -3229,7 +3277,7 @@
len = strlen(altbuf);
rcode = smtp_write(conn, altbuf, len, 0);
if (rcode != len) /* XXX */
- log(LOG_NOTICE,
+ mylog(LOG_NOTICE,
"Header of sent message will be corrupted: %s",
altbuf);
}
@@ -3301,7 +3349,7 @@
return 0;
if (cnf.debug & DEBUG_CONNECT)
- log(LOG_DEBUG, "reusability check: %s", conn->host->name);
+ mylog(LOG_DEBUG, "reusability check: %s", conn->host->name);
/* check possibility of reuse connection */
for (rmxp = conn->host->mx_ref; rmxp != NULL; rmxp = rmxp->mx_ref)
@@ -3323,7 +3371,7 @@
}
}
if (cnf.debug & DEBUG_CONNECT)
- log(LOG_DEBUG, "on domain: %s = %d", domp->name, reused);
+ mylog(LOG_DEBUG, "on domain: %s = %d", domp->name, reused);
if (reused == 0)
continue;
@@ -3335,7 +3383,7 @@
if (mxp == rmxp)
{
if (cnf.debug & DEBUG_CONNECT)
- log(LOG_DEBUG, "%d/%d: may be reused: %s",
+ mylog(LOG_DEBUG, "%d/%d: may be reused: %s",
conn->seq, conn->socket,
conn->host->name);
return 1;
@@ -3361,7 +3409,7 @@
{
if (errno > 0)
{
- log(LOG_INFO, "%d/%d: failed for %s: %s (%s)",
+ mylog(LOG_INFO, "%d/%d: failed for %s: %s (%s)",
conn->seq, conn->socket, conn->host->name,
smtpstrerror(errno), STATE(savestate));
}
@@ -3453,7 +3501,7 @@
{
if (errno > 0)
{
- log(LOG_INFO, "%d/%d: failed for %s: %s (%s)",
+ mylog(LOG_INFO, "%d/%d: failed for %s: %s (%s)",
conn->seq, conn->socket, conn->host->name,
smtpstrerror(errno), STATE(savestate));
}
@@ -3528,7 +3576,7 @@
{
if (errno > 0)
{
- log(LOG_INFO, "%d/%d: failed for %s: %s (%s)",
+ mylog(LOG_INFO, "%d/%d: failed for %s: %s (%s)",
conn->seq, conn->socket, conn->host->name,
smtpstrerror(errno), STATE(savestate));
}
@@ -3588,7 +3636,7 @@
markstatus(conn->rcpt, SMTP_TEMPFAIL(52),
newstr(buf), 1);
else
- log(LOG_INFO, "Trying next address of %s",
+ mylog(LOG_INFO, "Trying next address of %s",
conn->host->name);
if (conn->host->current != NULL) /* XXX for safe access */
conn->host->current = conn->host->current->next;
@@ -3614,7 +3662,7 @@
{
conn->host->state = STAT_CLOSED;
conn->host->current->stat = EX_TEMPFAIL;
- log(LOG_INFO, "Trying next address of %s",
+ mylog(LOG_INFO, "Trying next address of %s",
conn->host->name);
}
else
@@ -3641,17 +3689,17 @@
struct recipient *rcptp;
int i;
- log(LOG_INFO, "=== dumping internal information ===");
+ mylog(LOG_INFO, "=== dumping internal information ===");
for (rcptp = env.rcpt_list; rcptp != NULL; rcptp = rcptp->next)
{
switch (rcptp->stat)
{
case RCPT_NOOP:
- log(LOG_INFO, "rcpt=%s stat=noop", rcptp->address);
+ mylog(LOG_INFO, "rcpt=%s stat=noop", rcptp->address);
break;
case RCPT_WORK:
- log(LOG_INFO, "rcpt=%s stat=working mx=%s st=%s",
+ mylog(LOG_INFO, "rcpt=%s stat=working mx=%s st=%s",
rcptp->address,
(rcptp->domain->curmx == NULL)?"none":
rcptp->domain->curmx->name,
@@ -3660,18 +3708,18 @@
break;
case RCPT_RETRY:
if (rcptp->domain->curmx != NULL)
- log(LOG_INFO,
+ mylog(LOG_INFO,
"rcpt=%s stat=retry code=%d mx=%s st=%s",
rcptp->address, rcptp->result,
rcptp->domain->curmx->name,
STATE(rcptp->domain->curmx->host->state));
else
- log(LOG_INFO,
+ mylog(LOG_INFO,
"rcpt=%s stat=retry code=%d mx=none",
rcptp->address, rcptp->result);
break;
case RCPT_DONE:
- log(LOG_INFO, "rcpt=%s stat=done code=%d",
+ mylog(LOG_INFO, "rcpt=%s stat=done code=%d",
rcptp->address, rcptp->result);
break;
}
@@ -3681,12 +3729,12 @@
{
if (connwork[i].host == NULL)
continue;
- log(LOG_INFO, "slot=%d host=%s stat=%s", i,
+ mylog(LOG_INFO, "slot=%d host=%s stat=%s", i,
connwork[i].host->name,
STATE(connwork[i].host->state));
}
- log(LOG_INFO, "=== end of internal information ===");
+ mylog(LOG_INFO, "=== end of internal information ===");
}
static char *