diff mbox series

[BlueZ,1/8] obexd: remove support for external plugins

Message ID 20240116-rm-ext-plugins-v1-1-62990fb07369@gmail.com (mailing list archive)
State Superseded
Headers show
Series Remove support for external plugins | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
tedd_an/CheckPatch success CheckPatch PASS
tedd_an/GitLint success Gitlint PASS
tedd_an/BuildEll success Build ELL PASS
tedd_an/BluezMake success Bluez Make PASS
tedd_an/MakeCheck success Bluez Make Check PASS
tedd_an/MakeDistcheck success Make Distcheck PASS
tedd_an/CheckValgrind success Check Valgrind PASS
tedd_an/CheckSmatch success CheckSparse PASS
tedd_an/bluezmakeextell success Make External ELL PASS
tedd_an/IncrementalBuild success Incremental Build PASS
tedd_an/ScanBuild success Scan Build PASS

Commit Message

Emil Velikov via B4 Relay Jan. 16, 2024, 2:18 p.m. UTC
From: Emil Velikov <emil.velikov@collabora.com>

A while ago all the plugins were converted to built-in, although the
external machinery remained - remove it.

In practise, this means we no longer need to export obexd internal API
(fix coming in later patch). AFACIT supporting third-party plugins was
never a supported use-case.

Glancing around - no Linux distros seem to ship plugins, these days.
---
 Makefile.obexd     |  6 +----
 obexd/src/obexd.h  |  2 +-
 obexd/src/plugin.c | 73 +++++-------------------------------------------------
 obexd/src/plugin.h |  9 -------
 4 files changed, 8 insertions(+), 82 deletions(-)

Comments

bluez.test.bot@gmail.com Jan. 16, 2024, 4:47 p.m. UTC | #1
This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=817230

---Test result---

Test Summary:
CheckPatch                    PASS      3.87 seconds
GitLint                       PASS      2.60 seconds
BuildEll                      PASS      23.85 seconds
BluezMake                     PASS      702.42 seconds
MakeCheck                     PASS      11.69 seconds
MakeDistcheck                 PASS      159.11 seconds
CheckValgrind                 PASS      221.12 seconds
CheckSmatch                   PASS      326.34 seconds
bluezmakeextell               PASS      106.35 seconds
IncrementalBuild              PASS      5304.46 seconds
ScanBuild                     PASS      928.69 seconds



---
Regards,
Linux Bluetooth
diff mbox series

Patch

diff --git a/Makefile.obexd b/Makefile.obexd
index 5d1a4ff65..2774f3aec 100644
--- a/Makefile.obexd
+++ b/Makefile.obexd
@@ -11,8 +11,6 @@  EXTRA_DIST += obexd/src/obex.service.in obexd/src/org.bluez.obex.service
 
 if OBEX
 
-obex_plugindir = $(libdir)/obex/plugins
-
 obexd_builtin_modules =
 obexd_builtin_sources =
 obexd_builtin_nodist =
@@ -89,9 +87,7 @@  obexd_src_obexd_LDADD = lib/libbluetooth-internal.la \
 obexd_src_obexd_LDFLAGS = $(AM_LDFLAGS) -Wl,--export-dynamic
 
 obexd_src_obexd_CPPFLAGS = $(AM_CPPFLAGS) $(GLIB_CFLAGS) $(DBUS_CFLAGS) \
-				$(ICAL_CFLAGS) -DOBEX_PLUGIN_BUILTIN \
-				-DPLUGINDIR=\""$(obex_plugindir)"\" \
-				-D_FILE_OFFSET_BITS=64 \
+				$(ICAL_CFLAGS) -D_FILE_OFFSET_BITS=64 \
 				-I$(builddir)/lib -I$(builddir)/obexd/src
 
 obexd_src_obexd_CFLAGS = $(AM_CFLAGS) -fPIC
diff --git a/obexd/src/obexd.h b/obexd/src/obexd.h
index fe312a65b..af5265da5 100644
--- a/obexd/src/obexd.h
+++ b/obexd/src/obexd.h
@@ -18,7 +18,7 @@ 
 #define OBEX_MAS	(1 << 8)
 #define OBEX_MNS	(1 << 9)
 
-gboolean plugin_init(const char *pattern, const char *exclude);
+void plugin_init(const char *pattern, const char *exclude);
 void plugin_cleanup(void);
 
 gboolean manager_init(void);
diff --git a/obexd/src/plugin.c b/obexd/src/plugin.c
index 0df9d5258..185adac78 100644
--- a/obexd/src/plugin.c
+++ b/obexd/src/plugin.c
@@ -37,33 +37,29 @@ 
 static GSList *plugins = NULL;
 
 struct obex_plugin {
-	void *handle;
 	struct obex_plugin_desc *desc;
 };
 
-static gboolean add_plugin(void *handle, struct obex_plugin_desc *desc)
+static void add_plugin(struct obex_plugin_desc *desc)
 {
 	struct obex_plugin *plugin;
 
 	if (desc->init == NULL)
-		return FALSE;
+		return;
 
 	plugin = g_try_new0(struct obex_plugin, 1);
 	if (plugin == NULL)
-		return FALSE;
+		return;
 
-	plugin->handle = handle;
 	plugin->desc = desc;
 
 	if (desc->init() < 0) {
 		g_free(plugin);
-		return FALSE;
+		return;
 	}
 
 	plugins = g_slist_append(plugins, plugin);
 	DBG("Plugin %s loaded", desc->name);
-
-	return TRUE;
 }
 
 static gboolean check_plugin(struct obex_plugin_desc *desc,
@@ -95,17 +91,12 @@  static gboolean check_plugin(struct obex_plugin_desc *desc,
 
 #include "builtin.h"
 
-gboolean plugin_init(const char *pattern, const char *exclude)
+void plugin_init(const char *pattern, const char *exclude)
 {
 	char **patterns = NULL;
 	char **excludes = NULL;
-	GDir *dir;
-	const char *file;
 	unsigned int i;
 
-	if (strlen(PLUGINDIR) == 0)
-		return FALSE;
-
 	if (pattern)
 		patterns = g_strsplit_set(pattern, ":, ", -1);
 
@@ -119,60 +110,11 @@  gboolean plugin_init(const char *pattern, const char *exclude)
 					patterns, excludes) == FALSE)
 			continue;
 
-		add_plugin(NULL,  __obex_builtin[i]);
+		add_plugin(__obex_builtin[i]);
 	}
 
-	DBG("Loading plugins %s", PLUGINDIR);
-
-	dir = g_dir_open(PLUGINDIR, 0, NULL);
-	if (!dir) {
-		g_strfreev(patterns);
-		g_strfreev(excludes);
-		return FALSE;
-	}
-
-	while ((file = g_dir_read_name(dir)) != NULL) {
-		struct obex_plugin_desc *desc;
-		void *handle;
-		char *filename;
-
-		if (g_str_has_prefix(file, "lib") == TRUE ||
-				g_str_has_suffix(file, ".so") == FALSE)
-			continue;
-
-		filename = g_build_filename(PLUGINDIR, file, NULL);
-
-		handle = dlopen(filename, PLUGINFLAG);
-		if (handle == NULL) {
-			error("Can't load plugin %s: %s", filename,
-								dlerror());
-			g_free(filename);
-			continue;
-		}
-
-		g_free(filename);
-
-		desc = dlsym(handle, "obex_plugin_desc");
-		if (desc == NULL) {
-			error("Can't load plugin description: %s", dlerror());
-			dlclose(handle);
-			continue;
-		}
-
-		if (check_plugin(desc, patterns, excludes) == FALSE) {
-			dlclose(handle);
-			continue;
-		}
-
-		if (add_plugin(handle, desc) == FALSE)
-			dlclose(handle);
-	}
-
-	g_dir_close(dir);
 	g_strfreev(patterns);
 	g_strfreev(excludes);
-
-	return TRUE;
 }
 
 void plugin_cleanup(void)
@@ -187,9 +129,6 @@  void plugin_cleanup(void)
 		if (plugin->desc->exit)
 			plugin->desc->exit();
 
-		if (plugin->handle != NULL)
-			dlclose(plugin->handle);
-
 		g_free(plugin);
 	}
 
diff --git a/obexd/src/plugin.h b/obexd/src/plugin.h
index 703878460..2df66c79b 100644
--- a/obexd/src/plugin.h
+++ b/obexd/src/plugin.h
@@ -14,16 +14,7 @@  struct obex_plugin_desc {
 	void (*exit) (void);
 };
 
-#ifdef OBEX_PLUGIN_BUILTIN
 #define OBEX_PLUGIN_DEFINE(name, init, exit) \
 		struct obex_plugin_desc __obex_builtin_ ## name = { \
 			#name, init, exit \
 		};
-#else
-#define OBEX_PLUGIN_DEFINE(name,init,exit) \
-		extern struct obex_plugin_desc obex_plugin_desc \
-				__attribute__ ((visibility("default"))); \
-		struct obex_plugin_desc obex_plugin_desc = { \
-			#name, init, exit \
-		};
-#endif