diff options
author | Alon Bar-Lev <alon.barlev@gmail.com> | 2012-02-29 22:12:02 +0200 |
---|---|---|
committer | David Sommerseth <davids@redhat.com> | 2012-03-22 22:17:26 +0100 |
commit | bdae41107ddde61cae5ae2037c1420b539c52ff8 (patch) | |
tree | 6606526b4ad37eb3ca84d52237acf7998d713d57 /src/openvpn | |
parent | c3fc703d31f47ceef66bc8006e2870e3c4d05ee6 (diff) | |
download | openvpn-bdae41107ddde61cae5ae2037c1420b539c52ff8.tar.gz openvpn-bdae41107ddde61cae5ae2037c1420b539c52ff8.tar.xz openvpn-bdae41107ddde61cae5ae2037c1420b539c52ff8.zip |
build: libdl usage
1. properly detect.
2. Link only required components.
3. No way we don't have LoadLibrary on Windows.
4. ENABLE_PLUGIN should be controlled in autoconf.
Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
Acked-by: Adriaan de Jong <dejong@fox-it.com>
Acked-by: David Sommerseth <davids@redhat.com>
Signed-off-by: David Sommerseth <davids@redhat.com>
Diffstat (limited to 'src/openvpn')
-rw-r--r-- | src/openvpn/Makefile.am | 4 | ||||
-rw-r--r-- | src/openvpn/plugin.c | 16 | ||||
-rw-r--r-- | src/openvpn/plugin.h | 4 | ||||
-rw-r--r-- | src/openvpn/syshead.h | 11 |
4 files changed, 15 insertions, 20 deletions
diff --git a/src/openvpn/Makefile.am b/src/openvpn/Makefile.am index a509bba..c7626c8 100644 --- a/src/openvpn/Makefile.am +++ b/src/openvpn/Makefile.am @@ -95,7 +95,9 @@ openvpn_SOURCES = \ tun.c tun.h \ win32.h win32.c \ cryptoapi.h cryptoapi.c +openvpn_LDADD = \ + $(OPTIONAL_DL_LIBS) if WIN32 openvpn_SOURCES += openvpn_win32_resources.rc -openvpn_LDADD = -lgdi32 -lws2_32 -lwininet -lcrypt32 -liphlpapi -lwinmm -lshell32 +openvpn_LDADD += -lgdi32 -lws2_32 -lwininet -lcrypt32 -liphlpapi -lwinmm -lshell32 endif diff --git a/src/openvpn/plugin.c b/src/openvpn/plugin.c index 4cc9c36..3f379dd 100644 --- a/src/openvpn/plugin.c +++ b/src/openvpn/plugin.c @@ -26,6 +26,10 @@ #ifdef ENABLE_PLUGIN +#ifdef HAVE_DLFCN_H +#include <dlfcn.h> +#endif + #include "buffer.h" #include "error.h" #include "misc.h" @@ -160,7 +164,7 @@ plugin_option_list_print (const struct plugin_option_list *list, int msglevel) } #endif -#if defined(USE_LIBDL) +#ifndef WIN32 static void libdl_resolve_symbol (void *handle, void **dest, const char *symbol, const char *plugin_name, const unsigned int flags) @@ -170,7 +174,7 @@ libdl_resolve_symbol (void *handle, void **dest, const char *symbol, const char msg (M_FATAL, "PLUGIN: could not find required symbol '%s' in plugin shared object %s: %s", symbol, plugin_name, dlerror()); } -#elif defined(USE_LOAD_LIBRARY) +#else static void dll_resolve_symbol (HMODULE module, void **dest, const char *symbol, const char *plugin_name, const unsigned int flags) @@ -191,7 +195,7 @@ plugin_init_item (struct plugin *p, const struct plugin_option *o) p->so_pathname = o->so_pathname; p->plugin_type_mask = plugin_supported_types (); -#if defined(USE_LIBDL) +#ifndef WIN32 p->handle = NULL; #if defined(PLUGIN_LIBDIR) @@ -220,7 +224,7 @@ plugin_init_item (struct plugin *p, const struct plugin_option *o) # define PLUGIN_SYM(var, name, flags) libdl_resolve_symbol (p->handle, (void*)&p->var, name, p->so_pathname, flags) -#elif defined(USE_LOAD_LIBRARY) +#else rel = !absolute_pathname (p->so_pathname); p->module = LoadLibraryW (wide_string (p->so_pathname, &gc)); @@ -427,10 +431,10 @@ plugin_close_item (struct plugin *p) if (p->plugin_handle) (*p->close)(p->plugin_handle); -#if defined(USE_LIBDL) +#ifndef WIN32 if (dlclose (p->handle)) msg (M_WARN, "PLUGIN_CLOSE: dlclose() failed on plugin: %s", p->so_pathname); -#elif defined(USE_LOAD_LIBRARY) +#elif defined(WIN32) if (!FreeLibrary (p->module)) msg (M_WARN, "PLUGIN_CLOSE: FreeLibrary() failed on plugin: %s", p->so_pathname); #endif diff --git a/src/openvpn/plugin.h b/src/openvpn/plugin.h index 6f75e27..4c0a1fd 100644 --- a/src/openvpn/plugin.h +++ b/src/openvpn/plugin.h @@ -59,9 +59,9 @@ struct plugin { unsigned int plugin_type_mask; int requested_initialization_point; -#if defined(USE_LIBDL) +#ifndef WIN32 void *handle; -#elif defined(USE_LOAD_LIBRARY) +#else HMODULE module; #endif diff --git a/src/openvpn/syshead.h b/src/openvpn/syshead.h index b305660..1ad81d8 100644 --- a/src/openvpn/syshead.h +++ b/src/openvpn/syshead.h @@ -156,10 +156,6 @@ #include <grp.h> #endif -#ifdef USE_LIBDL -#include <dlfcn.h> -#endif - #ifdef HAVE_NETDB_H #include <netdb.h> #endif @@ -507,13 +503,6 @@ socket_defined (const socket_descriptor_t sd) #endif /* - * Do we have a plug-in capability? - */ -#if defined(USE_LIBDL) || defined(USE_LOAD_LIBRARY) -#define ENABLE_PLUGIN -#endif - -/* * Enable deferred authentication? */ #if defined(ENABLE_DEF_AUTH) && P2MP_SERVER && defined(ENABLE_PLUGIN) |