Skip to contentSkip to conversation

plugins/admin: Fix storage file location

PATCH Applied Frédéric Danis 3 participants 3 messages Jan 23 – Jan 26 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 plugins/admin: Fix storage file location

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(-)
doc/settings-storage.txt +1 -1
index 0a2cc706c..15f55f9ed 100644
@@ -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>
plugins/admin.c +10 -10
index 6ab3cba56..76c65d068 100644
@@ -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);
 
Signature · 1 line
2.43.0
#1 lore raw

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=1046379

---Test result---

Test Summary:

CheckPatch                    PENDING   0.37 seconds
GitLint                       PENDING   0.37 seconds
BuildEll                      PASS      20.23 seconds
BluezMake                     PASS      647.61 seconds
MakeCheck                     PASS      18.58 seconds
MakeDistcheck                 PASS      240.22 seconds
CheckValgrind                 PASS      292.37 seconds
CheckSmatch                   PASS      350.13 seconds
bluezmakeextell               PASS      181.61 seconds
IncrementalBuild              PENDING   0.35 seconds
ScanBuild                     PASS      1032.07 seconds

Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script
Output:

##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:

##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series Output:

---
Regards,
Linux Bluetooth

#2 lore raw
In reply to Frédéric Danis
This patch was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:

Hello:

This patch was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:

Quoted 7 lines · On Fri, 23 Jan 2026 17:42:57 +0100 you wrote:

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

Here is the summary with links:
- [BlueZ] plugins/admin: Fix storage file location

    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=2d5afe34bb05

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html