diff options
author | landry <landry@openbsd.org> | 2016-01-17 08:13:34 +0000 |
---|---|---|
committer | landry <landry@openbsd.org> | 2016-01-17 08:13:34 +0000 |
commit | fbd12f3eb579cc8103a66bfc90a0260298486bed (patch) | |
tree | e05f038b50c4f7db37d0240a84fc57d8a6a445c1 /usr.sbin/ldapd | |
parent | provide missing section number to Dt macro; (diff) | |
download | wireguard-openbsd-fbd12f3eb579cc8103a66bfc90a0260298486bed.tar.xz wireguard-openbsd-fbd12f3eb579cc8103a66bfc90a0260298486bed.zip |
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/ldapd')
-rw-r--r-- | usr.sbin/ldapd/control.c | 3 | ||||
-rw-r--r-- | usr.sbin/ldapd/ldapd.c | 25 |
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) { |