summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorLandry Breuil <landry@cvs.openbsd.org>2016-01-17 08:13:35 +0000
committerLandry Breuil <landry@cvs.openbsd.org>2016-01-17 08:13:35 +0000
commit10e478f17277533099f56dadcd49bc8769c713c1 (patch)
treea34be449cabaa7078d84aef4845cc5c49dd7b2ef /usr.sbin
parent6f2dde2309af830559ee9cac99e71d5a19d1c9ee (diff)
Properly remove unix sockets (control & listening) upon exit of the
parent process. Child process was killed by pledge because it tried to remove the control socket and didnt have cpath - anyway it couldnt remove it since it had chrooted.. ok jmatthew@ deraadt@
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/ldapd/control.c3
-rw-r--r--usr.sbin/ldapd/ldapd.c25
2 files changed, 25 insertions, 3 deletions
diff --git a/usr.sbin/ldapd/control.c b/usr.sbin/ldapd/control.c
index 545fde6a08e..ce25b20f400 100644
--- a/usr.sbin/ldapd/control.c
+++ b/usr.sbin/ldapd/control.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: control.c,v 1.12 2015/12/24 17:47:57 mmcc Exp $ */
+/* $OpenBSD: control.c,v 1.13 2016/01/17 08:13:34 landry Exp $ */
/*
* Copyright (c) 2010 Martin Hedenfalk <martin@bzero.se>
@@ -114,7 +114,6 @@ control_cleanup(struct control_sock *cs)
return;
event_del(&cs->cs_ev);
event_del(&cs->cs_evt);
- (void)unlink(cs->cs_name);
}
/* ARGSUSED */
diff --git a/usr.sbin/ldapd/ldapd.c b/usr.sbin/ldapd/ldapd.c
index 3ec54514bd2..fb45ebcef89 100644
--- a/usr.sbin/ldapd/ldapd.c
+++ b/usr.sbin/ldapd/ldapd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ldapd.c,v 1.15 2015/12/24 17:47:57 mmcc Exp $ */
+/* $OpenBSD: ldapd.c,v 1.16 2016/01/17 08:13:34 landry Exp $ */
/*
* Copyright (c) 2009, 2010 Martin Hedenfalk <martin@bzero.se>
@@ -17,6 +17,7 @@
*/
#include <sys/queue.h>
+#include <sys/un.h>
#include <sys/types.h>
#include <sys/wait.h>
@@ -45,6 +46,7 @@ static void ldapd_needfd(struct imsgev *iev);
static void ldapd_auth_request(struct imsgev *iev, struct imsg *imsg);
static void ldapd_open_request(struct imsgev *iev, struct imsg *imsg);
static void ldapd_log_verbose(struct imsg *imsg);
+static void ldapd_cleanup(char *);
struct ldapd_stats stats;
pid_t ldape_pid;
@@ -213,12 +215,33 @@ main(int argc, char *argv[])
err(1, "pledge");
event_dispatch();
+
+ ldapd_cleanup(csockpath);
log_debug("ldapd: exiting");
return 0;
}
static void
+ldapd_cleanup(char * csockpath)
+{
+ struct listener *l;
+ struct sockaddr_un *sun = NULL;
+
+ /* Remove control socket. */
+ (void)unlink(csockpath);
+
+ /* Remove unix listening sockets. */
+ TAILQ_FOREACH(l, &conf->listeners, entry) {
+ if (l->ss.ss_family == AF_UNIX) {
+ sun = (struct sockaddr_un *)&l->ss;
+ log_info("ldapd: removing unix socket %s", sun->sun_path);
+ (void)unlink(sun->sun_path);
+ }
+ }
+}
+
+static void
ldapd_imsgev(struct imsgev *iev, int code, struct imsg *imsg)
{
switch (code) {