Provide OpenVPN version information to plug-ins
cover Provide OpenVPN version information to plug-ins
From: David Sommerseth <[email protected]...>
These two patches enables both OpenVPN version information at compile time and run time. This can be used by plug-ins to adjust it's behavoiour and available features based on which OpenVPN plug-in API it is compiled against and run against.
This should further help writing plug-ins which can be used against a broader set of OpenVPN binaries.
David Sommerseth (2):
Provide compile time OpenVPN version information to plug-ins Provide OpenVPN runtime version information to plug-ins
.gitignore | 1 +
configure.ac | 7 +++++++
include/Makefile.am | 1 +
include/{openvpn-plugin.h => openvpn-plugin.h.in} | 16 +++++++++++++++-
sample/sample-plugins/log/log_v3.c | 6 ++++++
src/openvpn/plugin.c | 21 ++++++++++++++++++++-
version.m4 | 7 ++++++-
7 files changed, 56 insertions(+), 3 deletions(-)
rename include/{openvpn-plugin.h => openvpn-plugin.h.in} (97%)Signature · 1 line
1.8.3.1
PATCH 1/2 Provide compile time OpenVPN version information to plug-ins
From: David Sommerseth <[email protected]...>
This is to provide more fine grained information to plug-ins about the OpenVPN environment when OpenVPN was built.
---
.gitignore | 1 +
configure.ac | 4 ++++
include/Makefile.am | 1 +
include/{openvpn-plugin.h => openvpn-plugin.h.in} | 7 +++++++
version.m4 | 7 ++++++-
5 files changed, 19 insertions(+), 1 deletion(-)
rename include/{openvpn-plugin.h => openvpn-plugin.h.in} (98%).gitignore +1 -0
@@ -54,6 +54,7 @@ distro/rpm/openvpn.spec tests/t_client.sh tests/t_client-*-20??????-??????/ src/openvpn/openvpn +include/openvpn-plugin.h config-version.h nbproject test-driver
configure.ac +4 -0
@@ -30,6 +30,9 @@ m4_include(version.m4) AC_INIT([PRODUCT_NAME], [PRODUCT_VERSION], [PRODUCT_BUGREPORT], [PRODUCT_TARNAME]) m4_include(compat.m4) AC_DEFINE([OPENVPN_VERSION_RESOURCE], [PRODUCT_VERSION_RESOURCE], [Version in windows resource format]) +AC_SUBST([OPENVPN_VERSION_MAJOR], [PRODUCT_VERSION_MAJOR], [OpenVPN major version]) +AC_SUBST([OPENVPN_VERSION_MINOR], [PRODUCT_VERSION_MINOR], [OpenVPN minor version]) +AC_SUBST([OPENVPN_VERSION_PATCH], [PRODUCT_VERSION_PATCH], [OpenVPN patch level - may be a string or integer]) AC_CONFIG_AUX_DIR([.]) AC_CONFIG_HEADERS([config.h])
@@ -1223,6 +1226,7 @@ AC_CONFIG_FILES([ distro/rpm/Makefile distro/rpm/openvpn.spec include/Makefile + include/openvpn-plugin.h src/Makefile src/compat/Makefile src/openvpn/Makefile
include/Makefile.am +1 -0
@@ -11,5 +11,6 @@ MAINTAINERCLEANFILES = \ $(srcdir)/Makefile.in + $(srcdir)/openvpn-plugin.h.in include_HEADERS = openvpn-plugin.h
include/openvpn-plugin.h.in renamed from include/openvpn-plugin.h +7 -0
@@ -49,6 +49,13 @@ typedef X509 openvpn_x509_cert_t; extern "C" { #endif +/* Provide some basic version information to plug-ins at OpenVPN compile time + * This is will not be the complete version + */ +#define OPENVPN_VERSION_MAJOR @OPENVPN_VERSION_MAJOR@ +#define OPENVPN_VERSION_MINOR @OPENVPN_VERSION_MINOR@ +#define OPENVPN_VERSION_PATCH "@OPENVPN_VERSION_PATCH@" + /* * Plug-in types. These types correspond to the set of script callbacks * supported by OpenVPN.
version.m4 +6 -1
@@ -1,7 +1,12 @@ dnl define the OpenVPN version define([PRODUCT_NAME], [OpenVPN]) define([PRODUCT_TARNAME], [openvpn]) -define([PRODUCT_VERSION], [2.3_git]) +define([PRODUCT_VERSION_MAJOR], [2]) +define([PRODUCT_VERSION_MINOR], [3]) +define([PRODUCT_VERSION_PATCH], [_git]) +m4_append([PRODUCT_VERSION], [PRODUCT_VERSION_MAJOR]) +m4_append([PRODUCT_VERSION], [PRODUCT_VERSION_MINOR], [[.]]) +m4_append([PRODUCT_VERSION], [PRODUCT_VERSION_PATCH], [[]]) define([PRODUCT_BUGREPORT], [[email protected]]) define([PRODUCT_VERSION_RESOURCE], [2,3,0,0]) dnl define the TAP version
Signature · 1 line
1.8.3.1
Re: [Openvpn-devel] [PATCH 1/2] Provide compile time OpenVPN version information to plug-ins
Quoted 90 lines · David Sommerseth
From: David Sommerseth <[email protected]...>
This is to provide more fine grained information to plug-ins about the OpenVPN environment when OpenVPN was built.
Signed-off-by David Sommerseth <[email protected]...>--- .gitignore | 1 + configure.ac | 4 ++++ include/Makefile.am | 1 + include/{openvpn-plugin.h => openvpn-plugin.h.in} | 7 +++++++ version.m4 | 7 ++++++- 5 files changed, 19 insertions(+), 1 deletion(-)rename
include/{openvpn-plugin.h=> openvpn-plugin.h.in} (98%).gitignore +1
-0@@ -54,6 +54,7 @@ distro/rpm/openvpn.spec tests/t_client.sh tests/t_client-*-20??????-??????/ src/openvpn/openvpn +include/openvpn-plugin.h config-version.h nbproject test-driverconfigure.ac +4
-0@@ -30,6 +30,9 @@ m4_include(version.m4) AC_INIT([PRODUCT_NAME], [PRODUCT_VERSION], [PRODUCT_BUGREPORT], [PRODUCT_TARNAME]) m4_include(compat.m4) AC_DEFINE([OPENVPN_VERSION_RESOURCE], [PRODUCT_VERSION_RESOURCE], [Version in windows resource format]) +AC_SUBST([OPENVPN_VERSION_MAJOR], [PRODUCT_VERSION_MAJOR], [OpenVPN major version]) +AC_SUBST([OPENVPN_VERSION_MINOR], [PRODUCT_VERSION_MINOR], [OpenVPN minor version]) +AC_SUBST([OPENVPN_VERSION_PATCH], [PRODUCT_VERSION_PATCH], [OpenVPN patch level - may be a string or integer]) AC_CONFIG_AUX_DIR([.]) AC_CONFIG_HEADERS([config.h])@@ -1223,6 +1226,7 @@ AC_CONFIG_FILES([ distro/rpm/Makefile distro/rpm/openvpn.spec include/Makefile + include/openvpn-plugin.h src/Makefile src/compat/Makefile src/openvpn/Makefileinclude/Makefile.am +1
-0@@ -11,5 +11,6 @@ MAINTAINERCLEANFILES = \ $(srcdir)/Makefile.in + $(srcdir)/openvpn-plugin.h.in include_HEADERS = openvpn-plugin.hinclude/openvpn-plugin.h.in renamed from include/openvpn-plugin.h +7
-0@@ -49,6 +49,13 @@ typedef X509 openvpn_x509_cert_t; extern "C" { #endif +/* Provide some basic version information to plug-ins at OpenVPN compile time + * This is will not be the complete version + */ +#define OPENVPN_VERSION_MAJOR @OPENVPN_VERSION_MAJOR@ +#define OPENVPN_VERSION_MINOR @OPENVPN_VERSION_MINOR@ +#define OPENVPN_VERSION_PATCH "@OPENVPN_VERSION_PATCH@" + /* * Plug-in types. These types correspond to the set of script callbacks * supported by OpenVPN.version.m4 +0
-0@@ -1,7 +1,12 @@ dnl define the OpenVPN version define([PRODUCT_NAME], [OpenVPN]) define([PRODUCT_TARNAME], [openvpn])
version.m4 line 12
Quoted 10 lines
version.m4 +6
-1-define([PRODUCT_VERSION], [2.3_git]) +define([PRODUCT_VERSION_MAJOR], [2]) +define([PRODUCT_VERSION_MINOR], [3]) +define([PRODUCT_VERSION_PATCH], [_git]) +m4_append([PRODUCT_VERSION], [PRODUCT_VERSION_MAJOR]) +m4_append([PRODUCT_VERSION], [PRODUCT_VERSION_MINOR], [[.]]) +m4_append([PRODUCT_VERSION], [PRODUCT_VERSION_PATCH], [[]]) define([PRODUCT_BUGREPORT], [[email protected]]) define([PRODUCT_VERSION_RESOURCE], [2,3,0,0]) dnl define the TAP version
ACK
This keeps things the way they are, which helps to get these commits in (hence the ACK), but I think we should reconsider the '2.3_git' name. That causes the slightly weird
define([PRODUCT_VERSION_PATCH], [_git])
which will become a
define([PRODUCT_VERSION_PATCH], [.0])
for a x.y.0 version. Would be nicer if it could just become
define([PRODUCT_VERSION_PATCH], [0])
But we can treat that separate from this patch. This one is fine by me to go in as-is.
-Steffan
[Openvpn-devel] [PATCH applied] Re: Provide compile time OpenVPN version information to plug-ins
In reply to David SommersethYour patch has been applied to the master branch.
commit 9de35d4633ce3035b048957b2e20b81e31a40cd6
Author: David Sommerseth Date: Fri Jul 10 15:22:27 2015 +0200
Provide compile time OpenVPN version information to plug-ins
Signed-off-by: David Sommerseth <[email protected]...>
Acked-by: Steffan Karger <[email protected]...>
Message-Id: <[email protected]...>
URL: http://article.gmane.org/gmane.network.openvpn.devel/9905
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
Re: [Openvpn-devel] [PATCH applied] Re: Provide compile time OpenVPN version information to plug-ins
Hi,
Quoted 1 line · Gert Doering
Your patch has been applied to the master branch.
Actually, not... this breaks out of tree builds...
gcc -DHAVE_CONFIG_H -I. -I../../../openvpn/src/openvpn -I../.. -I../../../openvpn/include -I../../../openvpn/src/compat -g -O2 -MT error.o -MD -MP -MF .deps/error.Tpo -c -o error.o ../../../openvpn/src/openvpn/error.c
In file included from ../../../openvpn/src/openvpn/options.h:39:0,
from ../../../openvpn/src/openvpn/ssl.h:43,
from ../../../openvpn/src/openvpn/ps.h:32,
from ../../../openvpn/src/openvpn/error.c:43:
../../../openvpn/src/openvpn/plugin.h:38:28: fatal error: openvpn-plugin.h: No such file or directory
#include "openvpn-plugin.h"
^compilation terminated.
openvpn-plugin.h is nicely built from openvpn-plugin.h.in, but it is built in the *build* tree, and the -I statements above do not look there - it would need an "-I../../include" to work...
config.h is built in the root directory of the build tree, so "-I../.." catches that. Since we have nothing else in ../../include/, nothing adds it to the compile statement (and I'm not overly eager to see it there, already quite a bit of stuff on the command line).
So... patches, or revert time?
gert
Signature · 4 lines
USENET is *not* the non-clickable part of WWW!
//www.muc.de/~gert/
Gert Doering - Munich, Germany [email protected]...
fax: +49-89-35655025 [email protected]...Re: [Openvpn-devel] [PATCH applied] Re: Provide compile time OpenVPN version information to plug-ins
Quoted 15 lines · Gert Doering
Hi,
Quoted 1 line · Gert Doering
Your patch has been applied to the master branch.
Actually, not... this breaks out of tree builds...
gcc -DHAVE_CONFIG_H -I. -I../../../openvpn/src/openvpn -I../.. -I../../../openvpn/include -I../../../openvpn/src/compat -g -O2 -MT error.o -MD -MP -MF .deps/error.Tpo -c -o error.o
../../../openvpn/src/openvpn/error.c
In file included from../../../openvpn/src/openvpn/options.h:39:0,from ../../../openvpn/src/openvpn/ssl.h:43, from ../../../openvpn/src/openvpn/ps.h:32, from ../../../openvpn/src/openvpn/error.c:43: ../../../openvpn/src/openvpn/plugin.h:38:28: fatal error: openvpn-plugin.h: No such file or directory #include "openvpn-plugin.h" ^
Quoted 6 lines
compilation terminated.
openvpn-plugin.his nicely built from openvpn-plugin.h.in, but it is built in the *build* tree, and the -I statements above do not look there - it would need an "-I../../include" to work...
Hmmm ... That's surprising, as I'd expect we would have the same troubles also without these patches - as openvpn-plugin.h isn't really touched.
Quoted 6 lines
config.his built in the root directory of the build tree, so "-I../.." catches that. Since we have nothing else in ../../include/, nothing adds it to the compile statement (and I'm not overly eager to see it there, already quite a bit of stuff on the command line).So... patches, or revert time?
I'll do some more investigation and fix this ASAP (at least within this week).
Signature · 3 lines
kind regards, David Sommerseth
Re: [Openvpn-devel] [PATCH applied] Re: Provide compile time OpenVPN version information to plug-ins
Quoted 19 lines · David Sommerseth
Quoted 18 lines · Gert Doering
Hi,
Quoted 1 line · Gert Doering
Your patch has been applied to the master branch.
Actually, not... this breaks out of tree builds...
gcc -DHAVE_CONFIG_H -I. -I../../../openvpn/src/openvpn -I../.. -I../../../openvpn/include -I../../../openvpn/src/compat -g -O2 -MT error.o -MD -MP -MF .deps/error.Tpo -c -o error.o
../../../openvpn/src/openvpn/error.c
In file included from../../../openvpn/src/openvpn/options.h:39:0,from ../../../openvpn/src/openvpn/ssl.h:43, from ../../../openvpn/src/openvpn/ps.h:32, from ../../../openvpn/src/openvpn/error.c:43: ../../../openvpn/src/openvpn/plugin.h:38:28: fatal error: openvpn-plugin.h: No such file or directory #include "openvpn-plugin.h" ^compilation terminated.
Quoted 6 lines
Quoted 3 lines
openvpn-plugin.his nicely built from openvpn-plugin.h.in, but it is built in the *build* tree, and the -I statements above do not look there - it would need an "-I../../include" to work...Hmmm ... That's surprising, as I'd expect we would have the same troubles also without these patches - as
openvpn-plugin.hisn't really touched.
openvpn-plugin.h changed from 'static in the source tree' to 'generated by autotools' (and thus placed in the build tree). The location in the build tree was not in the include list.
Quoted 8 lines
Quoted 6 lines
config.his built in the root directory of the build tree, so "-I../.." catches that. Since we have nothing else in ../../include/, nothing adds it to the compile statement (and I'm not overly eager to see it there, already quite a bit of stuff on the command line).So... patches, or revert time?
I'll do some more investigation and fix this ASAP (at least within this week).
Fixes are already applied to the master branch. You can just sit back and relax :)
-Steffan
Re: [Openvpn-devel] [PATCH applied] Re: Provide compile time OpenVPN version information to plug-ins
Quoted 25 lines · Steffan Karger
Quoted 23 lines · David Sommerseth
Quoted 21 lines · Gert Doering
Hi,
Quoted 1 line · Gert Doering
Your patch has been applied to the master branch.
Actually, not... this breaks out of tree builds...
gcc -DHAVE_CONFIG_H -I. -I../../../openvpn/src/openvpn -I../.. -I../../../openvpn/include -I../../../openvpn/src/compat -g -O2 -MT error.o -MD -MP -MF .deps/error.Tpo -c -o error.o
../../../openvpn/src/openvpn/error.c
In file included from../../../openvpn/src/openvpn/options.h:39:0,from ../../../openvpn/src/openvpn/ssl.h:43, from ../../../openvpn/src/openvpn/ps.h:32, from ../../../openvpn/src/openvpn/error.c:43: ../../../openvpn/src/openvpn/plugin.h:38:28: fatal error: openvpn-plugin.h: No such file or directory #include "openvpn-plugin.h" ^compilation terminated.
openvpn-plugin.his nicely built from openvpn-plugin.h.in, but it is built in the *build* tree, and the -I statements above do not look there - it would need an "-I../../include" to work...
Quoted 6 lines
Quoted 2 lines
Hmmm ... That's surprising, as I'd expect we would have the same troubles also without these patches - as
openvpn-plugin.hisn't really touched.
openvpn-plugin.hchanged from 'static in the source tree' to 'generated by autotools' (and thus placed in the build tree). The location in the build tree was not in the include list.
Ahh! autotools magic, once again.
Quoted 11 lines
Quoted 8 lines
Quoted 6 lines
config.his built in the root directory of the build tree, so "-I../.." catches that. Since we have nothing else in ../../include/, nothing adds it to the compile statement (and I'm not overly eager to see it there, already quite a bit of stuff on the command line).So... patches, or revert time?
I'll do some more investigation and fix this ASAP (at least within this week).
Fixes are already applied to the master branch. You can just sit back and relax :)
Thanks a lot! Noticed building worked fine when I did a test build ... and noticed your patch in the log too late :)
Signature · 3 lines
kind regards, David Sommerseth
Re: [Openvpn-devel] [PATCH applied] Re: Provide compile time OpenVPN version information to plug-ins
In reply to David SommersethHi,
Quoted 6 lines · David Sommerseth
Quoted 3 lines
openvpn-plugin.his nicely built from openvpn-plugin.h.in, but it is built in the *build* tree, and the -I statements above do not look there - it would need an "-I../../include" to work...Hmmm ... That's surprising, as I'd expect we would have the same troubles also without these patches - as
openvpn-plugin.hisn't really touched.
Of course it is :-) - before the patches, it was always living in $(srcdir)/include/openvpn-plugin.h
Now it's in
$(srcdir)/include/openvpn-plugin.h.in
and then transformed to -> $(builddir)/include/openvpn-plugin.h
and $(builddir)/include wasn't in the -I path.
Steffan fixed that yesterday evening already.
gert
Signature · 4 lines
USENET is *not* the non-clickable part of WWW!
//www.muc.de/~gert/
Gert Doering - Munich, Germany [email protected]...
fax: +49-89-35655025 [email protected]...PATCH 2/2 Provide OpenVPN runtime version information to plug-ins
In reply to David SommersethFrom: David Sommerseth <[email protected]...>
Also updated the log_v3 sample-plugin to demonstrate how this works.
$ openvpn --plugin log_v3.so --dev tun Fri Jul 10 15:17:28 2015 OpenVPN 2.3_git [git:dev/plugin-version/f05d8623a29078bf+]..... ...more.openvpn.logging... log_v3: OpenVPN 2.3_git (Major: 2, Minor: 3, Patch: git:dev/plugin-version/f05d8623a29078bf+) ...more.openvpn.logging... $
--- configure.ac | 3 +++ include/openvpn-plugin.h.in | 9 ++++++++- sample/sample-plugins/log/log_v3.c | 6 ++++++ src/openvpn/plugin.c | 21 ++++++++++++++++++++- 4 files changed, 37 insertions(+), 2 deletions(-)
configure.ac +3 -0
@@ -33,6 +33,9 @@ AC_DEFINE([OPENVPN_VERSION_RESOURCE], [PRODUCT_VERSION_RESOURCE], [Version in wi AC_SUBST([OPENVPN_VERSION_MAJOR], [PRODUCT_VERSION_MAJOR], [OpenVPN major version]) AC_SUBST([OPENVPN_VERSION_MINOR], [PRODUCT_VERSION_MINOR], [OpenVPN minor version]) AC_SUBST([OPENVPN_VERSION_PATCH], [PRODUCT_VERSION_PATCH], [OpenVPN patch level - may be a string or integer]) +AC_DEFINE([OPENVPN_VERSION_MAJOR], [PRODUCT_VERSION_MAJOR], [OpenVPN major version - integer]) +AC_DEFINE([OPENVPN_VERSION_MINOR], [PRODUCT_VERSION_MINOR], [OpenVPN minor version - integer]) +AC_DEFINE([OPENVPN_VERSION_PATCH], ["PRODUCT_VERSION_PATCH"], [OpenVPN patch level - may be a string or integer]) AC_CONFIG_AUX_DIR([.]) AC_CONFIG_HEADERS([config.h])
include/openvpn-plugin.h.in +8 -1
@@ -215,8 +215,11 @@ struct openvpn_plugin_string_list * which identifies the SSL implementation OpenVPN is compiled * against. * + * 3 Added ovpn_version, ovpn_version_major, ovpn_version_minor + * and ovpn_version_patch to provide the runtime version of + * OpenVPN to plug-ins. */ -#define OPENVPN_PLUGINv3_STRUCTVER 2 +#define OPENVPN_PLUGINv3_STRUCTVER 3 /** * Definitions needed for the plug-in callback functions.
@@ -311,6 +314,10 @@ struct openvpn_plugin_args_open_in const char ** const envp; struct openvpn_plugin_callbacks *callbacks; const ovpnSSLAPI ssl_api; + const char *ovpn_version; + const unsigned int ovpn_version_major; + const unsigned int ovpn_version_minor; + const char * const ovpn_version_patch; };
sample/sample-plugins/log/log_v3.c +6 -0
@@ -82,6 +82,7 @@ openvpn_plugin_open_v3 (const int v3structver,/* Check that we are API compatible */ if ( v3structver != OPENVPN_PLUGINv3_STRUCTVER ) { +printf ("log_v3: ** ERROR ** Incompatible plug-in interface between this plug-in and OpenVPN\n" );return OPENVPN_PLUGIN_FUNC_ERROR ; }
@@ -90,6 +91,11 @@ openvpn_plugin_open_v3 (const int v3structver,return OPENVPN_PLUGIN_FUNC_ERROR ; } +/* Print some version information about the OpenVPN process using this plug-in */ +printf ("log_v3: OpenVPN %s (Major: %i, Minor: %i, Patch: %s)\n" , + args->ovpn_version, args->ovpn_version_major, + args->ovpn_version_minor, args->ovpn_version_patch); +/* Which callbacks to intercept. */ ret->type_mask = OPENVPN_PLUGIN_MASK (OPENVPN_PLUGIN_UP) |
src/openvpn/plugin.c +20 -1
@@ -27,6 +27,9 @@#elif defined(_MSC_VER)#include "config-msvc.h" #endif +#ifdef HAVE_CONFIG_VERSION_H +#include "config-version.h" +#endif #include "syshead.h"
@@ -347,6 +350,17 @@ static struct openvpn_plugin_callbacks callbacks = {plugin_vlog }; + +/* Provide a wrapper macro for a version patch level string to plug-ins. +* This is located here purely to not make the code too messy with #ifndef +* inside a struct declaration +*/ +#ifndef CONFIGURE_GIT_REVISION +# define _OPENVPN_PATCH_LEVEL OPENVPN_VERSION_PATCH +#else +# define _OPENVPN_PATCH_LEVEL "git:" CONFIGURE_GIT_REVISION CONFIGURE_GIT_FLAGS +#endif + static void plugin_open_item (struct plugin *p, const struct plugin_option *o,
@@ -375,7 +389,12 @@ plugin_open_item (struct plugin *p, (const char **const ) o->argv, (const char **const ) envp, &callbacks, - SSLAPI }; +SSLAPI , +PACKAGE_VERSION , +OPENVPN_VERSION_MAJOR , +OPENVPN_VERSION_MINOR , + _OPENVPN_PATCH_LEVEL + };struct openvpn_plugin_args_open_return retargs;CLEAR (retargs);
Signature · 1 line
1.8.3.1
[Openvpn-devel] [PATCH applied] Re: Provide OpenVPN runtime version information to plug-ins
ACK. Your patch has been applied to the master branch.
commit 6a40276c7500c2d0a2fe44b1a450ffe9cb2f37cd
Author: David Sommerseth Date: Fri Jul 10 15:22:28 2015 +0200
Provide OpenVPN runtime version information to plug-ins
Signed-off-by: David Sommerseth <[email protected]...>
Acked-by: Gert Doering <[email protected]...>
Message-Id: <[email protected]...>
URL: http://article.gmane.org/gmane.network.openvpn.devel/9904
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering