aboutsummaryrefslogtreecommitdiffstats
path: root/usr.sbin/smtpd/smtpd.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin/smtpd/smtpd.c')
-rw-r--r--usr.sbin/smtpd/smtpd.c32
1 files changed, 31 insertions, 1 deletions
diff --git a/usr.sbin/smtpd/smtpd.c b/usr.sbin/smtpd/smtpd.c
index f18b1446..240e688b 100644
--- a/usr.sbin/smtpd/smtpd.c
+++ b/usr.sbin/smtpd/smtpd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: smtpd.c,v 1.333 2020/05/06 16:03:30 millert Exp $ */
+/* $OpenBSD: smtpd.c,v 1.334 2020/09/23 18:01:27 martijn Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@poolp.org>
@@ -28,6 +28,7 @@
#include <sys/wait.h>
#include <sys/stat.h>
#include <sys/uio.h>
+#include <sys/un.h>
#include <sys/mman.h>
#ifdef BSD_AUTH
@@ -86,6 +87,7 @@
#include "smtpd.h"
#include "log.h"
#include "ssl.h"
+#include "subagentx.h"
extern char *__progname;
@@ -100,6 +102,7 @@ static void parent_send_config_lka(void);
static void parent_send_config_pony(void);
static void parent_send_config_ca(void);
static void parent_sig_handler(int, short, void *);
+static int parent_open_agentx(void);
static void forkmda(struct mproc *, uint64_t, struct deliver *);
static int parent_forward_open(char *, char *, uid_t, gid_t);
static struct child *child_add(pid_t, int, const char *);
@@ -302,6 +305,12 @@ parent_imsg(struct mproc *p, struct imsg *imsg)
m_add_string(p_lka, procname);
m_close(p_lka);
return;
+ case IMSG_AGENTX_GETFD:
+ fd = parent_open_agentx();
+
+ m_create(p_control, IMSG_AGENTX_GETFD, 0, 0, fd);
+ m_close(p_control);
+ return;
}
errx(1, "parent_imsg: unexpected %s imsg from %s",
@@ -508,6 +517,25 @@ parent_sig_handler(int sig, short event, void *p)
}
}
+static int
+parent_open_agentx(void)
+{
+ int fd;
+ struct sockaddr_un sun;
+
+ sun.sun_len = sizeof(sun);
+ sun.sun_family = AF_UNIX;
+ strlcpy(sun.sun_path, env->sc_agentx->path, sizeof(sun.sun_path));
+
+ if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1 ||
+ connect(fd, (struct sockaddr *)&sun, sizeof(sun)) == -1) {
+ log_warn("agentx connect");
+ close(fd);
+ return -1;
+ }
+ return fd;
+}
+
int
main(int argc, char *argv[])
{
@@ -2185,6 +2213,8 @@ imsg_to_str(int type)
CASE(IMSG_CA_RSA_PRIVENC);
CASE(IMSG_CA_RSA_PRIVDEC);
CASE(IMSG_CA_ECDSA_SIGN);
+
+ CASE(IMSG_AGENTX_GETFD);
default:
(void)snprintf(buf, sizeof(buf), "IMSG_??? (%d)", type);