Beispiel #1
0
int
main(int argc, char *argv[])
{
  set_process_name("ivpn-client");

  parse_options(argc, argv);

  if (geteuid() != 0) {
    lerr("Effective UID is %u. It need to be 0.", geteuid());
    return EXIT_FAILURE;
  }

  if (install_sigchld_handler() == 0)
    return EXIT_FAILURE;

  if (username == 0) {
    username = get_current_user();
    if (username == 0)
      exit(EXIT_FAILURE);
  }

  if (!sslutil_init(CA_CERT_FILE, 0, 0))
    return EXIT_SSL_ERROR;

  return run_client();
}
Beispiel #2
0
 ChildProcessManager() { install_sigchld_handler(); }
Beispiel #3
0
static int sigchld_pipe_fd = -1;

static void got_signal(int sig) {
	int saved_errno = errno;
	int ignored_result;

	/* write() errors are unhandled.  If the buffer is full, we don't
	 * care.  What about other errors? */
	ignored_result = write(sigchld_pipe_fd, "x", 1);

	errno = saved_errno;
}

PyDoc_STRVAR(install_sigchld_handler_doc, "\
install_sigchld_handler(fd)\n\
\n\
Installs a SIGCHLD handler which will write a byte to the given fd\n\
whenever a SIGCHLD occurs. This is done in C code because the python\n\
signal handling system is not reliable, and additionally cannot\n\
specify SA_RESTART.\n\
\n\
Please ensure fd is in non-blocking mode.\n\
");

static PyObject *
install_sigchld_handler(PyObject *self, PyObject *args) {
	int fd, old_fd;
	struct sigaction sa;

	if (!PyArg_ParseTuple(args, "i:install_sigchld_handler", &fd)) {