Don't require PLUGINDIR to be defined.
authorTobias Brunner <tobias@strongswan.org>
Fri, 10 Feb 2012 13:11:19 +0000 (14:11 +0100)
committerTobias Brunner <tobias@strongswan.org>
Wed, 8 Aug 2012 13:07:42 +0000 (15:07 +0200)
If it is not available, we just load monolithically built plugins.

src/libstrongswan/plugins/plugin_loader.c

index d5777e3..95a0bfc 100644 (file)
@@ -250,8 +250,11 @@ static bool load_plugin(private_plugin_loader_t *this, char *name, char *file,
                        this->plugins->insert_last(this->plugins, entry);
                        return TRUE;
                case NOT_FOUND:
-                       /* try to load the plugin from a file */
-                       break;
+                       if (file)
+                       {       /* try to load the plugin from a file */
+                               break;
+                       }
+                       /* fall-through */
                default:
                        return FALSE;
        }
@@ -651,16 +654,18 @@ METHOD(plugin_loader_t, load_plugins, bool,
        char *token;
        bool critical_failed = FALSE;
 
+#ifdef PLUGINDIR
        if (path == NULL)
        {
                path = PLUGINDIR;
        }
+#endif /* PLUGINDIR */
 
        enumerator = enumerator_create_token(list, " ", " ");
        while (!critical_failed && enumerator->enumerate(enumerator, &token))
        {
                bool critical = FALSE;
-               char file[PATH_MAX];
+               char buf[PATH_MAX], *file = NULL;
                int len;
 
                token = strdup(token);
@@ -675,10 +680,14 @@ METHOD(plugin_loader_t, load_plugins, bool,
                        free(token);
                        continue;
                }
-               if (snprintf(file, sizeof(file), "%s/libstrongswan-%s.so",
-                                        path, token) >= sizeof(file))
+               if (path)
                {
-                       return FALSE;
+                       if (snprintf(buf, sizeof(buf), "%s/libstrongswan-%s.so",
+                                                path, token) >= sizeof(buf))
+                       {
+                               return FALSE;
+                       }
+                       file = buf;
                }
                if (!load_plugin(this, token, file, critical) && critical)
                {