Hi,

Here's another path which removes the daemon's ability to delete its unix
control socket during shutdown and therefore "cpath" promise is no longer
needed.

While here I've also scrambled the pledge promises to their canonical form.

Regression tests still pass. OK?

Index: control.c
===================================================================
RCS file: /cvs/src/usr.sbin/snmpd/control.c,v
retrieving revision 1.43
diff -u -p -u -r1.43 control.c
--- control.c   17 Jun 2018 18:19:59 -0000      1.43
+++ control.c   5 Aug 2018 08:54:33 -0000
@@ -128,15 +128,6 @@ control_listen(struct control_sock *cs)
        return (0);
 }
 
-void
-control_cleanup(struct control_sock *cs)
-{
-       if (cs->cs_name == NULL)
-               return;
-       event_del(&cs->cs_ev);
-       event_del(&cs->cs_evt);
-}
-
 /* ARGSUSED */
 void
 control_accept(int listenfd, short event, void *arg)
Index: proc.c
===================================================================
RCS file: /cvs/src/usr.sbin/snmpd/proc.c,v
retrieving revision 1.24
diff -u -p -u -r1.24 proc.c
--- proc.c      29 May 2017 12:56:26 -0000      1.24
+++ proc.c      5 Aug 2018 08:54:34 -0000
@@ -475,9 +475,6 @@ proc_shutdown(struct privsep_proc *p)
 {
        struct privsep  *ps = p->p_ps;
 
-       if (p->p_id == PROC_CONTROL && ps)
-               control_cleanup(&ps->ps_csock);
-
        if (p->p_shutdown != NULL)
                (*p->p_shutdown)();
 
Index: snmpd.c
===================================================================
RCS file: /cvs/src/usr.sbin/snmpd/snmpd.c,v
retrieving revision 1.38
diff -u -p -u -r1.38 snmpd.c
--- snmpd.c     15 Apr 2018 11:57:29 -0000      1.38
+++ snmpd.c     5 Aug 2018 08:54:34 -0000
@@ -255,7 +255,7 @@ main(int argc, char *argv[])
 
        proc_connect(ps);
 
-       if (pledge("stdio rpath cpath dns id proc sendfd exec", NULL) == -1)
+       if (pledge("stdio rpath dns sendfd proc exec id", NULL) == -1)
                fatal("pledge");
 
        event_dispatch();
@@ -269,9 +269,6 @@ void
 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);
 
Index: snmpd.h
===================================================================
RCS file: /cvs/src/usr.sbin/snmpd/snmpd.h,v
retrieving revision 1.79
diff -u -p -u -r1.79 snmpd.h
--- snmpd.h     31 Jul 2018 11:01:29 -0000      1.79
+++ snmpd.h     5 Aug 2018 08:54:34 -0000
@@ -615,7 +615,6 @@ extern struct snmpd *snmpd_env;
 /* control.c */
 int             control_init(struct privsep *, struct control_sock *);
 int             control_listen(struct control_sock *);
-void            control_cleanup(struct control_sock *);
 
 /* parse.y */
 struct snmpd   *parse_config(const char *, u_int);

Reply via email to