}
}
-#ifdef IPSECPOLICY
- /* create info socket. */
- {
- err_t ugh = init_info_socket();
-
- if (ugh != NULL)
- {
- fprintf(stderr, "pluto: %s", ugh);
- exit_pluto(1);
- }
- }
-#endif
-
/* If not suppressed, do daemon fork */
if (fork_desired)
int i;
for (i = getdtablesize() - 1; i >= 0; i--) /* Bad hack */
- if ((!log_to_stderr || i != 2)
-#ifdef IPSECPOLICY
- && i != info_fd
-#endif
- && i != ctl_fd)
+ {
+ if ((!log_to_stderr || i != 2) && i != ctl_fd)
close(i);
+ }
/* make sure that stdin, stdout, stderr are reserved */
if (open("/dev/null", O_RDONLY) != 0)
unlink(ctl_addr.sun_path);
}
-#ifdef IPSECPOLICY
-/* Initialize the info socket.
- */
-err_t
-init_info_socket(void)
-{
- err_t failed = NULL;
-
- delete_info_socket(); /* preventative medicine */
- info_fd = socket(AF_UNIX, SOCK_STREAM, 0);
- if (info_fd == -1)
- failed = "create";
- else if (fcntl(info_fd, F_SETFD, FD_CLOEXEC) == -1)
- failed = "fcntl FD+CLOEXEC";
- else if (setsockopt(info_fd, SOL_SOCKET, SO_REUSEADDR, (const void *)&on, sizeof(on)) < 0)
- failed = "setsockopt";
- else
- {
- /* this socket should be openable by all proceses */
- mode_t ou = umask(0);
-
- if (bind(info_fd, (struct sockaddr *)&info_addr
- , offsetof(struct sockaddr_un, sun_path) + strlen(info_addr.sun_path)) < 0)
- failed = "bind";
- umask(ou);
- }
-
- /* 64 might be big enough, and the system may limit us anyway.
- */
- if (failed == NULL && listen(info_fd, 64) < 0)
- failed = "listen() on";
-
- return failed == NULL? NULL : builddiag("could not %s info socket: %d %s"
- , failed, errno, strerror(errno));
-}
-
-void
-delete_info_socket(void)
-{
- unlink(info_addr.sun_path);
-}
-#endif /* IPSECPOLICY */
-
-
bool listening = FALSE; /* should we pay attention to IKE messages? */
struct iface *interfaces = NULL; /* public interfaces */
FD_ZERO(&readfds);
FD_ZERO(&writefds);
FD_SET(ctl_fd, &readfds);
-#ifdef IPSECPOLICY
- FD_SET(info_fd, &readfds);
- if (maxfd < info_fd)
- maxfd = info_fd;
-#endif
/* the only write file-descriptor of interest */
if (adns_qfd != NULL_FD && unsent_ADNS_queries)
ndes--;
}
-#ifdef IPSECPOLICY
- if (FD_ISSET(info_fd, &readfds))
- {
- passert(ndes > 0);
- DBG(DBG_CONTROL,
- DBG_log(BLANK_FORMAT);
- DBG_log("*received info message"));
- info_handle(info_fd);
- passert(GLOBALS_ARE_RESET());
- ndes--;
- }
-#endif
-
passert(ndes == 0);
}
}