From: Christian Hesse Date: Wed, 25 Jan 2017 20:19:47 +0000 (+0100) Subject: Clean up plugin path handling X-Git-Tag: v2.5_beta1~752 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4590c383;p=thirdparty%2Fopenvpn.git Clean up plugin path handling 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 Acked-by: David Sommerseth 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 --- diff --git a/configure.ac b/configure.ac index 79fb1ba24..f305c5488 100644 --- a/configure.ac +++ b/configure.ac @@ -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]) diff --git a/include/Makefile.am b/include/Makefile.am index a52c4278b..37962a6f2 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -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 $@ diff --git a/include/openvpn-plugin.h.in b/include/openvpn-plugin.h.in index 0b303520a..a084fc1a7 100644 --- a/include/openvpn-plugin.h.in +++ b/include/openvpn-plugin.h.in @@ -27,6 +27,8 @@ #define OPENVPN_PLUGIN_VERSION 3 +#define PLUGIN_LIBDIR "@PLUGINDIR@" + #ifdef ENABLE_CRYPTO #ifdef ENABLE_CRYPTO_MBEDTLS #include diff --git a/src/openvpn/plugin.c b/src/openvpn/plugin.c index e530c0c5f..f77702786 100644 --- a/src/openvpn/plugin.c +++ b/src/openvpn/plugin.c @@ -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);