Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp2487061pxb; Sun, 5 Sep 2021 21:00:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw0QpFQxhTFKhAMSvbs8tNelnmnIRToNjANIH/v1ZdemqQrHB6UjNXnuGP2pm/HCd/uIr5T X-Received: by 2002:a17:906:8684:: with SMTP id g4mr11438045ejx.262.1630900824735; Sun, 05 Sep 2021 21:00:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630900824; cv=none; d=google.com; s=arc-20160816; b=se2xizLUoqhR8z60nSpcAf4tEqgXjteXRMwx8rZLv5O3iYmjBn/DDBCBa9OQ27/sag nuuH8NnOI6tQWZKQtvqcf8zUgpZlpHU9NEDit2wYYOjx9lmrcnfYp24bEwjgP4C80UPH E5geB2RRklpvyrgNtIjE2kWL92wfEW1beW3MHvVPjhlHFSbmSz31IQaonCn+NuCfS7m6 hLtvrQl6pYldqwMsNNQjkqgIz8ZgW1bVXjHGhu+YUGqG8OlDld96FkqH/T+1FnZciUzd qgJrws8wcnM2Q4iFZbTgY4gVa1mKWedsqqQjvuDIDamqzlhgDdueDTZjl6o4y9aWtQro 6ScA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=vXuzu/Z+J0Wg0UNmJT6LQXT5ypiablE/lzNgTc8r25Q=; b=HlaRyBe8v9ZBBK/DAka1uhOV/mM4BrVdp9vPjZeQQnmSQ52Q85OT3vLTmOxlIEIyvW agC+EKQ98DGStoE7ow54RFe1kt2jmdL5DdeojBOeqF3GkCCKLCm+FZ0LwM2xrcsUP/n3 u25vjg6waCxE2ThD+xBK8yDEYnHhAg5RvFyDknpRKRru4jhhWTbgYDCHSoVLVvnkPLdV CLXdvoyrdZoha5V4Q34fOOK5k/Kdn/XOg0yf+NLNn7PjxZfNL8rVl0U3g5lkkFDXPNQr nq5yiqsWxFveyI1iNT8UzpGvgTw4RxkslAcm7svKtkneUuIxCsfnAwaRS+fhUtq8imel QTAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="enPtM/sZ"; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z26si7951552ejc.486.2021.09.05.20.59.32; Sun, 05 Sep 2021 21:00:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="enPtM/sZ"; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238102AbhIFDlT (ORCPT + 99 others); Sun, 5 Sep 2021 23:41:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55386 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237574AbhIFDlT (ORCPT ); Sun, 5 Sep 2021 23:41:19 -0400 Received: from mail-pg1-x54a.google.com (mail-pg1-x54a.google.com [IPv6:2607:f8b0:4864:20::54a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E8B6C061757 for ; Sun, 5 Sep 2021 20:40:15 -0700 (PDT) Received: by mail-pg1-x54a.google.com with SMTP id w2-20020a63fb42000000b00255da18df0cso4052982pgj.9 for ; Sun, 05 Sep 2021 20:40:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=vXuzu/Z+J0Wg0UNmJT6LQXT5ypiablE/lzNgTc8r25Q=; b=enPtM/sZghbPl3JcCkreMhTHldjB6RfV3sVA8Cwr68XFT7lOHMMmdlDHqSrwgwuJvC cIKgNSBW+q7QaCOC+Wr0LKEKoWkuFWpxcGVKdHqWOF2aFq8+kBsPC0KyW+ItkqXaADV9 3CxbQ+tXki2BGvWei3It/e+OZU5pnbrFKwV8NxEmM26dAYGfCnK3+DMXm8DomIBXvNxE izY9wMPT51xv14Etj7LVlPV6aZlRlotc6MPFHqRPUTwrWv7ZhlcQ8CEouA3i3LxoM0aF HAJC/1F9LyVqfUUWWcPNjAOSCSy+8m80q7j7qKPhCqu0f0E9CzX2DDzpIQHMDvG2v8CP 0J7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=vXuzu/Z+J0Wg0UNmJT6LQXT5ypiablE/lzNgTc8r25Q=; b=U/Ndu0k6Du7iOeWL+TXCwE2ppfhnRD99/e66heqhC0XDz2FdkB87tEAFbEgnZhkU+1 xBEK8+nGcTdOhpA5tEYdZiognohBc/9TlPZwfZIhndbhx6QCXRI1VIINX3/xzrid0Tp6 f8V8bGSKpZHQhMTyf+x5IpQlU7knCKS0fid+FbtGuPC3oOyUmye7SnqkTG5DSe1PGKd0 1DDGxcrutUJLoNr7/UqGrh8/bUQcJWsR8xipIrNqLjVxTNDlktn6dZ7r675ewtvlSXm3 sa7rg2qOppZlPD1pWQQfT7SMCwwoZXgsIFTS3T9nrSBY1WootBwvXthA2rh1Oj7Vo23q zgPA== X-Gm-Message-State: AOAM532cb9qa/Pv1FBkxwfoS98GhCbelolxMe1upAezjKKnFlxidXaW+ iJjxGVezMn5A3Dt9G13NCjrIbHl0mkuBlxsEXSa8V+VelGsCnWNPosnMxfP7zm6zGPKbduE2yPj 0aQEuUj94PB9hmVXJIJVbFj8mcbLc0HhmCz8o+zePHxd9VejsEM0CuM0dXQjioaDXL7EV0sM6fP 8NmuEr0NmCprs= X-Received: from howardchung-p920.tpe.corp.google.com ([2401:fa00:1:10:d42:c8a9:b5b9:8c48]) (user=howardchung job=sendgmr) by 2002:a05:6a00:1404:b0:412:901a:3b36 with SMTP id l4-20020a056a00140400b00412901a3b36mr9889660pfu.52.1630899614326; Sun, 05 Sep 2021 20:40:14 -0700 (PDT) Date: Mon, 6 Sep 2021 11:40:06 +0800 In-Reply-To: <20210906113953.Bluez.v1.1.Id597e5ae87e680e6a744a8ed08d5000aacfce867@changeid> Message-Id: <20210906113953.Bluez.v1.2.Id6fa258f1381f5913f06dfa27f3946339033cec3@changeid> Mime-Version: 1.0 References: <20210906113953.Bluez.v1.1.Id597e5ae87e680e6a744a8ed08d5000aacfce867@changeid> X-Mailer: git-send-email 2.33.0.153.gba50c8fa24-goog Subject: [Bluez PATCH v1 2/2] plugins/admin: create admin_policy_settings if not exists From: Howard Chung To: linux-bluetooth@vger.kernel.org, luiz.dentz@gmail.com Cc: Yun-Hao Chung , Shyh-In Hwang , Miao-chen Chou Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Yun-Hao Chung If admin_policy_settings is not found when loading, we should create one instead of printing error. Reviewed-by: Shyh-In Hwang Reviewed-by: Miao-chen Chou --- 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