miniupnpd: Add --version commandline option

fixes #370
This commit is contained in:
Thomas Bernard 2019-10-05 21:59:42 +02:00
parent 700b86eeda
commit 49d3b57441
No known key found for this signature in database
GPG Key ID: 0FF11B67A5C0863C
7 changed files with 46 additions and 3 deletions

View File

@ -2,6 +2,7 @@ $Id: Changelog.txt,v 1.455 2019/10/05 18:05:10 nanard Exp $
2019/10/05: 2019/10/05:
Use OpenSSL TLS_server_method() instead of TLSv1_server_method() 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 \

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