summaryrefslogtreecommitdiff
path: root/plugins/admin.c
Commit message (Collapse)AuthorAgeFilesLines
* admin: Mark driver as experimentalLuiz Augusto von Dentz2023-05-161-5/+2
| | | | | This uses the btd_profile.experimental to mark the driver as experimental.
* admin: fix devices not resetYun-Hao Chung2021-11-151-1/+3
| | | | | | | | | When |admin_policy_remove| is called, we set |devices| to NULL but never set it back until |admin_init|. This makes admin lost track of current registered device interface, so the next |admin_policy_removed| will not be able to unregister those interfaces. Reviewed-by: Archie Pusaka <apusaka@chromium.org>
* plugins/admin: Fix unchecked return valueTedd Ho-Jeong An2021-10-181-2/+13
| | | | | This patch fixes the unchecked return value(CWE-252) issues reported by the Coverity.
* admin: Fix double freeLuiz Augusto von Dentz2021-09-171-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | Fixes the following double free which happen due to exit calling btd_unregister_adapter_driver: Invalid read of size 8 at 0x1CDA97: queue_foreach (queue.c:198) by 0x1318B8: admin_policy_remove (admin.c:591) by 0x18982A: plugin_cleanup (plugin.c:217) by 0x12E3FD: main (main.c:1214) Address 0x547ffb8 is 8 bytes inside a block of size 32 free'd at 0x483A9F5: free (vg_replace_malloc.c:538) by 0x1318CB: admin_policy_remove (admin.c:592) by 0x18F416: unload_driver (adapter.c:7215) by 0x496F50F: g_slist_foreach (in /usr/lib64/libglib-2.0.so.0.6600.8) by 0x131988: admin_exit (admin.c:623) by 0x18982A: plugin_cleanup (plugin.c:217) by 0x12E3FD: main (main.c:1214) Block was alloc'd at at 0x4839809: malloc (vg_replace_malloc.c:307) by 0x1CDE1E: btd_malloc (util.c:33) by 0x1CD83D: queue_new (queue.c:47) by 0x13150D: admin_init (admin.c:614) by 0x18966B: plugin_init (plugin.c:187) by 0x12E358: main (main.c:1198)
* admin: Fix leaking uuids loads from storageLuiz Augusto von Dentz2021-09-171-3/+6
| | | | | | | | | | | | | | | | | | | | | | This fixes the following trace: 8 bytes in 1 blocks are definitely lost in loss record 27 of 274 at 0x4839809: malloc (vg_replace_malloc.c:307) by 0x495BBB8: g_malloc (in /usr/lib64/libglib-2.0.so.0.6600.8) by 0x494C024: g_key_file_get_string_list (in /usr/lib64/libglib-2.0.so.0.6600.8) by 0x131ECD: key_file_load_service_allowlist (admin.c:294) by 0x131ECD: load_policy_settings (admin.c:346) by 0x131ECD: admin_policy_adapter_probe (admin.c:497) by 0x18F554: probe_driver (adapter.c:4858) by 0x19DF5A: load_drivers (adapter.c:4873) by 0x19DF5A: adapter_register (adapter.c:8975) by 0x19DF5A: read_info_complete (adapter.c:9791) by 0x1CE831: request_complete (mgmt.c:264) by 0x1CF7D4: can_read_data (mgmt.c:356) by 0x1DE634: watch_callback (io-glib.c:157) by 0x4953A9E: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.6600.8) by 0x49A5A97: ??? (in /usr/lib64/libglib-2.0.so.0.6600.8) by 0x4953162: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.6600.8)
* plugins/admin: create admin_policy_settings if not existsYun-Hao Chung2021-09-151-7/+3
| | | | | | | | 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>
* plugins/admin: add adapter_remove handlerYun-Hao Chung2021-09-151-7/+28
| | | | | | | | | | | | Currently admin doesn't handle adapter removed callbacks, which causes interfaces AdminPolicySet1 and AdminPolicyStatus1 not being unregistered, which in turns causes these interfaces can not be re-registered once adapter is back. This adds handler for adapter_remove. Reviewed-by: Shyh-In Hwang <josephsih@chromium.org> Reviewed-by: Miao-chen Chou <mcchou@chromium.org>
* plugin/admin: fix set empty allowlist no persistence issueYun-Hao Chung2021-08-311-1/+6
| | | | | | | This patch fixes a bug when setting empty service allowlist, the allowlist sets successfully but it fails to be stored in the file. Reviewed-by: Miao-chen Chou <mcchou@chromium.org>
* plugins/admin: add uuid duplicate checkYun-Hao Chung2021-08-111-1/+15
| | | | | | SetServiceAllowlist should ignore those duplicated UUIDs. Reviewed-by: Miao-chen Chou <mcchou@chromium.org>
* plugins/admin: persist policy settingsYun-Hao Chung2021-08-041-1/+164
| | | | | | | | This adds code to store the ServiceAllowlist to file /var/lib/bluetooth/{MAC_ADDR}/admin_policy The stored settings will be loaded upon admin_policy initialized. Reviewed-by: Miao-chen Chou <mcchou@chromium.org>
* plugins/admin: add AffectedByPolicy propertyYun-Hao Chung2021-08-041-2/+71
| | | | | | | This adds property to indicate if a device has any service that is being blocked by admin policy. Reviewed-by: Miao-chen Chou <mcchou@chromium.org>
* plugins/admin: add device callbacksYun-Hao Chung2021-08-041-0/+78
| | | | | | | This adds callbacks for device resolved and device removed. It is necessary for implementation of "AffectedByPolicy" property since it needs to register an interface for each device object and unregister it once the device gets removed.
* plugins/admin: add ServiceAllowList propertyYun-Hao Chung2021-08-041-0/+58
| | | | | | | | | | | | | | This adds code to register interface org.bluez.AdminPolicyStatus. The interface will provide read-only properties to indicate the current settings of admin policies. We separate this from AdminPolicySet so that normal clients can check current policy settings while only a few clients can change policies. This patch also adds readonly property ServiceAllowlist to AdminPolicyStatus1, which indicates the current setting of service allowlist. Reviewed-by: Miao-chen Chou <mcchou@chromium.org>
* plugins/admin: add ServiceAllowList methodYun-Hao Chung2021-08-041-1/+126
| | | | | | | | | | | | This adds code to register interface org.bluez.AdminPolicySet1. The interface will provide methods to limit users to operate certain functions of bluez, such as allow/disallow user to taggle adapter power, or only allow users to connect services in the specified list, etc. This patch also implements ServiceAllowlist in org.bluez.AdminPolicySet1. Reviewed-by: Miao-chen Chou <mcchou@chromium.org>
* plugins/admin: add admin_policy adapter driverYun-Hao Chung2021-08-041-1/+66
| | | | | | | | | | | This adds code to register admin_policy driver to adapter when admin plugin is enabled. The following test steps were performed: 1. restart bluetoothd 2. check if "Admin Policy is enabled" in system log Reviewed-by: Miao-chen Chou <mcchou@chromium.org>
* plugins: new pluginYun-Hao Chung2021-08-041-0/+32
This adds an initial code for a new plugin admin. Reviewed-by: Miao-chen Chou <mcchou@chromium.org>