summaryrefslogtreecommitdiffstats
path: root/hcid
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.dentz@openbossa.org>2008-03-26 19:28:52 +0000
committerLuiz Augusto von Dentz <luiz.dentz@openbossa.org>2008-03-26 19:28:52 +0000
commite213b1b8cc0043c971196c0646f3dbaf9344958f (patch)
tree1842697665d18f80d93b85f27edea96b1662776b /hcid
parentb313aacb3dd7ab17e773206d1c6e074deba913b4 (diff)
Fix plugin init to just load .so files and add a stat check.
Diffstat (limited to 'hcid')
-rw-r--r--hcid/plugin.c15
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);