When the monitor dies, it sends its child a TERM signal but if it
segfaults or is killed with an uncatchable signal, the child will
continue to run "unharmed". On Linux, it is possible to send a signal to
the child in this case, with `prctl()`. Do that.
/* priv.c */
void priv_init(const char*, int, uid_t, gid_t);
+void priv_init_os(void);
void priv_wait(void);
void priv_ctl_cleanup(const char *ctlname);
char *priv_gethostname(void);
#include <errno.h>
#include <string.h>
+void
+priv_init_os()
+{
+}
+
int
asroot_iface_init_os(int ifindex, char *name, int *fd)
{
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
+#include <signal.h>
#include <fcntl.h>
#include <errno.h>
#include <regex.h>
#include <sys/ioctl.h>
+#include <sys/prctl.h>
#include <netpacket/packet.h> /* For sockaddr_ll */
#include <linux/filter.h> /* For BPF filtering */
#include <linux/ethtool.h>
#include <linux/sockios.h>
+void
+priv_init_os()
+{
+ if (prctl(PR_SET_PDEATHSIG, SIGTERM) == -1)
+ log_warn("privsep", "unable to setup parent death signal");
+}
+
/* Proxy for open */
int
priv_open(char *file)
#endif
}
close(pair[1]);
+ priv_init_os();
priv_ping();
break;
default: