diff options
author | Ted Unangst <tedu@cvs.openbsd.org> | 2016-10-07 19:14:57 +0000 |
---|---|---|
committer | Ted Unangst <tedu@cvs.openbsd.org> | 2016-10-07 19:14:57 +0000 |
commit | 64024f9f3ad06a70b0564fbac15d4b3298b50dc4 (patch) | |
tree | 8f84e90a484b4870d522b2fda3c1d9e163ed6c3d | |
parent | 135cf36469b19618f0aceabfb398be5583d08186 (diff) |
the parent mostly never crashes, but the child might. or the config file
disappears. in such cases, the parent will exit. make sure to always
reset the jackport, not just when receiving sigterm.
(doesn't protect against parent crashing, but that shouldn't happen.)
-rw-r--r-- | usr.sbin/rebound/rebound.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/usr.sbin/rebound/rebound.c b/usr.sbin/rebound/rebound.c index b70bfd5dc90..cb7aed50692 100644 --- a/usr.sbin/rebound/rebound.c +++ b/usr.sbin/rebound/rebound.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rebound.c,v 1.71 2016/10/07 19:07:36 tedu Exp $ */ +/* $OpenBSD: rebound.c,v 1.72 2016/10/07 19:14:56 tedu Exp $ */ /* * Copyright (c) 2015 Ted Unangst <tedu@openbsd.org> * @@ -680,6 +680,15 @@ openconfig(const char *confname, int kq) return conffd; } +static void +resetport(void) +{ + int dnsjacking[2] = { CTL_KERN, KERN_DNSJACKPORT }; + int jackport = 0; + + sysctl(dnsjacking, 2, NULL, NULL, &jackport, sizeof(jackport)); +} + static void __dead usage(void) { @@ -759,6 +768,7 @@ main(int argc, char **argv) if (listen(ld, 10) == -1) logerr("listen: %s", strerror(errno)); + atexit(resetport); sysctl(dnsjacking, 2, NULL, NULL, &jackport, sizeof(jackport)); signal(SIGPIPE, SIG_IGN); @@ -824,9 +834,6 @@ main(int argc, char **argv) /* good bye */ logmsg(LOG_INFO, "received TERM, quitting"); kill(child, SIGTERM); - jackport = 0; - sysctl(dnsjacking, 2, NULL, NULL, &jackport, - sizeof(jackport)); exit(0); } else if (kev.filter == EVFILT_PROC) { /* child died. wait for our own HUP. */ |