linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH BlueZ v4 0/8] Remove support for external plugins
@ 2024-01-29 14:44 Emil Velikov via B4 Relay
  2024-01-29 14:44 ` [PATCH BlueZ v4 1/8] configure, README: introduce --enable-external-plugins Emil Velikov via B4 Relay
                   ` (8 more replies)
  0 siblings, 9 replies; 18+ messages in thread
From: Emil Velikov via B4 Relay @ 2024-01-29 14:44 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Emil Velikov

Hello everyone,

With v4 we have moved from pre-processor to compilation checking for the
external plugins support.

Namely, as we build without one the dead-code elimination will discard
all the relevant code. Ultimately this means we compile check both paths
in order to catch mistakes. Thanks to Luiz for the suggestion.

Link to the previous revision can be found below.

Thanks
Emil

- Link to v3: https://lore.kernel.org/r/20240125-rm-ext-plugins-v3-0-d141f7870bb6@gmail.com

---
Emil Velikov (8):
      configure, README: introduce --enable-external-plugins
      obexd: factor out external plugin support
      bluetoothd: remove external-dummy plugin
      bluetoothd: convert external sixaxis plugin to builtin
      bluetoothd: factor out external plugin support
      bluetoothd: don't export internal API
      bluetoothd: change plugin loading alike obexd
      android: export only (android) entrypoint from the modules

 Makefile.am              |  17 ++----
 Makefile.obexd           |   2 +
 Makefile.plugins         |   8 ++-
 README                   |  13 +++++
 android/Makefile.am      |   3 ++
 android/hal-audio.c      |   1 +
 android/hal-bluetooth.c  |   1 +
 android/hal-sco.c        |   1 +
 configure.ac             |  10 ++++
 obexd/src/obexd.h        |   2 +-
 obexd/src/plugin.c       |  89 ++++++++++++++++++++-----------
 obexd/src/plugin.h       |   4 ++
 plugins/external-dummy.c |  28 ----------
 src/btd.h                |   2 +-
 src/plugin.c             | 135 ++++++++++++++++++++++++++++-------------------
 src/plugin.h             |   4 ++
 16 files changed, 188 insertions(+), 132 deletions(-)
---
base-commit: 0de32f67f685b95c35a5c2f1206081af89bd88b6
change-id: 20240116-rm-ext-plugins-ba0b852a492b

Best regards,
-- 
Emil Velikov <emil.l.velikov@gmail.com>


^ permalink raw reply	[flat|nested] 18+ messages in thread
* [PATCH BlueZ v3 1/8] configure, README: introduce --enable-external-plugins
@ 2024-01-25  0:07 Emil Velikov via B4 Relay
  2024-01-25  3:15 ` Remove support for external plugins bluez.test.bot
  0 siblings, 1 reply; 18+ messages in thread
From: Emil Velikov via B4 Relay @ 2024-01-25  0:07 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Emil Velikov

From: Emil Velikov <emil.velikov@collabora.com>

As the README chunk says, disabled by default, since they rely on
internal API/ABI and can break at any point.

Instead everyone affected should work and upstream their plugin into the
bluez project.
---
 README       | 13 +++++++++++++
 configure.ac | 10 ++++++++++
 2 files changed, 23 insertions(+)

diff --git a/README b/README
index 7de7045a8..6c0777046 100644
--- a/README
+++ b/README
@@ -249,6 +249,19 @@ For a working system, certain configuration options need to be enabled:
 		systems. The behavior of the deprecated tools may be unstable
 		or simply don't work anymore.
 
+	--enable-external-plugins
+
+		Enable support for external plugins
+
+		By default external plugins for bluetoothd and obexd are not
+		supported and thus disabled.
+
+		External plugins require access to internal, undocumented and
+		unversioned API in said daemons. As such they can break at any
+		time. If you have such plugins, enable this option and work
+		actively with the community to make said plugin part of the
+		upstream bluez project.
+
 	--enable-nfc
 
 		This option enable NFC pairing support.
diff --git a/configure.ac b/configure.ac
index cab5da581..5e353a1d6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -364,6 +364,16 @@ AC_ARG_ENABLE(deprecated, AS_HELP_STRING([--enable-deprecated],
 					[enable_deprecated=${enableval}])
 AM_CONDITIONAL(DEPRECATED, test "${enable_deprecated}" = "yes")
 
+AC_ARG_ENABLE(external-plugsin, AS_HELP_STRING([--enable-external-plugins],
+			[enable support for external plugins]),
+					[enable_external_plugins=${enableval}])
+AM_CONDITIONAL(EXTERNAL_PLUGINS, test "${enable_external_plugins}" = "yes")
+if (test "${enable_external_plugins}" = "yes"); then
+	AC_DEFINE(EXTERNAL_PLUGINS, 1, [Define if external plugin support is required])
+else
+	AC_DEFINE(EXTERNAL_PLUGINS, 0, [Define if external plugin support is required])
+fi
+
 AC_ARG_ENABLE(sixaxis, AS_HELP_STRING([--enable-sixaxis],
 		[enable sixaxis plugin]), [enable_sixaxis=${enableval}])
 AM_CONDITIONAL(SIXAXIS, test "${enable_sixaxis}" = "yes" &&

-- 
2.43.0


^ permalink raw reply related	[flat|nested] 18+ messages in thread
* [PATCH BlueZ v2 1/8] configure, README: introduce --enable-external-plugins
@ 2024-01-24 16:07 Emil Velikov via B4 Relay
  2024-01-24 18:17 ` Remove support for external plugins bluez.test.bot
  0 siblings, 1 reply; 18+ messages in thread
From: Emil Velikov via B4 Relay @ 2024-01-24 16:07 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Emil Velikov

From: Emil Velikov <emil.velikov@collabora.com>

As the README chunk says, disabled by default, since they rely on
internal API/ABI and can break at any point.

Instead everyone affected should work and upstream their plugin into the
bluez project.
---
 README       | 13 +++++++++++++
 configure.ac | 10 ++++++++++
 2 files changed, 23 insertions(+)

diff --git a/README b/README
index 7de7045a8..6c0777046 100644
--- a/README
+++ b/README
@@ -249,6 +249,19 @@ For a working system, certain configuration options need to be enabled:
 		systems. The behavior of the deprecated tools may be unstable
 		or simply don't work anymore.
 
+	--enable-external-plugins
+
+		Enable support for external plugins
+
+		By default external plugins for bluetoothd and obexd are not
+		supported and thus disabled.
+
+		External plugins require access to internal, undocumented and
+		unversioned API in said daemons. As such they can break at any
+		time. If you have such plugins, enable this option and work
+		actively with the community to make said plugin part of the
+		upstream bluez project.
+
 	--enable-nfc
 
 		This option enable NFC pairing support.
diff --git a/configure.ac b/configure.ac
index cab5da581..5e353a1d6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -364,6 +364,16 @@ AC_ARG_ENABLE(deprecated, AS_HELP_STRING([--enable-deprecated],
 					[enable_deprecated=${enableval}])
 AM_CONDITIONAL(DEPRECATED, test "${enable_deprecated}" = "yes")
 
+AC_ARG_ENABLE(external-plugsin, AS_HELP_STRING([--enable-external-plugins],
+			[enable support for external plugins]),
+					[enable_external_plugins=${enableval}])
+AM_CONDITIONAL(EXTERNAL_PLUGINS, test "${enable_external_plugins}" = "yes")
+if (test "${enable_external_plugins}" = "yes"); then
+	AC_DEFINE(EXTERNAL_PLUGINS, 1, [Define if external plugin support is required])
+else
+	AC_DEFINE(EXTERNAL_PLUGINS, 0, [Define if external plugin support is required])
+fi
+
 AC_ARG_ENABLE(sixaxis, AS_HELP_STRING([--enable-sixaxis],
 		[enable sixaxis plugin]), [enable_sixaxis=${enableval}])
 AM_CONDITIONAL(SIXAXIS, test "${enable_sixaxis}" = "yes" &&

-- 
2.43.0


^ permalink raw reply related	[flat|nested] 18+ messages in thread
* [PATCH BlueZ 1/8] obexd: remove support for external plugins
@ 2024-01-16 14:18 Emil Velikov via B4 Relay
  2024-01-16 16:47 ` Remove " bluez.test.bot
  0 siblings, 1 reply; 18+ messages in thread
From: Emil Velikov via B4 Relay @ 2024-01-16 14:18 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Emil Velikov

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(-)

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

-- 
2.43.0


^ permalink raw reply related	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2024-01-29 19:00 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-29 14:44 [PATCH BlueZ v4 0/8] Remove support for external plugins Emil Velikov via B4 Relay
2024-01-29 14:44 ` [PATCH BlueZ v4 1/8] configure, README: introduce --enable-external-plugins Emil Velikov via B4 Relay
2024-01-29 17:27   ` Remove support for external plugins bluez.test.bot
2024-01-29 14:44 ` [PATCH BlueZ v4 2/8] obexd: factor out external plugin support Emil Velikov via B4 Relay
2024-01-29 14:44 ` [PATCH BlueZ v4 3/8] bluetoothd: remove external-dummy plugin Emil Velikov via B4 Relay
2024-01-29 14:44 ` [PATCH BlueZ v4 4/8] bluetoothd: convert external sixaxis plugin to builtin Emil Velikov via B4 Relay
2024-01-29 14:44 ` [PATCH BlueZ v4 5/8] bluetoothd: factor out external plugin support Emil Velikov via B4 Relay
2024-01-29 14:44 ` [PATCH BlueZ v4 6/8] bluetoothd: don't export internal API Emil Velikov via B4 Relay
2024-01-29 14:44 ` [PATCH BlueZ v4 7/8] bluetoothd: change plugin loading alike obexd Emil Velikov via B4 Relay
2024-01-29 15:37   ` Paul Menzel
2024-01-29 16:22     ` Luiz Augusto von Dentz
2024-01-29 17:47       ` Emil Velikov
2024-01-29 14:44 ` [PATCH BlueZ v4 8/8] android: export only (android) entrypoint from the modules Emil Velikov via B4 Relay
2024-01-29 15:38   ` Paul Menzel
2024-01-29 19:00 ` [PATCH BlueZ v4 0/8] Remove support for external plugins patchwork-bot+bluetooth
  -- strict thread matches above, loose matches on Subject: below --
2024-01-25  0:07 [PATCH BlueZ v3 1/8] configure, README: introduce --enable-external-plugins Emil Velikov via B4 Relay
2024-01-25  3:15 ` Remove support for external plugins bluez.test.bot
2024-01-24 16:07 [PATCH BlueZ v2 1/8] configure, README: introduce --enable-external-plugins Emil Velikov via B4 Relay
2024-01-24 18:17 ` Remove support for external plugins bluez.test.bot
2024-01-16 14:18 [PATCH BlueZ 1/8] obexd: remove " Emil Velikov via B4 Relay
2024-01-16 16:47 ` Remove " bluez.test.bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).