diff mbox series

[Bluez,v2,2/2] plugins/admin: create admin_policy_settings if not exists

Message ID 20210906140250.Bluez.v2.2.Id6fa258f1381f5913f06dfa27f3946339033cec3@changeid
State New
Headers show
Series [Bluez,v2,1/2] plugins/admin: add adapter_remove handler | expand

Commit Message

Yun-hao Chung Sept. 6, 2021, 6:03 a.m. UTC
From: Yun-Hao Chung <howardchung@chromium.org>

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

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

(no changes since v1)

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

Patch

diff --git a/plugins/admin.c b/plugins/admin.c
index 82c00cabdb6b..8390f3c32bbd 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;
 }
@@ -335,12 +335,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();