summaryrefslogtreecommitdiff
path: root/usr.sbin/smtpd/smtpctl.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin/smtpd/smtpctl.c')
-rw-r--r--usr.sbin/smtpd/smtpctl.c36
1 files changed, 35 insertions, 1 deletions
diff --git a/usr.sbin/smtpd/smtpctl.c b/usr.sbin/smtpd/smtpctl.c
index 964b5f5a4ef..d190a8e9096 100644
--- a/usr.sbin/smtpd/smtpctl.c
+++ b/usr.sbin/smtpd/smtpctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: smtpctl.c,v 1.134 2015/10/28 07:24:28 sunil Exp $ */
+/* $OpenBSD: smtpctl.c,v 1.135 2015/10/29 10:25:36 sunil Exp $ */
/*
* Copyright (c) 2013 Eric Faurot <eric@openbsd.org>
@@ -910,6 +910,38 @@ do_show_mta_block(int argc, struct parameter *argv)
return (0);
}
+static int
+do_discover(int argc, struct parameter *argv)
+{
+ uint64_t evpid;
+ uint32_t msgid;
+ size_t n_evp;
+
+ if (ibuf == NULL && !srv_connect())
+ errx(1, "smtpd doesn't seem to be running");
+
+ if (argv[0].type == P_EVPID) {
+ evpid = argv[0].u.u_evpid;
+ srv_send(IMSG_CTL_DISCOVER_EVPID, &evpid, sizeof evpid);
+ srv_recv(IMSG_CTL_DISCOVER_EVPID);
+ } else {
+ msgid = argv[0].u.u_msgid;
+ srv_send(IMSG_CTL_DISCOVER_MSGID, &msgid, sizeof msgid);
+ srv_recv(IMSG_CTL_DISCOVER_MSGID);
+ }
+
+ if (rlen == 0) {
+ srv_end();
+ return (0);
+ } else {
+ srv_read(&n_evp, sizeof n_evp);
+ srv_end();
+ }
+
+ printf("%zu envelope%s discovered\n", n_evp, (n_evp != 1) ? "s" : "");
+ return (0);
+}
+
int
main(int argc, char **argv)
{
@@ -941,6 +973,8 @@ main(int argc, char **argv)
if (setresgid(gid, gid, gid) == -1)
err(1, "setresgid");
+ cmd_install("discover <evpid>", do_discover);
+ cmd_install("discover <msgid>", do_discover);
cmd_install("encrypt", do_encrypt);
cmd_install("encrypt <str>", do_encrypt);
cmd_install("pause mta from <addr> for <str>", do_block_mta);