From 4abd97d807a1c3629e4f9bf7c9b3a47914c5d6db Mon Sep 17 00:00:00 2001 From: florian Date: Sat, 4 Aug 2018 09:36:49 +0000 Subject: [PATCH] Leave the control socket behind on shutdown. It doesn't hurt anyone. On the other hand it is much more powerful to get rid of cpath; slaacd has no filesystem access whatsoever. Triggered by mestre@'s work to fix unlinking in other daemons and a question from deraadt@ OK mestre --- sbin/slaacd/control.c | 13 +------------ sbin/slaacd/control.h | 3 +-- sbin/slaacd/slaacd.c | 19 +++++-------------- 3 files changed, 7 insertions(+), 28 deletions(-) diff --git a/sbin/slaacd/control.c b/sbin/slaacd/control.c index 1d3556b612f..1a0c2b0305a 100644 --- a/sbin/slaacd/control.c +++ b/sbin/slaacd/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.3 2018/04/26 17:08:18 florian Exp $ */ +/* $OpenBSD: control.c,v 1.4 2018/08/04 09:36:49 florian Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -105,17 +105,6 @@ control_listen(void) return (0); } -void -control_cleanup(char *path) -{ - if (path == NULL) - return; - event_del(&control_state.ev); - event_del(&control_state.evt); - if (unlink(path) != 0) - log_warn("unlink %s", path); -} - void control_accept(int listenfd, short event, void *bula) { diff --git a/sbin/slaacd/control.h b/sbin/slaacd/control.h index 52b576c5862..c244ed5a5a4 100644 --- a/sbin/slaacd/control.h +++ b/sbin/slaacd/control.h @@ -1,4 +1,4 @@ -/* $OpenBSD: control.h,v 1.2 2017/07/06 15:02:53 florian Exp $ */ +/* $OpenBSD: control.h,v 1.3 2018/08/04 09:36:49 florian Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -33,5 +33,4 @@ int control_listen(void); void control_accept(int, short, void *); void control_dispatch_imsg(int, short, void *); int control_imsg_relay(struct imsg *); -void control_cleanup(char *); #endif /* SMALL */ diff --git a/sbin/slaacd/slaacd.c b/sbin/slaacd/slaacd.c index 344fc148537..244ac4350d9 100644 --- a/sbin/slaacd/slaacd.c +++ b/sbin/slaacd/slaacd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: slaacd.c,v 1.28 2018/07/27 06:20:01 bket Exp $ */ +/* $OpenBSD: slaacd.c,v 1.29 2018/08/04 09:36:49 florian Exp $ */ /* * Copyright (c) 2017 Florian Obser @@ -80,11 +80,7 @@ struct imsgev *iev_engine; pid_t frontend_pid; pid_t engine_pid; -int routesock, ioctl_sock; - -char *csock; - -int rtm_seq = 0; +int routesock, ioctl_sock, rtm_seq = 0; void main_sig_handler(int sig, short event, void *arg) @@ -129,12 +125,11 @@ main(int argc, char *argv[]) int pipe_main2engine[2]; int icmp6sock, on = 1; int frontend_routesock, rtfilter; + char *csock = SLAACD_SOCKET; #ifndef SMALL int control_fd; #endif /* SMALL */ - csock = SLAACD_SOCKET; - log_init(1, LOG_DAEMON); /* Log to stderr until daemonized. */ log_setverbose(1); @@ -285,7 +280,7 @@ main(int argc, char *argv[]) fatalx("control socket setup failed"); #endif /* SMALL */ - if (pledge("stdio cpath sendfd wroute", NULL) == -1) + if (pledge("stdio sendfd wroute", NULL) == -1) fatal("pledge"); main_imsg_compose_frontend_fd(IMSG_ICMP6SOCK, 0, icmp6sock); @@ -331,10 +326,6 @@ main_shutdown(void) free(iev_frontend); free(iev_engine); -#ifndef SMALL - control_cleanup(csock); -#endif /* SMALL */ - log_info("terminating"); exit(0); } @@ -420,7 +411,7 @@ main_dispatch_frontend(int fd, short event, void *bula) switch (imsg.hdr.type) { case IMSG_STARTUP_DONE: - if (pledge("stdio cpath wroute", NULL) == -1) + if (pledge("stdio wroute", NULL) == -1) fatal("pledge"); break; #ifndef SMALL -- 2.20.1