From e213b1b8cc0043c971196c0646f3dbaf9344958f Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Wed, 26 Mar 2008 19:28:52 +0000 Subject: Fix plugin init to just load .so files and add a stat check. --- hcid/plugin.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) 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 #include +#include + +#include +#include #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); -- cgit