summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Faurot <eric@cvs.openbsd.org>2012-11-23 10:55:26 +0000
committerEric Faurot <eric@cvs.openbsd.org>2012-11-23 10:55:26 +0000
commit9148fde19ae4f252180ff413f9553484cf5cd8d9 (patch)
tree2b7f0ea05914fadf77410863c308e8ded54bf073
parent23bce6aeda84d214fb7ec2b091f5f15167c8d3fb (diff)
knf
ok gilles@
-rw-r--r--usr.sbin/smtpd/bounce.c24
-rw-r--r--usr.sbin/smtpd/control.c76
-rw-r--r--usr.sbin/smtpd/delivery_filename.c6
-rw-r--r--usr.sbin/smtpd/delivery_maildir.c4
-rw-r--r--usr.sbin/smtpd/delivery_mbox.c4
-rw-r--r--usr.sbin/smtpd/delivery_mda.c4
-rw-r--r--usr.sbin/smtpd/dns.c27
-rw-r--r--usr.sbin/smtpd/enqueue.c33
-rw-r--r--usr.sbin/smtpd/iobuf.c22
-rw-r--r--usr.sbin/smtpd/ioev.c12
-rw-r--r--usr.sbin/smtpd/log.c4
-rw-r--r--usr.sbin/smtpd/makemap.c26
-rw-r--r--usr.sbin/smtpd/parser.c38
-rw-r--r--usr.sbin/smtpd/scheduler_backend.c4
-rw-r--r--usr.sbin/smtpd/smtp.c27
-rw-r--r--usr.sbin/smtpd/smtp_session.c66
-rw-r--r--usr.sbin/smtpd/ssl.c27
-rw-r--r--usr.sbin/smtpd/ssl_privsep.c48
-rw-r--r--usr.sbin/smtpd/stat_backend.c9
-rw-r--r--usr.sbin/smtpd/util.c118
-rw-r--r--usr.sbin/smtpd/waitq.c4
21 files changed, 318 insertions, 265 deletions
diff --git a/usr.sbin/smtpd/bounce.c b/usr.sbin/smtpd/bounce.c
index e2f09e6163e..5e07ceb9bef 100644
--- a/usr.sbin/smtpd/bounce.c
+++ b/usr.sbin/smtpd/bounce.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bounce.c,v 1.52 2012/11/12 14:58:53 eric Exp $ */
+/* $OpenBSD: bounce.c,v 1.53 2012/11/23 10:55:25 eric Exp $ */
/*
* Copyright (c) 2009 Gilles Chehade <gilles@openbsd.org>
@@ -140,7 +140,7 @@ bounce_run(uint64_t id, int fd)
{
struct bounce *bounce;
int msgfd;
-
+
log_trace(TRACE_BOUNCE, "bounce: run %016" PRIx64 " fd %i", id, fd);
bounce = tree_xpop(&bounces_by_uid, id);
@@ -216,7 +216,8 @@ bounce_drain()
tree_xset(&bounces_by_uid, bounce->id, bounce);
- log_debug("debug: bounce: %p: requesting enqueue socket with id 0x%016" PRIx64,
+ log_debug("debug: bounce: %p: requesting enqueue socket "
+ "with id 0x%016" PRIx64,
bounce, bounce->id);
imsg_compose_event(env->sc_ievs[PROC_SMTP], IMSG_SMTP_ENQUEUE,
@@ -242,7 +243,7 @@ bounce_send(struct bounce *bounce, const char *fmt, ...)
iobuf_xfqueue(&bounce->iobuf, "bounce_send", "%s\n", p);
- free(p);
+ free(p);
}
/* This can simplified once we support PIPELINING */
@@ -253,7 +254,7 @@ bounce_next(struct bounce *bounce)
char *line;
size_t len, s;
- switch(bounce->state) {
+ switch (bounce->state) {
case BOUNCE_EHLO:
bounce_send(bounce, "EHLO %s", env->sc_hostname);
bounce->state = BOUNCE_MAIL;
@@ -303,7 +304,8 @@ bounce_next(struct bounce *bounce)
line = evp->errorline;
if (strlen(line) > 4 && (*line == '1' || *line == '6'))
line += 4;
- iobuf_xfqueue(&bounce->iobuf, "bounce_next: DATA_NOTICE",
+ iobuf_xfqueue(&bounce->iobuf,
+ "bounce_next: DATA_NOTICE",
"Recipient: %s@%s\n"
"Reason: %s\n",
evp->dest.user, evp->dest.domain, line);
@@ -389,12 +391,12 @@ bounce_status(struct bounce *bounce, const char *fmt, ...)
evp->retry++;
envelope_set_errormsg(evp, "%s", status);
queue_envelope_update(evp);
- imsg_compose_event(env->sc_ievs[PROC_SCHEDULER], msg, 0, 0, -1,
- evp, sizeof *evp);
+ imsg_compose_event(env->sc_ievs[PROC_SCHEDULER], msg, 0,
+ 0, -1, evp, sizeof *evp);
} else {
queue_envelope_delete(evp);
- imsg_compose_event(env->sc_ievs[PROC_SCHEDULER], msg, 0, 0, -1,
- &evp->id, sizeof evp->id);
+ imsg_compose_event(env->sc_ievs[PROC_SCHEDULER], msg, 0,
+ 0, -1, &evp->id, sizeof evp->id);
}
TAILQ_REMOVE(&bounce->envelopes, evp, entry);
free(evp);
@@ -452,7 +454,7 @@ bounce_io(struct io *io, int evt)
}
iobuf_normalize(&bounce->iobuf);
break;
- }
+ }
log_trace(TRACE_BOUNCE, "bounce: %p: <<< %s", bounce, line);
diff --git a/usr.sbin/smtpd/control.c b/usr.sbin/smtpd/control.c
index 86de6d06357..c2e44f31b24 100644
--- a/usr.sbin/smtpd/control.c
+++ b/usr.sbin/smtpd/control.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: control.c,v 1.79 2012/11/20 09:47:45 eric Exp $ */
+/* $OpenBSD: control.c,v 1.80 2012/11/23 10:55:25 eric Exp $ */
/*
* Copyright (c) 2012 Gilles Chehade <gilles@openbsd.org>
@@ -214,7 +214,8 @@ control(void)
}
(void)umask(old_umask);
- if (chmod(SMTPD_SOCKET, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH) == -1) {
+ if (chmod(SMTPD_SOCKET,
+ S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH) == -1) {
(void)unlink(SMTPD_SOCKET);
fatal("control: chmod");
}
@@ -410,7 +411,7 @@ control_dispatch_ext(int fd, short event, void *arg)
uint64_t id;
struct stat_kv *kvp;
char *key;
- struct stat_value val;
+ struct stat_value val;
size_t len;
if (getpeereid(fd, &euid, &egid) == -1)
@@ -448,8 +449,8 @@ control_dispatch_ext(int fd, short event, void *arg)
case IMSG_SMTP_ENQUEUE:
if (env->sc_flags & (SMTPD_SMTP_PAUSED |
SMTPD_CONFIGURING | SMTPD_EXITING)) {
- imsg_compose_event(&c->iev, IMSG_CTL_FAIL, 0, 0, -1,
- NULL, 0);
+ imsg_compose_event(&c->iev, IMSG_CTL_FAIL, 0, 0,
+ -1, NULL, 0);
break;
}
imsg_compose_event(env->sc_ievs[PROC_SMTP],
@@ -459,7 +460,8 @@ control_dispatch_ext(int fd, short event, void *arg)
case IMSG_STATS:
if (euid)
goto badcred;
- imsg_compose_event(&c->iev, IMSG_STATS, 0, 0, -1, NULL, 0);
+ imsg_compose_event(&c->iev, IMSG_STATS, 0, 0, -1,
+ NULL, 0);
break;
case IMSG_DIGEST:
@@ -512,9 +514,11 @@ control_dispatch_ext(int fd, short event, void *arg)
memcpy(&verbose, imsg.data, sizeof(verbose));
log_verbose(verbose);
- imsg_compose_event(env->sc_ievs[PROC_PARENT], IMSG_CTL_VERBOSE,
- 0, 0, -1, &verbose, sizeof(verbose));
- imsg_compose_event(&c->iev, IMSG_CTL_OK, 0, 0, -1, NULL, 0);
+ imsg_compose_event(env->sc_ievs[PROC_PARENT],
+ IMSG_CTL_VERBOSE, 0, 0, -1, &verbose,
+ sizeof(verbose));
+ imsg_compose_event(&c->iev, IMSG_CTL_OK, 0, 0, -1,
+ NULL, 0);
break;
case IMSG_QUEUE_PAUSE_MDA:
@@ -522,15 +526,16 @@ control_dispatch_ext(int fd, short event, void *arg)
goto badcred;
if (env->sc_flags & SMTPD_MDA_PAUSED) {
- imsg_compose_event(&c->iev, IMSG_CTL_FAIL, 0, 0, -1,
- NULL, 0);
+ imsg_compose_event(&c->iev, IMSG_CTL_FAIL, 0, 0,
+ -1, NULL, 0);
break;
}
log_info("info: mda paused");
env->sc_flags |= SMTPD_MDA_PAUSED;
imsg_compose_event(env->sc_ievs[PROC_QUEUE],
IMSG_QUEUE_PAUSE_MDA, 0, 0, -1, NULL, 0);
- imsg_compose_event(&c->iev, IMSG_CTL_OK, 0, 0, -1, NULL, 0);
+ imsg_compose_event(&c->iev, IMSG_CTL_OK, 0, 0, -1,
+ NULL, 0);
break;
case IMSG_QUEUE_PAUSE_MTA:
@@ -538,15 +543,16 @@ control_dispatch_ext(int fd, short event, void *arg)
goto badcred;
if (env->sc_flags & SMTPD_MTA_PAUSED) {
- imsg_compose_event(&c->iev, IMSG_CTL_FAIL, 0, 0, -1,
- NULL, 0);
+ imsg_compose_event(&c->iev, IMSG_CTL_FAIL, 0, 0,
+ -1, NULL, 0);
break;
}
log_info("info: mta paused");
env->sc_flags |= SMTPD_MTA_PAUSED;
imsg_compose_event(env->sc_ievs[PROC_QUEUE],
IMSG_QUEUE_PAUSE_MTA, 0, 0, -1, NULL, 0);
- imsg_compose_event(&c->iev, IMSG_CTL_OK, 0, 0, -1, NULL, 0);
+ imsg_compose_event(&c->iev, IMSG_CTL_OK, 0, 0, -1,
+ NULL, 0);
break;
case IMSG_SMTP_PAUSE:
@@ -554,15 +560,16 @@ control_dispatch_ext(int fd, short event, void *arg)
goto badcred;
if (env->sc_flags & SMTPD_SMTP_PAUSED) {
- imsg_compose_event(&c->iev, IMSG_CTL_FAIL, 0, 0, -1,
- NULL, 0);
+ imsg_compose_event(&c->iev, IMSG_CTL_FAIL, 0, 0,
+ -1, NULL, 0);
break;
}
log_info("info: smtp paused");
env->sc_flags |= SMTPD_SMTP_PAUSED;
- imsg_compose_event(env->sc_ievs[PROC_SMTP], IMSG_SMTP_PAUSE,
- 0, 0, -1, NULL, 0);
- imsg_compose_event(&c->iev, IMSG_CTL_OK, 0, 0, -1, NULL, 0);
+ imsg_compose_event(env->sc_ievs[PROC_SMTP],
+ IMSG_SMTP_PAUSE, 0, 0, -1, NULL, 0);
+ imsg_compose_event(&c->iev, IMSG_CTL_OK, 0, 0, -1,
+ NULL, 0);
break;
case IMSG_QUEUE_RESUME_MDA:
@@ -570,15 +577,16 @@ control_dispatch_ext(int fd, short event, void *arg)
goto badcred;
if (! (env->sc_flags & SMTPD_MDA_PAUSED)) {
- imsg_compose_event(&c->iev, IMSG_CTL_FAIL, 0, 0, -1,
- NULL, 0);
+ imsg_compose_event(&c->iev, IMSG_CTL_FAIL, 0, 0,
+ -1, NULL, 0);
break;
}
log_info("info: mda resumed");
env->sc_flags &= ~SMTPD_MDA_PAUSED;
imsg_compose_event(env->sc_ievs[PROC_QUEUE],
IMSG_QUEUE_RESUME_MDA, 0, 0, -1, NULL, 0);
- imsg_compose_event(&c->iev, IMSG_CTL_OK, 0, 0, -1, NULL, 0);
+ imsg_compose_event(&c->iev, IMSG_CTL_OK, 0, 0, -1,
+ NULL, 0);
break;
case IMSG_QUEUE_RESUME_MTA:
@@ -586,15 +594,16 @@ control_dispatch_ext(int fd, short event, void *arg)
goto badcred;
if (!(env->sc_flags & SMTPD_MTA_PAUSED)) {
- imsg_compose_event(&c->iev, IMSG_CTL_FAIL, 0, 0, -1,
- NULL, 0);
+ imsg_compose_event(&c->iev, IMSG_CTL_FAIL, 0, 0,
+ -1, NULL, 0);
break;
}
log_info("info: mta resumed");
env->sc_flags &= ~SMTPD_MTA_PAUSED;
imsg_compose_event(env->sc_ievs[PROC_QUEUE],
IMSG_QUEUE_RESUME_MTA, 0, 0, -1, NULL, 0);
- imsg_compose_event(&c->iev, IMSG_CTL_OK, 0, 0, -1, NULL, 0);
+ imsg_compose_event(&c->iev, IMSG_CTL_OK, 0, 0, -1,
+ NULL, 0);
break;
case IMSG_SMTP_RESUME:
@@ -602,15 +611,16 @@ control_dispatch_ext(int fd, short event, void *arg)
goto badcred;
if (!(env->sc_flags & SMTPD_SMTP_PAUSED)) {
- imsg_compose_event(&c->iev, IMSG_CTL_FAIL, 0, 0, -1,
- NULL, 0);
+ imsg_compose_event(&c->iev, IMSG_CTL_FAIL, 0, 0,
+ -1, NULL, 0);
break;
}
log_info("info: smtp resumed");
env->sc_flags &= ~SMTPD_SMTP_PAUSED;
- imsg_compose_event(env->sc_ievs[PROC_SMTP], IMSG_SMTP_RESUME,
- 0, 0, -1, NULL, 0);
- imsg_compose_event(&c->iev, IMSG_CTL_OK, 0, 0, -1, NULL, 0);
+ imsg_compose_event(env->sc_ievs[PROC_SMTP],
+ IMSG_SMTP_RESUME, 0, 0, -1, NULL, 0);
+ imsg_compose_event(&c->iev, IMSG_CTL_OK, 0, 0, -1,
+ NULL, 0);
break;
case IMSG_SCHEDULER_MESSAGES:
@@ -660,8 +670,8 @@ control_dispatch_ext(int fd, short event, void *arg)
if (len >= MAX_LINE_SIZE)
goto invalid;
- imsg_compose_event(env->sc_ievs[PROC_LKA], IMSG_LKA_UPDATE_MAP,
- 0, 0, -1, imsg.data, len + 1);
+ imsg_compose_event(env->sc_ievs[PROC_LKA],
+ IMSG_LKA_UPDATE_MAP, 0, 0, -1, imsg.data, len + 1);
break;
default:
diff --git a/usr.sbin/smtpd/delivery_filename.c b/usr.sbin/smtpd/delivery_filename.c
index d0aa28bf186..0c072b25420 100644
--- a/usr.sbin/smtpd/delivery_filename.c
+++ b/usr.sbin/smtpd/delivery_filename.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: delivery_filename.c,v 1.6 2012/10/03 17:58:03 gilles Exp $ */
+/* $OpenBSD: delivery_filename.c,v 1.7 2012/11/23 10:55:25 eric Exp $ */
/*
* Copyright (c) 2011 Gilles Chehade <gilles@openbsd.org>
@@ -52,7 +52,7 @@ struct delivery_backend delivery_backend_filename = {
static void
delivery_filename_open(struct deliver *deliver)
{
- struct stat sb;
+ struct stat sb;
time_t now;
size_t len;
int fd;
@@ -61,7 +61,7 @@ delivery_filename_open(struct deliver *deliver)
char *msg;
int n;
-#define error(m) { msg = m; goto err; }
+#define error(m) { msg = m; goto err; }
#define error2(m) { msg = m; goto err2; }
setproctitle("file delivery");
diff --git a/usr.sbin/smtpd/delivery_maildir.c b/usr.sbin/smtpd/delivery_maildir.c
index 493cbce2fc7..259901d6ee0 100644
--- a/usr.sbin/smtpd/delivery_maildir.c
+++ b/usr.sbin/smtpd/delivery_maildir.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: delivery_maildir.c,v 1.9 2012/10/03 17:58:03 gilles Exp $ */
+/* $OpenBSD: delivery_maildir.c,v 1.10 2012/11/23 10:55:25 eric Exp $ */
/*
* Copyright (c) 2011 Gilles Chehade <gilles@openbsd.org>
@@ -58,7 +58,7 @@ delivery_maildir_open(struct deliver *deliver)
char *msg;
int n;
-#define error(m) { msg = m; goto err; }
+#define error(m) { msg = m; goto err; }
#define error2(m) { msg = m; goto err2; }
setproctitle("maildir delivery");
diff --git a/usr.sbin/smtpd/delivery_mbox.c b/usr.sbin/smtpd/delivery_mbox.c
index 28002d8f54e..c5882bb74a7 100644
--- a/usr.sbin/smtpd/delivery_mbox.c
+++ b/usr.sbin/smtpd/delivery_mbox.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: delivery_mbox.c,v 1.6 2012/10/03 17:58:03 gilles Exp $ */
+/* $OpenBSD: delivery_mbox.c,v 1.7 2012/11/23 10:55:25 eric Exp $ */
/*
* Copyright (c) 2011 Gilles Chehade <gilles@openbsd.org>
@@ -52,7 +52,7 @@ static void
delivery_mbox_open(struct deliver *deliver)
{
char *environ_new[2];
-
+
environ_new[0] = "PATH=" _PATH_DEFPATH;
environ_new[1] = (char *)NULL;
environ = environ_new;
diff --git a/usr.sbin/smtpd/delivery_mda.c b/usr.sbin/smtpd/delivery_mda.c
index 9568bdfbc5f..4d91bfc41b7 100644
--- a/usr.sbin/smtpd/delivery_mda.c
+++ b/usr.sbin/smtpd/delivery_mda.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: delivery_mda.c,v 1.5 2012/10/03 17:58:03 gilles Exp $ */
+/* $OpenBSD: delivery_mda.c,v 1.6 2012/11/23 10:55:25 eric Exp $ */
/*
* Copyright (c) 2011 Gilles Chehade <gilles@openbsd.org>
@@ -50,7 +50,7 @@ static void
delivery_mda_open(struct deliver *deliver)
{
char *environ_new[2];
-
+
environ_new[0] = "PATH=" _PATH_DEFPATH;
environ_new[1] = (char *)NULL;
environ = environ_new;
diff --git a/usr.sbin/smtpd/dns.c b/usr.sbin/smtpd/dns.c
index c3dad9f77a3..fc23ca4d43b 100644
--- a/usr.sbin/smtpd/dns.c
+++ b/usr.sbin/smtpd/dns.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dns.c,v 1.61 2012/11/12 14:58:53 eric Exp $ */
+/* $OpenBSD: dns.c,v 1.62 2012/11/23 10:55:25 eric Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -99,8 +99,8 @@ dns_query_mx(char *host, char *backup, int port, uint64_t id)
query.port = port;
query.id = id;
- imsg_compose_event(env->sc_ievs[PROC_LKA], IMSG_DNS_MX, 0, 0, -1, &query,
- sizeof(query));
+ imsg_compose_event(env->sc_ievs[PROC_LKA], IMSG_DNS_MX, 0, 0, -1,
+ &query, sizeof(query));
}
void
@@ -112,8 +112,8 @@ dns_query_ptr(struct sockaddr_storage *ss, uint64_t id)
query.ss = *ss;
query.id = id;
- imsg_compose_event(env->sc_ievs[PROC_LKA], IMSG_DNS_PTR, 0, 0, -1, &query,
- sizeof(query));
+ imsg_compose_event(env->sc_ievs[PROC_LKA], IMSG_DNS_PTR, 0, 0, -1,
+ &query, sizeof(query));
}
/* LKA interface */
@@ -131,7 +131,8 @@ dns_async(struct imsgev *asker, int type, struct dns *query)
log_debug("debug: dns: lookup host \"%s\"", query->host);
if (sockaddr_from_str((struct sockaddr*)&query->ss, PF_UNSPEC,
query->host) == 0) {
- log_debug("debug: dns: \"%s\" is an IP address", query->host);
+ log_debug("debug: dns: \"%s\" is an IP address",
+ query->host);
query->error = DNS_OK;
dns_reply(query, IMSG_DNS_HOST);
dns_reply(query, IMSG_DNS_HOST_END);
@@ -183,7 +184,7 @@ static void
dns_asr_event_set(struct dnssession *s, struct async_res *ar)
{
struct timeval tv = { 0, 0 };
-
+
tv.tv_usec = ar->ar_timeout * 1000;
event_set(&s->ev, ar->ar_fd,
ar->ar_cond == ASYNC_READ ? EV_READ : EV_WRITE, dns_asr_handler, s);
@@ -195,7 +196,7 @@ dns_asr_handler(int fd, short event, void *arg)
{
struct dnssession *s = arg;
- switch(s->query.type) {
+ switch (s->query.type) {
case IMSG_DNS_HOST:
dns_asr_dispatch_host(s);
break;
@@ -294,7 +295,7 @@ next:
if (mx == NULL || (s->preference != -1
&& s->preference <= mx->preference)) {
if (mx)
- log_debug("debug: dns: ignoring mx with lower preference");
+ log_debug("debug: dns: ignoring mx with < pri");
if (s->mxfound)
query->error = DNS_OK;
dns_reply(query, IMSG_DNS_HOST_END);
@@ -321,7 +322,8 @@ next:
if (ar.ar_gai_errno == 0) {
for (ai = ar.ar_addrinfo; ai; ai = ai->ai_next) {
memcpy(&query->ss, ai->ai_addr, ai->ai_addrlen);
- log_debug("debug: dns: got address %s", ss_to_text(&query->ss));
+ log_debug("debug: dns: got address %s",
+ ss_to_text(&query->ss));
dns_reply(query, IMSG_DNS_HOST);
s->mxfound++;
}
@@ -375,7 +377,7 @@ dnssession_destroy(struct dnssession *s)
stat_decrement("lka.session", 1);
event_del(&s->ev);
- while((mx = TAILQ_FIRST(&s->mx))) {
+ while ((mx = TAILQ_FIRST(&s->mx))) {
TAILQ_REMOVE(&s->mx, mx, entry);
free(mx->host);
free(mx);
@@ -393,7 +395,8 @@ dnssession_mx_insert(struct dnssession *s, const char *host, int preference)
mx->host = xstrdup(host, "dnssession_mx_insert");
mx->preference = preference;
- log_debug("debug: dns: found mx \"%s\" with preference %i", host, preference);
+ log_debug("debug: dns: found mx \"%s\" with preference %i",
+ host, preference);
TAILQ_FOREACH(e, &s->mx, entry) {
if (mx->preference <= e->preference) {
diff --git a/usr.sbin/smtpd/enqueue.c b/usr.sbin/smtpd/enqueue.c
index 2254a74c208..b5800c7a166 100644
--- a/usr.sbin/smtpd/enqueue.c
+++ b/usr.sbin/smtpd/enqueue.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: enqueue.c,v 1.64 2012/11/12 14:58:53 eric Exp $ */
+/* $OpenBSD: enqueue.c,v 1.65 2012/11/23 10:55:25 eric Exp $ */
/*
* Copyright (c) 2005 Henning Brauer <henning@bulabula.org>
@@ -141,7 +141,7 @@ qp_encoded_write(FILE *fp, char *buf, size_t len)
fprintf(fp, "=3D");
else if (*buf == ' ' || *buf == '\t') {
char *p = buf;
-
+
while (*p != '\n') {
if (*p != ' ' && *p != '\t')
break;
@@ -226,7 +226,7 @@ enqueue(int argc, char *argv[])
build_from(fake_from, pw);
- while(argc > 0) {
+ while (argc > 0) {
rcpt_add(argv[0]);
argv++;
argc--;
@@ -279,7 +279,7 @@ enqueue(int argc, char *argv[])
if (!msg.saw_from)
send_line(fout, 0, "From: %s%s<%s>\n",
msg.fromname ? msg.fromname : "",
- msg.fromname ? " " : "",
+ msg.fromname ? " " : "",
msg.from);
/* add Date */
@@ -296,14 +296,17 @@ enqueue(int argc, char *argv[])
if (!msg.saw_mime_version)
send_line(fout, 0, "MIME-Version: 1.0\n");
if (!msg.saw_content_type)
- send_line(fout, 0, "Content-Type: text/plain; charset=unknown-8bit\n");
+ send_line(fout, 0, "Content-Type: text/plain; "
+ "charset=unknown-8bit\n");
if (!msg.saw_content_disposition)
send_line(fout, 0, "Content-Disposition: inline\n");
if (!msg.saw_content_transfer_encoding)
- send_line(fout, 0, "Content-Transfer-Encoding: quoted-printable\n");
+ send_line(fout, 0, "Content-Transfer-Encoding: "
+ "quoted-printable\n");
}
if (!msg.saw_user_agent)
- send_line(fout, 0, "User-Agent: OpenSMTPD enqueuer (Demoosh)\n");
+ send_line(fout, 0, "User-Agent: OpenSMTPD enqueuer (%s)\n",
+ "Demoosh");
/* add separating newline */
if (noheader)
@@ -329,7 +332,8 @@ enqueue(int argc, char *argv[])
line = buf;
- if (msg.saw_content_transfer_encoding || noheader || inheaders || !msg.need_linesplit) {
+ if (msg.saw_content_transfer_encoding || noheader ||
+ inheaders || !msg.need_linesplit) {
send_line(fout, 0, "%.*s", (int)len, line);
if (inheaders && buf[0] == '\n')
inheaders = 0;
@@ -343,7 +347,8 @@ enqueue(int argc, char *argv[])
break;
}
else {
- qp_encoded_write(fout, line, LINESPLIT - 2 - dotted);
+ qp_encoded_write(fout, line,
+ LINESPLIT - 2 - dotted);
send_line(fout, 0, "=\n");
line += LINESPLIT - 2 - dotted;
len -= LINESPLIT - 2 - dotted;
@@ -351,10 +356,10 @@ enqueue(int argc, char *argv[])
} while (len);
}
send_line(fout, verbose, ".\n");
- get_responses(fout, 1);
+ get_responses(fout, 1);
send_line(fout, verbose, "QUIT\n");
- get_responses(fout, 1);
+ get_responses(fout, 1);
fclose(fp);
fclose(fout);
@@ -373,7 +378,7 @@ get_responses(FILE *fin, int n)
if ((e = ferror(fin)))
errx(1, "ferror: %i", e);
- while(n) {
+ while (n) {
buf = fgetln(fin, &len);
if (buf == NULL && ferror(fin))
err(1, "fgetln");
@@ -575,7 +580,7 @@ parse_addr(char *s, size_t len, int is_from)
if (!pstate.comment && !pstate.quote && !pstate.esc) {
if (s[pos] == ':') { /* group */
- for(pos++; pos < len && WSP(s[pos]); pos++)
+ for (pos++; pos < len && WSP(s[pos]); pos++)
; /* nothing */
pstate.wpos = 0;
}
@@ -634,7 +639,7 @@ parse_addr_terminal(int is_from)
else
rcpt_add(pstate.buf);
pstate.wpos = 0;
- }
+ }
}
static char *
diff --git a/usr.sbin/smtpd/iobuf.c b/usr.sbin/smtpd/iobuf.c
index 227e41fc3cb..9ce5c83178a 100644
--- a/usr.sbin/smtpd/iobuf.c
+++ b/usr.sbin/smtpd/iobuf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: iobuf.c,v 1.2 2012/02/01 17:25:29 eric Exp $ */
+/* $OpenBSD: iobuf.c,v 1.3 2012/11/23 10:55:25 eric Exp $ */
/*
* Copyright (c) 2012 Eric Faurot <eric@openbsd.org>
*
@@ -47,7 +47,7 @@ iobuf_init(struct iobuf *io, size_t size, size_t max)
if (size == 0)
size = max;
-
+
if (size > max)
return (-1);
@@ -68,7 +68,7 @@ iobuf_clear(struct iobuf *io)
if (io->buf)
free(io->buf);
- while((q = io->outq)) {
+ while ((q = io->outq)) {
io->outq = q->next;
free(q);
}
@@ -82,7 +82,7 @@ iobuf_drain(struct iobuf *io, size_t n)
struct ioqbuf *q;
size_t left = n;
- while((q = io->outq) && left) {
+ while ((q = io->outq) && left) {
if ((q->wpos - q->rpos) > left) {
q->rpos += left;
left = 0;
@@ -180,7 +180,7 @@ iobuf_getline(struct iobuf *iobuf, size_t *rlen)
return (buf);
}
- return (NULL);
+ return (NULL);
}
void
@@ -231,9 +231,9 @@ ioqbuf_alloc(struct iobuf *io, size_t len)
return (NULL);
q->rpos = 0;
- q->wpos = 0;
- q->size = len;
- q->next = NULL;
+ q->wpos = 0;
+ q->size = len;
+ q->next = NULL;
q->buf = (char *)(q) + sizeof(*q);
if (io->outqlast == NULL)
@@ -295,13 +295,13 @@ iobuf_queuev(struct iobuf *io, const struct iovec *iov, int iovcnt)
size_t len = 0;
char *buf;
- for(i = 0; i < iovcnt; i++)
+ for (i = 0; i < iovcnt; i++)
len += iov[i].iov_len;
if ((buf = iobuf_reserve(io, len)) == NULL)
return (-1);
- for(i = 0; i < iovcnt; i++) {
+ for (i = 0; i < iovcnt; i++) {
if (iov[i].iov_len == 0)
continue;
memmove(buf, iov[i].iov_base, iov[i].iov_len);
@@ -351,7 +351,7 @@ iobuf_write(struct iobuf *io, int fd)
ssize_t n;
i = 0;
- for(q = io->outq; q ; q = q->next) {
+ for (q = io->outq; q ; q = q->next) {
if (i >= IOV_MAX)
break;
iov[i].iov_base = q->buf + q->rpos;
diff --git a/usr.sbin/smtpd/ioev.c b/usr.sbin/smtpd/ioev.c
index 4905c108444..fc726619130 100644
--- a/usr.sbin/smtpd/ioev.c
+++ b/usr.sbin/smtpd/ioev.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ioev.c,v 1.8 2012/11/12 14:58:53 eric Exp $ */
+/* $OpenBSD: ioev.c,v 1.9 2012/11/23 10:55:25 eric Exp $ */
/*
* Copyright (c) 2012 Eric Faurot <eric@openbsd.org>
*
@@ -114,7 +114,7 @@ io_strevent(int evt)
{
static char buf[32];
- switch(evt) {
+ switch (evt) {
CASE(IO_CONNECTED);
CASE(IO_TLSREADY);
CASE(IO_DATAIN);
@@ -423,7 +423,7 @@ io_reset(struct io *io, short events, void (*dispatch)(int, short, void*))
} else
ptv = NULL;
- event_add(&io->ev, ptv);
+ event_add(&io->ev, ptv);
}
size_t
@@ -445,7 +445,7 @@ io_strflags(int flags)
buf[0] = '\0';
- switch(flags & IO_RW) {
+ switch (flags & IO_RW) {
case 0:
strlcat(buf, "rw", sizeof buf);
break;
@@ -567,7 +567,7 @@ io_dispatch(int fd, short ev, void *humppa)
io_callback(io, IO_DATAIN);
}
- leave:
+leave:
io_frame_leave(io);
}
@@ -815,7 +815,7 @@ io_reload_ssl(struct io *io)
{
void (*dispatch)(int, short, void*) = NULL;
- switch(io->state) {
+ switch (io->state) {
case IO_STATE_CONNECT_SSL:
dispatch = io_dispatch_connect_ssl;
break;
diff --git a/usr.sbin/smtpd/log.c b/usr.sbin/smtpd/log.c
index c5738952527..6554b2842ce 100644
--- a/usr.sbin/smtpd/log.c
+++ b/usr.sbin/smtpd/log.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: log.c,v 1.12 2011/10/22 00:16:33 eric Exp $ */
+/* $OpenBSD: log.c,v 1.13 2012/11/23 10:55:25 eric Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -38,7 +38,7 @@ int verbose;
void vlog(int, const char *, va_list);
void logit(int, const char *, ...)
- __attribute__ ((format (printf, 2, 3)));
+ __attribute__((format (printf, 2, 3)));
void
diff --git a/usr.sbin/smtpd/makemap.c b/usr.sbin/smtpd/makemap.c
index 746c9216e4b..9f306183dd6 100644
--- a/usr.sbin/smtpd/makemap.c
+++ b/usr.sbin/smtpd/makemap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: makemap.c,v 1.40 2012/10/13 09:44:25 gilles Exp $ */
+/* $OpenBSD: makemap.c,v 1.41 2012/11/23 10:55:25 eric Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -151,15 +151,18 @@ main(int argc, char *argv[])
p = strstr(argv[1], ".db");
if (p == NULL || strcmp(p, ".db") != 0) {
- if (! bsnprintf(dbname, sizeof dbname, "%s.db", argv[1]))
+ if (! bsnprintf(dbname, sizeof dbname, "%s.db",
+ argv[1]))
errx(1, "database name too long");
}
else {
- if (strlcpy(dbname, argv[1], sizeof dbname) >= sizeof dbname)
+ if (strlcpy(dbname, argv[1], sizeof dbname)
+ >= sizeof dbname)
errx(1, "database name too long");
}
- execlp(execname, execname, "-d", argv[0], "-o", dbname, "-", NULL);
+ execlp(execname, execname, "-d", argv[0], "-o", dbname, "-",
+ NULL);
err(1, "execlp");
}
@@ -197,7 +200,8 @@ main(int argc, char *argv[])
if (strcmp(source, "-") != 0)
if (fchmod(db->fd(db), sb.st_mode) == -1 ||
fchown(db->fd(db), sb.st_uid, sb.st_gid) == -1) {
- warn("couldn't carry ownership and perms to %s", dbname);
+ warn("couldn't carry ownership and perms to %s",
+ dbname);
goto bad;
}
@@ -364,7 +368,7 @@ parse_setentry(char *line, size_t len, size_t lineno)
if (db->put(db, &key, &val, 0) == -1) {
warn("dbput");
return 0;
- }
+ }
dbputs++;
@@ -384,9 +388,9 @@ int
make_aliases(DBT *val, char *text)
{
struct expandnode xn;
- char *subrcpt;
- char *endp;
- char *origtext;
+ char *subrcpt;
+ char *endp;
+ char *origtext;
val->data = NULL;
val->size = 0;
@@ -448,7 +452,7 @@ usage(void)
if (mode == P_NEWALIASES)
fprintf(stderr, "usage: %s [-f file]\n", __progname);
else
- fprintf(stderr, "usage: %s [-d dbtype] [-o dbfile] [-t type] file\n",
- __progname);
+ fprintf(stderr, "usage: %s [-d dbtype] [-o dbfile] "
+ "[-t type] file\n", __progname);
exit(1);
}
diff --git a/usr.sbin/smtpd/parser.c b/usr.sbin/smtpd/parser.c
index c93386de32f..466177f29e9 100644
--- a/usr.sbin/smtpd/parser.c
+++ b/usr.sbin/smtpd/parser.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: parser.c,v 1.29 2012/10/14 11:58:23 gilles Exp $ */
+/* $OpenBSD: parser.c,v 1.30 2012/11/23 10:55:25 eric Exp $ */
/*
* Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -60,16 +60,16 @@ static const struct token t_update[];
static const struct token t_update_map[];
static const struct token t_main[] = {
- {KEYWORD, "schedule-id", NONE, t_schedule_id},
- {KEYWORD, "schedule-all", SCHEDULE_ALL, NULL},
- {KEYWORD, "show", NONE, t_show},
+ {KEYWORD, "schedule-id", NONE, t_schedule_id},
+ {KEYWORD, "schedule-all", SCHEDULE_ALL, NULL},
+ {KEYWORD, "show", NONE, t_show},
{KEYWORD, "monitor", MONITOR, NULL},
- {KEYWORD, "pause", NONE, t_pause},
- {KEYWORD, "remove", NONE, t_remove},
- {KEYWORD, "resume", NONE, t_resume},
- {KEYWORD, "stop", SHUTDOWN, NULL},
- {KEYWORD, "log", NONE, t_log},
- {KEYWORD, "update", NONE, t_update},
+ {KEYWORD, "pause", NONE, t_pause},
+ {KEYWORD, "remove", NONE, t_remove},
+ {KEYWORD, "resume", NONE, t_resume},
+ {KEYWORD, "stop", SHUTDOWN, NULL},
+ {KEYWORD, "log", NONE, t_log},
+ {KEYWORD, "update", NONE, t_update},
{ENDTOKEN, "", NONE, NULL}
};
@@ -105,30 +105,30 @@ static const struct token t_pause[] = {
{KEYWORD, "mda", PAUSE_MDA, NULL},
{KEYWORD, "mta", PAUSE_MTA, NULL},
{KEYWORD, "smtp", PAUSE_SMTP, NULL},
- {ENDTOKEN, "", NONE, NULL}
+ {ENDTOKEN, "", NONE, NULL}
};
static const struct token t_resume[] = {
{KEYWORD, "mda", RESUME_MDA, NULL},
{KEYWORD, "mta", RESUME_MTA, NULL},
{KEYWORD, "smtp", RESUME_SMTP, NULL},
- {ENDTOKEN, "", NONE, NULL}
+ {ENDTOKEN, "", NONE, NULL}
};
static const struct token t_log[] = {
- {KEYWORD, "verbose", LOG_VERBOSE, NULL},
- {KEYWORD, "brief", LOG_BRIEF, NULL},
- {ENDTOKEN, "", NONE, NULL}
+ {KEYWORD, "verbose", LOG_VERBOSE, NULL},
+ {KEYWORD, "brief", LOG_BRIEF, NULL},
+ {ENDTOKEN, "", NONE, NULL}
};
static const struct token t_update[] = {
- {KEYWORD, "map", NONE, t_update_map},
- {ENDTOKEN, "", NONE, NULL}
+ {KEYWORD, "map", NONE, t_update_map},
+ {ENDTOKEN, "", NONE, NULL}
};
static const struct token t_update_map[] = {
- {VARIABLE, "name", UPDATE_MAP, NULL},
- {ENDTOKEN, "", NONE, NULL}
+ {VARIABLE, "name", UPDATE_MAP, NULL},
+ {ENDTOKEN, "", NONE, NULL}
};
diff --git a/usr.sbin/smtpd/scheduler_backend.c b/usr.sbin/smtpd/scheduler_backend.c
index 6fccd4da8ae..36b9f8cf70f 100644
--- a/usr.sbin/smtpd/scheduler_backend.c
+++ b/usr.sbin/smtpd/scheduler_backend.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: scheduler_backend.c,v 1.6 2012/09/11 19:19:13 gilles Exp $ */
+/* $OpenBSD: scheduler_backend.c,v 1.7 2012/11/23 10:55:25 eric Exp $ */
/*
* Copyright (c) 2012 Gilles Chehade <gilles@openbsd.org>
@@ -68,5 +68,5 @@ scheduler_compute_schedule(struct scheduler_info *sched)
delay = ((delay * sched->retry) * sched->retry) / 2;
- return (sched->creation + delay);
+ return (sched->creation + delay);
}
diff --git a/usr.sbin/smtpd/smtp.c b/usr.sbin/smtpd/smtp.c
index 73067afcd74..142ea2519c6 100644
--- a/usr.sbin/smtpd/smtp.c
+++ b/usr.sbin/smtpd/smtp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: smtp.c,v 1.121 2012/11/12 14:58:53 eric Exp $ */
+/* $OpenBSD: smtp.c,v 1.122 2012/11/23 10:55:25 eric Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -131,7 +131,9 @@ smtp_imsg(struct imsgev *iev, struct imsg *imsg)
case IMSG_QUEUE_TEMPFAIL:
skey.s_id = ss->id;
- /* do not use lookup since this is not a expected imsg -- eric@ */
+ /* do not use lookup since this is not a expected imsg
+ * -- eric@
+ */
s = SPLAY_FIND(sessiontree, &env->sc_sessions, &skey);
if (s == NULL)
fatalx("smtp: session is gone");
@@ -167,7 +169,8 @@ smtp_imsg(struct imsgev *iev, struct imsg *imsg)
if (env->sc_flags & SMTPD_CONFIGURING)
return;
env->sc_flags |= SMTPD_CONFIGURING;
- env->sc_listeners = calloc(1, sizeof *env->sc_listeners);
+ env->sc_listeners = calloc(1,
+ sizeof *env->sc_listeners);
env->sc_ssl = calloc(1, sizeof *env->sc_ssl);
if (env->sc_listeners == NULL || env->sc_ssl == NULL)
fatal(NULL);
@@ -183,8 +186,8 @@ smtp_imsg(struct imsgev *iev, struct imsg *imsg)
*ssl = *(struct ssl *)imsg->data;
ssl->ssl_cert = xstrdup((char *)imsg->data +
sizeof *ssl, "smtp:ssl_cert");
- ssl->ssl_key = xstrdup((char *)imsg->data + sizeof *ssl +
- ssl->ssl_cert_len, "smtp:ssl_key");
+ ssl->ssl_key = xstrdup((char *)imsg->data +
+ sizeof *ssl + ssl->ssl_cert_len, "smtp:ssl_key");
if (ssl->ssl_dhparams_len) {
ssl->ssl_dhparams = xstrdup((char *)imsg->data
+ sizeof *ssl + ssl->ssl_cert_len +
@@ -463,21 +466,24 @@ smtp_accept(int fd, short event, void *p)
socklen_t len;
if ((s = smtp_new(l)) == NULL) {
- log_warnx("warn: smtp: client limit hit, disabling incoming connections");
+ log_warnx("warn: smtp: "
+ "client limit hit, disabling incoming connections");
goto pause;
}
len = sizeof(s->s_ss);
- if ((s->s_io.sock = accept(fd, (struct sockaddr *)&s->s_ss, &len)) == -1) {
+ if ((s->s_io.sock = accept(fd, (struct sockaddr *)&s->s_ss, &len))
+ == -1) {
if (errno == ENFILE || errno == EMFILE) {
- log_warnx("warn: smtp: fd exhaustion, disabling incoming connections");
+ log_warnx("warn: smtp: "
+ "fd exhaustion, disabling incoming connections");
goto pause;
}
if (errno == EINTR || errno == ECONNABORTED)
return;
fatal("smtp_accept");
}
-
+
io_set_timeout(&s->s_io, SMTPD_SESSION_TIMEOUT * 1000);
io_set_write(&s->s_io);
dns_query_ptr(&s->s_ss, s->s_id);
@@ -537,7 +543,8 @@ smtp_destroy(struct session *session)
return;
if (env->sc_flags & SMTPD_SMTP_DISABLED) {
- log_warnx("warn: smtp: fd exaustion over, re-enabling incoming connections");
+ log_warnx("warn: smtp: "
+ "fd exaustion over, re-enabling incoming connections");
env->sc_flags &= ~SMTPD_SMTP_DISABLED;
smtp_resume();
}
diff --git a/usr.sbin/smtpd/smtp_session.c b/usr.sbin/smtpd/smtp_session.c
index 39637ffc58c..c2a8a04327f 100644
--- a/usr.sbin/smtpd/smtp_session.c
+++ b/usr.sbin/smtpd/smtp_session.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: smtp_session.c,v 1.175 2012/11/12 14:58:53 eric Exp $ */
+/* $OpenBSD: smtp_session.c,v 1.176 2012/11/23 10:55:25 eric Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -214,7 +214,8 @@ session_rfc4954_auth_plain(struct session *s, char *arg)
case S_AUTH_INIT:
/* String is not NUL terminated, leave room. */
- if ((len = __b64_pton(arg, (unsigned char *)buf, sizeof(buf) - 1)) == -1)
+ if ((len = __b64_pton(arg, (unsigned char *)buf,
+ sizeof(buf) - 1)) == -1)
goto abort;
/* buf is a byte string, NUL terminate. */
buf[len] = '\0';
@@ -267,7 +268,8 @@ session_rfc4954_auth_login(struct session *s, char *arg)
case S_AUTH_USERNAME:
bzero(a->user, sizeof(a->user));
- if (__b64_pton(arg, (unsigned char *)a->user, sizeof(a->user) - 1) == -1)
+ if (__b64_pton(arg, (unsigned char *)a->user,
+ sizeof(a->user) - 1) == -1)
goto abort;
session_enter_state(s, S_AUTH_PASSWORD);
@@ -276,7 +278,8 @@ session_rfc4954_auth_login(struct session *s, char *arg)
case S_AUTH_PASSWORD:
bzero(a->pass, sizeof(a->pass));
- if (__b64_pton(arg, (unsigned char *)a->pass, sizeof(a->pass) - 1) == -1)
+ if (__b64_pton(arg, (unsigned char *)a->pass,
+ sizeof(a->pass) - 1) == -1)
goto abort;
session_enter_state(s, S_AUTH_FINALIZE);
@@ -287,7 +290,7 @@ session_rfc4954_auth_login(struct session *s, char *arg)
bzero(a->pass, sizeof(a->pass));
return;
-
+
default:
fatal("session_rfc4954_auth_login: unknown state");
}
@@ -312,8 +315,9 @@ session_rfc1652_mail_handler(struct session *s, char *args)
*body++ = '\0';
if (strncasecmp(body, "AUTH=", 5) == 0) {
- log_debug("debug: smtp: AUTH in MAIL FROM command, skipping");
- continue;
+ log_debug("debug: smtp: "
+ "AUTH in MAIL FROM command, skipping");
+ continue;
}
if (strncasecmp(body, "BODY=", 5) == 0) {
@@ -325,12 +329,13 @@ session_rfc1652_mail_handler(struct session *s, char *args)
}
else if (strncasecmp("body=8bitmime", body, 13) != 0) {
- session_respond(s, "503 5.5.4 Unsupported option %s", body);
+ session_respond(s,
+ "503 5.5.4 Unsupported option %s", body);
return 1;
}
}
}
-
+
return session_rfc5321_mail_handler(s, args);
}
@@ -519,7 +524,8 @@ session_rfc5321_data_handler(struct session *s, char *args)
static int
session_rfc5321_vrfy_handler(struct session *s, char *args)
{
- session_respond(s, "252 5.5.1 Cannot VRFY; try RCPT to attempt delivery");
+ session_respond(s,
+ "252 5.5.1 Cannot VRFY; try RCPT to attempt delivery");
return 1;
}
@@ -527,7 +533,8 @@ session_rfc5321_vrfy_handler(struct session *s, char *args)
static int
session_rfc5321_expn_handler(struct session *s, char *args)
{
- session_respond(s, "502 5.5.2 Sorry, we do not allow this operation");
+ session_respond(s,
+ "502 5.5.2 Sorry, we do not allow this operation");
return 1;
}
@@ -535,7 +542,8 @@ session_rfc5321_expn_handler(struct session *s, char *args)
static int
session_rfc5321_turn_handler(struct session *s, char *args)
{
- session_respond(s, "502 5.5.2 Sorry, we do not allow this operation");
+ session_respond(s,
+ "502 5.5.2 Sorry, we do not allow this operation");
return 1;
}
@@ -637,9 +645,10 @@ session_io(struct io *io, int evt)
char *line;
size_t len;
- log_trace(TRACE_IO, "smtp: %p: %s %s", s, io_strevent(evt), io_strio(io));
+ log_trace(TRACE_IO, "smtp: %p: %s %s", s, io_strevent(evt),
+ io_strio(io));
- switch(evt) {
+ switch (evt) {
case IO_TLSREADY:
s->s_flags |= F_SECURE;
@@ -685,7 +694,8 @@ session_io(struct io *io, int evt)
/* pipelining not supported */
if (iobuf_len(&s->s_iobuf)) {
- session_respond(s, "500 5.0.0 Pipelining not supported");
+ session_respond(s,
+ "500 5.0.0 Pipelining not supported");
session_enter_state(s, S_QUIT);
io_set_write(io);
return;
@@ -725,8 +735,8 @@ session_io(struct io *io, int evt)
break;
case IO_DISCONNECTED:
- log_info("smtp-in: Received disconnect from session %016" PRIx64,
- s->s_id);
+ log_info("smtp-in: "
+ "Received disconnect from session %016" PRIx64, s->s_id);
session_destroy(s, "disconnected");
break;
@@ -762,10 +772,11 @@ session_pickup(struct session *s, struct submit_status *ss)
case S_CONNECTED:
session_enter_state(s, S_INIT);
- log_info("smtp-in: New session %016" PRIx64 " from host %s [%s]",
- s->s_id,
- s->s_hostname,
- ss_to_text(&s->s_ss));
+ log_info("smtp-in: "
+ "New session %016" PRIx64 " from host %s [%s]",
+ s->s_id,
+ s->s_hostname,
+ ss_to_text(&s->s_ss));
s->s_msg.session_id = s->s_id;
s->s_msg.ss = s->s_ss;
session_imsg(s, PROC_MFA, IMSG_MFA_CONNECT, 0, 0, -1,
@@ -792,7 +803,7 @@ session_pickup(struct session *s, struct submit_status *ss)
break;
case S_AUTH_FINALIZE:
- strnvis(user, s->s_auth.user, sizeof user, VIS_WHITE | VIS_SAFE);
+ strnvis(user, s->s_auth.user, sizeof user, VIS_WHITE|VIS_SAFE);
if (s->s_flags & F_AUTHENTICATED) {
session_respond(s, "235 Authentication succeeded");
log_info("smtp-in: Accepted authentication for user %s "
@@ -827,7 +838,10 @@ session_pickup(struct session *s, struct submit_status *ss)
session_respond(s, "250-8BITMIME");
session_respond(s, "250-ENHANCEDSTATUSCODES");
- /* XXX - we also want to support reading SIZE from MAIL parameters */
+ /* XXX */
+ /* we also want to support reading SIZE from MAIL
+ * parameters
+ */
session_respond(s, "250-SIZE %zu", env->sc_maxsize);
if (ADVERTISE_TLS(s))
@@ -867,7 +881,8 @@ session_pickup(struct session *s, struct submit_status *ss)
session_enter_state(s, S_MAIL);
else
session_enter_state(s, S_RCPT);
- session_respond(s, "%d 5.0.0 Recipient rejected: %s@%s", ss->code,
+ session_respond(s, "%d 5.0.0 Recipient rejected: %s@%s",
+ ss->code,
s->s_msg.rcpt.user,
s->s_msg.rcpt.domain);
break;
@@ -914,7 +929,8 @@ session_pickup(struct session *s, struct submit_status *ss)
break;
case S_DONE:
- session_respond(s, "250 2.0.0 %08x Message accepted for delivery",
+ session_respond(s,
+ "250 2.0.0 %08x Message accepted for delivery",
evpid_to_msgid(s->s_msg.id));
log_info("smtp-in: Accepted message %08x on session %016" PRIx64
": from=<%s%s%s>, size=%ld, nrcpts=%zu, proto=%s",
diff --git a/usr.sbin/smtpd/ssl.c b/usr.sbin/smtpd/ssl.c
index 3ecf57b47c3..29bf57ea253 100644
--- a/usr.sbin/smtpd/ssl.c
+++ b/usr.sbin/smtpd/ssl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ssl.c,v 1.50 2012/11/12 14:58:53 eric Exp $ */
+/* $OpenBSD: ssl.c,v 1.51 2012/11/23 10:55:25 eric Exp $ */
/*
* Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -142,7 +142,8 @@ ssl_load_certfile(const char *name, uint8_t flags)
if (strlcpy(key.ssl_name, name, sizeof(key.ssl_name))
>= sizeof(key.ssl_name)) {
- log_warnx("warn: ssl_load_certfile: certificate name truncated");
+ log_warnx("warn: ssl_load_certfile: "
+ "certificate name truncated");
return -1;
}
@@ -396,11 +397,11 @@ ssl_smtp_init(void *ssl_ctx)
log_debug("debug: session_start_ssl: switching to SSL");
if ((ssl = SSL_new(ssl_ctx)) == NULL)
- goto err;
- if (!SSL_set_ssl_method(ssl, SSLv23_server_method()))
- goto err;
+ goto err;
+ if (!SSL_set_ssl_method(ssl, SSLv23_server_method()))
+ goto err;
- return (void*)(ssl);
+ return (void*)(ssl);
err:
if (ssl != NULL)
@@ -444,24 +445,24 @@ get_dh1024(void)
0x02
};
- if ((dh = DH_new()) == NULL)
+ if ((dh = DH_new()) == NULL)
return NULL;
- dh->p = BN_bin2bn(dh1024_p, sizeof(dh1024_p), NULL);
- dh->g = BN_bin2bn(dh1024_g, sizeof(dh1024_g), NULL);
- if (dh->p == NULL || dh->g == NULL) {
+ dh->p = BN_bin2bn(dh1024_p, sizeof(dh1024_p), NULL);
+ dh->g = BN_bin2bn(dh1024_g, sizeof(dh1024_g), NULL);
+ if (dh->p == NULL || dh->g == NULL) {
DH_free(dh);
return NULL;
}
- return dh;
+ return dh;
}
DH *
get_dh_from_memory(char *params, size_t len)
{
BIO *mem;
- DH *dh;
+ DH *dh;
mem = BIO_new_mem_buf(params, len);
if (mem == NULL)
@@ -469,7 +470,7 @@ get_dh_from_memory(char *params, size_t len)
dh = PEM_read_bio_DHparams(mem, NULL, NULL, NULL);
if (dh == NULL)
goto err;
- if (dh->p == NULL || dh->g == NULL)
+ if (dh->p == NULL || dh->g == NULL)
goto err;
return dh;
diff --git a/usr.sbin/smtpd/ssl_privsep.c b/usr.sbin/smtpd/ssl_privsep.c
index d7601054364..1d819a90db4 100644
--- a/usr.sbin/smtpd/ssl_privsep.c
+++ b/usr.sbin/smtpd/ssl_privsep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ssl_privsep.c,v 1.3 2009/04/26 19:55:39 gilles Exp $ */
+/* $OpenBSD: ssl_privsep.c,v 1.4 2012/11/23 10:55:25 eric Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
@@ -83,15 +83,15 @@ int ssl_by_mem_ctrl(X509_LOOKUP *, int, const char *, long, char **);
X509_LOOKUP_METHOD x509_mem_lookup = {
"Load cert from memory",
- NULL, /* new */
- NULL, /* free */
- NULL, /* init */
- NULL, /* shutdown */
- ssl_by_mem_ctrl, /* ctrl */
- NULL, /* get_by_subject */
- NULL, /* get_by_issuer_serial */
- NULL, /* get_by_fingerprint */
- NULL, /* get_by_alias */
+ NULL, /* new */
+ NULL, /* free */
+ NULL, /* init */
+ NULL, /* shutdown */
+ ssl_by_mem_ctrl, /* ctrl */
+ NULL, /* get_by_subject */
+ NULL, /* get_by_issuer_serial */
+ NULL, /* get_by_fingerprint */
+ NULL, /* get_by_alias */
};
#define X509_L_ADD_MEM 3
@@ -131,18 +131,18 @@ ssl_ctx_load_verify_memory(SSL_CTX *ctx, char *buf, off_t len)
{
X509_LOOKUP *lu;
struct iovec iov;
-
+
if ((lu = X509_STORE_add_lookup(ctx->cert_store,
&x509_mem_lookup)) == NULL)
return (0);
-
+
iov.iov_base = buf;
iov.iov_len = len;
-
+
if (!ssl_by_mem_ctrl(lu, X509_L_ADD_MEM,
(const char *)&iov, X509_FILETYPE_PEM, NULL))
return (0);
-
+
return (1);
}
@@ -155,35 +155,35 @@ ssl_by_mem_ctrl(X509_LOOKUP *lu, int cmd, const char *buf,
X509_INFO *itmp;
BIO *in = NULL;
int i, count = 0;
-
+
iov = (const struct iovec *)buf;
-
+
if (type != X509_FILETYPE_PEM)
goto done;
-
+
if ((in = BIO_new_mem_buf(iov->iov_base, iov->iov_len)) == NULL)
goto done;
-
+
if ((inf = PEM_X509_INFO_read_bio(in, NULL, NULL, NULL)) == NULL)
goto done;
-
- for(i = 0; i < sk_X509_INFO_num(inf); i++) {
+
+ for (i = 0; i < sk_X509_INFO_num(inf); i++) {
itmp = sk_X509_INFO_value(inf, i);
- if(itmp->x509) {
+ if (itmp->x509) {
X509_STORE_add_cert(lu->store_ctx, itmp->x509);
count++;
}
- if(itmp->crl) {
+ if (itmp->crl) {
X509_STORE_add_crl(lu->store_ctx, itmp->crl);
count++;
}
}
sk_X509_INFO_pop_free(inf, X509_INFO_free);
-
+
done:
if (!count)
X509err(X509_F_X509_LOAD_CERT_CRL_FILE,ERR_R_PEM_LIB);
-
+
if (in != NULL)
BIO_free(in);
return (count);
diff --git a/usr.sbin/smtpd/stat_backend.c b/usr.sbin/smtpd/stat_backend.c
index 4aaa5affd20..8a935d705f3 100644
--- a/usr.sbin/smtpd/stat_backend.c
+++ b/usr.sbin/smtpd/stat_backend.c
@@ -55,7 +55,8 @@ stat_increment(const char *name, size_t count)
s = buf + sizeof *value;
if ((len = strlcpy(s, name, STAT_KEY_SIZE)) >= STAT_KEY_SIZE) {
len = STAT_KEY_SIZE - 1;
- log_warn("warn: stat_increment: truncated key '%s', ignored", name);
+ log_warn("warn: stat_increment: truncated key '%s', ignored",
+ name);
}
imsg_compose_event(env->sc_ievs[PROC_CONTROL],
@@ -74,7 +75,8 @@ stat_decrement(const char *name, size_t count)
s = buf + sizeof *value;
if ((len = strlcpy(s, name, STAT_KEY_SIZE)) >= STAT_KEY_SIZE) {
len = STAT_KEY_SIZE - 1;
- log_warn("warn: stat_increment: truncated key '%s', ignored", name);
+ log_warn("warn: stat_increment: truncated key '%s', ignored",
+ name);
}
imsg_compose_event(env->sc_ievs[PROC_CONTROL],
@@ -91,7 +93,8 @@ stat_set(const char *name, const struct stat_value *value)
s = buf + sizeof *value;
if ((len = strlcpy(s, name, STAT_KEY_SIZE)) >= STAT_KEY_SIZE) {
len = STAT_KEY_SIZE - 1;
- log_warn("warn: stat_increment: truncated key '%s', ignored", name);
+ log_warn("warn: stat_increment: truncated key '%s', ignored",
+ name);
}
imsg_compose_event(env->sc_ievs[PROC_CONTROL],
diff --git a/usr.sbin/smtpd/util.c b/usr.sbin/smtpd/util.c
index 820bbd4cf85..0be3106a140 100644
--- a/usr.sbin/smtpd/util.c
+++ b/usr.sbin/smtpd/util.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: util.c,v 1.88 2012/11/12 14:58:53 eric Exp $ */
+/* $OpenBSD: util.c,v 1.89 2012/11/23 10:55:25 eric Exp $ */
/*
* Copyright (c) 2000,2001 Markus Friedl. All rights reserved.
@@ -349,7 +349,8 @@ mktmpfile(void)
char path[MAXPATHLEN];
int fd;
- if (! bsnprintf(path, sizeof(path), "%s/smtpd.XXXXXXXXXX", PATH_TEMPORARY))
+ if (! bsnprintf(path, sizeof(path), "%s/smtpd.XXXXXXXXXX",
+ PATH_TEMPORARY))
err(1, "snprintf");
if ((fd = mkstemp(path)) == -1)
@@ -413,20 +414,20 @@ valid_localpart(const char *s)
*/
#define IS_ATEXT(c) (isalnum((int)(c)) || strchr("%+-=_", (c)))
nextatom:
- if (! IS_ATEXT(*s) || *s == '\0')
- return 0;
- while (*(++s) != '\0') {
- if (*s == '.')
- break;
- if (IS_ATEXT(*s))
- continue;
- return 0;
- }
- if (*s == '.') {
- s++;
- goto nextatom;
- }
- return 1;
+ if (! IS_ATEXT(*s) || *s == '\0')
+ return 0;
+ while (*(++s) != '\0') {
+ if (*s == '.')
+ break;
+ if (IS_ATEXT(*s))
+ continue;
+ return 0;
+ }
+ if (*s == '.') {
+ s++;
+ goto nextatom;
+ }
+ return 1;
}
int
@@ -454,22 +455,22 @@ valid_domainpart(const char *s)
}
nextsub:
- if (!isalnum((int)*s))
- return 0;
- while (*(++s) != '\0') {
- if (*s == '.')
- break;
- if (isalnum((int)*s) || *s == '-')
- continue;
- return 0;
- }
- if (s[-1] == '-')
- return 0;
- if (*s == '.') {
+ if (!isalnum((int)*s))
+ return 0;
+ while (*(++s) != '\0') {
+ if (*s == '.')
+ break;
+ if (isalnum((int)*s) || *s == '-')
+ continue;
+ return 0;
+ }
+ if (s[-1] == '-')
+ return 0;
+ if (*s == '.') {
s++;
- goto nextsub;
+ goto nextsub;
}
- return 1;
+ return 1;
}
int
@@ -515,25 +516,22 @@ ss_to_text(const struct sockaddr_storage *ss)
buf[0] = '\0';
p = buf;
- if (ss->ss_family == AF_LOCAL) {
+ if (ss->ss_family == AF_LOCAL)
strlcpy(buf, "local", sizeof buf);
- }
else if (ss->ss_family == AF_INET) {
in_addr_t addr;
-
+
addr = ((const struct sockaddr_in *)ss)->sin_addr.s_addr;
- addr = ntohl(addr);
- bsnprintf(p, NI_MAXHOST,
- "%d.%d.%d.%d",
- (addr >> 24) & 0xff,
- (addr >> 16) & 0xff,
- (addr >> 8) & 0xff,
- addr & 0xff);
+ addr = ntohl(addr);
+ bsnprintf(p, NI_MAXHOST, "%d.%d.%d.%d",
+ (addr >> 24) & 0xff, (addr >> 16) & 0xff,
+ (addr >> 8) & 0xff, addr & 0xff);
}
else if (ss->ss_family == AF_INET6) {
- const struct sockaddr_in6 *in6 = (const struct sockaddr_in6 *)ss;
+ const struct sockaddr_in6 *in6;
const struct in6_addr *in6_addr;
+ in6 = (const struct sockaddr_in6 *)ss;
strlcpy(buf, "IPv6:", sizeof(buf));
p = buf + 5;
in6_addr = &in6->sin6_addr;
@@ -547,26 +545,27 @@ char *
time_to_text(time_t when)
{
struct tm *lt;
- static char buf[40];
+ static char buf[40];
char *day[] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
char *month[] = {"Jan","Feb","Mar","Apr","May","Jun",
- "Jul","Aug","Sep","Oct","Nov","Dec"};
+ "Jul","Aug","Sep","Oct","Nov","Dec"};
lt = localtime(&when);
- if (lt == NULL || when == 0)
+ if (lt == NULL || when == 0)
fatalx("time_to_text: localtime");
/* We do not use strftime because it is subject to locale substitution*/
- if (! bsnprintf(buf, sizeof(buf), "%s, %d %s %d %02d:%02d:%02d %c%02d%02d (%s)",
- day[lt->tm_wday], lt->tm_mday, month[lt->tm_mon],
- lt->tm_year + 1900,
- lt->tm_hour, lt->tm_min, lt->tm_sec,
- lt->tm_gmtoff >= 0 ? '+' : '-',
- abs((int)lt->tm_gmtoff / 3600),
- abs((int)lt->tm_gmtoff % 3600) / 60,
- lt->tm_zone))
+ if (! bsnprintf(buf, sizeof(buf),
+ "%s, %d %s %d %02d:%02d:%02d %c%02d%02d (%s)",
+ day[lt->tm_wday], lt->tm_mday, month[lt->tm_mon],
+ lt->tm_year + 1900,
+ lt->tm_hour, lt->tm_min, lt->tm_sec,
+ lt->tm_gmtoff >= 0 ? '+' : '-',
+ abs((int)lt->tm_gmtoff / 3600),
+ abs((int)lt->tm_gmtoff % 3600) / 60,
+ lt->tm_zone))
fatalx("time_to_text: bsnprintf");
-
+
return buf;
}
@@ -694,7 +693,7 @@ text_to_relayhost(struct relayhost *relay, const char *s)
{ "smtp://", 0 },
{ "smtps://", F_SMTPS },
{ "tls://", F_STARTTLS },
- { "smtps+auth://", F_SMTPS|F_AUTH },
+ { "smtps+auth://", F_SMTPS|F_AUTH },
{ "tls+auth://", F_STARTTLS|F_AUTH },
{ "ssl://", F_SMTPS|F_STARTTLS },
{ "ssl+auth://", F_SMTPS|F_STARTTLS|F_AUTH }
@@ -706,7 +705,8 @@ text_to_relayhost(struct relayhost *relay, const char *s)
int len;
for (i = 0; i < nitems(schemas); ++i)
- if (strncasecmp(schemas[i].name, s, strlen(schemas[i].name)) == 0)
+ if (strncasecmp(schemas[i].name, s,
+ strlen(schemas[i].name)) == 0)
break;
if (i == nitems(schemas)) {
@@ -729,7 +729,7 @@ text_to_relayhost(struct relayhost *relay, const char *s)
return 0;
len = sep - p;
}
- else
+ else
len = strlen(p);
if (strlcpy(relay->hostname, p, sizeof (relay->hostname))
@@ -856,7 +856,8 @@ sa_set_port(struct sockaddr *sa, int port)
struct addrinfo hints, *res;
int error;
- error = getnameinfo(sa, sa->sa_len, hbuf, sizeof(hbuf), NULL, 0, NI_NUMERICHOST);
+ error = getnameinfo(sa, sa->sa_len, hbuf, sizeof(hbuf), NULL, 0,
+ NI_NUMERICHOST);
if (error)
fatalx("sa_set_port: getnameinfo failed");
@@ -1087,7 +1088,8 @@ log_envelope(const struct envelope *evp, const char *extra, const char *prefix,
if (extra == NULL)
extra = "";
- log_info("%s: %s for %016" PRIx64 ": from=<%s@%s>, to=<%s@%s>, %s%sdelay=%s, %sstat=%s",
+ log_info("%s: %s for %016" PRIx64 ": from=<%s@%s>, to=<%s@%s>, "
+ "%s%sdelay=%s, %sstat=%s",
evp->type == D_MDA ? "delivery" : "relay",
prefix,
evp->id, evp->sender.user, evp->sender.domain,
diff --git a/usr.sbin/smtpd/waitq.c b/usr.sbin/smtpd/waitq.c
index da6519a6506..56f20215227 100644
--- a/usr.sbin/smtpd/waitq.c
+++ b/usr.sbin/smtpd/waitq.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: waitq.c,v 1.1 2012/10/07 17:21:37 eric Exp $ */
+/* $OpenBSD: waitq.c,v 1.2 2012/11/23 10:55:25 eric Exp $ */
/*
* Copyright (c) 2012 Eric Faurot <eric@openbsd.org>
@@ -91,7 +91,7 @@ waitq_run(void *tag, void *result)
wq = SPLAY_FIND(waitqtree, &waitqs, &key);
SPLAY_REMOVE(waitqtree, &waitqs, wq);
- while((w = TAILQ_FIRST(&wq->waiters))) {
+ while ((w = TAILQ_FIRST(&wq->waiters))) {
TAILQ_REMOVE(&wq->waiters, w, entry);
w->cb(tag, w->arg, result);
free(w);