diff --git a/miniupnpd/Changelog.txt b/miniupnpd/Changelog.txt index 4616f59..858f5e4 100644 --- a/miniupnpd/Changelog.txt +++ b/miniupnpd/Changelog.txt @@ -2,6 +2,7 @@ $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() diff --git a/miniupnpd/Makefile b/miniupnpd/Makefile index 426fa4e..2b6b9b5 100644 --- a/miniupnpd/Makefile +++ b/miniupnpd/Makefile @@ -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 \ diff --git a/miniupnpd/Makefile.linux b/miniupnpd/Makefile.linux index fc81883..7ce7369 100644 --- a/miniupnpd/Makefile.linux +++ b/miniupnpd/Makefile.linux @@ -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 \ diff --git a/miniupnpd/Makefile.linux_nft b/miniupnpd/Makefile.linux_nft index 0d6d546..0894c4b 100644 --- a/miniupnpd/Makefile.linux_nft +++ b/miniupnpd/Makefile.linux_nft @@ -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 \ diff --git a/miniupnpd/gitrev.mk b/miniupnpd/gitrev.mk new file mode 100644 index 0000000..cb59fce --- /dev/null +++ b/miniupnpd/gitrev.mk @@ -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 diff --git a/miniupnpd/miniupnpd.8 b/miniupnpd/miniupnpd.8 index 83123c4..093e38c 100644 --- a/miniupnpd/miniupnpd.8 +++ b/miniupnpd/miniupnpd.8 @@ -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" ] diff --git a/miniupnpd/miniupnpd.c b/miniupnpd/miniupnpd.c index 665499d..84f15d2 100644 --- a/miniupnpd/miniupnpd.c +++ b/miniupnpd/miniupnpd.c @@ -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 #endif +#ifdef ENABLE_HTTPS +#include +#endif #ifdef TOMATO #include @@ -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