2021-09-06 04:00:24

by Yun-hao Chung

[permalink] [raw]
Subject: [Bluez PATCH v1 2/2] plugins/admin: create admin_policy_settings if not exists

From: Yun-Hao Chung <[email protected]>

If admin_policy_settings is not found when loading, we should create one
instead of printing error.

Reviewed-by: Shyh-In Hwang <[email protected]>
Reviewed-by: Miao-chen Chou <[email protected]>
---
This patch has been tested with following steps:
rm /var/lib/bluetooth/admin_policy_settings and restart bluetoothd.
Check if the file is created.

plugins/admin.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/plugins/admin.c b/plugins/admin.c
index 9440581409fa..fe1d71acbb8f 100644
--- a/plugins/admin.c
+++ b/plugins/admin.c
@@ -67,7 +67,7 @@ static struct btd_admin_policy *admin_policy_new(struct btd_adapter *adapter)

admin_policy->adapter = adapter;
admin_policy->adapter_id = btd_adapter_get_index(adapter);
- admin_policy->service_allowlist = NULL;
+ admin_policy->service_allowlist = queue_new();

return admin_policy;
}
@@ -337,12 +337,8 @@ static void load_policy_settings(struct btd_admin_policy *admin_policy)
char *filename = ADMIN_POLICY_STORAGE;
struct stat st;

- if (stat(filename, &st) < 0) {
- btd_error(admin_policy->adapter_id,
- "Failed to get file %s information",
- filename);
- return;
- }
+ if (stat(filename, &st) < 0)
+ store_policy_settings(policy_data);

key_file = g_key_file_new();

--
2.33.0.153.gba50c8fa24-goog