summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorJacek Masiulaniec <jacekm@cvs.openbsd.org>2009-11-03 11:10:44 +0000
committerJacek Masiulaniec <jacekm@cvs.openbsd.org>2009-11-03 11:10:44 +0000
commit5c1f76d49ef66706cbe3e14b25b5415a69c04f34 (patch)
tree1528386e6deb9772aaa4cec6ff04439875bb56ac /usr.sbin
parent51ced11242bdb281a317fc09a67fa3748db8b4b6 (diff)
Improve error logging.
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/smtpd/aliases.c12
-rw-r--r--usr.sbin/smtpd/runner.c4
-rw-r--r--usr.sbin/smtpd/smtpd.c42
3 files changed, 37 insertions, 21 deletions
diff --git a/usr.sbin/smtpd/aliases.c b/usr.sbin/smtpd/aliases.c
index 16db574246d..e12d788f6b1 100644
--- a/usr.sbin/smtpd/aliases.c
+++ b/usr.sbin/smtpd/aliases.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: aliases.c,v 1.22 2009/10/12 23:57:44 gilles Exp $ */
+/* $OpenBSD: aliases.c,v 1.23 2009/11/03 11:10:43 jacekm Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -57,7 +57,7 @@ aliases_exist(struct smtpd *env, char *username)
aliasesdb = dbopen(map->m_config, O_RDONLY, 0600, DB_HASH, NULL);
if (aliasesdb == NULL) {
- log_warn("aliases_exist: dbopen");
+ log_warn("aliases_exist: dbopen: %s", map->m_config);
return 0;
}
@@ -94,7 +94,7 @@ aliases_get(struct smtpd *env, struct aliaseslist *aliases, char *username)
aliasesdb = dbopen(map->m_config, O_RDONLY, 0600, DB_HASH, NULL);
if (aliasesdb == NULL) {
- log_warn("aliases_get: dbopen");
+ log_warn("aliases_get: dbopen: %s", map->m_config);
return 0;
}
@@ -149,7 +149,7 @@ aliases_vdomain_exists(struct smtpd *env, struct map *map, char *hostname)
vtable = dbopen(map->m_config, O_RDONLY, 0600, DB_HASH, NULL);
if (vtable == NULL) {
- log_warn("aliases_vdomain_exists: dbopen");
+ log_warn("aliases_vdomain_exists: dbopen: %s", map->m_config);
return 0;
}
@@ -185,7 +185,7 @@ aliases_virtual_exist(struct smtpd *env, struct map *map, struct path *path)
aliasesdb = dbopen(map->m_config, O_RDONLY, 0600, DB_HASH, NULL);
if (aliasesdb == NULL) {
- log_warn("aliases_virtual_exist: dbopen");
+ log_warn("aliases_virtual_exist: dbopen: %s", map->m_config);
return 0;
}
@@ -242,7 +242,7 @@ aliases_virtual_get(struct smtpd *env, struct map *map,
aliasesdb = dbopen(map->m_config, O_RDONLY, 0600, DB_HASH, NULL);
if (aliasesdb == NULL) {
- log_warn("aliases_virtual_get: dbopen");
+ log_warn("aliases_virtual_get: dbopen: %s", map->m_config);
return 0;
}
diff --git a/usr.sbin/smtpd/runner.c b/usr.sbin/smtpd/runner.c
index 103dbf1e0c6..cb7f3d3ef29 100644
--- a/usr.sbin/smtpd/runner.c
+++ b/usr.sbin/smtpd/runner.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: runner.c,v 1.69 2009/11/01 22:15:27 gilles Exp $ */
+/* $OpenBSD: runner.c,v 1.70 2009/11/03 11:10:43 jacekm Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -747,10 +747,8 @@ runner_batch_dispatch(struct smtpd *env, struct batch *batchp, time_t curtime)
log_debug("in batch dispatch");
if (batchp->type == T_BOUNCE_BATCH) {
while ((messagep = TAILQ_FIRST(&batchp->messages))) {
- log_debug("starting");
bounce_process(env, messagep);
TAILQ_REMOVE(&batchp->messages, messagep, entry);
- log_debug("ending");
bzero(messagep, sizeof(*messagep));
free(messagep);
}
diff --git a/usr.sbin/smtpd/smtpd.c b/usr.sbin/smtpd/smtpd.c
index 6df2f9b7005..e5da9571a28 100644
--- a/usr.sbin/smtpd/smtpd.c
+++ b/usr.sbin/smtpd/smtpd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: smtpd.c,v 1.87 2009/10/19 20:00:46 gilles Exp $ */
+/* $OpenBSD: smtpd.c,v 1.88 2009/11/03 11:10:43 jacekm Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -467,10 +467,17 @@ parent_dispatch_mda(int imsgfd, short event, void *p)
errno = 0;
pw = getpwnam(pw_name);
if (pw == NULL) {
- if (errno)
+ if (errno) {
+ log_warn("%s: getpwnam: %s",
+ batchp->message.message_id,
+ pw_name);
parent_mda_tempfail(env, batchp);
- else
+ } else {
+ log_warnx("%s: getpwnam: %s: user does not exist",
+ batchp->message.message_id,
+ pw_name);
parent_mda_permfail(env, batchp);
+ }
break;
}
@@ -482,9 +489,11 @@ parent_dispatch_mda(int imsgfd, short event, void *p)
if (setegid(0) || seteuid(0))
fatal("privraise failed");
- if (fd == -1)
+ if (fd == -1) {
+ log_warnx("%s: could not init delivery for %s",
+ batchp->message.message_id, pw_name);
parent_mda_tempfail(env, batchp);
- else
+ } else
imsg_compose_event(iev,
IMSG_PARENT_MAILBOX_OPEN, 0, 0, fd, batchp,
sizeof(*batchp));
@@ -518,7 +527,6 @@ parent_dispatch_mda(int imsgfd, short event, void *p)
path = &batchp->message.sender;
}
-
if (path->rule.r_user != NULL)
pw_name = path->rule.r_user;
else
@@ -527,10 +535,17 @@ parent_dispatch_mda(int imsgfd, short event, void *p)
errno = 0;
pw = getpwnam(pw_name);
if (pw == NULL) {
- if (errno)
+ if (errno) {
+ log_warn("%s: getpwnam: %s",
+ batchp->message.message_id,
+ pw_name);
parent_mda_tempfail(env, batchp);
- else
+ } else {
+ log_warnx("%s: getpwnam: %s: user does not exist",
+ batchp->message.message_id,
+ pw_name);
parent_mda_permfail(env, batchp);
+ }
break;
}
@@ -544,17 +559,20 @@ parent_dispatch_mda(int imsgfd, short event, void *p)
if (seteuid(pw->pw_uid) == -1)
fatal("privdrop failed");
- if (imsg.hdr.type == IMSG_PARENT_MAILDIR_FAIL)
- ret = -1;
- else
+ if (imsg.hdr.type == IMSG_PARENT_MAILDIR_FAIL) {
+ unlink(tmp);
+ ret = 0;
+ } else
ret = rename(tmp, new);
if (seteuid(0) == -1)
fatal("privraise failed");
if (ret < 0) {
- unlink(tmp);
+ log_warn("%s: %s: cannot rename to the 'new' directory",
+ batchp->message.message_id, tmp);
parent_mda_tempfail(env, batchp);
+ unlink(tmp);
} else
parent_mda_success(env, batchp);
break;