]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
Clean up plugin path handling
authorChristian Hesse <mail@eworm.de>
Wed, 25 Jan 2017 20:19:47 +0000 (21:19 +0100)
committerDavid Sommerseth <davids@openvpn.net>
Wed, 25 Jan 2017 21:13:38 +0000 (22:13 +0100)
Drop --with-plugindir, instead use an environment variable PLUGINDIR
to specify the plugin directory.

This puts a define into include/openvpn-plugin.h.in which has the plugin
directory.

The configure script does not know about the final plugin path. Thus we
have to make Make generate the final header file for us.

As the path is always available remove the compile time condition (and
dead code) from src/openvpn/plugin.c.

v2: The configure script can not evaluate the final $libdir path. So
    use make to create a header file on the containing the final path.

v3: Fix whitespace errors and gitignore location.

v4: No extra header file, generate src/openvpn/plugin.h on the fly.
    Remove condition and dead code.

v5: Move the define to include/openvpn-plugin.h.in and let make generate
    the final header file.

Signed-off-by: Christian Hesse <mail@eworm.de>
Acked-by: David Sommerseth <davids@openvpn.net>
Message-Id: <20170125201947.17197-1-list@eworm.de>
URL: http://www.mail-archive.com/search?l=mid&q=20170125201947.17197-1-list@eworm.de
Signed-off-by: David Sommerseth <davids@openvpn.net>
(cherry picked from commit 4590c3831d0400096fab08aa1ed7f909da870ced)

configure.ac
include/Makefile.am
include/openvpn-plugin.h.in
src/openvpn/plugin.c

index 79fb1ba2499c79a72e1671c7d0807169bff7a4f8..f305c54880ddd37564c71870bd6f3f631e321a5c 100644 (file)
@@ -38,7 +38,7 @@ AC_DEFINE([OPENVPN_VERSION_MINOR], [PRODUCT_VERSION_MINOR], [OpenVPN minor versi
 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])
+AC_CONFIG_HEADERS([config.h])
 AC_CONFIG_SRCDIR([src/openvpn/syshead.h])
 AC_CONFIG_MACRO_DIR([m4])
 
@@ -301,13 +301,12 @@ AC_ARG_WITH(
        [with_crypto_library="openssl"]
 )
 
-AC_ARG_WITH(
-       [plugindir],
-       [AS_HELP_STRING([--with-plugindir], [plugin directory @<:@default=LIBDIR/openvpn@:>@])],
-       ,
-       [with_plugindir="\$(libdir)/openvpn/plugins"]
-)
-
+AC_ARG_VAR([PLUGINDIR], [Path of plug-in directory @<:@default=LIBDIR/openvpn/plugins@:>@])
+if test -n "${PLUGINDIR}"; then
+       plugindir="${PLUGINDIR}"
+else
+       plugindir="\${libdir}/openvpn/plugins"
+fi
 
 AC_DEFINE_UNQUOTED([TARGET_ALIAS], ["${host}"], [A string representing our host])
 case "$host" in
@@ -1284,7 +1283,6 @@ AM_CONDITIONAL([ENABLE_PLUGIN_DOWN_ROOT], [test "${enable_plugin_down_root}" = "
 AM_CONDITIONAL([ENABLE_CRYPTO], [test "${enable_crypto}" = "yes"])
 AM_CONDITIONAL([HAVE_LD_WRAP_SUPPORT], [test "${have_ld_wrap_support}" = "yes"])
 
-plugindir="${with_plugindir}"
 sampledir="\$(docdir)/sample"
 AC_SUBST([plugindir])
 AC_SUBST([sampledir])
index a52c4278bce00ee3453ba590ed0ef0645466535d..37962a6f21e2cb74497bf7ff00425160e5696e61 100644 (file)
@@ -16,3 +16,10 @@ MAINTAINERCLEANFILES = \
 include_HEADERS = \
        openvpn-plugin.h \
        openvpn-msg.h
+
+openvpn-plugin.h: openvpn-plugin.h.in Makefile
+       $(AM_V_GEN)sed -e 's|\@PLUGINDIR\@|$(plugindir)|' \
+               -e 's|\@OPENVPN_VERSION_MAJOR\@|$(OPENVPN_VERSION_MAJOR)|' \
+               -e 's|\@OPENVPN_VERSION_MINOR\@|$(OPENVPN_VERSION_MINOR)|' \
+               -e 's|\@OPENVPN_VERSION_PATCH\@|$(OPENVPN_VERSION_PATCH)|' \
+               $< > $@.tmp && mv $@.tmp $@
index 0b303520a305448003541afae306e0221aaa4410..a084fc1a7d0bacb0bbae4e5da34569ef86156080 100644 (file)
@@ -27,6 +27,8 @@
 
 #define OPENVPN_PLUGIN_VERSION 3
 
+#define PLUGIN_LIBDIR "@PLUGINDIR@"
+
 #ifdef ENABLE_CRYPTO
 #ifdef ENABLE_CRYPTO_MBEDTLS
 #include <mbedtls/x509_crt.h>
index e530c0c5f3e3fa2dbbcf5476df9a2879646acf6b..f77702786f49c218e9eed8eb27226b6319215dcd 100644 (file)
@@ -234,23 +234,15 @@ plugin_init_item(struct plugin *p, const struct plugin_option *o)
 #ifndef _WIN32
 
     p->handle = NULL;
-#if defined(PLUGIN_LIBDIR)
+
     if (!absolute_pathname(p->so_pathname))
     {
         char full[PATH_MAX];
 
         openvpn_snprintf(full, sizeof(full), "%s/%s", PLUGIN_LIBDIR, p->so_pathname);
         p->handle = dlopen(full, RTLD_NOW);
-#if defined(ENABLE_PLUGIN_SEARCH)
-        if (!p->handle)
-        {
-            rel = true;
-            p->handle = dlopen(p->so_pathname, RTLD_NOW);
-        }
-#endif
     }
     else
-#endif
     {
         rel = !absolute_pathname(p->so_pathname);
         p->handle = dlopen(p->so_pathname, RTLD_NOW);