]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
Added PLUGIN_LIBDIR preprocessor string to prepend a default plugin
authorjames <james@e7ae566f-a301-0410-adde-c780ea21d3b5>
Mon, 21 Jan 2008 19:00:43 +0000 (19:00 +0000)
committerjames <james@e7ae566f-a301-0410-adde-c780ea21d3b5>
Mon, 21 Jan 2008 19:00:43 +0000 (19:00 +0000)
directory to the dlopen search list when the user specifies the basename
of the plugin only (Marius Tomaschewski).

git-svn-id: http://svn.openvpn.net/projects/openvpn/branches/BETA21/openvpn@2637 e7ae566f-a301-0410-adde-c780ea21d3b5

plugin.c

index e841dc77ef1fa26dc0ea8ac62bcee30f1cc578c7..7bf69124bf59adb6f05d239ced5bf9ff0b156349 100644 (file)
--- a/plugin.c
+++ b/plugin.c
@@ -191,7 +191,26 @@ plugin_init_item (struct plugin *p, const struct plugin_option *o)
 
 #if defined(USE_LIBDL)
 
-  p->handle = dlopen (p->so_pathname, RTLD_NOW);
+  p->handle = NULL;
+#if defined(PLUGIN_LIBDIR)
+  if (!strrchr(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)
+       {
+         p->handle = dlopen (p->so_pathname, RTLD_NOW);
+       }
+#endif
+    }
+  else
+#endif
+    {
+      p->handle = dlopen (p->so_pathname, RTLD_NOW);
+    }
   if (!p->handle)
     msg (M_ERR, "PLUGIN_INIT: could not load plugin shared object %s: %s", p->so_pathname, dlerror());