summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoreric <eric@openbsd.org>2011-12-14 23:08:40 +0000
committereric <eric@openbsd.org>2011-12-14 23:08:40 +0000
commit8b2c41cb6e29379921a323a95b6497dbfad79f41 (patch)
treed58ed61b234aacf45d6ce19a8e280bd58bc6f4e4
parentsplit auth_backend.c for consistency (diff)
downloadwireguard-openbsd-8b2c41cb6e29379921a323a95b6497dbfad79f41.tar.xz
wireguard-openbsd-8b2c41cb6e29379921a323a95b6497dbfad79f41.zip
finally kill queue_shared.c and move what is left to bounce.c
where it belongs. ok gilles@
-rw-r--r--usr.sbin/smtpd/bounce.c60
-rw-r--r--usr.sbin/smtpd/queue_shared.c97
-rw-r--r--usr.sbin/smtpd/smtpd.h9
-rw-r--r--usr.sbin/smtpd/smtpd/Makefile4
4 files changed, 63 insertions, 107 deletions
diff --git a/usr.sbin/smtpd/bounce.c b/usr.sbin/smtpd/bounce.c
index 09b83cb2d86..4cf4be80424 100644
--- a/usr.sbin/smtpd/bounce.c
+++ b/usr.sbin/smtpd/bounce.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bounce.c,v 1.35 2011/10/27 14:32:57 chl Exp $ */
+/* $OpenBSD: bounce.c,v 1.36 2011/12/14 23:08:40 eric Exp $ */
/*
* Copyright (c) 2009 Gilles Chehade <gilles@openbsd.org>
@@ -46,6 +46,8 @@ struct client_ctx {
FILE *msgfp;
};
+static void queue_message_update(struct envelope *);
+
int
bounce_session(int fd, struct envelope *m)
{
@@ -178,3 +180,59 @@ rw:
event_set(&cc->ev, fd, EV_READ|EV_WRITE, bounce_event, cc);
event_add(&cc->ev, &cc->pcb->timeout);
}
+
+int
+bounce_record_message(struct envelope *e, struct envelope *bounce)
+{
+ u_int32_t msgid;
+
+ bzero(bounce, sizeof(*bounce));
+
+ if (e->type == D_BOUNCE) {
+ log_debug("mailer daemons loop detected !");
+ return 0;
+ }
+
+ *bounce = *e;
+ bounce->type = D_BOUNCE;
+ bounce->status &= ~DS_PERMFAILURE;
+
+ msgid = evpid_to_msgid(e->id);
+ if (! queue_message_create(Q_BOUNCE, &msgid))
+ return 0;
+
+ bounce->id = msgid_to_evpid(msgid);
+ if (! queue_envelope_create(Q_BOUNCE, bounce))
+ return 0;
+
+ return queue_message_commit(Q_BOUNCE, msgid);
+}
+
+static void
+queue_message_update(struct envelope *e)
+{
+ e->batch_id = 0;
+ e->status &= ~(DS_ACCEPTED|DS_REJECTED);
+ e->retry++;
+
+
+ if (e->status & DS_PERMFAILURE) {
+ if (e->type != D_BOUNCE &&
+ e->sender.user[0] != '\0') {
+ struct envelope bounce;
+
+ bounce_record_message(e, &bounce);
+ }
+ queue_envelope_delete(Q_QUEUE, e);
+ return;
+ }
+
+ if (e->status & DS_TEMPFAILURE) {
+ e->status &= ~DS_TEMPFAILURE;
+ queue_envelope_update(Q_QUEUE, e);
+ return;
+ }
+
+ /* no error, remove envelope */
+ queue_envelope_delete(Q_QUEUE, e);
+}
diff --git a/usr.sbin/smtpd/queue_shared.c b/usr.sbin/smtpd/queue_shared.c
deleted file mode 100644
index 41c5883644b..00000000000
--- a/usr.sbin/smtpd/queue_shared.c
+++ /dev/null
@@ -1,97 +0,0 @@
-/* $OpenBSD: queue_shared.c,v 1.55 2011/12/14 18:42:27 eric Exp $ */
-
-/*
- * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
- * Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org>
- * Copyright (c) 2008-2009 Jacek Masiulaniec <jacekm@dobremiasto.net>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <sys/types.h>
-#include <sys/queue.h>
-#include <sys/tree.h>
-#include <sys/param.h>
-#include <sys/socket.h>
-#include <sys/stat.h>
-
-#include <dirent.h>
-#include <err.h>
-#include <errno.h>
-#include <event.h>
-#include <fcntl.h>
-#include <imsg.h>
-#include <inttypes.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#include "smtpd.h"
-#include "log.h"
-
-int
-bounce_record_message(struct envelope *e, struct envelope *bounce)
-{
- u_int32_t msgid;
-
- bzero(bounce, sizeof(*bounce));
-
- if (e->type == D_BOUNCE) {
- log_debug("mailer daemons loop detected !");
- return 0;
- }
-
- *bounce = *e;
- bounce->type = D_BOUNCE;
- bounce->status &= ~DS_PERMFAILURE;
-
- msgid = evpid_to_msgid(e->id);
- if (! queue_message_create(Q_BOUNCE, &msgid))
- return 0;
-
- bounce->id = msgid_to_evpid(msgid);
- if (! queue_envelope_create(Q_BOUNCE, bounce))
- return 0;
-
- return queue_message_commit(Q_BOUNCE, msgid);
-}
-
-void
-queue_message_update(struct envelope *e)
-{
- e->batch_id = 0;
- e->status &= ~(DS_ACCEPTED|DS_REJECTED);
- e->retry++;
-
-
- if (e->status & DS_PERMFAILURE) {
- if (e->type != D_BOUNCE &&
- e->sender.user[0] != '\0') {
- struct envelope bounce;
-
- bounce_record_message(e, &bounce);
- }
- queue_envelope_delete(Q_QUEUE, e);
- return;
- }
-
- if (e->status & DS_TEMPFAILURE) {
- e->status &= ~DS_TEMPFAILURE;
- queue_envelope_update(Q_QUEUE, e);
- return;
- }
-
- /* no error, remove envelope */
- queue_envelope_delete(Q_QUEUE, e);
-}
diff --git a/usr.sbin/smtpd/smtpd.h b/usr.sbin/smtpd/smtpd.h
index 9aca791c89f..dda11e7b3cd 100644
--- a/usr.sbin/smtpd/smtpd.h
+++ b/usr.sbin/smtpd/smtpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: smtpd.h,v 1.266 2011/12/14 22:28:02 eric Exp $ */
+/* $OpenBSD: smtpd.h,v 1.267 2011/12/14 23:08:40 eric Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -978,7 +978,7 @@ struct auth_backend *auth_backend_lookup(enum auth_type);
int bounce_session(int, struct envelope *);
int bounce_session_switch(FILE *, enum session_state *, char *, struct envelope *);
void bounce_event(int, short, void *);
-
+int bounce_record_message(struct envelope *, struct envelope *);
/* config.c */
#define PURGE_LISTENERS 0x01
@@ -1094,11 +1094,6 @@ int qwalk(void *, u_int64_t *);
void qwalk_close(void *);
-/* queue_shared.c */
-void queue_message_update(struct envelope *);
-int bounce_record_message(struct envelope *, struct envelope *);
-
-
/* ramqueue.c */
void ramqueue_init(struct ramqueue *);
int ramqueue_load(struct ramqueue *, time_t *);
diff --git a/usr.sbin/smtpd/smtpd/Makefile b/usr.sbin/smtpd/smtpd/Makefile
index e3c25eb0249..f732a3f8bfa 100644
--- a/usr.sbin/smtpd/smtpd/Makefile
+++ b/usr.sbin/smtpd/smtpd/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.36 2011/12/14 22:28:02 eric Exp $
+# $OpenBSD: Makefile,v 1.37 2011/12/14 23:08:40 eric Exp $
PROG= smtpd
SRCS= aliases.c auth.c auth_bsd.c auth_pwd.c bounce.c \
@@ -7,7 +7,7 @@ SRCS= aliases.c auth.c auth_bsd.c auth_pwd.c bounce.c \
config.c control.c dns.c expand.c forward.c \
lka.c lka_session.c log.c map.c map_db.c map_stdio.c \
mda.c mfa.c mfa_session.c mta.c parse.y \
- queue.c queue_shared.c ruleset.c runner.c smtp.c \
+ queue.c ruleset.c runner.c smtp.c \
smtp_session.c smtpd.c ssl.c ssl_privsep.c util.c asr.c \
print.c pack.c dname.c res_random.c sockaddr.c \
ramqueue.c queue_backend.c queue_fsqueue.c \