From: florian Date: Thu, 28 May 2015 17:08:08 +0000 (+0000) Subject: Do not try to unlink the control socket in an unprivileged child X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=5f32a1dbe9963761b0b92f3ff25dad191e02129d;p=openbsd Do not try to unlink the control socket in an unprivileged child process on shutdown. Found while working on tame(2). OK benno@ --- diff --git a/usr.sbin/httpd/control.c b/usr.sbin/httpd/control.c index fe603754308..5c715454458 100644 --- a/usr.sbin/httpd/control.c +++ b/usr.sbin/httpd/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.6 2015/01/21 22:21:05 reyk Exp $ */ +/* $OpenBSD: control.c,v 1.7 2015/05/28 17:08:08 florian Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -126,7 +126,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/httpd/httpd.c b/usr.sbin/httpd/httpd.c index c6f183fd9bf..5019fce6be3 100644 --- a/usr.sbin/httpd/httpd.c +++ b/usr.sbin/httpd/httpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: httpd.c,v 1.35 2015/02/23 18:43:18 reyk Exp $ */ +/* $OpenBSD: httpd.c,v 1.36 2015/05/28 17:08:09 florian Exp $ */ /* * Copyright (c) 2014 Reyk Floeter @@ -210,7 +210,7 @@ main(int argc, char *argv[]) errx(1, "unknown user %s", HTTPD_USER); /* Configure the control socket */ - ps->ps_csock.cs_name = HTTPD_SOCKET; + ps->ps_csock.cs_name = NULL; log_init(debug); log_verbose(verbose); @@ -404,6 +404,8 @@ parent_shutdown(struct httpd *env) proc_kill(env->sc_ps); control_cleanup(&env->sc_ps->ps_csock); + if (env->sc_ps->ps_csock.cs_name != NULL) + (void)unlink(env->sc_ps->ps_csock.cs_name); free(env->sc_ps); free(env); diff --git a/usr.sbin/relayd/control.c b/usr.sbin/relayd/control.c index 8c72b78748e..ee742aadd02 100644 --- a/usr.sbin/relayd/control.c +++ b/usr.sbin/relayd/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.48 2015/01/22 17:42:09 reyk Exp $ */ +/* $OpenBSD: control.c,v 1.49 2015/05/28 17:08:09 florian Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -126,7 +126,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/relayd/relayd.c b/usr.sbin/relayd/relayd.c index 729af4bb14e..9e0a3486594 100644 --- a/usr.sbin/relayd/relayd.c +++ b/usr.sbin/relayd/relayd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: relayd.c,v 1.139 2015/05/02 13:15:24 claudio Exp $ */ +/* $OpenBSD: relayd.c,v 1.140 2015/05/28 17:08:09 florian Exp $ */ /* * Copyright (c) 2007 - 2014 Reyk Floeter @@ -408,6 +408,7 @@ parent_shutdown(struct relayd *env) proc_kill(env->sc_ps); control_cleanup(&env->sc_ps->ps_csock); + (void)unlink(env->sc_ps->ps_csock.cs_name); carp_demote_shutdown(); free(env->sc_ps); diff --git a/usr.sbin/snmpd/control.c b/usr.sbin/snmpd/control.c index ca47f5ef20c..43468ab69c3 100644 --- a/usr.sbin/snmpd/control.c +++ b/usr.sbin/snmpd/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.28 2015/01/16 00:05:13 deraadt Exp $ */ +/* $OpenBSD: control.c,v 1.29 2015/05/28 17:08:09 florian Exp $ */ /* * Copyright (c) 2010-2013 Reyk Floeter @@ -135,7 +135,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/snmpd/snmpd.c b/usr.sbin/snmpd/snmpd.c index 37bcf23e8c1..b88154bbb00 100644 --- a/usr.sbin/snmpd/snmpd.c +++ b/usr.sbin/snmpd/snmpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: snmpd.c,v 1.27 2015/02/08 23:28:48 tedu Exp $ */ +/* $OpenBSD: snmpd.c,v 1.28 2015/05/28 17:08:09 florian Exp $ */ /* * Copyright (c) 2007, 2008, 2012 Reyk Floeter @@ -241,6 +241,9 @@ snmpd_shutdown(struct snmpd *env) { proc_kill(&env->sc_ps); + if (env->sc_ps.ps_csock.cs_name != NULL) + (void)unlink(env->sc_ps.ps_csock.cs_name); + free(env); log_info("terminating");