m_state
strlcpy(m_state.root, pw->pw_dir, sizeof m_state.root);
m_state.pid = fork();
if (m_state.pid == -1)
if (m_state.pid == 0) {
m_state.s = p[0];
m_state.s = p[1];
m_state.pid ? "priv" : "child", getpid(), m_state.s,
m_state.pid ? ", waiting for SIGCONT" : "");
if (m_state.pid)
kill(m_state.pid, SIGCONT); /* Continue child. */
return m_state.pid;
if (m_state.pid != 0) {
kill(m_state.pid, SIGTERM);
pid = waitpid(m_state.pid, &status, 0);
close(m_state.s);
pf_key_v2_socket = mm_receive_fd(m_state.s);
snprintf(pathreal, sizeof pathreal, "%s/%s", m_state.root,
fd = mm_receive_fd(m_state.s);
if (m_state.pid)
if (mm_send_fd(m_state.s, s)) {
if (mm_send_fd(m_state.s, s)) {
fd = mm_receive_fd(m_state.s);
if (m_state.pid > 0)
kill(m_state.pid, sig);
if (fd > 0 && mm_send_fd(m_state.s, fd)) {
if (mm_send_fd(m_state.s, v) == -1)
sock = mm_receive_fd(m_state.s);
} m_state;
sock = mm_receive_fd(m_state.s);
res = read(m_state.s, s + pos, n - pos);
res = write(m_state.s, s + pos, n - pos);
mm_send_fd(m_state.s, fd);
bzero(&m_state, sizeof m_state);
} else if (m_state.pid == 0) {
m_state.s = p[0];
m_state.s = p[1];
return m_state.pid;
if (m_state.pid != -1)
kill(m_state.pid, s);
ioctl(m_state.s, FIONBIO, &one);
while (m_read(m_state.s, &tmp, 1) > 0)
ioctl(m_state.s, FIONBIO, 0);
pid = waitpid(m_state.pid, &status, WNOHANG);
if (pid == m_state.pid &&
FD_SET(m_state.s, &rfds);
if (select(m_state.s + 1, &rfds, NULL, NULL, tvp) == -1) {
if (FD_ISSET(m_state.s, &rfds)) {
if ((r = m_read(m_state.s, &v, sizeof v)) < 1) {
m_priv_pfkey_snap(m_state.s);
if (m_write(m_state.s, &mtype, sizeof mtype) < 1)
if (m_write(m_state.s, &mtype, sizeof mtype) < 1)
if (m_write(m_state.s, &v, sizeof v) < 1)
if (m_read(m_state.s, sadbsize, sizeof *sadbsize) < 1)
rbytes = m_read(m_state.s, *sadb, *sadbsize);
if (m_read(m_state.s, spdsize, sizeof *spdsize) < 1) {
rbytes = m_read(m_state.s, *spd, *spdsize);
if (write(m_state.s, &cmd, sizeof cmd) < 1)
} m_state;
m_state.pid = fork();
if (m_state.pid == -1) {