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;
fi
- 'CONFIG_OPTIONS="--ipv6 --igd2" make -f $MAKEFILE -j3'
- make -f $MAKEFILE check
- if [ "$TRAVIS_OS_NAME" = "linux" ] && [ "$PROJECT" = "miniupnpd" ]; then
make -f Makefile.linux_nft clean ;
make -f Makefile.linux_nft ;
fi
- make -f $MAKEFILE check
- 'if [ "$TRAVIS_OS_NAME" = "linux" ] && [ "$PROJECT" = "miniupnpd" ]; then make -f $MAKEFILE dox ; fi'
- if [ "$PROJECT" = "miniupnpc" ]; then
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:
Use OpenBSD pledge()

View File

@ -98,6 +98,13 @@ CFLAGS += -m64 -mcmodel=medlow
.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 \
upnpredirect.o getifaddr.o daemonize.o upnpglobalvars.o \
options.o upnppermissions.o minissdp.o natpmp.o pcpserver.o \

View File

@ -48,6 +48,8 @@ SBININSTALLDIR = $(INSTALLPREFIX)/sbin
ETCINSTALLDIR = $(PREFIX)/etc/miniupnpd
MANINSTALLDIR = $(INSTALLPREFIX)/share/man/man8
include gitrev.mk
BASEOBJS = miniupnpd.o upnphttp.o upnpdescgen.o upnpsoap.o \
upnpreplyparse.o minixml.o portinuse.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
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
./testupnppermissions.sh

View File

@ -39,6 +39,8 @@ SBININSTALLDIR = $(INSTALLPREFIX)/sbin
ETCINSTALLDIR = $(PREFIX)/etc/miniupnpd
MANINSTALLDIR = $(INSTALLPREFIX)/share/man/man8
include gitrev.mk
BASEOBJS = miniupnpd.o upnphttp.o upnpdescgen.o upnpsoap.o \
upnpreplyparse.o minixml.o portinuse.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
.SH SYNOPSIS
.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 [ "\-u \fIuuid" "] [" "\-s \fIserial" "] [" "\-m \fImodel_number" ]
.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
* MiniUPnP project
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
@ -49,6 +49,9 @@
#ifdef USE_MINIUPNPDCTL
#include <sys/un.h>
#endif
#ifdef ENABLE_HTTPS
#include <openssl/crypto.h>
#endif
#ifdef TOMATO
#include <sys/stat.h>
@ -1851,6 +1854,7 @@ init(int argc, char * * argv, struct runtime_vars * v)
return 0;
print_usage:
fprintf(stderr, "Usage:\n\t"
"%s --version\n\t"
"%s "
#ifndef DISABLE_CONFIG_FILE
"[-f config_file] "
@ -1930,7 +1934,7 @@ print_usage:
"\t-1 force reporting IGDv1 in rootDesc *use with care*\n"
#endif
"\t-h prints this help and quits.\n"
"", argv[0], pidfilename, DEFAULT_CONFIG);
"", argv[0], argv[0], pidfilename, DEFAULT_CONFIG);
return 1;
}
@ -1991,6 +1995,23 @@ main(int argc, char * * argv)
unsigned int next_pinhole_ts;
#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)
return 1;
#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
* Project : miniupnp
* Website : http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
* 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
* LICENCE file included in this distribution.
* */
@ -67,9 +67,17 @@ int init_ssl(void)
const SSL_METHOD *method;
SSL_library_init();
SSL_load_error_strings();
#if OPENSSL_VERSION_NUMBER < 0x10100000L
method = TLSv1_server_method();
#else
method = TLS_server_method();
#endif
if(method == NULL) {
#if OPENSSL_VERSION_NUMBER < 0x10100000L
syslog(LOG_ERR, "TLSv1_server_method() failed");
#else
syslog(LOG_ERR, "TLS_server_method() failed");
#endif
syslogsslerr();
return -1;
}
@ -111,7 +119,11 @@ void free_ssl(void)
SSL_CTX_free(ssl_ctx);
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);
#endif
ENGINE_cleanup();
CONF_modules_unload(1);
ERR_free_strings();