diff options
-rw-r--r-- | usr.sbin/smtpd/control.c | 10 | ||||
-rw-r--r-- | usr.sbin/smtpd/smtpctl.8 | 6 | ||||
-rw-r--r-- | usr.sbin/smtpd/smtpctl.c | 21 | ||||
-rw-r--r-- | usr.sbin/smtpd/smtpd.c | 3 | ||||
-rw-r--r-- | usr.sbin/smtpd/smtpd.h | 5 |
5 files changed, 38 insertions, 7 deletions
diff --git a/usr.sbin/smtpd/control.c b/usr.sbin/smtpd/control.c index 38320819564..d3b97b43076 100644 --- a/usr.sbin/smtpd/control.c +++ b/usr.sbin/smtpd/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.96 2014/02/04 15:22:39 eric Exp $ */ +/* $OpenBSD: control.c,v 1.97 2014/02/17 13:33:56 eric Exp $ */ /* * Copyright (c) 2012 Gilles Chehade <gilles@poolp.org> @@ -721,6 +721,14 @@ control_dispatch_ext(struct mproc *p, struct imsg *imsg) m_forward(p_mta, imsg); return; + case IMSG_CTL_SHOW_STATUS: + if (c->euid) + goto badcred; + + m_compose(p, IMSG_CTL_SHOW_STATUS, 0, 0, -1, &env->sc_flags, + sizeof(env->sc_flags)); + return; + case IMSG_CTL_MTA_BLOCK: case IMSG_CTL_MTA_UNBLOCK: if (c->euid) diff --git a/usr.sbin/smtpd/smtpctl.8 b/usr.sbin/smtpd/smtpctl.8 index 8afd395c31a..bce483ba1f9 100644 --- a/usr.sbin/smtpd/smtpctl.8 +++ b/usr.sbin/smtpd/smtpctl.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: smtpctl.8,v 1.46 2013/11/13 09:15:41 eric Exp $ +.\" $OpenBSD: smtpctl.8,v 1.47 2014/02/17 13:33:56 eric Exp $ .\" .\" Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org> .\" Copyright (c) 2012 Gilles Chehade <gilles@poolp.org> @@ -15,7 +15,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: November 13 2013 $ +.Dd $Mdocdate: February 17 2014 $ .Dt SMTPCTL 8 .Os .Sh NAME @@ -226,6 +226,8 @@ reactivate or discard it. .It Cm show stats Displays runtime statistics concerning .Xr smtpd 8 . +.It Cm show status +Shows if MTA, MDA and SMTP systems are currently running or paused. .It Cm stop Stop the server. .It Cm trace Ar subsystem diff --git a/usr.sbin/smtpd/smtpctl.c b/usr.sbin/smtpd/smtpctl.c index 8c040d3c7c6..84bd628a46b 100644 --- a/usr.sbin/smtpd/smtpctl.c +++ b/usr.sbin/smtpd/smtpctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smtpctl.c,v 1.115 2014/02/04 15:22:39 eric Exp $ */ +/* $OpenBSD: smtpctl.c,v 1.116 2014/02/17 13:33:56 eric Exp $ */ /* * Copyright (c) 2013 Eric Faurot <eric@openbsd.org> @@ -755,6 +755,24 @@ do_show_stats(int argc, struct parameter *argv) } static int +do_show_status(int argc, struct parameter *argv) +{ + uint32_t sc_flags; + + srv_send(IMSG_CTL_SHOW_STATUS, NULL, 0); + srv_recv(IMSG_CTL_SHOW_STATUS); + srv_read(&sc_flags, sizeof(sc_flags)); + srv_end(); + printf("MDA %s\n", + (sc_flags & SMTPD_MDA_PAUSED) ? "paused" : "running"); + printf("MTA %s\n", + (sc_flags & SMTPD_MTA_PAUSED) ? "paused" : "running"); + printf("SMTP %s\n", + (sc_flags & SMTPD_SMTP_PAUSED) ? "paused" : "running"); + return (0); +} + +static int do_stop(int argc, struct parameter *argv) { srv_send(IMSG_CTL_SHUTDOWN, NULL, 0); @@ -908,6 +926,7 @@ main(int argc, char **argv) cmd_install("show relays", do_show_relays); cmd_install("show routes", do_show_routes); cmd_install("show stats", do_show_stats); + cmd_install("show status", do_show_status); cmd_install("stop", do_stop); cmd_install("trace <str>", do_trace); cmd_install("unprofile <str>", do_unprofile); diff --git a/usr.sbin/smtpd/smtpd.c b/usr.sbin/smtpd/smtpd.c index cbe8aca73e6..d3ad8be811a 100644 --- a/usr.sbin/smtpd/smtpd.c +++ b/usr.sbin/smtpd/smtpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smtpd.c,v 1.212 2014/02/10 09:28:05 eric Exp $ */ +/* $OpenBSD: smtpd.c,v 1.213 2014/02/17 13:33:56 eric Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@poolp.org> @@ -1326,6 +1326,7 @@ imsg_to_str(int type) CASE(IMSG_CTL_LIST_ENVELOPES); CASE(IMSG_CTL_REMOVE); CASE(IMSG_CTL_SCHEDULE); + CASE(IMSG_CTL_SHOW_STATUS); CASE(IMSG_CTL_TRACE); CASE(IMSG_CTL_UNTRACE); diff --git a/usr.sbin/smtpd/smtpd.h b/usr.sbin/smtpd/smtpd.h index cb5d43aa559..b8b87fcbc5f 100644 --- a/usr.sbin/smtpd/smtpd.h +++ b/usr.sbin/smtpd/smtpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: smtpd.h,v 1.449 2014/02/10 09:28:05 eric Exp $ */ +/* $OpenBSD: smtpd.h,v 1.450 2014/02/17 13:33:56 eric Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@poolp.org> @@ -150,7 +150,7 @@ union lookup { * Bump IMSG_VERSION whenever a change is made to enum imsg_type. * This will ensure that we can never use a wrong version of smtpctl with smtpd. */ -#define IMSG_VERSION 8 +#define IMSG_VERSION 9 enum imsg_type { IMSG_NONE, @@ -171,6 +171,7 @@ enum imsg_type { IMSG_CTL_LIST_ENVELOPES, IMSG_CTL_REMOVE, IMSG_CTL_SCHEDULE, + IMSG_CTL_SHOW_STATUS, IMSG_CTL_TRACE, IMSG_CTL_UNTRACE, |