Merge branch 'version'

This commit is contained in:
Thomas Bernard 2019-10-06 22:17:25 +02:00
commit 8ac3784fe2
9 changed files with 72 additions and 8 deletions

View File

@ -56,11 +56,11 @@ script:
make -f $MAKEFILE depend; make -f $MAKEFILE depend;
fi fi
- 'CONFIG_OPTIONS="--ipv6 --igd2" make -f $MAKEFILE -j3' - 'CONFIG_OPTIONS="--ipv6 --igd2" make -f $MAKEFILE -j3'
- make -f $MAKEFILE check
- if [ "$TRAVIS_OS_NAME" = "linux" ] && [ "$PROJECT" = "miniupnpd" ]; then - if [ "$TRAVIS_OS_NAME" = "linux" ] && [ "$PROJECT" = "miniupnpd" ]; then
make -f Makefile.linux_nft clean ; make -f Makefile.linux_nft clean ;
make -f Makefile.linux_nft ; make -f Makefile.linux_nft ;
fi fi
- make -f $MAKEFILE check
- 'if [ "$TRAVIS_OS_NAME" = "linux" ] && [ "$PROJECT" = "miniupnpd" ]; then make -f $MAKEFILE dox ; fi' - 'if [ "$TRAVIS_OS_NAME" = "linux" ] && [ "$PROJECT" = "miniupnpd" ]; then make -f $MAKEFILE dox ; fi'
- if [ "$PROJECT" = "miniupnpc" ]; then - if [ "$PROJECT" = "miniupnpc" ]; then
INSTALLPREFIX="$HOME/_pythonmodule" make -f $MAKEFILE pythonmodule; INSTALLPREFIX="$HOME/_pythonmodule" make -f $MAKEFILE pythonmodule;

View File

@ -1,4 +1,8 @@
$Id: Changelog.txt,v 1.454 2019/10/03 20:40:37 nanard Exp $ $Id: Changelog.txt,v 1.455 2019/10/05 18:05:10 nanard Exp $
2019/10/05:
Use OpenSSL TLS_server_method() instead of TLSv1_server_method()
Add --version commandline option
2019/10/03: 2019/10/03:
Use OpenBSD pledge() Use OpenBSD pledge()

View File

@ -98,6 +98,13 @@ CFLAGS += -m64 -mcmodel=medlow
.endif .endif
.endif .endif
ISGITREPO != git rev-parse --is-inside-work-tree
.if $(ISGITREPO) == "true"
GITREF != git rev-parse --short HEAD
GITBRANCH != git rev-parse --abbrev-ref HEAD
CFLAGS += -DMINIUPNPD_GIT_REF=\"$(GITBRANCH)-$(GITREF)\"
.endif
STDOBJS = miniupnpd.o upnphttp.o upnpdescgen.o upnpsoap.o \ STDOBJS = miniupnpd.o upnphttp.o upnpdescgen.o upnpsoap.o \
upnpredirect.o getifaddr.o daemonize.o upnpglobalvars.o \ upnpredirect.o getifaddr.o daemonize.o upnpglobalvars.o \
options.o upnppermissions.o minissdp.o natpmp.o pcpserver.o \ options.o upnppermissions.o minissdp.o natpmp.o pcpserver.o \

View File

@ -48,6 +48,8 @@ SBININSTALLDIR = $(INSTALLPREFIX)/sbin
ETCINSTALLDIR = $(PREFIX)/etc/miniupnpd ETCINSTALLDIR = $(PREFIX)/etc/miniupnpd
MANINSTALLDIR = $(INSTALLPREFIX)/share/man/man8 MANINSTALLDIR = $(INSTALLPREFIX)/share/man/man8
include gitrev.mk
BASEOBJS = miniupnpd.o upnphttp.o upnpdescgen.o upnpsoap.o \ BASEOBJS = miniupnpd.o upnphttp.o upnpdescgen.o upnpsoap.o \
upnpreplyparse.o minixml.o portinuse.o \ upnpreplyparse.o minixml.o portinuse.o \
upnpredirect.o getifaddr.o daemonize.o upnpglobalvars.o \ upnpredirect.o getifaddr.o daemonize.o upnpglobalvars.o \
@ -238,7 +240,13 @@ else
sed -i -e "s/^uuid=[-0-9a-f]*/uuid=`($(STAGING_DIR_HOST)/bin/genuuid||$(STAGING_DIR_HOST)/bin/uuidgen||$(STAGING_DIR_HOST)/bin/uuid) 2>/dev/null`/" miniupnpd.conf sed -i -e "s/^uuid=[-0-9a-f]*/uuid=`($(STAGING_DIR_HOST)/bin/genuuid||$(STAGING_DIR_HOST)/bin/uuidgen||$(STAGING_DIR_HOST)/bin/uuid) 2>/dev/null`/" miniupnpd.conf
endif endif
check: validateupnppermissions validategetifaddr validatessdppktgen check: validateupnppermissions validategetifaddr validatessdppktgen \
validateversion
validateversion: miniupnpd VERSION
./miniupnpd --version
[ "`./miniupnpd --version | head -1 | cut -d' ' -f-2`" = "miniupnpd `cat VERSION`" ]
touch $@
validateupnppermissions: testupnppermissions testupnppermissions.sh validateupnppermissions: testupnppermissions testupnppermissions.sh
./testupnppermissions.sh ./testupnppermissions.sh

View File

@ -39,6 +39,8 @@ SBININSTALLDIR = $(INSTALLPREFIX)/sbin
ETCINSTALLDIR = $(PREFIX)/etc/miniupnpd ETCINSTALLDIR = $(PREFIX)/etc/miniupnpd
MANINSTALLDIR = $(INSTALLPREFIX)/share/man/man8 MANINSTALLDIR = $(INSTALLPREFIX)/share/man/man8
include gitrev.mk
BASEOBJS = miniupnpd.o upnphttp.o upnpdescgen.o upnpsoap.o \ BASEOBJS = miniupnpd.o upnphttp.o upnpdescgen.o upnpsoap.o \
upnpreplyparse.o minixml.o portinuse.o \ upnpreplyparse.o minixml.o portinuse.o \
upnpredirect.o getifaddr.o daemonize.o \ upnpredirect.o getifaddr.o daemonize.o \

9
miniupnpd/gitrev.mk Normal file
View File

@ -0,0 +1,9 @@
# (c) 2019 Thomas Bernard
# For GNU Make
ISGITREPO := $(shell git rev-parse --is-inside-work-tree)
ifeq ($(ISGITREPO),true)
GITREF := $(shell git rev-parse --short HEAD)
GITBRANCH := $(shell git rev-parse --abbrev-ref HEAD)
CFLAGS += -DMINIUPNPD_GIT_REF=\"$(GITBRANCH)-$(GITREF)\"
endif

View File

@ -3,7 +3,8 @@
miniupnpd \- UPnP Internet Gateway Device Daemon miniupnpd \- UPnP Internet Gateway Device Daemon
.SH SYNOPSIS .SH SYNOPSIS
.B miniupnpd .B miniupnpd
.RB [ "\-f \fIconfig_file" "] [" "\-i \fIext_ifname" "] [" "\-o \fIext_ip" ] .RB [--version]
.RB [ "\-f \fIconfig_file" "] [" "\-i \fIext_ifname" "] [" "\-I \fIext_ifname6" "] [" "\-o \fIext_ip" ]
.RB [ "\-a \fIlistening_ip" "] [" "\-p \fIport" "] [" \-d "] [" \-U "] [" \-S "] [" \-N ] .RB [ "\-a \fIlistening_ip" "] [" "\-p \fIport" "] [" \-d "] [" \-U "] [" \-S "] [" \-N ]
.RB [ "\-u \fIuuid" "] [" "\-s \fIserial" "] [" "\-m \fImodel_number" ] .RB [ "\-u \fIuuid" "] [" "\-s \fIserial" "] [" "\-m \fImodel_number" ]
.RB [ "\-t \fInotify_interval" "] [" "\-P \fIpid_filename" ] .RB [ "\-t \fInotify_interval" "] [" "\-P \fIpid_filename" ]

View File

@ -1,4 +1,4 @@
/* $Id: miniupnpd.c,v 1.237 2019/10/03 20:40:40 nanard Exp $ */ /* $Id: miniupnpd.c,v 1.239 2019/10/05 20:21:47 nanard Exp $ */
/* vim: tabstop=4 shiftwidth=4 noexpandtab /* vim: tabstop=4 shiftwidth=4 noexpandtab
* MiniUPnP project * MiniUPnP project
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
@ -49,6 +49,9 @@
#ifdef USE_MINIUPNPDCTL #ifdef USE_MINIUPNPDCTL
#include <sys/un.h> #include <sys/un.h>
#endif #endif
#ifdef ENABLE_HTTPS
#include <openssl/crypto.h>
#endif
#ifdef TOMATO #ifdef TOMATO
#include <sys/stat.h> #include <sys/stat.h>
@ -1851,6 +1854,7 @@ init(int argc, char * * argv, struct runtime_vars * v)
return 0; return 0;
print_usage: print_usage:
fprintf(stderr, "Usage:\n\t" fprintf(stderr, "Usage:\n\t"
"%s --version\n\t"
"%s " "%s "
#ifndef DISABLE_CONFIG_FILE #ifndef DISABLE_CONFIG_FILE
"[-f config_file] " "[-f config_file] "
@ -1930,7 +1934,7 @@ print_usage:
"\t-1 force reporting IGDv1 in rootDesc *use with care*\n" "\t-1 force reporting IGDv1 in rootDesc *use with care*\n"
#endif #endif
"\t-h prints this help and quits.\n" "\t-h prints this help and quits.\n"
"", argv[0], pidfilename, DEFAULT_CONFIG); "", argv[0], argv[0], pidfilename, DEFAULT_CONFIG);
return 1; return 1;
} }
@ -1991,6 +1995,23 @@ main(int argc, char * * argv)
unsigned int next_pinhole_ts; unsigned int next_pinhole_ts;
#endif #endif
for(i = 0; i < argc; i++) {
if(strcmp(argv[i], "version") == 0 || strcmp(argv[i], "--version") == 0) {
puts("miniupnpd " MINIUPNPD_VERSION
#ifdef MINIUPNPD_GIT_REF
" " MINIUPNPD_GIT_REF
#endif
" " __DATE__ );
#ifdef ENABLE_HTTPS
#ifdef OPENSSL_VERSION
puts(OpenSSL_version(OPENSSL_VERSION));
#else
puts(SSLeay_version(SSLEAY_VERSION));
#endif
#endif
return 0;
}
}
if(init(argc, argv, &v) != 0) if(init(argc, argv, &v) != 0)
return 1; return 1;
#ifdef ENABLE_HTTPS #ifdef ENABLE_HTTPS

View File

@ -1,9 +1,9 @@
/* $Id: upnphttp.c,v 1.107 2018/01/16 00:50:49 nanard Exp $ */ /* $Id: upnphttp.c,v 1.108 2019/10/05 18:05:13 nanard Exp $ */
/* vim: tabstop=4 shiftwidth=4 noexpandtab /* vim: tabstop=4 shiftwidth=4 noexpandtab
* Project : miniupnp * Project : miniupnp
* Website : http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ * Website : http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
* Author : Thomas Bernard * Author : Thomas Bernard
* Copyright (c) 2005-2018 Thomas Bernard * Copyright (c) 2005-2019 Thomas Bernard
* This software is subject to the conditions detailed in the * This software is subject to the conditions detailed in the
* LICENCE file included in this distribution. * LICENCE file included in this distribution.
* */ * */
@ -67,9 +67,17 @@ int init_ssl(void)
const SSL_METHOD *method; const SSL_METHOD *method;
SSL_library_init(); SSL_library_init();
SSL_load_error_strings(); SSL_load_error_strings();
#if OPENSSL_VERSION_NUMBER < 0x10100000L
method = TLSv1_server_method(); method = TLSv1_server_method();
#else
method = TLS_server_method();
#endif
if(method == NULL) { if(method == NULL) {
#if OPENSSL_VERSION_NUMBER < 0x10100000L
syslog(LOG_ERR, "TLSv1_server_method() failed"); syslog(LOG_ERR, "TLSv1_server_method() failed");
#else
syslog(LOG_ERR, "TLS_server_method() failed");
#endif
syslogsslerr(); syslogsslerr();
return -1; return -1;
} }
@ -111,7 +119,11 @@ void free_ssl(void)
SSL_CTX_free(ssl_ctx); SSL_CTX_free(ssl_ctx);
ssl_ctx = NULL; ssl_ctx = NULL;
} }
#if OPENSSL_VERSION_NUMBER >= 0x10000000L && OPENSSL_VERSION_NUMBER < 0x10100000L
ERR_remove_thread_state(NULL);
#elif OPENSSL_VERSION_NUMBER < 0x10000000L
ERR_remove_state(0); ERR_remove_state(0);
#endif
ENGINE_cleanup(); ENGINE_cleanup();
CONF_modules_unload(1); CONF_modules_unload(1);
ERR_free_strings(); ERR_free_strings();