summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorJacek Masiulaniec <jacekm@cvs.openbsd.org>2009-02-14 00:00:48 +0000
committerJacek Masiulaniec <jacekm@cvs.openbsd.org>2009-02-14 00:00:48 +0000
commitc5e8590e236808988c2bf3620445bd1bf52dd262 (patch)
treeb80f87fbfca7a06017489035a38fe3b9330846bf /usr.sbin
parent919942636a548852be080fc2e66e1671f62908a0 (diff)
Display envelope status & flags in "show queue"; ok gilles@
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/smtpd/queue_shared.c44
1 files changed, 41 insertions, 3 deletions
diff --git a/usr.sbin/smtpd/queue_shared.c b/usr.sbin/smtpd/queue_shared.c
index 4c901e2d07a..42d0cff4109 100644
--- a/usr.sbin/smtpd/queue_shared.c
+++ b/usr.sbin/smtpd/queue_shared.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: queue_shared.c,v 1.6 2009/01/30 16:37:52 gilles Exp $ */
+/* $OpenBSD: queue_shared.c,v 1.7 2009/02/14 00:00:47 jacekm Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -53,6 +53,7 @@ int walk_simple(struct qwalk *, char *);
int walk_queue(struct qwalk *, char *);
void display_envelope(struct message *, int);
+void getflag(u_int *, int, char *, char *, size_t);
int
queue_create_layout_message(char *queuepath, char *message_id)
@@ -366,6 +367,7 @@ void
queue_message_update(struct message *messagep)
{
messagep->flags &= ~F_MESSAGE_PROCESSING;
+ messagep->status &= ~(S_MESSAGE_ACCEPTED|S_MESSAGE_REJECTED);
messagep->batch_id = 0;
messagep->retry++;
@@ -683,6 +685,31 @@ show_queue(char *queuepath, int flags)
void
display_envelope(struct message *envelope, int flags)
{
+ char status[128];
+
+ status[0] = '\0';
+
+ getflag(&envelope->status, S_MESSAGE_TEMPFAILURE, "TEMPFAIL",
+ status, sizeof(status));
+
+ if (envelope->status)
+ errx(1, "%s: unexpected status 0x%04x", envelope->message_uid,
+ envelope->status);
+
+ getflag(&envelope->flags, F_MESSAGE_SCHEDULED, "SCHEDULED",
+ status, sizeof(status));
+ getflag(&envelope->flags, F_MESSAGE_PROCESSING, "PROCESSING",
+ status, sizeof(status));
+
+ if (envelope->flags)
+ errx(1, "%s: unexpected flags 0x%04x", envelope->message_uid,
+ envelope->flags);
+
+ if (status[0])
+ status[strlen(status) - 1] = '\0';
+ else
+ strlcpy(status, "-", sizeof(status));
+
switch (envelope->type) {
case T_MDA_MESSAGE:
printf("MDA");
@@ -699,11 +726,22 @@ display_envelope(struct message *envelope, int flags)
default:
printf("UNKNOWN");
}
-
- printf("|%s|%s@%s|%s@%s|%d|%u\n",
+
+ printf("|%s|%s|%s@%s|%s@%s|%d|%u\n",
envelope->message_uid,
+ status,
envelope->sender.user, envelope->sender.domain,
envelope->recipient.user, envelope->recipient.domain,
envelope->lasttry,
envelope->retry);
}
+
+void
+getflag(u_int *bitmap, int bit, char *bitstr, char *buf, size_t len)
+{
+ if (*bitmap & bit) {
+ *bitmap &= ~bit;
+ strlcat(buf, bitstr, len);
+ strlcat(buf, ",", len);
+ }
+}