Commit Graph
86 Commits
Author SHA1 Message Date
Tobias Brunner ed13c60c4f plugin-loader: Move indent variables into !USE_FUZZING block
This avoids compile errors on Travis.
2017-08-15 10:35:20 +02:00
Tobias Brunner 2e4d110d1e linked-list: Change return value of find_first() and signature of its callback
This avoids the unportable five pointer hack.
2017-05-26 13:56:44 +02:00
Tobias Brunner 525cc46cab Change interface for enumerator_create_filter() callback
This avoids the unportable 5 pointer hack, but requires enumerating in
the callback.
2017-05-26 13:56:44 +02:00
Tobias Brunner 3963dbbde5 plugin-loader: Disable some logging output when building fuzz targets
This avoids evaluating %N. An alternative would be to define a printf-hook
for plugin features.
2017-05-23 18:29:12 +02:00
Tobias Brunner 1a06bf03f9 plugin-loader: Add facility to register plugin constructors
Enabled when building monolithically and statically.

This should allow us to work around the -whole-archive issue with
libtool.  If the libraries register the plugin constructors they provide
they reference the constructors and will therefore prevent the linker from
removing these seemingly unused symbols from the final executable.

For use cases where dlsym() can be used, e.g. because the static libraries
are manually linked with -whole-archive (Linux) or -force-load (Apple),
this can be disabled by passing ss_cv_static_plugin_constructors=no to
the configure script.
2017-05-23 18:29:12 +02:00
Tobias Brunner ac4942c3c3 plugin-loader: Fix hashing of registered plugin features
This strangely never caused any noticeable issues, but was the reason for
build failures in certain test cases (mostly BLISS) due to missing plugin
features when built with specific options on Travis (was not reproducible
locally).
2017-02-24 18:29:08 +01:00
Tobias Brunner 5078f87a52 plugin-loader: Strip '!' from critical plugin names when setting paths 2016-11-18 12:21:49 +01:00
Tobias Brunner 7c81219bb8 plugin-loader: Allow selective modification of the default plugin list
This change allows selectively modifying the default plugin list by setting
the `load` setting of individual plugins (e.g. to disable them or to change
their priority) without enabling charon.load_modular and having to configure
a section and a load statement for every plugin.
2016-06-29 11:16:48 +02:00
Tobias Brunner 305c4aa82c plugin-loader: Optionally use RTLD_NOW with dlopen()
This can be useful when writing custom plugins as typos or missing
linker flags that result in unresolved symbols in the shared object
could otherwise cause late crashes.  In particular, if such a symbol
is used in a code path that is rarely executed.  During development
and testing using RTLD_NOW instead of RTLD_LAZY will prevent the
plugin from getting loaded and makes the error visible immediately.
2015-11-09 14:37:08 +01:00
Tobias Brunner 1bfa5e0cac plugin-loader: Increase log level for warning about plugin features that failed to load
Since we can't get rid of all unmet dependencies (at least not in every
possible plugin configuration) the message is more confusing than
helpful.  In particular because a detailed warning about plugin features
that failed to load due to unmet dependencies is only logged on level 2.
2015-03-09 15:45:29 +01:00
Martin Willi 20a0fd9255 plugin-loader: Do not unload libraries during dlclose(), if supported
Unloading libraries calls any library constructor/destructor functions. Some
libraries can't handle that in our excessive unit test use. GnuTLS leaks
a /dev/urandom file descriptor, letting unit tests fail with arbitrary
out-of-resources errors.
2015-02-24 12:25:01 +01:00
Martin Willi 5421092b75 plugin-loader: Support a reload() callback for static features 2014-09-22 13:55:12 +02:00
Martin Willi 2e6c203bad windows: Provide wrappers for dlopen() function family 2014-06-03 12:24:34 +02:00
Tobias Brunner 0ab7d5f1f9 plugin-loader: Properly initialize modular plugin list if no plugins are enabled 2014-03-18 10:56:39 +01:00
Tobias Brunner 190a278854 plugin-loader: Optionally use load option in each plugin section to load plugins
This now works because all plugins use the same config namespace.

If <ns>.load_modular is true, the list of plugins to load is determined
via the value of the <ns>.plugins.<name>.load options.

Using includes the following is possible:

charon {
  load_modular = yes
  plugins {
    include strongswan.d/charon/*.conf
  }
}

charon-cmd {
  load_modular = yes
  plugins {
    include strongswan.d/charon-cmd/*.conf
  }
}

Where each .conf file would contain something like:

<name> {
  load = yes
  <option> = <value>
}

To increase the priority of individual plugins load = <priority> can be
used (the default is 1).  For instance, to use openssl instead of the
built-in crypto plugins set in strongswan.d/charon/openssl.conf:

openssl {
  load = 10
}

If two plugins have the same priority their order in the default plugin
list is preserved.  Plugins not found in that list are ordered
alphabetically before other plugins with the same priority.
2014-02-12 14:34:33 +01:00
Tobias Brunner 8d2450d8b8 plugin-loader: Convenience function added to add plugin dirs in build tree 2013-11-06 10:31:07 +01:00
Tobias Brunner b18a531715 plugin-loader: Removed unused path argument of load() method
Multiple additional search paths can be added with the add_path()
method.
2013-06-28 10:44:15 +02:00
Tobias Brunner f2086e42ff plugin-loader: Method added to provide additional search paths for plugins 2013-06-27 10:27:24 +02:00
Tobias Brunner 0d25c4ef87 plugin-loader: Move logging of failed features to status()
Still log an error message if critical features fail, as loaded
plugins/features are not logged in that case.

This way loaded plugins are printed before failed features and
the relation is easier to make for users.  It also allows programs
to log this message on a different level.
2013-06-21 15:22:46 +02:00
Tobias Brunner 607f8e9906 plugin-loader: Add method to print loaded plugins on a given log level 2013-06-21 15:17:53 +02:00
Tobias Brunner 34ee14dd28 plugin-loader: Collect statistics while loading features, print them in case features failed to load
There is no need to explicitly search for failed features in critical
plugins as this is now detected while loading the features.
2013-06-21 15:13:25 +02:00
Tobias Brunner 681e53c70c plugin-loader: Use different log level if failed feature is in critical plugin 2013-06-21 15:13:25 +02:00
Tobias Brunner 13d2d8f634 plugin-loader: Log message when failing to load plugin 2013-06-21 15:13:25 +02:00
Tobias Brunner 51b9d7513d plugin-loader: Reduce verbosity while loading plugins 2013-06-21 15:13:25 +02:00
Martin Willi 2bedb0f270 Move test-runners has_feature() function to plugin loader 2013-06-21 10:53:22 +02:00
Tobias Brunner 49d7a98f47 Refactored plugin-loader with improved dependency resolution
With the new implementation the plugins don't have to be listed in any
special order, dependencies are properly resolved.  The order only
matters if two plugins provide the same feature.
2013-06-11 11:18:19 +02:00
Tobias Brunner 8a6cc1e35f plugin-feature: Function added to exactly compare plugin features 2013-06-11 11:18:17 +02:00
Tobias Brunner f05b427265 Moved debug.[ch] to utils folder 2012-10-24 16:00:51 +02:00
Tobias Brunner 08944b68ac Moved integrity_checker_t to utils folder 2012-10-24 16:00:50 +02:00
Tobias Brunner 12642a6831 Moved data structures to new collections subfolder 2012-10-24 16:00:49 +02:00
Tobias Brunner a9f169f699 Don't require PLUGINDIR to be defined.
If it is not available, we just load monolithically built plugins.
2012-08-08 15:07:42 +02:00
Tobias Brunner 18d21a57df Added a method to plugin_loader_t to add 'static' plugin features
This allows daemons and other components to register plugin features
like those provided by plugins (following the same lifecycle).

The added features are internally handled like they were added by a
plugin.
2012-06-25 17:03:07 +02:00
Tobias Brunner e07122436c Make sure that all features of critical plugins are loaded 2012-06-25 17:03:07 +02:00
Tobias Brunner 79d5c4f06b Fixed return values of several functions (e.g. return FALSE for pointer types). 2012-05-31 17:39:04 +02:00
Tobias Brunner fda9f104b4 Fixed check for loaded plugins with feature types that are not compared exactly.
Previously e.g. RNGs with weaker strength would have overwritten stronger
ones.
2012-05-24 15:15:34 +02:00
Tobias Brunner 9eac6106d0 Use a hashtable to check for already loaded plugin features. 2012-05-23 17:50:05 +02:00
Martin Willi 40ca363a8b If we load new features from a plugin, restart loading from first plugin 2012-05-03 11:08:09 +02:00
Martin Willi f14bf6345f Don't depend on a feature that has a dependency to the same feauture during unload 2012-05-02 14:05:52 +02:00
Tobias Brunner f1ba06c1c6 Cache list of plugin names to further simplify its usage.
Also helpful for ipsec statusall to avoid having to enumerate plugins.
2012-01-19 12:37:42 +01:00
Tobias Brunner ad1aaf4be3 Function added to plugin_loader to get a list of the names of loaded plugins. 2012-01-19 11:51:51 +01:00
Martin Willi 8b8fcfd631 Be less verbose if plugin dependecy not satisfied 2011-12-07 13:42:10 +01:00
Martin Willi 58fcdc4f06 Don't enforce features with soft dependencies before all plugins are loaded 2011-10-14 10:05:49 +02:00
Martin Willi a07f2a4b9b Don't try to load a feature again after failure 2011-10-14 10:05:49 +02:00
Martin Willi 59c4e88b16 Reset registration function for each plugin during feature loading 2011-10-14 10:05:49 +02:00
Martin Willi 61c1dec8d4 Fixed memleak in plugin unloading 2011-10-14 10:05:47 +02:00
Martin Willi 2feed2f3fe Load features after each plugin loaded until all plugins have feature support 2011-10-14 10:05:47 +02:00
Martin Willi d965872d66 Implemented feature unloading, moved feature registration plugin_features.c 2011-10-14 10:05:47 +02:00
Tobias Brunner c293c87761 Don't use union members directly in plugin_feature_t. 2011-10-14 10:05:47 +02:00
Tobias Brunner ef80de6010 Unload plugins which we were not able to load any features from. 2011-10-14 10:05:46 +02:00
Tobias Brunner 076aa51fc9 Easier to understand test for soft dependencies in dependencies_satisfied. 2011-10-14 10:05:46 +02:00