[Pkg-privacy-commits] [onioncat] 186/241: pid file is created optionally, OC stays in foreground in Cygwin by default.

Intrigeri intrigeri at moszumanska.debian.org
Wed Aug 26 16:17:04 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 2afa7e21965da7cfaf650487674cfe62e58363e5
Author: eagle <eagle at 58e1ccc2-750e-0410-8d0d-f93ca75ab447>
Date:   Wed Jul 1 14:05:12 2009 +0000

    pid file is created optionally,
    OC stays in foreground in Cygwin by default.
    
    
    git-svn-id: https://www.cypherpunk.at/svn/onioncat/trunk@507 58e1ccc2-750e-0410-8d0d-f93ca75ab447
---
 AUTHORS         |  1 +
 ChangeLog       |  1 +
 configure       | 22 +++++++++++-----------
 src/ocat.c      | 20 ++++++++++++++++----
 src/ocat.h      |  1 +
 src/ocatctrl.c  |  2 +-
 src/ocatsetup.c |  9 +++++++--
 7 files changed, 38 insertions(+), 18 deletions(-)

diff --git a/AUTHORS b/AUTHORS
index 7594bf1..ddb1028 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -3,4 +3,5 @@
 * Debian and Ubuntu packages: Ferdinand Haselbacher <fhasex20 _at_ cypherpunk at>
   - Debian package
   - Ubuntu package
+* Basic conceptual ideas, Mac OSX Testing: Daniel Haslinger <creo _at_ cypherpunk.at>
 
diff --git a/ChangeLog b/ChangeLog
index b1af6ba..986aeb8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,5 @@
 * version 0.2.0
+ - syslog messages contain name and PID
 
 * version 0.1.13
  - released 2009/06/09, Bernhard R. Fischer
diff --git a/configure b/configure
index 9552dbc..9de5104 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.61 for onioncat 0.2.0.r504.
+# Generated by GNU Autoconf 2.61 for onioncat 0.2.0.r506.
 #
 # Report bugs to <rahra at cypherpunk.at>.
 #
@@ -574,8 +574,8 @@ SHELL=${CONFIG_SHELL-/bin/sh}
 # Identity of this package.
 PACKAGE_NAME='onioncat'
 PACKAGE_TARNAME='onioncat'
-PACKAGE_VERSION='0.2.0.r504'
-PACKAGE_STRING='onioncat 0.2.0.r504'
+PACKAGE_VERSION='0.2.0.r506'
+PACKAGE_STRING='onioncat 0.2.0.r506'
 PACKAGE_BUGREPORT='rahra at cypherpunk.at'
 
 ac_subst_vars='SHELL
@@ -1178,7 +1178,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.0.r504 to adapt to many kinds of systems.
+\`configure' configures onioncat 0.2.0.r506 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1248,7 +1248,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of onioncat 0.2.0.r504:";;
+     short | recursive ) echo "Configuration of onioncat 0.2.0.r506:";;
    esac
   cat <<\_ACEOF
 
@@ -1337,7 +1337,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-onioncat configure 0.2.0.r504
+onioncat configure 0.2.0.r506
 generated by GNU Autoconf 2.61
 
 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
@@ -1351,7 +1351,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.0.r504, which was
+It was created by onioncat $as_me 0.2.0.r506, which was
 generated by GNU Autoconf 2.61.  Invocation command line was
 
   $ $0 $@
@@ -2041,7 +2041,7 @@ fi
 
 # Define the identity of the package.
  PACKAGE='onioncat'
- VERSION='0.2.0.r504'
+ VERSION='0.2.0.r506'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -2192,7 +2192,7 @@ ac_config_headers="$ac_config_headers config.h"
 
 
 cat >>confdefs.h <<\_ACEOF
-#define SVN_REVISION "504"
+#define SVN_REVISION "506"
 _ACEOF
 
 
@@ -4940,7 +4940,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.0.r504, which was
+This file was extended by onioncat $as_me 0.2.0.r506, which was
 generated by GNU Autoconf 2.61.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -4993,7 +4993,7 @@ Report bugs to <bug-autoconf at gnu.org>."
 _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF
 ac_cs_version="\\
-onioncat config.status 0.2.0.r504
+onioncat config.status 0.2.0.r506
 configured by $0, generated by GNU Autoconf 2.61,
   with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
 
diff --git a/src/ocat.c b/src/ocat.c
index 3cb1f0d..fe37abd 100644
--- a/src/ocat.c
+++ b/src/ocat.c
@@ -88,7 +88,7 @@ int open_logfile(void)
 }
 
 
-int mk_pid_file(void)
+int mk_pid_file(uid_t uid)
 {
    FILE *f;
 
@@ -102,6 +102,9 @@ int mk_pid_file(void)
    fclose(f);
    log_debug("pid_file %s created, pid = %d", CNF(pid_file), getpid());
 
+   if (chown(CNF(pid_file), uid, 0) == -1)
+      log_msg(LOG_ERR, "could not change owner of pid_file \"%s\" to %d: %s", CNF(pid_file), uid, strerror(errno));
+
    return 0;
 }
 
@@ -207,6 +210,9 @@ void cleanup_system(void)
    }
 
    delete_listeners(CNF(oc_listen), CNF(oc_listen_fd), CNF(oc_listen_cnt));
+
+   if (CNF(create_pid_file) && (unlink(CNF(pid_file)) == -1))
+      log_msg(LOG_ERR, "could not remove pid file \"%s\": %s", CNF(pid_file), strerror(errno));
 }
 
 
@@ -274,7 +280,11 @@ int main(int argc, char *argv[])
             break;
 
          case 'P':
-            CNF(pid_file) = optarg;
+            CNF(create_pid_file) = 1;
+            if (optarg[0] == '-')
+               optind--;
+            else
+               CNF(pid_file) = optarg;
             break;
 
          case 'r':
@@ -325,7 +335,8 @@ int main(int argc, char *argv[])
    if (!CNF(daemon))
       CNF(logf) = stderr;
  
-   (void) open_logfile();
+   if ((open_logfile() == -1) && !CNF(logf))
+      openlog(PACKAGE_NAME, LOG_NDELAY | LOG_PID, LOG_DAEMON);
 
    // init main thread
    (void) init_ocat_thread("main");
@@ -438,7 +449,8 @@ int main(int argc, char *argv[])
    }
 
    // create pid_file
-   mk_pid_file();
+   if (CNF(create_pid_file))
+      mk_pid_file(pwd->pw_uid);
 
    if (!runasroot && !getuid())
    {
diff --git a/src/ocat.h b/src/ocat.h
index 29b2ab0..ea990c3 100644
--- a/src/ocat.h
+++ b/src/ocat.h
@@ -276,6 +276,7 @@ struct OcatSetup
    //! local OnionCat MAC address
    uint8_t ocat_hwaddr[ETHER_ADDR_LEN];
    char *pid_file;
+   int create_pid_file;
    char *logfn;
    FILE *logf;
    int daemon;
diff --git a/src/ocatctrl.c b/src/ocatctrl.c
index 31fe1b1..74cc759 100644
--- a/src/ocatctrl.c
+++ b/src/ocatctrl.c
@@ -160,9 +160,9 @@ void *ctrl_handler(void *p)
          for (peer = get_first_peer(); peer; peer = peer->next)
             if (peer->tcpfd == cfd)
             {
-               log_msg(LOG_INFO | LOG_FCONN, "close request for %d", cfd);
                oe_close(cfd);
                delete_peer(peer);
+               log_msg(LOG_INFO | LOG_FCONN, "%d was successfully closed up on user request", cfd);
                break;
             }
          if (!peer)
diff --git a/src/ocatsetup.c b/src/ocatsetup.c
index 8e8fd1c..5cb3493 100644
--- a/src/ocatsetup.c
+++ b/src/ocatsetup.c
@@ -60,9 +60,14 @@ struct OcatSetup setup_ =
    0,                                      // use_tap
 #endif
    {0x00, 0x00, 0x6c, 0x00, 0x00, 0x00},   // ocat_hwaddr (OnionCat MAC address)
-   PID_FILE,
+   PID_FILE,                               // pid_file
+   0,                                      // create_pid_file
    NULL, NULL,                             // logfile
+#ifdef __CYGWIN__
+   0,
+#else
    1,                                      // daemon
+#endif
    {
       /*
       {{{0xfd, 0x87, 0xd8, 0x7e, 0xeb, 0x43,
@@ -231,7 +236,7 @@ void print_setup_struct(FILE *f)
          logf,
          setup_.daemon,
          t / (3600 * 24), t / 3600 % 24, t / 60 % 60,
-         strlen(setup_.version), VERSION_STRING_LEN, setup_.version,
+         (int) strlen(setup_.version), VERSION_STRING_LEN, setup_.version,
          setup_.sizeof_setup,
          setup_.term_req
          );

-- 
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