On Tue, 2020-12-29 at 08:57 +0100, Giovanni Bechis wrote:
> On 12/20/20 12:21 AM, gil...@poolp.org wrote:
> > December 19, 2020 11:26 PM, "Martijn van Duren" 
> > <openbsd+t...@list.imperialat.at> wrote:
> > 
> > > Personally I'd rather wait to keep the names in sync, especially since
> > > it's an easy 2 line diff that can easily be incorperated in the bigger
> > > thing. But it's not something I'm going to loose sleep over if others
> > > thing it can go in right now.
> > > 
> > 
> > Fair enough :-)
> > 
> > Below is the diff that changes all references to pony into dispatcher.
> > 
> > I didn't rename pony.c to dispatcher.c as this would break the diff, but if 
> > this gets
> > committed I'll submit a diff for the rename + Makefile bit
> > 
> I like it and it reads OK for me.
>  Giovanni
> 
Here's the final diff that moves pony.c to dispatcher.c and (including
in smtpd.h).

OK?

martijn@

Index: bounce.c
===================================================================
RCS file: /cvs/src/usr.sbin/smtpd/bounce.c,v
retrieving revision 1.82
diff -u -p -r1.82 bounce.c
--- bounce.c    24 Apr 2020 11:34:07 -0000      1.82
+++ bounce.c    30 Dec 2020 08:25:55 -0000
@@ -290,7 +290,7 @@ bounce_drain()
                }
 
                log_debug("debug: bounce: requesting new enqueue socket...");
-               m_compose(p_pony, IMSG_QUEUE_SMTP_SESSION, 0, 0, -1, NULL, 0);
+               m_compose(p_dispatcher, IMSG_QUEUE_SMTP_SESSION, 0, 0, -1, 
NULL, 0);
 
                running += 1;
        }
Index: ca.c
===================================================================
RCS file: /cvs/src/usr.sbin/smtpd/ca.c,v
retrieving revision 1.36
diff -u -p -r1.36 ca.c
--- ca.c        21 Sep 2019 07:46:53 -0000      1.36
+++ ca.c        30 Dec 2020 08:25:55 -0000
@@ -110,10 +110,10 @@ ca(void)
 
        config_peer(PROC_CONTROL);
        config_peer(PROC_PARENT);
-       config_peer(PROC_PONY);
+       config_peer(PROC_DISPATCHER);
 
        /* Ignore them until we get our config */
-       mproc_disable(p_pony);
+       mproc_disable(p_dispatcher);
 
        if (pledge("stdio", NULL) == -1)
                err(1, "pledge");
@@ -246,7 +246,7 @@ ca_imsg(struct mproc *p, struct imsg *im
                ca_init();
 
                /* Start fulfilling requests */
-               mproc_enable(p_pony);
+               mproc_enable(p_dispatcher);
                return;
 
        case IMSG_CTL_VERBOSE:
@@ -385,7 +385,7 @@ rsae_send_imsg(int flen, const unsigned 
                        if (n == 0)
                                break;
 
-                       log_imsg(PROC_PONY, PROC_CA, &imsg);
+                       log_imsg(PROC_DISPATCHER, PROC_CA, &imsg);
 
                        switch (imsg.hdr.type) {
                        case IMSG_CA_RSA_PRIVENC:
@@ -393,7 +393,7 @@ rsae_send_imsg(int flen, const unsigned 
                                break;
                        default:
                                /* Another imsg is queued up in the buffer */
-                               pony_imsg(p_ca, &imsg);
+                               dispatcher_imsg(p_ca, &imsg);
                                imsg_free(&imsg);
                                continue;
                        }
@@ -569,14 +569,14 @@ ecdsae_send_enc_imsg(const unsigned char
                        if (n == 0)
                                break;
 
-                       log_imsg(PROC_PONY, PROC_CA, &imsg);
+                       log_imsg(PROC_DISPATCHER, PROC_CA, &imsg);
 
                        switch (imsg.hdr.type) {
                        case IMSG_CA_ECDSA_SIGN:
                                break;
                        default:
                                /* Another imsg is queued up in the buffer */
-                               pony_imsg(p_ca, &imsg);
+                               dispatcher_imsg(p_ca, &imsg);
                                imsg_free(&imsg);
                                continue;
                        }
Index: config.c
===================================================================
RCS file: /cvs/src/usr.sbin/smtpd/config.c,v
retrieving revision 1.51
diff -u -p -r1.51 config.c
--- config.c    18 Dec 2019 10:00:39 -0000      1.51
+++ config.c    30 Dec 2020 08:25:55 -0000
@@ -325,8 +325,8 @@ config_peer(enum smtp_proc_type proc)
                p = p_queue;
        else if (proc == PROC_SCHEDULER)
                p = p_scheduler;
-       else if (proc == PROC_PONY)
-               p = p_pony;
+       else if (proc == PROC_DISPATCHER)
+               p = p_dispatcher;
        else if (proc == PROC_CA)
                p = p_ca;
        else
Index: control.c
===================================================================
RCS file: /cvs/src/usr.sbin/smtpd/control.c,v
retrieving revision 1.125
diff -u -p -r1.125 control.c
--- control.c   23 Sep 2020 19:11:50 -0000      1.125
+++ control.c   30 Dec 2020 08:25:55 -0000
@@ -248,7 +248,7 @@ control(void)
        config_peer(PROC_QUEUE);
        config_peer(PROC_PARENT);
        config_peer(PROC_LKA);
-       config_peer(PROC_PONY);
+       config_peer(PROC_DISPATCHER);
        config_peer(PROC_CA);
 
        control_listen();
@@ -450,7 +450,7 @@ control_dispatch_ext(struct mproc *p, st
                        m_compose(p, IMSG_CTL_FAIL, 0, 0, -1, NULL, 0);
                        return;
                }
-               m_compose(p_pony, IMSG_CTL_SMTP_SESSION, c->id, 0, -1,
+               m_compose(p_dispatcher, IMSG_CTL_SMTP_SESSION, c->id, 0, -1,
                    &c->euid, sizeof(c->euid));
                return;
 
@@ -597,7 +597,7 @@ control_dispatch_ext(struct mproc *p, st
                }
                log_info("info: smtp paused");
                env->sc_flags |= SMTPD_SMTP_PAUSED;
-               m_compose(p_pony, IMSG_CTL_PAUSE_SMTP, 0, 0, -1, NULL, 0);
+               m_compose(p_dispatcher, IMSG_CTL_PAUSE_SMTP, 0, 0, -1, NULL, 0);
                m_compose(p, IMSG_CTL_OK, 0, 0, -1, NULL, 0);
                return;
 
@@ -647,7 +647,7 @@ control_dispatch_ext(struct mproc *p, st
                }
                log_info("info: smtp resumed");
                env->sc_flags &= ~SMTPD_SMTP_PAUSED;
-               m_forward(p_pony, imsg);
+               m_forward(p_dispatcher, imsg);
                m_compose(p, IMSG_CTL_OK, 0, 0, -1, NULL, 0);
                return;
 
@@ -655,7 +655,7 @@ control_dispatch_ext(struct mproc *p, st
                if (c->euid)
                        goto badcred;
 
-               m_forward(p_pony, imsg);
+               m_forward(p_dispatcher, imsg);
                m_compose(p, IMSG_CTL_OK, 0, 0, -1, NULL, 0);
                return;
 
@@ -682,7 +682,7 @@ control_dispatch_ext(struct mproc *p, st
                        goto badcred;
 
                imsg->hdr.peerid = c->id;
-               m_forward(p_pony, imsg);
+               m_forward(p_dispatcher, imsg);
                return;
 
        case IMSG_CTL_SHOW_STATUS:
@@ -701,10 +701,10 @@ control_dispatch_ext(struct mproc *p, st
                if (imsg->hdr.len - IMSG_HEADER_SIZE <= sizeof(ss))
                        goto invalid;
                memmove(&ss, imsg->data, sizeof(ss));
-               m_create(p_pony, imsg->hdr.type, c->id, 0, -1);
-               m_add_sockaddr(p_pony, (struct sockaddr *)&ss);
-               m_add_string(p_pony, (char *)imsg->data + sizeof(ss));
-               m_close(p_pony);
+               m_create(p_dispatcher, imsg->hdr.type, c->id, 0, -1);
+               m_add_sockaddr(p_dispatcher, (struct sockaddr *)&ss);
+               m_add_string(p_dispatcher, (char *)imsg->data + sizeof(ss));
+               m_close(p_dispatcher);
                return;
 
        case IMSG_CTL_SCHEDULE:
@@ -780,9 +780,9 @@ control_broadcast_verbose(int msg, int v
        m_add_int(p_lka, v);
        m_close(p_lka);
 
-       m_create(p_pony, msg, 0, 0, -1);
-       m_add_int(p_pony, v);
-       m_close(p_pony);
+       m_create(p_dispatcher, msg, 0, 0, -1);
+       m_add_int(p_dispatcher, v);
+       m_close(p_dispatcher);
 
        m_create(p_queue, msg, 0, 0, -1);
        m_add_int(p_queue, v);
Index: dispatcher.c
===================================================================
RCS file: dispatcher.c
diff -N dispatcher.c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ dispatcher.c        30 Dec 2020 08:25:55 -0000
@@ -0,0 +1,208 @@
+/*     $OpenBSD: pony.c,v 1.27 2019/06/13 11:45:35 eric Exp $  */
+
+/*
+ * Copyright (c) 2014 Gilles Chehade <gil...@poolp.org>
+ *
+ * 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/socket.h>
+
+#include <ctype.h>
+#include <err.h>
+#include <errno.h>
+#include <event.h>
+#include <imsg.h>
+#include <inttypes.h>
+#include <pwd.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <unistd.h>
+#include <limits.h>
+#include <grp.h>
+
+#include "smtpd.h"
+#include "log.h"
+
+void mda_imsg(struct mproc *, struct imsg *);
+void mta_imsg(struct mproc *, struct imsg *);
+void smtp_imsg(struct mproc *, struct imsg *);
+
+static void dispatcher_shutdown(void);
+
+void
+dispatcher_imsg(struct mproc *p, struct imsg *imsg)
+{
+       struct msg      m;
+       int             v;
+
+       if (imsg == NULL)
+               dispatcher_shutdown();
+
+       switch (imsg->hdr.type) {
+
+       case IMSG_GETADDRINFO:
+       case IMSG_GETADDRINFO_END:
+       case IMSG_GETNAMEINFO:
+       case IMSG_RES_QUERY:
+               resolver_dispatch_result(p, imsg);
+               return;
+
+       case IMSG_CERT_INIT:
+       case IMSG_CERT_VERIFY:
+               cert_dispatch_result(p, imsg);
+               return;
+
+       case IMSG_CONF_START:
+               return;
+       case IMSG_CONF_END:
+               smtp_configure();
+               return;
+       case IMSG_CTL_VERBOSE:
+               m_msg(&m, imsg);
+               m_get_int(&m, &v);
+               m_end(&m);
+               log_trace_verbose(v);
+               return;
+       case IMSG_CTL_PROFILE:
+               m_msg(&m, imsg);
+               m_get_int(&m, &v);
+               m_end(&m);
+               profiling = v;
+               return;
+
+       /* smtp imsg */
+       case IMSG_SMTP_CHECK_SENDER:
+       case IMSG_SMTP_EXPAND_RCPT:
+       case IMSG_SMTP_LOOKUP_HELO:
+       case IMSG_SMTP_AUTHENTICATE:
+       case IMSG_SMTP_MESSAGE_COMMIT:
+       case IMSG_SMTP_MESSAGE_CREATE:
+       case IMSG_SMTP_MESSAGE_OPEN:
+       case IMSG_FILTER_SMTP_PROTOCOL:
+       case IMSG_FILTER_SMTP_DATA_BEGIN:
+       case IMSG_QUEUE_ENVELOPE_SUBMIT:
+       case IMSG_QUEUE_ENVELOPE_COMMIT:
+       case IMSG_QUEUE_SMTP_SESSION:
+       case IMSG_CTL_SMTP_SESSION:
+       case IMSG_CTL_PAUSE_SMTP:
+       case IMSG_CTL_RESUME_SMTP:
+               smtp_imsg(p, imsg);
+               return;
+
+        /* mta imsg */
+       case IMSG_QUEUE_TRANSFER:
+       case IMSG_MTA_OPEN_MESSAGE:
+       case IMSG_MTA_LOOKUP_CREDENTIALS:
+       case IMSG_MTA_LOOKUP_SMARTHOST:
+       case IMSG_MTA_LOOKUP_SOURCE:
+       case IMSG_MTA_LOOKUP_HELO:
+       case IMSG_MTA_DNS_HOST:
+       case IMSG_MTA_DNS_HOST_END:
+       case IMSG_MTA_DNS_MX_PREFERENCE:
+       case IMSG_CTL_RESUME_ROUTE:
+       case IMSG_CTL_MTA_SHOW_HOSTS:
+       case IMSG_CTL_MTA_SHOW_RELAYS:
+       case IMSG_CTL_MTA_SHOW_ROUTES:
+       case IMSG_CTL_MTA_SHOW_HOSTSTATS:
+       case IMSG_CTL_MTA_BLOCK:
+       case IMSG_CTL_MTA_UNBLOCK:
+       case IMSG_CTL_MTA_SHOW_BLOCK:
+               mta_imsg(p, imsg);
+               return;
+
+        /* mda imsg */
+       case IMSG_MDA_LOOKUP_USERINFO:
+       case IMSG_QUEUE_DELIVER:
+       case IMSG_MDA_OPEN_MESSAGE:
+       case IMSG_MDA_FORK:
+       case IMSG_MDA_DONE:
+               mda_imsg(p, imsg);
+               return;
+       default:
+               break;
+       }
+
+       errx(1, "session_imsg: unexpected %s imsg", 
imsg_to_str(imsg->hdr.type));
+}
+
+static void
+dispatcher_shutdown(void)
+{
+       log_debug("debug: dispatcher agent exiting");
+       _exit(0);
+}
+
+int
+dispatcher(void)
+{
+       struct passwd   *pw;
+
+       mda_postfork();
+       mta_postfork();
+       smtp_postfork();
+
+       /* do not purge listeners and pki, they are purged
+        * in smtp_configure()
+        */
+       purge_config(PURGE_TABLES|PURGE_RULES);
+
+       if ((pw = getpwnam(SMTPD_USER)) == NULL)
+               fatalx("unknown user " SMTPD_USER);
+
+       if (chroot(PATH_CHROOT) == -1)
+               fatal("dispatcher: chroot");
+       if (chdir("/") == -1)
+               fatal("dispatcher: chdir(\"/\")");
+
+       config_process(PROC_DISPATCHER);
+
+       if (setgroups(1, &pw->pw_gid) ||
+           setresgid(pw->pw_gid, pw->pw_gid, pw->pw_gid) ||
+           setresuid(pw->pw_uid, pw->pw_uid, pw->pw_uid))
+               fatal("dispatcher: cannot drop privileges");
+
+       imsg_callback = dispatcher_imsg;
+       event_init();
+
+       mda_postprivdrop();
+       mta_postprivdrop();
+       smtp_postprivdrop();
+
+       signal(SIGINT, SIG_IGN);
+       signal(SIGTERM, SIG_IGN);
+       signal(SIGPIPE, SIG_IGN);
+       signal(SIGHUP, SIG_IGN);
+
+       config_peer(PROC_PARENT);
+       config_peer(PROC_QUEUE);
+       config_peer(PROC_LKA);
+       config_peer(PROC_CONTROL);
+       config_peer(PROC_CA);
+
+       ca_engine_init();
+
+       if (pledge("stdio inet unix recvfd sendfd", NULL) == -1)
+               err(1, "pledge");
+
+       event_dispatch();
+       fatalx("exited event loop");
+
+       return (0);
+}
Index: lka.c
===================================================================
RCS file: /cvs/src/usr.sbin/smtpd/lka.c,v
retrieving revision 1.243
diff -u -p -r1.243 lka.c
--- lka.c       21 Dec 2019 10:23:37 -0000      1.243
+++ lka.c       30 Dec 2020 08:25:55 -0000
@@ -334,7 +334,7 @@ lka_imsg(struct mproc *p, struct imsg *i
 
        case IMSG_LKA_AUTHENTICATE:
                imsg->hdr.type = IMSG_SMTP_AUTHENTICATE;
-               m_forward(p_pony, imsg);
+               m_forward(p_dispatcher, imsg);
                return;
 
        case IMSG_CTL_VERBOSE:
@@ -701,10 +701,10 @@ lka(void)
        config_peer(PROC_PARENT);
        config_peer(PROC_QUEUE);
        config_peer(PROC_CONTROL);
-       config_peer(PROC_PONY);
+       config_peer(PROC_DISPATCHER);
 
        /* Ignore them until we get our config */
-       mproc_disable(p_pony);
+       mproc_disable(p_dispatcher);
 
        lka_report_init();
        lka_filter_init();
@@ -729,7 +729,7 @@ proc_timeout(int fd, short event, void *
                goto reset;
 
        lka_filter_ready();
-       mproc_enable(p_pony);
+       mproc_enable(p_dispatcher);
        return;
 
 reset:
Index: lka_filter.c
===================================================================
RCS file: /cvs/src/usr.sbin/smtpd/lka_filter.c,v
retrieving revision 1.65
diff -u -p -r1.65 lka_filter.c
--- lka_filter.c        23 Dec 2020 20:17:49 -0000      1.65
+++ lka_filter.c        30 Dec 2020 08:25:55 -0000
@@ -559,10 +559,10 @@ lka_filter_data_begin(uint64_t reqid)
        io_set_callback(fs->io, filter_session_io, fs);
 
 end:
-       m_create(p_pony, IMSG_FILTER_SMTP_DATA_BEGIN, 0, 0, fd);
-       m_add_id(p_pony, reqid);
-       m_add_int(p_pony, fd != -1 ? 1 : 0);
-       m_close(p_pony);
+       m_create(p_dispatcher, IMSG_FILTER_SMTP_DATA_BEGIN, 0, 0, fd);
+       m_add_id(p_dispatcher, reqid);
+       m_add_int(p_dispatcher, fd != -1 ? 1 : 0);
+       m_close(p_dispatcher);
        log_trace(TRACE_FILTERS, "%016"PRIx64" filters data-begin fd=%d", 
reqid, fd);
 }
 
@@ -981,49 +981,49 @@ filter_data_query(struct filter *filter,
 static void
 filter_result_proceed(uint64_t reqid)
 {
-       m_create(p_pony, IMSG_FILTER_SMTP_PROTOCOL, 0, 0, -1);
-       m_add_id(p_pony, reqid);
-       m_add_int(p_pony, FILTER_PROCEED);
-       m_close(p_pony);
+       m_create(p_dispatcher, IMSG_FILTER_SMTP_PROTOCOL, 0, 0, -1);
+       m_add_id(p_dispatcher, reqid);
+       m_add_int(p_dispatcher, FILTER_PROCEED);
+       m_close(p_dispatcher);
 }
 
 static void
 filter_result_junk(uint64_t reqid)
 {
-       m_create(p_pony, IMSG_FILTER_SMTP_PROTOCOL, 0, 0, -1);
-       m_add_id(p_pony, reqid);
-       m_add_int(p_pony, FILTER_JUNK);
-       m_close(p_pony);
+       m_create(p_dispatcher, IMSG_FILTER_SMTP_PROTOCOL, 0, 0, -1);
+       m_add_id(p_dispatcher, reqid);
+       m_add_int(p_dispatcher, FILTER_JUNK);
+       m_close(p_dispatcher);
 }
 
 static void
 filter_result_rewrite(uint64_t reqid, const char *param)
 {
-       m_create(p_pony, IMSG_FILTER_SMTP_PROTOCOL, 0, 0, -1);
-       m_add_id(p_pony, reqid);
-       m_add_int(p_pony, FILTER_REWRITE);
-       m_add_string(p_pony, param);
-       m_close(p_pony);
+       m_create(p_dispatcher, IMSG_FILTER_SMTP_PROTOCOL, 0, 0, -1);
+       m_add_id(p_dispatcher, reqid);
+       m_add_int(p_dispatcher, FILTER_REWRITE);
+       m_add_string(p_dispatcher, param);
+       m_close(p_dispatcher);
 }
 
 static void
 filter_result_reject(uint64_t reqid, const char *message)
 {
-       m_create(p_pony, IMSG_FILTER_SMTP_PROTOCOL, 0, 0, -1);
-       m_add_id(p_pony, reqid);
-       m_add_int(p_pony, FILTER_REJECT);
-       m_add_string(p_pony, message);
-       m_close(p_pony);
+       m_create(p_dispatcher, IMSG_FILTER_SMTP_PROTOCOL, 0, 0, -1);
+       m_add_id(p_dispatcher, reqid);
+       m_add_int(p_dispatcher, FILTER_REJECT);
+       m_add_string(p_dispatcher, message);
+       m_close(p_dispatcher);
 }
 
 static void
 filter_result_disconnect(uint64_t reqid, const char *message)
 {
-       m_create(p_pony, IMSG_FILTER_SMTP_PROTOCOL, 0, 0, -1);
-       m_add_id(p_pony, reqid);
-       m_add_int(p_pony, FILTER_DISCONNECT);
-       m_add_string(p_pony, message);
-       m_close(p_pony);
+       m_create(p_dispatcher, IMSG_FILTER_SMTP_PROTOCOL, 0, 0, -1);
+       m_add_id(p_dispatcher, reqid);
+       m_add_int(p_dispatcher, FILTER_DISCONNECT);
+       m_add_string(p_dispatcher, message);
+       m_close(p_dispatcher);
 }
 
 
Index: lka_session.c
===================================================================
RCS file: /cvs/src/usr.sbin/smtpd/lka_session.c,v
retrieving revision 1.93
diff -u -p -r1.93 lka_session.c
--- lka_session.c       20 Sep 2019 17:46:05 -0000      1.93
+++ lka_session.c       30 Dec 2020 08:25:55 -0000
@@ -215,20 +215,20 @@ lka_resume(struct lka_session *lks)
        }
     error:
        if (lks->error) {
-               m_create(p_pony, IMSG_SMTP_EXPAND_RCPT, 0, 0, -1);
-               m_add_id(p_pony, lks->id);
-               m_add_int(p_pony, lks->error);
+               m_create(p_dispatcher, IMSG_SMTP_EXPAND_RCPT, 0, 0, -1);
+               m_add_id(p_dispatcher, lks->id);
+               m_add_int(p_dispatcher, lks->error);
 
                if (lks->errormsg)
-                       m_add_string(p_pony, lks->errormsg);
+                       m_add_string(p_dispatcher, lks->errormsg);
                else {
                        if (lks->error == LKA_PERMFAIL)
-                               m_add_string(p_pony, "550 Invalid recipient");
+                               m_add_string(p_dispatcher, "550 Invalid 
recipient");
                        else if (lks->error == LKA_TEMPFAIL)
-                               m_add_string(p_pony, "451 Temporary failure");
+                               m_add_string(p_dispatcher, "451 Temporary 
failure");
                }
 
-               m_close(p_pony);
+               m_close(p_dispatcher);
                while ((ep = TAILQ_FIRST(&lks->deliverylist)) != NULL) {
                        TAILQ_REMOVE(&lks->deliverylist, ep, entry);
                        free(ep);
Index: parse.y
===================================================================
RCS file: /cvs/src/usr.sbin/smtpd/parse.y,v
retrieving revision 1.281
diff -u -p -r1.281 parse.y
--- parse.y     23 Sep 2020 19:11:50 -0000      1.281
+++ parse.y     30 Dec 2020 08:25:55 -0000
@@ -103,7 +103,7 @@ struct mta_limits   *limits;
 static struct pki      *pki;
 static struct ca       *sca;
 
-struct dispatcher      *dispatcher;
+struct dispatcher      *dsp;
 struct rule            *rule;
 struct filter_proc     *processor;
 struct filter_config   *filter_config;
@@ -582,37 +582,37 @@ SRS KEY STRING {
 
 dispatcher_local_option:
 USER STRING {
-       if (dispatcher->u.local.is_mbox) {
+       if (dsp->u.local.is_mbox) {
                yyerror("user may not be specified for this dispatcher");
                YYERROR;
        }
 
-       if (dispatcher->u.local.forward_only) {
+       if (dsp->u.local.forward_only) {
                yyerror("user may not be specified for forward-only");
                YYERROR;
        }
 
-       if (dispatcher->u.local.expand_only) {
+       if (dsp->u.local.expand_only) {
                yyerror("user may not be specified for expand-only");
                YYERROR;
        }
 
-       if (dispatcher->u.local.user) {
+       if (dsp->u.local.user) {
                yyerror("user already specified for this dispatcher");
                YYERROR;
        }
 
-       dispatcher->u.local.user = $2;
+       dsp->u.local.user = $2;
 }
 | ALIAS tables {
        struct table   *t = $2;
 
-       if (dispatcher->u.local.table_alias) {
+       if (dsp->u.local.table_alias) {
                yyerror("alias mapping already specified for this dispatcher");
                YYERROR;
        }
 
-       if (dispatcher->u.local.table_virtual) {
+       if (dsp->u.local.table_virtual) {
                yyerror("virtual mapping already specified for this 
dispatcher");
                YYERROR;
        }
@@ -623,17 +623,17 @@ USER STRING {
                YYERROR;
        }
 
-       dispatcher->u.local.table_alias = strdup(t->t_name);
+       dsp->u.local.table_alias = strdup(t->t_name);
 }
 | VIRTUAL tables {
        struct table   *t = $2;
 
-       if (dispatcher->u.local.table_virtual) {
+       if (dsp->u.local.table_virtual) {
                yyerror("virtual mapping already specified for this 
dispatcher");
                YYERROR;
        }
 
-       if (dispatcher->u.local.table_alias) {
+       if (dsp->u.local.table_alias) {
                yyerror("alias mapping already specified for this dispatcher");
                YYERROR;
        }
@@ -644,12 +644,12 @@ USER STRING {
                YYERROR;
        }
 
-       dispatcher->u.local.table_virtual = strdup(t->t_name);
+       dsp->u.local.table_virtual = strdup(t->t_name);
 }
 | USERBASE tables {
        struct table   *t = $2;
 
-       if (dispatcher->u.local.table_userbase) {
+       if (dsp->u.local.table_userbase) {
                yyerror("userbase mapping already specified for this 
dispatcher");
                YYERROR;
        }
@@ -660,14 +660,14 @@ USER STRING {
                YYERROR;
        }
 
-       dispatcher->u.local.table_userbase = strdup(t->t_name);
+       dsp->u.local.table_userbase = strdup(t->t_name);
 }
 | WRAPPER STRING {
        if (! dict_get(conf->sc_mda_wrappers, $2)) {
                yyerror("no mda wrapper with that name: %s", $2);
                YYERROR;
        }
-       dispatcher->u.local.mda_wrapper = $2;
+       dsp->u.local.mda_wrapper = $2;
 }
 ;
 
@@ -678,67 +678,67 @@ dispatcher_local_option dispatcher_local
 
 dispatcher_local:
 MBOX {
-       dispatcher->u.local.is_mbox = 1;
-       asprintf(&dispatcher->u.local.command, "/usr/libexec/mail.local -f 
%%{mbox.from} -- %%{user.username}");
+       dsp->u.local.is_mbox = 1;
+       asprintf(&dsp->u.local.command, "/usr/libexec/mail.local -f 
%%{mbox.from} -- %%{user.username}");
 } dispatcher_local_options
 | MAILDIR {
-       asprintf(&dispatcher->u.local.command, "/usr/libexec/mail.maildir");
+       asprintf(&dsp->u.local.command, "/usr/libexec/mail.maildir");
 } dispatcher_local_options
 | MAILDIR JUNK {
-       asprintf(&dispatcher->u.local.command, "/usr/libexec/mail.maildir -j");
+       asprintf(&dsp->u.local.command, "/usr/libexec/mail.maildir -j");
 } dispatcher_local_options
 | MAILDIR STRING {
        if (strncmp($2, "~/", 2) == 0)
-               asprintf(&dispatcher->u.local.command,
+               asprintf(&dsp->u.local.command,
                    "/usr/libexec/mail.maildir \"%%{user.directory}/%s\"", 
$2+2);
        else
-               asprintf(&dispatcher->u.local.command,
+               asprintf(&dsp->u.local.command,
                    "/usr/libexec/mail.maildir \"%s\"", $2);
 } dispatcher_local_options
 | MAILDIR STRING JUNK {
        if (strncmp($2, "~/", 2) == 0)
-               asprintf(&dispatcher->u.local.command,
+               asprintf(&dsp->u.local.command,
                    "/usr/libexec/mail.maildir -j \"%%{user.directory}/%s\"", 
$2+2);
        else
-               asprintf(&dispatcher->u.local.command,
+               asprintf(&dsp->u.local.command,
                    "/usr/libexec/mail.maildir -j \"%s\"", $2);
 } dispatcher_local_options
 | LMTP STRING {
-       asprintf(&dispatcher->u.local.command,
+       asprintf(&dsp->u.local.command,
            "/usr/libexec/mail.lmtp -d %s -u", $2);
-       dispatcher->u.local.user = SMTPD_USER;
+       dsp->u.local.user = SMTPD_USER;
 } dispatcher_local_options
 | LMTP STRING RCPT_TO {
-       asprintf(&dispatcher->u.local.command,
+       asprintf(&dsp->u.local.command,
            "/usr/libexec/mail.lmtp -d %s -r", $2);
-       dispatcher->u.local.user = SMTPD_USER;
+       dsp->u.local.user = SMTPD_USER;
 } dispatcher_local_options
 | MDA STRING {
-       asprintf(&dispatcher->u.local.command,
+       asprintf(&dsp->u.local.command,
            "/usr/libexec/mail.mda \"%s\"", $2);
 } dispatcher_local_options
 | FORWARD_ONLY {
-       dispatcher->u.local.forward_only = 1;
+       dsp->u.local.forward_only = 1;
 } dispatcher_local_options
 | EXPAND_ONLY {
-       dispatcher->u.local.expand_only = 1;
+       dsp->u.local.expand_only = 1;
 } dispatcher_local_options
 
 ;
 
 dispatcher_remote_option:
 HELO STRING {
-       if (dispatcher->u.remote.helo) {
+       if (dsp->u.remote.helo) {
                yyerror("helo already specified for this dispatcher");
                YYERROR;
        }
 
-       dispatcher->u.remote.helo = $2;
+       dsp->u.remote.helo = $2;
 }
 | HELO_SRC tables {
        struct table   *t = $2;
 
-       if (dispatcher->u.remote.helo_source) {
+       if (dsp->u.remote.helo_source) {
                yyerror("helo-source mapping already specified for this 
dispatcher");
                YYERROR;
        }
@@ -748,28 +748,28 @@ HELO STRING {
                YYERROR;
        }
 
-       dispatcher->u.remote.helo_source = strdup(t->t_name);
+       dsp->u.remote.helo_source = strdup(t->t_name);
 }
 | PKI STRING {
-       if (dispatcher->u.remote.pki) {
+       if (dsp->u.remote.pki) {
                yyerror("pki already specified for this dispatcher");
                YYERROR;
        }
 
-       dispatcher->u.remote.pki = $2;
+       dsp->u.remote.pki = $2;
 }
 | CA STRING {
-       if (dispatcher->u.remote.ca) {
+       if (dsp->u.remote.ca) {
                yyerror("ca already specified for this dispatcher");
                YYERROR;
        }
 
-       dispatcher->u.remote.ca = $2;
+       dsp->u.remote.ca = $2;
 }
 | SRC tables {
        struct table   *t = $2;
 
-       if (dispatcher->u.remote.source) {
+       if (dsp->u.remote.source) {
                yyerror("source mapping already specified for this dispatcher");
                YYERROR;
        }
@@ -780,49 +780,49 @@ HELO STRING {
                YYERROR;
        }
 
-       dispatcher->u.remote.source = strdup(t->t_name);
+       dsp->u.remote.source = strdup(t->t_name);
 }
 | MAIL_FROM STRING {
-       if (dispatcher->u.remote.mail_from) {
+       if (dsp->u.remote.mail_from) {
                yyerror("mail-from already specified for this dispatcher");
                YYERROR;
        }
 
-       dispatcher->u.remote.mail_from = $2;
+       dsp->u.remote.mail_from = $2;
 }
 | BACKUP MX STRING {
-       if (dispatcher->u.remote.backup) {
+       if (dsp->u.remote.backup) {
                yyerror("backup already specified for this dispatcher");
                YYERROR;
        }
-       if (dispatcher->u.remote.smarthost) {
+       if (dsp->u.remote.smarthost) {
                yyerror("backup and host are mutually exclusive");
                YYERROR;
        }
 
-       dispatcher->u.remote.backup = 1;
-       dispatcher->u.remote.backupmx = $3;
+       dsp->u.remote.backup = 1;
+       dsp->u.remote.backupmx = $3;
 }
 | BACKUP {
-       if (dispatcher->u.remote.backup) {
+       if (dsp->u.remote.backup) {
                yyerror("backup already specified for this dispatcher");
                YYERROR;
        }
-       if (dispatcher->u.remote.smarthost) {
+       if (dsp->u.remote.smarthost) {
                yyerror("backup and host are mutually exclusive");
                YYERROR;
        }
 
-       dispatcher->u.remote.backup = 1;
+       dsp->u.remote.backup = 1;
 }
 | HOST tables {
        struct table   *t = $2;
 
-       if (dispatcher->u.remote.smarthost) {
+       if (dsp->u.remote.smarthost) {
                yyerror("host mapping already specified for this dispatcher");
                YYERROR;
        }
-       if (dispatcher->u.remote.backup) {
+       if (dsp->u.remote.backup) {
                yyerror("backup and host are mutually exclusive");
                YYERROR;
        }
@@ -833,16 +833,16 @@ HELO STRING {
                YYERROR;
        }
 
-       dispatcher->u.remote.smarthost = strdup(t->t_name);
+       dsp->u.remote.smarthost = strdup(t->t_name);
 }
 | DOMAIN tables {
        struct table   *t = $2;
 
-       if (dispatcher->u.remote.smarthost) {
+       if (dsp->u.remote.smarthost) {
                yyerror("host mapping already specified for this dispatcher");
                YYERROR;
        }
-       if (dispatcher->u.remote.backup) {
+       if (dsp->u.remote.backup) {
                yyerror("backup and domain are mutually exclusive");
                YYERROR;
        }
@@ -853,35 +853,35 @@ HELO STRING {
                YYERROR;
        }
 
-       dispatcher->u.remote.smarthost = strdup(t->t_name);
-       dispatcher->u.remote.smarthost_domain = 1;
+       dsp->u.remote.smarthost = strdup(t->t_name);
+       dsp->u.remote.smarthost_domain = 1;
 }
 | TLS {
-       if (dispatcher->u.remote.tls_required == 1) {
+       if (dsp->u.remote.tls_required == 1) {
                yyerror("tls already specified for this dispatcher");
                YYERROR;
        }
 
-       dispatcher->u.remote.tls_required = 1;
+       dsp->u.remote.tls_required = 1;
 }
 | TLS NO_VERIFY {
-       if (dispatcher->u.remote.tls_required == 1) {
+       if (dsp->u.remote.tls_required == 1) {
                yyerror("tls already specified for this dispatcher");
                YYERROR;
        }
 
-       dispatcher->u.remote.tls_required = 1;
-       dispatcher->u.remote.tls_noverify = 1;
+       dsp->u.remote.tls_required = 1;
+       dsp->u.remote.tls_noverify = 1;
 }
 | AUTH tables {
        struct table   *t = $2;
 
-       if (dispatcher->u.remote.smarthost == NULL) {
+       if (dsp->u.remote.smarthost == NULL) {
                yyerror("auth may not be specified without host on a 
dispatcher");
                YYERROR;
        }
 
-       if (dispatcher->u.remote.auth) {
+       if (dsp->u.remote.auth) {
                yyerror("auth mapping already specified for this dispatcher");
                YYERROR;
        }
@@ -892,12 +892,12 @@ HELO STRING {
                YYERROR;
        }
 
-       dispatcher->u.remote.auth = strdup(t->t_name);
+       dsp->u.remote.auth = strdup(t->t_name);
 }
 | FILTER STRING {
        struct filter_config *fc;
 
-       if (dispatcher->u.remote.filtername) {
+       if (dsp->u.remote.filtername) {
                yyerror("filter already specified for this dispatcher");
                YYERROR;
        }
@@ -908,13 +908,13 @@ HELO STRING {
                YYERROR;
        }
        fc->filter_subsystem |= FILTER_SUBSYSTEM_SMTP_OUT;
-       dispatcher->u.remote.filtername = $2;
+       dsp->u.remote.filtername = $2;
 }
 | FILTER {
        char    buffer[128];
        char    *filtername;
 
-       if (dispatcher->u.remote.filtername) {
+       if (dsp->u.remote.filtername) {
                yyerror("filter already specified for this dispatcher");
                YYERROR;
        }
@@ -928,9 +928,9 @@ HELO STRING {
        filter_config->filter_type = FILTER_TYPE_CHAIN;
        filter_config->filter_subsystem |= FILTER_SUBSYSTEM_SMTP_OUT;
        dict_init(&filter_config->chain_procs);
-       dispatcher->u.remote.filtername = filtername;
+       dsp->u.remote.filtername = filtername;
 } '{' filter_list '}' {
-       dict_set(conf->sc_filters_dict, dispatcher->u.remote.filtername, 
filter_config);
+       dict_set(conf->sc_filters_dict, dsp->u.remote.filtername, 
filter_config);
        filter_config = NULL;
 }
 | SRS {
@@ -938,12 +938,12 @@ HELO STRING {
                yyerror("an srs key is required for srs to be specified in an 
action");
                YYERROR;
        }
-       if (dispatcher->u.remote.srs == 1) {
+       if (dsp->u.remote.srs == 1) {
                yyerror("srs already specified for this dispatcher");
                YYERROR;
        }
 
-       dispatcher->u.remote.srs = 1;
+       dsp->u.remote.srs = 1;
 }
 ;
 
@@ -958,22 +958,22 @@ RELAY dispatcher_remote_options
 
 dispatcher_type:
 dispatcher_local {
-       dispatcher->type = DISPATCHER_LOCAL;
+       dsp->type = DISPATCHER_LOCAL;
 }
 | dispatcher_remote {
-       dispatcher->type = DISPATCHER_REMOTE;
+       dsp->type = DISPATCHER_REMOTE;
 }
 ;
 
 dispatcher_option:
 TTL STRING {
-       if (dispatcher->ttl) {
+       if (dsp->ttl) {
                yyerror("ttl already specified for this dispatcher");
                YYERROR;
        }
 
-       dispatcher->ttl = delaytonum($2);
-       if (dispatcher->ttl == -1) {
+       dsp->ttl = delaytonum($2);
+       if (dsp->ttl == -1) {
                yyerror("ttl delay \"%s\" is invalid", $2);
                free($2);
                YYERROR;
@@ -993,13 +993,13 @@ ACTION STRING {
                yyerror("dispatcher already declared with that name: %s", $2);
                YYERROR;
        }
-       dispatcher = xcalloc(1, sizeof *dispatcher);
+       dsp = xcalloc(1, sizeof *dsp);
 } dispatcher_type dispatcher_options {
-       if (dispatcher->type == DISPATCHER_LOCAL)
-               if (dispatcher->u.local.table_userbase == NULL)
-                       dispatcher->u.local.table_userbase = "<getpwnam>";
-       dict_set(conf->sc_dispatchers, $2, dispatcher);
-       dispatcher = NULL;
+       if (dsp->type == DISPATCHER_LOCAL)
+               if (dsp->u.local.table_userbase == NULL)
+                       dsp->u.local.table_userbase = "<getpwnam>";
+       dict_set(conf->sc_dispatchers, $2, dsp);
+       dsp = NULL;
 }
 ;
 
Index: pony.c
===================================================================
RCS file: pony.c
diff -N pony.c
--- pony.c      13 Jun 2019 11:45:35 -0000      1.27
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,208 +0,0 @@
-/*     $OpenBSD: pony.c,v 1.27 2019/06/13 11:45:35 eric Exp $  */
-
-/*
- * Copyright (c) 2014 Gilles Chehade <gil...@poolp.org>
- *
- * 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/socket.h>
-
-#include <ctype.h>
-#include <err.h>
-#include <errno.h>
-#include <event.h>
-#include <imsg.h>
-#include <inttypes.h>
-#include <pwd.h>
-#include <signal.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
-#include <unistd.h>
-#include <limits.h>
-#include <grp.h>
-
-#include "smtpd.h"
-#include "log.h"
-
-void mda_imsg(struct mproc *, struct imsg *);
-void mta_imsg(struct mproc *, struct imsg *);
-void smtp_imsg(struct mproc *, struct imsg *);
-
-static void pony_shutdown(void);
-
-void
-pony_imsg(struct mproc *p, struct imsg *imsg)
-{
-       struct msg      m;
-       int             v;
-
-       if (imsg == NULL)
-               pony_shutdown();
-
-       switch (imsg->hdr.type) {
-
-       case IMSG_GETADDRINFO:
-       case IMSG_GETADDRINFO_END:
-       case IMSG_GETNAMEINFO:
-       case IMSG_RES_QUERY:
-               resolver_dispatch_result(p, imsg);
-               return;
-
-       case IMSG_CERT_INIT:
-       case IMSG_CERT_VERIFY:
-               cert_dispatch_result(p, imsg);
-               return;
-
-       case IMSG_CONF_START:
-               return;
-       case IMSG_CONF_END:
-               smtp_configure();
-               return;
-       case IMSG_CTL_VERBOSE:
-               m_msg(&m, imsg);
-               m_get_int(&m, &v);
-               m_end(&m);
-               log_trace_verbose(v);
-               return;
-       case IMSG_CTL_PROFILE:
-               m_msg(&m, imsg);
-               m_get_int(&m, &v);
-               m_end(&m);
-               profiling = v;
-               return;
-
-       /* smtp imsg */
-       case IMSG_SMTP_CHECK_SENDER:
-       case IMSG_SMTP_EXPAND_RCPT:
-       case IMSG_SMTP_LOOKUP_HELO:
-       case IMSG_SMTP_AUTHENTICATE:
-       case IMSG_SMTP_MESSAGE_COMMIT:
-       case IMSG_SMTP_MESSAGE_CREATE:
-       case IMSG_SMTP_MESSAGE_OPEN:
-       case IMSG_FILTER_SMTP_PROTOCOL:
-       case IMSG_FILTER_SMTP_DATA_BEGIN:
-       case IMSG_QUEUE_ENVELOPE_SUBMIT:
-       case IMSG_QUEUE_ENVELOPE_COMMIT:
-       case IMSG_QUEUE_SMTP_SESSION:
-       case IMSG_CTL_SMTP_SESSION:
-       case IMSG_CTL_PAUSE_SMTP:
-       case IMSG_CTL_RESUME_SMTP:
-               smtp_imsg(p, imsg);
-               return;
-
-        /* mta imsg */
-       case IMSG_QUEUE_TRANSFER:
-       case IMSG_MTA_OPEN_MESSAGE:
-       case IMSG_MTA_LOOKUP_CREDENTIALS:
-       case IMSG_MTA_LOOKUP_SMARTHOST:
-       case IMSG_MTA_LOOKUP_SOURCE:
-       case IMSG_MTA_LOOKUP_HELO:
-       case IMSG_MTA_DNS_HOST:
-       case IMSG_MTA_DNS_HOST_END:
-       case IMSG_MTA_DNS_MX_PREFERENCE:
-       case IMSG_CTL_RESUME_ROUTE:
-       case IMSG_CTL_MTA_SHOW_HOSTS:
-       case IMSG_CTL_MTA_SHOW_RELAYS:
-       case IMSG_CTL_MTA_SHOW_ROUTES:
-       case IMSG_CTL_MTA_SHOW_HOSTSTATS:
-       case IMSG_CTL_MTA_BLOCK:
-       case IMSG_CTL_MTA_UNBLOCK:
-       case IMSG_CTL_MTA_SHOW_BLOCK:
-               mta_imsg(p, imsg);
-               return;
-
-        /* mda imsg */
-       case IMSG_MDA_LOOKUP_USERINFO:
-       case IMSG_QUEUE_DELIVER:
-       case IMSG_MDA_OPEN_MESSAGE:
-       case IMSG_MDA_FORK:
-       case IMSG_MDA_DONE:
-               mda_imsg(p, imsg);
-               return;
-       default:
-               break;
-       }
-
-       errx(1, "session_imsg: unexpected %s imsg", 
imsg_to_str(imsg->hdr.type));
-}
-
-static void
-pony_shutdown(void)
-{
-       log_debug("debug: pony agent exiting");
-       _exit(0);
-}
-
-int
-pony(void)
-{
-       struct passwd   *pw;
-
-       mda_postfork();
-       mta_postfork();
-       smtp_postfork();
-
-       /* do not purge listeners and pki, they are purged
-        * in smtp_configure()
-        */
-       purge_config(PURGE_TABLES|PURGE_RULES);
-
-       if ((pw = getpwnam(SMTPD_USER)) == NULL)
-               fatalx("unknown user " SMTPD_USER);
-
-       if (chroot(PATH_CHROOT) == -1)
-               fatal("pony: chroot");
-       if (chdir("/") == -1)
-               fatal("pony: chdir(\"/\")");
-
-       config_process(PROC_PONY);
-
-       if (setgroups(1, &pw->pw_gid) ||
-           setresgid(pw->pw_gid, pw->pw_gid, pw->pw_gid) ||
-           setresuid(pw->pw_uid, pw->pw_uid, pw->pw_uid))
-               fatal("pony: cannot drop privileges");
-
-       imsg_callback = pony_imsg;
-       event_init();
-
-       mda_postprivdrop();
-       mta_postprivdrop();
-       smtp_postprivdrop();
-
-       signal(SIGINT, SIG_IGN);
-       signal(SIGTERM, SIG_IGN);
-       signal(SIGPIPE, SIG_IGN);
-       signal(SIGHUP, SIG_IGN);
-
-       config_peer(PROC_PARENT);
-       config_peer(PROC_QUEUE);
-       config_peer(PROC_LKA);
-       config_peer(PROC_CONTROL);
-       config_peer(PROC_CA);
-
-       ca_engine_init();
-
-       if (pledge("stdio inet unix recvfd sendfd", NULL) == -1)
-               err(1, "pledge");
-
-       event_dispatch();
-       fatalx("exited event loop");
-
-       return (0);
-}
Index: queue.c
===================================================================
RCS file: /cvs/src/usr.sbin/smtpd/queue.c,v
retrieving revision 1.190
diff -u -p -r1.190 queue.c
--- queue.c     22 Apr 2020 11:35:34 -0000      1.190
+++ queue.c     30 Dec 2020 08:25:55 -0000
@@ -152,15 +152,15 @@ queue_imsg(struct mproc *p, struct imsg 
                        log_warnx("warn: imsg_queue_submit_envelope: msgid=0, "
                            "evpid=%016"PRIx64, evp.id);
                ret = queue_envelope_create(&evp);
-               m_create(p_pony, IMSG_QUEUE_ENVELOPE_SUBMIT, 0, 0, -1);
-               m_add_id(p_pony, reqid);
+               m_create(p_dispatcher, IMSG_QUEUE_ENVELOPE_SUBMIT, 0, 0, -1);
+               m_add_id(p_dispatcher, reqid);
                if (ret == 0)
-                       m_add_int(p_pony, 0);
+                       m_add_int(p_dispatcher, 0);
                else {
-                       m_add_int(p_pony, 1);
-                       m_add_evpid(p_pony, evp.id);
+                       m_add_int(p_dispatcher, 1);
+                       m_add_evpid(p_dispatcher, evp.id);
                }
-               m_close(p_pony);
+               m_close(p_dispatcher);
                if (ret) {
                        m_create(p_scheduler,
                            IMSG_QUEUE_ENVELOPE_SUBMIT, 0, 0, -1);
@@ -173,10 +173,10 @@ queue_imsg(struct mproc *p, struct imsg 
                m_msg(&m, imsg);
                m_get_id(&m, &reqid);
                m_end(&m);
-               m_create(p_pony, IMSG_QUEUE_ENVELOPE_COMMIT, 0, 0, -1);
-               m_add_id(p_pony, reqid);
-               m_add_int(p_pony, 1);
-               m_close(p_pony);
+               m_create(p_dispatcher, IMSG_QUEUE_ENVELOPE_COMMIT, 0, 0, -1);
+               m_add_id(p_dispatcher, reqid);
+               m_add_int(p_dispatcher, 1);
+               m_close(p_dispatcher);
                return;
 
        case IMSG_SCHED_ENVELOPE_REMOVE:
@@ -250,9 +250,9 @@ queue_imsg(struct mproc *p, struct imsg 
                        return;
                }
                evp.lasttry = time(NULL);
-               m_create(p_pony, IMSG_QUEUE_DELIVER, 0, 0, -1);
-               m_add_envelope(p_pony, &evp);
-               m_close(p_pony);
+               m_create(p_dispatcher, IMSG_QUEUE_DELIVER, 0, 0, -1);
+               m_add_envelope(p_dispatcher, &evp);
+               m_close(p_dispatcher);
                return;
 
        case IMSG_SCHED_ENVELOPE_INJECT:
@@ -275,9 +275,9 @@ queue_imsg(struct mproc *p, struct imsg 
                        return;
                }
                evp.lasttry = time(NULL);
-               m_create(p_pony, IMSG_QUEUE_TRANSFER, 0, 0, -1);
-               m_add_envelope(p_pony, &evp);
-               m_close(p_pony);
+               m_create(p_dispatcher, IMSG_QUEUE_TRANSFER, 0, 0, -1);
+               m_add_envelope(p_dispatcher, &evp);
+               m_close(p_dispatcher);
                return;
 
        case IMSG_CTL_LIST_ENVELOPES:
@@ -665,7 +665,7 @@ queue(void)
        config_peer(PROC_CONTROL);
        config_peer(PROC_LKA);
        config_peer(PROC_SCHEDULER);
-       config_peer(PROC_PONY);
+       config_peer(PROC_DISPATCHER);
 
        /* setup queue loading task */
        evtimer_set(&ev_qload, queue_timeout, &ev_qload);
Index: smtpd.c
===================================================================
RCS file: /cvs/src/usr.sbin/smtpd/smtpd.c,v
retrieving revision 1.335
diff -u -p -r1.335 smtpd.c
--- smtpd.c     23 Sep 2020 19:11:50 -0000      1.335
+++ smtpd.c     30 Dec 2020 08:25:55 -0000
@@ -66,7 +66,7 @@ static int smtpd(void);
 static void parent_shutdown(void);
 static void parent_send_config(int, short, void *);
 static void parent_send_config_lka(void);
-static void parent_send_config_pony(void);
+static void parent_send_config_dispatcher(void);
 static void parent_send_config_ca(void);
 static void parent_sig_handler(int, short, void *);
 static void forkmda(struct mproc *, uint64_t, struct deliver *);
@@ -140,7 +140,7 @@ struct mproc        *p_lka = NULL;
 struct mproc   *p_parent = NULL;
 struct mproc   *p_queue = NULL;
 struct mproc   *p_scheduler = NULL;
-struct mproc   *p_pony = NULL;
+struct mproc   *p_dispatcher = NULL;
 struct mproc   *p_ca = NULL;
 
 const char     *backend_queue = "fs";
@@ -289,7 +289,7 @@ parent_shutdown(void)
        pid_t pid;
 
        mproc_clear(p_ca);
-       mproc_clear(p_pony);
+       mproc_clear(p_dispatcher);
        mproc_clear(p_control);
        mproc_clear(p_lka);
        mproc_clear(p_scheduler);
@@ -309,17 +309,17 @@ static void
 parent_send_config(int fd, short event, void *p)
 {
        parent_send_config_lka();
-       parent_send_config_pony();
+       parent_send_config_dispatcher();
        parent_send_config_ca();
        purge_config(PURGE_PKI);
 }
 
 static void
-parent_send_config_pony(void)
+parent_send_config_dispatcher(void)
 {
-       log_debug("debug: parent_send_config: configuring pony process");
-       m_compose(p_pony, IMSG_CONF_START, 0, 0, -1, NULL, 0);
-       m_compose(p_pony, IMSG_CONF_END, 0, 0, -1, NULL, 0);
+       log_debug("debug: parent_send_config: configuring dispatcher process");
+       m_compose(p_dispatcher, IMSG_CONF_START, 0, 0, -1, NULL, 0);
+       m_compose(p_dispatcher, IMSG_CONF_END, 0, 0, -1, NULL, 0);
 }
 
 void
@@ -437,13 +437,13 @@ parent_sig_handler(int sig, short event,
                                    "for session %016"PRIx64 ": %s",
                                    child->mda_id, cause);
 
-                               m_create(p_pony, IMSG_MDA_DONE, 0, 0,
+                               m_create(p_dispatcher, IMSG_MDA_DONE, 0, 0,
                                    child->mda_out);
-                               m_add_id(p_pony, child->mda_id);
-                               m_add_int(p_pony, mda_status);
-                               m_add_int(p_pony, mda_sysexit);
-                               m_add_string(p_pony, cause);
-                               m_close(p_pony);
+                               m_add_id(p_dispatcher, child->mda_id);
+                               m_add_int(p_dispatcher, mda_status);
+                               m_add_int(p_dispatcher, mda_sysexit);
+                               m_add_string(p_dispatcher, cause);
+                               m_close(p_dispatcher);
 
                                break;
 
@@ -698,8 +698,8 @@ main(int argc, char *argv[])
                p_lka = start_child(save_argc, save_argv, "lka");
                p_lka->proc = PROC_LKA;
 
-               p_pony = start_child(save_argc, save_argv, "pony");
-               p_pony->proc = PROC_PONY;
+               p_dispatcher = start_child(save_argc, save_argv, "dispatcher");
+               p_dispatcher->proc = PROC_DISPATCHER;
 
                p_queue = start_child(save_argc, save_argv, "queue");
                p_queue->proc = PROC_QUEUE;
@@ -709,12 +709,12 @@ main(int argc, char *argv[])
 
                setup_peers(p_control, p_ca);
                setup_peers(p_control, p_lka);
-               setup_peers(p_control, p_pony);
+               setup_peers(p_control, p_dispatcher);
                setup_peers(p_control, p_queue);
                setup_peers(p_control, p_scheduler);
-               setup_peers(p_pony, p_ca);
-               setup_peers(p_pony, p_lka);
-               setup_peers(p_pony, p_queue);
+               setup_peers(p_dispatcher, p_ca);
+               setup_peers(p_dispatcher, p_lka);
+               setup_peers(p_dispatcher, p_queue);
                setup_peers(p_queue, p_lka);
                setup_peers(p_queue, p_scheduler);
 
@@ -730,7 +730,7 @@ main(int argc, char *argv[])
                setup_done(p_ca);
                setup_done(p_control);
                setup_done(p_lka);
-               setup_done(p_pony);
+               setup_done(p_dispatcher);
                setup_done(p_queue);
                setup_done(p_scheduler);
 
@@ -767,11 +767,11 @@ main(int argc, char *argv[])
                return lka();
        }
 
-       else if (!strcmp(rexec, "pony")) {
-               smtpd_process = PROC_PONY;
+       else if (!strcmp(rexec, "dispatcher")) {
+               smtpd_process = PROC_DISPATCHER;
                setup_proc();
 
-               return pony();
+               return dispatcher();
        }
 
        else if (!strcmp(rexec, "queue")) {
@@ -978,8 +978,8 @@ setup_peer(enum smtp_proc_type proc, pid
        case PROC_SCHEDULER:
                pp = &p_scheduler;
                break;
-       case PROC_PONY:
-               pp = &p_pony;
+       case PROC_DISPATCHER:
+               pp = &p_dispatcher;
                break;
        case PROC_CA:
                pp = &p_ca;
@@ -1050,7 +1050,7 @@ smtpd(void) {
        child_add(p_control->pid, CHILD_DAEMON, proc_title(PROC_CONTROL));
        child_add(p_lka->pid, CHILD_DAEMON, proc_title(PROC_LKA));
        child_add(p_scheduler->pid, CHILD_DAEMON, proc_title(PROC_SCHEDULER));
-       child_add(p_pony->pid, CHILD_DAEMON, proc_title(PROC_PONY));
+       child_add(p_dispatcher->pid, CHILD_DAEMON, proc_title(PROC_DISPATCHER));
        child_add(p_ca->pid, CHILD_DAEMON, proc_title(PROC_CA));
 
        event_init();
@@ -1069,7 +1069,7 @@ smtpd(void) {
        config_peer(PROC_LKA);
        config_peer(PROC_QUEUE);
        config_peer(PROC_CA);
-       config_peer(PROC_PONY);
+       config_peer(PROC_DISPATCHER);
 
        evtimer_set(&config_ev, parent_send_config, NULL);
        memset(&tv, 0, sizeof(tv));
@@ -1421,12 +1421,12 @@ forkmda(struct mproc *p, uint64_t id, st
                        (void)snprintf(ebuf, sizeof ebuf,
                            "delivery user '%s' does not exist",
                            dsp->u.local.user);
-                       m_create(p_pony, IMSG_MDA_DONE, 0, 0, -1);
-                       m_add_id(p_pony, id);
-                       m_add_int(p_pony, MDA_PERMFAIL);
-                       m_add_int(p_pony, EX_NOUSER);
-                       m_add_string(p_pony, ebuf);
-                       m_close(p_pony);
+                       m_create(p_dispatcher, IMSG_MDA_DONE, 0, 0, -1);
+                       m_add_id(p_dispatcher, id);
+                       m_add_int(p_dispatcher, MDA_PERMFAIL);
+                       m_add_int(p_dispatcher, EX_NOUSER);
+                       m_add_string(p_dispatcher, ebuf);
+                       m_close(p_dispatcher);
                        return;
                }
                pw_name = pw->pw_name;
@@ -1451,23 +1451,23 @@ forkmda(struct mproc *p, uint64_t id, st
        if (pw_uid == 0 && !dsp->u.local.is_mbox) {
                (void)snprintf(ebuf, sizeof ebuf, "not allowed to deliver to: 
%s",
                    deliver->userinfo.username);
-               m_create(p_pony, IMSG_MDA_DONE, 0, 0, -1);
-               m_add_id(p_pony, id);
-               m_add_int(p_pony, MDA_PERMFAIL);
-               m_add_int(p_pony, EX_NOPERM);
-               m_add_string(p_pony, ebuf);
-               m_close(p_pony);
+               m_create(p_dispatcher, IMSG_MDA_DONE, 0, 0, -1);
+               m_add_id(p_dispatcher, id);
+               m_add_int(p_dispatcher, MDA_PERMFAIL);
+               m_add_int(p_dispatcher, EX_NOPERM);
+               m_add_string(p_dispatcher, ebuf);
+               m_close(p_dispatcher);
                return;
        }
 
        if (pipe(pipefd) == -1) {
                (void)snprintf(ebuf, sizeof ebuf, "pipe: %s", strerror(errno));
-               m_create(p_pony, IMSG_MDA_DONE, 0, 0, -1);
-               m_add_id(p_pony, id);
-               m_add_int(p_pony, MDA_TEMPFAIL);
-               m_add_int(p_pony, EX_OSERR);
-               m_add_string(p_pony, ebuf);
-               m_close(p_pony);
+               m_create(p_dispatcher, IMSG_MDA_DONE, 0, 0, -1);
+               m_add_id(p_dispatcher, id);
+               m_add_int(p_dispatcher, MDA_TEMPFAIL);
+               m_add_int(p_dispatcher, EX_OSERR);
+               m_add_string(p_dispatcher, ebuf);
+               m_close(p_dispatcher);
                return;
        }
 
@@ -1476,12 +1476,12 @@ forkmda(struct mproc *p, uint64_t id, st
        allout = mkstemp(sfn);
        if (allout == -1) {
                (void)snprintf(ebuf, sizeof ebuf, "mkstemp: %s", 
strerror(errno));
-               m_create(p_pony, IMSG_MDA_DONE, 0, 0, -1);
-               m_add_id(p_pony, id);
-               m_add_int(p_pony, MDA_TEMPFAIL);
-               m_add_int(p_pony, EX_OSERR);
-               m_add_string(p_pony, ebuf);
-               m_close(p_pony);
+               m_create(p_dispatcher, IMSG_MDA_DONE, 0, 0, -1);
+               m_add_id(p_dispatcher, id);
+               m_add_int(p_dispatcher, MDA_TEMPFAIL);
+               m_add_int(p_dispatcher, EX_OSERR);
+               m_add_string(p_dispatcher, ebuf);
+               m_close(p_dispatcher);
                close(pipefd[0]);
                close(pipefd[1]);
                return;
@@ -1491,12 +1491,12 @@ forkmda(struct mproc *p, uint64_t id, st
        pid = fork();
        if (pid == -1) {
                (void)snprintf(ebuf, sizeof ebuf, "fork: %s", strerror(errno));
-               m_create(p_pony, IMSG_MDA_DONE, 0, 0, -1);
-               m_add_id(p_pony, id);
-               m_add_int(p_pony, MDA_TEMPFAIL);
-               m_add_int(p_pony, EX_OSERR);
-               m_add_string(p_pony, ebuf);
-               m_close(p_pony);
+               m_create(p_dispatcher, IMSG_MDA_DONE, 0, 0, -1);
+               m_add_id(p_dispatcher, id);
+               m_add_int(p_dispatcher, MDA_TEMPFAIL);
+               m_add_int(p_dispatcher, EX_OSERR);
+               m_add_string(p_dispatcher, ebuf);
+               m_close(p_dispatcher);
                close(pipefd[0]);
                close(pipefd[1]);
                close(allout);
@@ -1912,10 +1912,10 @@ proc_title(enum smtp_proc_type proc)
                return "control";
        case PROC_SCHEDULER:
                return "scheduler";
-       case PROC_PONY:
-               return "pony express";
+       case PROC_DISPATCHER:
+               return "dispatcher";
        case PROC_CA:
-               return "klondike";
+               return "crypto";
        case PROC_CLIENT:
                return "client";
        case PROC_PROCESSOR:
@@ -1938,8 +1938,8 @@ proc_name(enum smtp_proc_type proc)
                return "control";
        case PROC_SCHEDULER:
                return "scheduler";
-       case PROC_PONY:
-               return "pony";
+       case PROC_DISPATCHER:
+               return "dispatcher";
        case PROC_CA:
                return "ca";
        case PROC_CLIENT:
Index: smtpd.h
===================================================================
RCS file: /cvs/src/usr.sbin/smtpd/smtpd.h,v
retrieving revision 1.659
diff -u -p -r1.659 smtpd.h
--- smtpd.h     23 Sep 2020 19:11:50 -0000      1.659
+++ smtpd.h     30 Dec 2020 08:25:55 -0000
@@ -345,7 +345,7 @@ enum smtp_proc_type {
        PROC_QUEUE,
        PROC_CONTROL,
        PROC_SCHEDULER,
-       PROC_PONY,
+       PROC_DISPATCHER,
        PROC_CA,
        PROC_PROCESSOR,
        PROC_CLIENT,
@@ -1007,7 +1007,7 @@ extern struct mproc *p_parent;
 extern struct mproc *p_lka;
 extern struct mproc *p_queue;
 extern struct mproc *p_scheduler;
-extern struct mproc *p_pony;
+extern struct mproc *p_dispatcher;
 extern struct mproc *p_ca;
 
 extern struct smtpd    *env;
@@ -1579,9 +1579,9 @@ struct scheduler_backend *scheduler_back
 void scheduler_info(struct scheduler_info *, struct envelope *);
 
 
-/* pony.c */
-int pony(void);
-void pony_imsg(struct mproc *, struct imsg *);
+/* dispatcher.c */
+int dispatcher(void);
+void dispatcher_imsg(struct mproc *, struct imsg *);
 
 
 /* resolver.c */
Index: smtpd/Makefile
===================================================================
RCS file: /cvs/src/usr.sbin/smtpd/smtpd/Makefile,v
retrieving revision 1.109
diff -u -p -r1.109 Makefile
--- smtpd/Makefile      23 Sep 2020 19:11:50 -0000      1.109
+++ smtpd/Makefile      30 Dec 2020 08:25:55 -0000
@@ -35,7 +35,7 @@ SRCS+=        mproc.c
 SRCS+= mta.c
 SRCS+= mta_session.c
 SRCS+= parse.y
-SRCS+= pony.c
+SRCS+= dispatcher.c
 SRCS+= proxy.c
 SRCS+= queue.c
 SRCS+= queue_backend.c


Reply via email to