Browse code

Added PLUGIN_LIBDIR preprocessor string to prepend a default plugin 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

james authored on 2008/01/22 04:00:43
Showing 1 changed files
... ...
@@ -191,7 +191,26 @@ plugin_init_item (struct plugin *p, const struct plugin_option *o)
191 191
 
192 192
 #if defined(USE_LIBDL)
193 193
 
194
-  p->handle = dlopen (p->so_pathname, RTLD_NOW);
194
+  p->handle = NULL;
195
+#if defined(PLUGIN_LIBDIR)
196
+  if (!strrchr(p->so_pathname, '/'))
197
+    {
198
+      char full[PATH_MAX];
199
+
200
+      openvpn_snprintf (full, sizeof(full), "%s/%s", PLUGIN_LIBDIR, p->so_pathname);
201
+      p->handle = dlopen (full, RTLD_NOW);
202
+#if defined(ENABLE_PLUGIN_SEARCH)
203
+      if (!p->handle)
204
+	{
205
+	  p->handle = dlopen (p->so_pathname, RTLD_NOW);
206
+	}
207
+#endif
208
+    }
209
+  else
210
+#endif
211
+    {
212
+      p->handle = dlopen (p->so_pathname, RTLD_NOW);
213
+    }
195 214
   if (!p->handle)
196 215
     msg (M_ERR, "PLUGIN_INIT: could not load plugin shared object %s: %s", p->so_pathname, dlerror());
197 216