[Pkg-privacy-commits] [onioncat] 217/241: - fixed order of pid-process creation - AC_PROG_MKDIR_P was missing - child reaper was missing in case of pid-process getting killed

Intrigeri intrigeri at moszumanska.debian.org
Wed Aug 26 16:17:12 UTC 2015


This is an automated email from the git hooks/post-receive script.

intrigeri pushed a commit to branch upstream-master
in repository onioncat.

commit 2aa1b0f72353068f81d9115bf34e1f3c43047c46
Author: eagle <eagle at 58e1ccc2-750e-0410-8d0d-f93ca75ab447>
Date:   Fri Feb 12 11:32:55 2010 +0000

    - fixed order of pid-process creation
    - AC_PROG_MKDIR_P was missing
    - child reaper was missing in case of pid-process getting killed
    
    
    git-svn-id: https://www.cypherpunk.at/svn/onioncat/trunk@546 58e1ccc2-750e-0410-8d0d-f93ca75ab447
---
 Makefile.in            |  1 +
 config.h.in            |  3 ++
 configure              | 75 ++++++++++++++++++++++++++++++++++++++++++--------
 configure.ac           |  3 +-
 debian/Makefile.in     |  1 +
 freebsd/Makefile.in    |  1 +
 i2p/Makefile.in        |  1 +
 man/Makefile.in        |  1 +
 src/Makefile.in        |  1 +
 src/cygwin/Makefile.in |  1 +
 src/ocat.c             | 27 ++++++++++++++----
 src/ocat.h             |  3 ++
 src/ocatctrl.c         |  4 +++
 13 files changed, 104 insertions(+), 18 deletions(-)

diff --git a/Makefile.in b/Makefile.in
index 0c9559f..9926709 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -112,6 +112,7 @@ LIBS = @LIBS@
 LN_S = @LN_S@
 LTLIBOBJS = @LTLIBOBJS@
 MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
diff --git a/config.h.in b/config.h.in
index 0082e57..cf7ba80 100644
--- a/config.h.in
+++ b/config.h.in
@@ -87,6 +87,9 @@
 /* Define to 1 if you have the <sys/types.h> header file. */
 #undef HAVE_SYS_TYPES_H
 
+/* Define to 1 if you have the <sys/wait.h> header file. */
+#undef HAVE_SYS_WAIT_H
+
 /* enable RTT measurement */
 #undef MEASURE_RTT
 
diff --git a/configure b/configure
index a00ed84..c243da4 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.62 for onioncat 0.2.2.r545.
+# Generated by GNU Autoconf 2.62 for onioncat 0.2.2.r546.
 #
 # Report bugs to <rahra at cypherpunk.at>.
 #
@@ -596,8 +596,8 @@ SHELL=${CONFIG_SHELL-/bin/sh}
 # Identity of this package.
 PACKAGE_NAME='onioncat'
 PACKAGE_TARNAME='onioncat'
-PACKAGE_VERSION='0.2.2.r545'
-PACKAGE_STRING='onioncat 0.2.2.r545'
+PACKAGE_VERSION='0.2.2.r546'
+PACKAGE_STRING='onioncat 0.2.2.r546'
 PACKAGE_BUGREPORT='rahra at cypherpunk.at'
 
 ac_subst_vars='SHELL
@@ -675,6 +675,7 @@ CCDEPMODE
 am__fastdepCC_TRUE
 am__fastdepCC_FALSE
 LN_S
+MKDIR_P
 build
 build_cpu
 build_vendor
@@ -1260,7 +1261,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures onioncat 0.2.2.r545 to adapt to many kinds of systems.
+\`configure' configures onioncat 0.2.2.r546 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1330,7 +1331,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of onioncat 0.2.2.r545:";;
+     short | recursive ) echo "Configuration of onioncat 0.2.2.r546:";;
    esac
   cat <<\_ACEOF
 
@@ -1422,7 +1423,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-onioncat configure 0.2.2.r545
+onioncat configure 0.2.2.r546
 generated by GNU Autoconf 2.62
 
 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
@@ -1436,7 +1437,7 @@ cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by onioncat $as_me 0.2.2.r545, which was
+It was created by onioncat $as_me 0.2.2.r546, which was
 generated by GNU Autoconf 2.62.  Invocation command line was
 
   $ $0 $@
@@ -2085,7 +2086,7 @@ fi
 
 # Define the identity of the package.
  PACKAGE='onioncat'
- VERSION='0.2.2.r545'
+ VERSION='0.2.2.r546'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -2236,7 +2237,7 @@ ac_config_headers="$ac_config_headers config.h"
 
 
 cat >>confdefs.h <<\_ACEOF
-#define SVN_REVISION "545"
+#define SVN_REVISION "546"
 _ACEOF
 
 
@@ -3416,6 +3417,48 @@ else
 $as_echo "no, using $LN_S" >&6; }
 fi
 
+{ $as_echo "$as_me:$LINENO: checking for a thread-safe mkdir -p" >&5
+$as_echo_n "checking for a thread-safe mkdir -p... " >&6; }
+if test -z "$MKDIR_P"; then
+  if test "${ac_cv_path_mkdir+set}" = set; then
+  $as_echo_n "(cached) " >&6
+else
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_prog in mkdir gmkdir; do
+	 for ac_exec_ext in '' $ac_executable_extensions; do
+	   { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; } || continue
+	   case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #(
+	     'mkdir (GNU coreutils) '* | \
+	     'mkdir (coreutils) '* | \
+	     'mkdir (fileutils) '4.1*)
+	       ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext
+	       break 3;;
+	   esac
+	 done
+       done
+done
+IFS=$as_save_IFS
+
+fi
+
+  if test "${ac_cv_path_mkdir+set}" = set; then
+    MKDIR_P="$ac_cv_path_mkdir -p"
+  else
+    # As a last resort, use the slow shell script.  Don't cache a
+    # value for MKDIR_P within a source directory, because that will
+    # break other packages using the cache if that directory is
+    # removed, or if the value is a relative name.
+    test -d ./--version && rmdir ./--version
+    MKDIR_P="$ac_install_sh -d"
+  fi
+fi
+{ $as_echo "$as_me:$LINENO: result: $MKDIR_P" >&5
+$as_echo "$MKDIR_P" >&6; }
+
 
 # ===========================================================================
 #           http://www.nongnu.org/autoconf-archive/ax_pthread.html
@@ -4075,7 +4118,8 @@ CC="$PTHREAD_CC"
 
 
 
-for ac_header in sys/types.h sys/socket.h netinet/in.h netinet/in_systm.h netinet/ip.h netinet/ip6.h netinet/in6.h net/if.h net/if_tun.h linux/if_tun.h linux/sockios.h endian.h sys/endian.h netinet/icmp6.h net/ethernet.h netinet/if_ether.h netinet/ether.h
+
+for ac_header in sys/types.h sys/wait.h sys/socket.h netinet/in.h netinet/in_systm.h netinet/ip.h netinet/ip6.h netinet/in6.h net/if.h net/if_tun.h linux/if_tun.h linux/sockios.h endian.h sys/endian.h netinet/icmp6.h net/ethernet.h netinet/if_ether.h netinet/ether.h
 do
 as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
 { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
@@ -5325,7 +5369,7 @@ exec 6>&1
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by onioncat $as_me 0.2.2.r545, which was
+This file was extended by onioncat $as_me 0.2.2.r546, which was
 generated by GNU Autoconf 2.62.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -5378,7 +5422,7 @@ Report bugs to <bug-autoconf at gnu.org>."
 _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_version="\\
-onioncat config.status 0.2.2.r545
+onioncat config.status 0.2.2.r546
 configured by $0, generated by GNU Autoconf 2.62,
   with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
 
@@ -5389,6 +5433,7 @@ gives unlimited permission to copy, distribute and modify it."
 ac_pwd='$ac_pwd'
 srcdir='$srcdir'
 INSTALL='$INSTALL'
+MKDIR_P='$MKDIR_P'
 AWK='$AWK'
 test -n "\$AWK" || AWK=awk
 _ACEOF
@@ -6004,6 +6049,11 @@ ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
   [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;;
   *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;;
   esac
+  ac_MKDIR_P=$MKDIR_P
+  case $MKDIR_P in
+  [\\/$]* | ?:[\\/]* ) ;;
+  */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;;
+  esac
 _ACEOF
 
 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
@@ -6060,6 +6110,7 @@ s&@builddir@&$ac_builddir&;t t
 s&@abs_builddir@&$ac_abs_builddir&;t t
 s&@abs_top_builddir@&$ac_abs_top_builddir&;t t
 s&@INSTALL@&$ac_INSTALL&;t t
+s&@MKDIR_P@&$ac_MKDIR_P&;t t
 $ac_datarootdir_hack
 "
 eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$tmp/subs.awk" >$tmp/out \
diff --git a/configure.ac b/configure.ac
index d904db8..e6e2d49 100644
--- a/configure.ac
+++ b/configure.ac
@@ -20,6 +20,7 @@ AC_ARG_ENABLE([rtt], AS_HELP_STRING([--enable-rtt],[enable inband RTT measuremen
 AC_PROG_CC
 #AC_PROG_INSTALL
 AC_PROG_LN_S
+AC_PROG_MKDIR_P
 
 m4_include([ax_pthread.m4])
 ACX_PTHREAD
@@ -35,7 +36,7 @@ CC="$PTHREAD_CC"
 
 # Checks for header files.
 #AC_HEADER_STDC
-AC_CHECK_HEADERS([sys/types.h sys/socket.h netinet/in.h netinet/in_systm.h netinet/ip.h netinet/ip6.h netinet/in6.h net/if.h net/if_tun.h linux/if_tun.h linux/sockios.h endian.h sys/endian.h netinet/icmp6.h net/ethernet.h netinet/if_ether.h netinet/ether.h], [], [],
+AC_CHECK_HEADERS([sys/types.h sys/wait.h sys/socket.h netinet/in.h netinet/in_systm.h netinet/ip.h netinet/ip6.h netinet/in6.h net/if.h net/if_tun.h linux/if_tun.h linux/sockios.h endian.h sys/endian.h netinet/icmp6.h net/ethernet.h netinet/if_ether.h netinet/ether.h], [], [],
 [[
 #ifdef HAVE_SYS_TYPES_H
 #include <sys/types.h>
diff --git a/debian/Makefile.in b/debian/Makefile.in
index 29e807b..0150b6e 100644
--- a/debian/Makefile.in
+++ b/debian/Makefile.in
@@ -77,6 +77,7 @@ LIBS = @LIBS@
 LN_S = @LN_S@
 LTLIBOBJS = @LTLIBOBJS@
 MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
diff --git a/freebsd/Makefile.in b/freebsd/Makefile.in
index 9ab70bb..01ac953 100644
--- a/freebsd/Makefile.in
+++ b/freebsd/Makefile.in
@@ -77,6 +77,7 @@ LIBS = @LIBS@
 LN_S = @LN_S@
 LTLIBOBJS = @LTLIBOBJS@
 MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
diff --git a/i2p/Makefile.in b/i2p/Makefile.in
index bf50098..f301718 100644
--- a/i2p/Makefile.in
+++ b/i2p/Makefile.in
@@ -88,6 +88,7 @@ LIBS = @LIBS@
 LN_S = @LN_S@
 LTLIBOBJS = @LTLIBOBJS@
 MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
diff --git a/man/Makefile.in b/man/Makefile.in
index d643c5b..209ac82 100644
--- a/man/Makefile.in
+++ b/man/Makefile.in
@@ -81,6 +81,7 @@ LIBS = @LIBS@
 LN_S = @LN_S@
 LTLIBOBJS = @LTLIBOBJS@
 MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
diff --git a/src/Makefile.in b/src/Makefile.in
index 695736b..427404f 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -103,6 +103,7 @@ LIBS = @LIBS@
 LN_S = @LN_S@
 LTLIBOBJS = @LTLIBOBJS@
 MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
diff --git a/src/cygwin/Makefile.in b/src/cygwin/Makefile.in
index 4cbadd1..ad4c68c 100644
--- a/src/cygwin/Makefile.in
+++ b/src/cygwin/Makefile.in
@@ -82,6 +82,7 @@ LIBS = @LIBS@
 LN_S = @LN_S@
 LTLIBOBJS = @LTLIBOBJS@
 MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
diff --git a/src/ocat.c b/src/ocat.c
index 5b95e8d..11fda8e 100644
--- a/src/ocat.c
+++ b/src/ocat.c
@@ -90,7 +90,7 @@ int open_logfile(void)
 }
 
 
-int mk_pid_file(uid_t uid)
+int mk_pid_file(void)
 {
    FILE *f;
    char c;
@@ -121,6 +121,13 @@ int mk_pid_file(uid_t uid)
       // child
       case 0:
          oe_close(CNF(pid_fd[1]));
+
+         // close tunnel device
+         oe_close(CNF(tunfd[0]));
+         if (CNF(tunfd[0]) != CNF(tunfd[1]))
+            oe_close(CNF(tunfd[1]));
+
+         // wait for something happening on pipe
          if (read(CNF(pid_fd[0]), &c, 1) == -1)
             log_msg(LOG_ERR, "error reading from pid_fd %d: \"%s\"",
                   CNF(pid_fd[0]), strerror(errno)), exit(1);
@@ -128,6 +135,7 @@ int mk_pid_file(uid_t uid)
          if (unlink(CNF(pid_file)) == -1)
             log_msg(LOG_WARNING, "error deleting pid ]ile \"%s\": \"%s\"",
                   CNF(pid_file), strerror(errno)), exit(1);
+         log_msg(LOG_INFO, "pid file deleted, exiting.");
          exit(0);
 
       // parent
@@ -182,8 +190,14 @@ void background(void)
 /*! Signal handler for SIGINT. */
 void sig_handler(int sig)
 {
+   int status;
+
    switch (sig)
    {
+      case SIGCHLD:
+         // FIXME: there should be some error handling
+         (void) waitpid(-1, &status, WNOHANG);
+
       case SIGTERM:
       case SIGINT:
          // emergency shutdown if signalled twice
@@ -215,6 +229,9 @@ void install_sig(void)
       log_msg(LOG_ERR, "could not install SIGHUP handler: \"%s\"", strerror(errno)), exit(1);
    if (sigaction(SIGUSR1, &sa, NULL) == -1)
       log_msg(LOG_ERR, "could not install SIGUSR1 handler: \"%s\"", strerror(errno)), exit(1);
+   if (sigaction(SIGCHLD, &sa, NULL) == -1)
+      log_msg(LOG_ERR, "could not install SIGCHLD handler: \"%s\"", strerror(errno)), exit(1);
+
 }
 
 
@@ -551,6 +568,10 @@ int main(int argc, char *argv[])
    if (CNF(daemon))
       background();
 
+   // create pid_file
+   if (CNF(create_pid_file))
+      mk_pid_file();
+
    if (!CNF(oc_listen))
       add_listener(def);
 
@@ -579,10 +600,6 @@ int main(int argc, char *argv[])
       CNF(create_clog) = 0;
    }
 
-   // create pid_file
-   if (CNF(create_pid_file))
-      mk_pid_file(pwd->pw_uid);
-
    if (!CNF(runasroot) && !getuid())
    {
       log_msg(LOG_INFO, "running as root, changing uid/gid to %s (uid %d/gid %d)", CNF(usrname), pwd->pw_uid, pwd->pw_gid);
diff --git a/src/ocat.h b/src/ocat.h
index f5bbcb0..089868e 100644
--- a/src/ocat.h
+++ b/src/ocat.h
@@ -52,6 +52,9 @@
 #ifdef HAVE_SYS_TYPES_H
 #include <sys/types.h>
 #endif
+#ifdef HAVE_SYS_WAIT_H
+#include <sys/wait.h>
+#endif
 #ifdef HAVE_NETINET_IN_H
 #include <netinet/in.h>
 #endif
diff --git a/src/ocatctrl.c b/src/ocatctrl.c
index a762d4f..8d31a7e 100644
--- a/src/ocatctrl.c
+++ b/src/ocatctrl.c
@@ -55,6 +55,8 @@ void *ctrl_handler(void *p)
       if (!(ff = fdopen(fd, "r+")))
       {
          log_msg(LOG_ERR, "could not open %d for writing: %s", fd, strerror(errno));
+         oe_close(pfd[0]);
+         oe_close(pfd[1]);
          return NULL;
       }
       log_debug("fd %d fdopen'ed \"r+\"", fd);
@@ -68,6 +70,8 @@ void *ctrl_handler(void *p)
       {
          log_msg(LOG_ERR, "could not open %d for reading: %s", fd, strerror(errno));
          CNF(config_read) = 1;
+         oe_close(pfd[0]);
+         oe_close(pfd[1]);
          return NULL;
       }
       log_debug("fd %d fdopen'ed \"r\"", fd);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/onioncat.git



More information about the Pkg-privacy-commits mailing list