Hi,

Currently the eigrp engine process from eigrpd(8) runs in a chroot and at the
same time the unlink(socket) is called when its shutdown, of course this won't
work because the file won't be found within the chroot environment.

To solve this the patch below brings the control_cleanup() function into the
the main process instead, and to please pledge(2) the cpath promise is also
moved from one process to the other. This is the way it's done for other
daemons as well which use the same function.

OK?

Index: eigrpd.c
===================================================================
RCS file: /cvs/src/usr.sbin/eigrpd/eigrpd.c,v
retrieving revision 1.21
diff -u -p -u -r1.21 eigrpd.c
--- eigrpd.c    2 Sep 2016 17:59:58 -0000       1.21
+++ eigrpd.c    1 Aug 2018 19:22:45 -0000
@@ -36,6 +36,7 @@
 #include "eigrpe.h"
 #include "rde.h"
 #include "log.h"
+#include "control.h"
 
 static void             main_sig_handler(int, short, void *);
 static __dead void      usage(void);
@@ -167,6 +168,8 @@ main(int argc, char *argv[])
        else if (eflag)
                eigrpe(debug, global.cmd_opts & EIGRPD_OPT_VERBOSE, sockname);
 
+       global.csock = sockname;
+
        mib[0] = CTL_NET;
        mib[1] = PF_INET;
        mib[2] = IPPROTO_IP;
@@ -268,7 +271,7 @@ main(int argc, char *argv[])
            eigrpd_conf->rdomain) == -1)
                fatalx("kr_init failed");
 
-       if (pledge("inet rpath stdio sendfd", NULL) == -1)
+       if (pledge("inet rpath cpath stdio sendfd", NULL) == -1)
                fatal("pledge");
 
        event_dispatch();
@@ -290,6 +293,7 @@ eigrpd_shutdown(void)
        msgbuf_clear(&iev_rde->ibuf.w);
        close(iev_rde->ibuf.fd);
 
+       control_cleanup(global.csock);
        kr_shutdown();
        config_clear(eigrpd_conf);
 
Index: eigrpe.c
===================================================================
RCS file: /cvs/src/usr.sbin/eigrpd/eigrpe.c,v
retrieving revision 1.34
diff -u -p -u -r1.34 eigrpe.c
--- eigrpe.c    2 Sep 2016 17:59:58 -0000       1.34
+++ eigrpe.c    1 Aug 2018 19:22:45 -0000
@@ -133,7 +133,7 @@ eigrpe(int debug, int verbose, char *soc
            setresuid(pw->pw_uid, pw->pw_uid, pw->pw_uid))
                fatal("can't drop privileges");
 
-       if (pledge("stdio cpath inet mcast recvfd", NULL) == -1)
+       if (pledge("stdio inet mcast recvfd", NULL) == -1)
                fatal("pledge");
 
        event_init();
@@ -187,7 +187,6 @@ eigrpe_shutdown(void)
        msgbuf_clear(&iev_main->ibuf.w);
        close(iev_main->ibuf.fd);
 
-       control_cleanup(global.csock);
        config_clear(econf);
 
        event_del(&ev4);

Reply via email to