Browse code

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 <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>

Christian Hesse authored on 2017/01/26 05:19:47
Showing 4 changed files
... ...
@@ -38,7 +38,7 @@ AC_DEFINE([OPENVPN_VERSION_MINOR], [PRODUCT_VERSION_MINOR], [OpenVPN minor versi
38 38
 AC_DEFINE([OPENVPN_VERSION_PATCH], ["PRODUCT_VERSION_PATCH"], [OpenVPN patch level - may be a string or integer])
39 39
 
40 40
 AC_CONFIG_AUX_DIR([.])
41
-AC_CONFIG_HEADERS([config.h include/openvpn-plugin.h])
41
+AC_CONFIG_HEADERS([config.h])
42 42
 AC_CONFIG_SRCDIR([src/openvpn/syshead.h])
43 43
 AC_CONFIG_MACRO_DIR([m4])
44 44
 
... ...
@@ -301,13 +301,12 @@ AC_ARG_WITH(
301 301
 	[with_crypto_library="openssl"]
302 302
 )
303 303
 
304
-AC_ARG_WITH(
305
-	[plugindir],
306
-	[AS_HELP_STRING([--with-plugindir], [plugin directory @<:@default=LIBDIR/openvpn@:>@])],
307
-	,
308
-	[with_plugindir="\$(libdir)/openvpn/plugins"]
309
-)
310
-
304
+AC_ARG_VAR([PLUGINDIR], [Path of plug-in directory @<:@default=LIBDIR/openvpn/plugins@:>@])
305
+if test -n "${PLUGINDIR}"; then
306
+	plugindir="${PLUGINDIR}"
307
+else
308
+	plugindir="\${libdir}/openvpn/plugins"
309
+fi
311 310
 
312 311
 AC_DEFINE_UNQUOTED([TARGET_ALIAS], ["${host}"], [A string representing our host])
313 312
 case "$host" in
... ...
@@ -1284,7 +1283,6 @@ AM_CONDITIONAL([ENABLE_PLUGIN_DOWN_ROOT], [test "${enable_plugin_down_root}" = "
1284 1284
 AM_CONDITIONAL([ENABLE_CRYPTO], [test "${enable_crypto}" = "yes"])
1285 1285
 AM_CONDITIONAL([HAVE_LD_WRAP_SUPPORT], [test "${have_ld_wrap_support}" = "yes"])
1286 1286
 
1287
-plugindir="${with_plugindir}"
1288 1287
 sampledir="\$(docdir)/sample"
1289 1288
 AC_SUBST([plugindir])
1290 1289
 AC_SUBST([sampledir])
... ...
@@ -16,3 +16,10 @@ MAINTAINERCLEANFILES = \
16 16
 include_HEADERS = \
17 17
 	openvpn-plugin.h \
18 18
 	openvpn-msg.h
19
+
20
+openvpn-plugin.h: openvpn-plugin.h.in Makefile
21
+	$(AM_V_GEN)sed -e 's|\@PLUGINDIR\@|$(plugindir)|' \
22
+		-e 's|\@OPENVPN_VERSION_MAJOR\@|$(OPENVPN_VERSION_MAJOR)|' \
23
+		-e 's|\@OPENVPN_VERSION_MINOR\@|$(OPENVPN_VERSION_MINOR)|' \
24
+		-e 's|\@OPENVPN_VERSION_PATCH\@|$(OPENVPN_VERSION_PATCH)|' \
25
+               $< > $@.tmp && mv $@.tmp $@
... ...
@@ -27,6 +27,8 @@
27 27
 
28 28
 #define OPENVPN_PLUGIN_VERSION 3
29 29
 
30
+#define PLUGIN_LIBDIR "@PLUGINDIR@"
31
+
30 32
 #ifdef ENABLE_CRYPTO
31 33
 #ifdef ENABLE_CRYPTO_MBEDTLS
32 34
 #include <mbedtls/x509_crt.h>
... ...
@@ -234,23 +234,15 @@ plugin_init_item(struct plugin *p, const struct plugin_option *o)
234 234
 #ifndef _WIN32
235 235
 
236 236
     p->handle = NULL;
237
-#if defined(PLUGIN_LIBDIR)
237
+
238 238
     if (!absolute_pathname(p->so_pathname))
239 239
     {
240 240
         char full[PATH_MAX];
241 241
 
242 242
         openvpn_snprintf(full, sizeof(full), "%s/%s", PLUGIN_LIBDIR, p->so_pathname);
243 243
         p->handle = dlopen(full, RTLD_NOW);
244
-#if defined(ENABLE_PLUGIN_SEARCH)
245
-        if (!p->handle)
246
-        {
247
-            rel = true;
248
-            p->handle = dlopen(p->so_pathname, RTLD_NOW);
249
-        }
250
-#endif
251 244
     }
252 245
     else
253
-#endif
254 246
     {
255 247
         rel = !absolute_pathname(p->so_pathname);
256 248
         p->handle = dlopen(p->so_pathname, RTLD_NOW);