public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH BlueZ] plugins/admin: Fix storage file location
@ 2026-01-23 16:42 Frédéric Danis
  2026-01-23 17:40 ` [BlueZ] " bluez.test.bot
  2026-01-26 23:00 ` [PATCH BlueZ] " patchwork-bot+bluetooth
  0 siblings, 2 replies; 3+ messages in thread
From: Frédéric Danis @ 2026-01-23 16:42 UTC (permalink / raw)
  To: linux-bluetooth

The admin policy is set per adapter, as stated in
doc/settings-storage.txt and doc/org.bluez.AdminPolicySet.rst but
currently stored directly under STORAGEDIR.
---
 doc/settings-storage.txt |  2 +-
 plugins/admin.c          | 20 ++++++++++----------
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/doc/settings-storage.txt b/doc/settings-storage.txt
index 0a2cc706c..15f55f9ed 100644
--- a/doc/settings-storage.txt
+++ b/doc/settings-storage.txt
@@ -56,7 +56,7 @@ So the directory structure is:
     /var/lib/bluetooth/<adapter address>/
         ./settings
         ./attributes
-	./admin_policy_settings
+        ./admin_policy_settings
         ./cache/
             ./<remote device address>
             ./<remote device address>
diff --git a/plugins/admin.c b/plugins/admin.c
index 6ab3cba56..76c65d068 100644
--- a/plugins/admin.c
+++ b/plugins/admin.c
@@ -34,7 +34,6 @@
 
 #define ADMIN_POLICY_SET_INTERFACE	"org.bluez.AdminPolicySet1"
 #define ADMIN_POLICY_STATUS_INTERFACE	"org.bluez.AdminPolicyStatus1"
-#define ADMIN_POLICY_STORAGE		STORAGEDIR "/admin_policy_settings"
 
 #define DBUS_BLUEZ_SERVICE		"org.bluez"
 #define BTD_DEVICE_INTERFACE		"org.bluez.Device1"
@@ -248,7 +247,7 @@ static void store_policy_settings(struct btd_admin_policy *admin_policy)
 {
 	GKeyFile *key_file = NULL;
 	GError *gerr = NULL;
-	char *filename = ADMIN_POLICY_STORAGE;
+	char filename[PATH_MAX];
 	char *key_file_data = NULL;
 	char **uuid_strs = NULL;
 	gsize length, num_uuids;
@@ -268,16 +267,14 @@ static void store_policy_settings(struct btd_admin_policy *admin_policy)
 					(const gchar * const *)uuid_strs,
 					num_uuids);
 
-	if (create_file(ADMIN_POLICY_STORAGE, 0600) < 0) {
-		btd_error(admin_policy->adapter_id, "create %s failed, %s",
-						filename, strerror(errno));
-		goto failed;
-	}
+	create_filename(filename, PATH_MAX, "/%s/admin_policy_settings",
+			btd_adapter_get_storage_dir(admin_policy->adapter));
+	create_file(filename, 0600);
 
 	key_file_data = g_key_file_to_data(key_file, &length, NULL);
-	if (!g_file_set_contents(ADMIN_POLICY_STORAGE, key_file_data, length,
+	if (!g_file_set_contents(filename, key_file_data, length,
 								&gerr)) {
-		error("Unable set contents for %s: (%s)", ADMIN_POLICY_STORAGE,
+		error("Unable set contents for %s: (%s)", filename,
 								gerr->message);
 		g_error_free(gerr);
 	}
@@ -342,9 +339,12 @@ static void load_policy_settings(struct btd_admin_policy *admin_policy)
 {
 	GKeyFile *key_file;
 	GError *gerr = NULL;
-	char *filename = ADMIN_POLICY_STORAGE;
+	char filename[PATH_MAX];
 	struct stat st;
 
+	create_filename(filename, PATH_MAX, "/%s/admin_policy_settings",
+			btd_adapter_get_storage_dir(admin_policy->adapter));
+
 	if (stat(filename, &st) < 0)
 		store_policy_settings(policy_data);
 
-- 
2.43.0


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

end of thread, other threads:[~2026-01-26 23:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-23 16:42 [PATCH BlueZ] plugins/admin: Fix storage file location Frédéric Danis
2026-01-23 17:40 ` [BlueZ] " bluez.test.bot
2026-01-26 23:00 ` [PATCH BlueZ] " patchwork-bot+bluetooth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox