diff options
-rw-r--r-- | hcid/plugin.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/hcid/plugin.c b/hcid/plugin.c index b74108bd..c2b7790c 100644 --- a/hcid/plugin.c +++ b/hcid/plugin.c @@ -27,6 +27,10 @@ #include <glib.h> #include <gmodule.h> +#include <string.h> + +#include <sys/stat.h> +#include <errno.h> #include "plugin.h" #include "logging.h" @@ -71,12 +75,21 @@ gboolean plugin_init(void) GModule *module; struct bluetooth_plugin_desc *desc; gchar *filename; + struct stat st; - if (g_str_has_prefix(file, "lib") == FALSE) + if (g_str_has_prefix(file, "lib") == FALSE || + g_str_has_suffix(file, ".so") == FALSE) continue; filename = g_build_filename(PLUGINDIR, file, NULL); + if (stat(filename, &st) < 0) { + error("Can't load plugin %s: %s (%d)", filename, + strerror(errno), errno); + g_free(filename); + continue; + } + module = g_module_open(filename, 0); if (module == NULL) { error("Can't load plugin %s", filename); |