From 70cf739729db4c5d7f72b64207855889e57ee49a Mon Sep 17 00:00:00 2001 From: Darshaka Pathirana Date: Thu, 26 Jan 2017 02:45:45 +0100 Subject: [PATCH] Imported Upstream version 0.3.6 --- .gitignore | 8 ++++++++ ChangeLog | 7 +++++++ README | 8 ++++---- doc/uanytun.8 | 6 +++--- src/bsd/tun.c | 8 ++++++-- src/configure | 41 ++++++++++++++++++++++------------------- src/options.c | 10 ++++++++-- src/seq_window.c | 2 +- src/sig_handler.c | 8 ++++---- src/uanytun.c | 14 ++++++++++---- src/udp.c | 4 ++++ version | 2 +- 12 files changed, 78 insertions(+), 40 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5efe091 --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +doc/uanytun.8.xml +src/*.o +src/*.d +src/*.d.* +src/tun.c +src/include.mk +src/version.h +src/uanytun diff --git a/ChangeLog b/ChangeLog index 8b9c45a..e295fc0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2017.01.04 -- Version 0.3.6 + +* moved to GIT +* make build reproducible +* the return code after receiving a signal now correctly contains + the signal number which caused the shutdown. + 2014.06.21 -- Version 0.3.5 * added support for libnettle as crypt library diff --git a/README b/README index dc07a11..2cc3ad8 100644 --- a/README +++ b/README @@ -59,13 +59,12 @@ if you want to rebuild the manpage: Installation ============ -Getting the source via subversion: ----------------------------------- +Getting the source via GIT: +--------------------------- -svn co https://svn.anytun.org/uanytun/trunk uanytun +git clone https://git.spreadspace.org/anytun/uanytun.git cd uanytun - Building from source -------------------- @@ -81,6 +80,7 @@ using ssl crypto library: # ./configure --use-ssl-crypto # make + Notes: - try './configure --help' for further information - if using openssl pre 0.9.8 you have to disable passphrase diff --git a/doc/uanytun.8 b/doc/uanytun.8 index 299c742..941cdaa 100644 --- a/doc/uanytun.8 +++ b/doc/uanytun.8 @@ -1,13 +1,13 @@ '\" t .\" Title: uanytun .\" Author: [see the "AUTHORS" section] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 06/21/2014 +.\" Generator: DocBook XSL Stylesheets v1.79.1 +.\" Date: 01/04/2017 .\" Manual: \ \& .\" Source: \ \& .\" Language: English .\" -.TH "UANYTUN" "8" "06/21/2014" "\ \&" "\ \&" +.TH "UANYTUN" "8" "01/04/2017" "\ \&" "\ \&" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/src/bsd/tun.c b/src/bsd/tun.c index a469c58..ceb54a1 100644 --- a/src/bsd/tun.c +++ b/src/bsd/tun.c @@ -46,14 +46,15 @@ * files in the program, then also delete it here. */ +#define _GNU_SOURCE +#include + #include "datatypes.h" #include "tun.h" #include "tun_helper.h" -#include "log.h" - #include #include #include @@ -69,6 +70,9 @@ #include #define DEVICE_FILE_MAX 255 +#include "log.h" +#include "sysexec.h" + int tun_init(tun_device_t* dev, const char* dev_name, const char* dev_type, const char* ifcfg_addr, u_int16_t ifcfg_prefix) { if(!dev) diff --git a/src/configure b/src/configure index 16d5cc7..8044552 100755 --- a/src/configure +++ b/src/configure @@ -153,12 +153,12 @@ if [ -n "$ERRORS" ] && [ $EBUILD_COMPAT -ne 1 ]; then fi if [ $USE_CLANG -eq 0 ]; then - CFLAGS='-g -Wall -O2' - LDFLAGS='-g -Wall -O2' + CFLAGS=$CFLAGS'-g -Wall -O2' + LDFLAGS=$LDFLAGS'-g -Wall -O2' COMPILER='gcc' else - CFLAGS='-g -O2' - LDFLAGS='-g -O2' + CFLAGS=$CFLAGS'-g -O2' + LDFLAGS=$LDFLAGS'-g -O2' COMPILER='clang' fi @@ -183,28 +183,33 @@ case $TARGET in ;; esac - +CRYPTO_LIB_NAME="" case $CRYPTO_LIB in gcrypt) CFLAGS=$CFLAGS' -DUSE_GCRYPT' LDFLAGS=$LDFLAGS' -lgcrypt' - echo "using gcrypt library" + CRYPTO_LIB_NAME="libgcrypt" ;; nettle) CFLAGS=$CFLAGS' -DUSE_NETTLE' LDFLAGS=$LDFLAGS' -lnettle' - echo "using nettle library" + CRYPTO_LIB_NAME="Nettle" ;; ssl) CFLAGS=$CFLAGS' -DUSE_SSL_CRYPTO' LDFLAGS=$LDFLAGS' -lcrypto' - echo "using ssl crypto library" + CRYPTO_LIB_NAME="OpenSSL" ;; none) CFLAGS=$CFLAGS' -DNO_CRYPT' - echo "disabling crypto" + CRYPTO_LIB_NAME="none" + ;; + *) + echo "unknown crypto library: $$CRYPTO_LIB" + exit 1 ;; esac +echo "crypto-library: $CRYPTO_LIB_NAME" if [ $PASSPHRASE -eq 0 ]; then CFLAGS=$CFLAGS' -DNO_PASSPHRASE' @@ -239,7 +244,7 @@ LDFLAGS := $LDFLAGS STRIP := strip INSTALL := install -PREFIX := $PREFIX +prefix := $PREFIX SBINDIR := $SBINDIR ETCDIR := $ETCDIR EOF @@ -263,14 +268,12 @@ else fi VERSION=`cat ../version` -if which svn >/dev/null; then - SVN_REV=`svn info 2> /dev/null | grep "^Revision: " | awk '{print($2)}'` - if [ -n "$SVN_REV" ]; then - VERSION="$VERSION (svn$SVN_REV)" - fi +if which git >/dev/null; then + GIT_HASH=`git rev-parse HEAD 2> /dev/null` + if [ -n "$GIT_HASH" ]; then + VERSION="$VERSION (git $GIT_HASH)" + fi fi -HOSTNAME=`hostname` -DATE=`date +"%d.%m.%Y %H:%M:%S %Z"` cat > version.h < version.h <sender_id_, ptr->max_); window_size_t i = ptr->pos_; - while(1) { + for(;;) { if(ptr->window_[i]) printf("O"); else diff --git a/src/sig_handler.c b/src/sig_handler.c index 5de168e..f23d070 100644 --- a/src/sig_handler.c +++ b/src/sig_handler.c @@ -139,10 +139,10 @@ int signal_handle() for(sig=1; sig < NSIG; ++sig) { if(sigismember(&set, sig)) { switch(sig) { - case SIGINT: log_printf(NOTICE, "SIG-Int caught, exitting"); return_value = 1; break; - case SIGQUIT: log_printf(NOTICE, "SIG-Quit caught, exitting"); return_value = 1; break; - case SIGTERM: log_printf(NOTICE, "SIG-Term caught, exitting"); return_value = 1; break; - case SIGHUP: log_printf(NOTICE, "SIG-Hup caught"); return_value = 2; break; + case SIGINT: log_printf(NOTICE, "SIG-Int caught, exitting"); return_value = SIGINT; break; + case SIGQUIT: log_printf(NOTICE, "SIG-Quit caught, exitting"); return_value = SIGQUIT; break; + case SIGTERM: log_printf(NOTICE, "SIG-Term caught, exitting"); return_value = SIGTERM; break; + case SIGHUP: log_printf(NOTICE, "SIG-Hup caught"); return_value = SIGHUP; break; case SIGUSR1: log_printf(NOTICE, "SIG-Usr1 caught"); break; case SIGUSR2: log_printf(NOTICE, "SIG-Usr2 caught"); break; default: log_printf(WARNING, "unknown signal %d caught, ignoring", sig); break; diff --git a/src/uanytun.c b/src/uanytun.c index 159f773..da90eda 100644 --- a/src/uanytun.c +++ b/src/uanytun.c @@ -52,6 +52,10 @@ #include #include #include +#include +#include +#include +#include #include "log.h" #include "sig_handler.h" @@ -258,9 +262,8 @@ int main_loop(tun_device_t* dev, udp_t* sock, options_t* opt) if(FD_ISSET(sig_fd, &readyfds)) { return_value = signal_handle(); - if(return_value == 1) - break; - else if(return_value == 2) { + if(return_value == SIGINT || return_value == SIGQUIT || return_value == SIGTERM) break; + else if(return_value == SIGHUP) { seq_win_clear(&seq_win); seq_nr = 0; log_printf(NOTICE, "sequence window cleared"); @@ -447,8 +450,11 @@ int main(int argc, char* argv[]) log_printf(NOTICE, "normal shutdown"); else if(ret < 0) log_printf(NOTICE, "shutdown after error"); - else + else { log_printf(NOTICE, "shutdown after signal"); + log_close(); + kill(getpid(), ret); + } log_close(); diff --git a/src/udp.c b/src/udp.c index 9217688..239e074 100644 --- a/src/udp.c +++ b/src/udp.c @@ -65,6 +65,10 @@ #include #include +#ifndef AI_ADDRCONFIG +#define AI_ADDRCONFIG 0 +#endif + static int udp_resolv_local(udp_t* sock, const char* local_addr, const char* port, resolv_addr_type_t resolv_type, unsigned int* idx) { struct addrinfo hints, *res; diff --git a/version b/version index c2c0004..449d7e7 100644 --- a/version +++ b/version @@ -1 +1 @@ -0.3.5 +0.3.6 -- 2.1.4