summaryrefslogtreecommitdiff
path: root/plugins
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.
* hostname: Fallback to transient hostnameBastien Nocera2022-11-161-2/+55
| | | | | | | | | | | | | | | | After pretty hostname, and static hostname, also support transient hostname as a last resort before 'BlueZ X.XX'. This happens on Fedora's Workstation installation as it calls "hostnamectl set-hostname" on startup. In Fedora Silverblue, the default hostname is set as fedora in /etc/os-release. In both cases, we should fall back to that transient hostname, as bad as it could be. Note that the transient hostname needs to be monitored through the kernel directly, as explained in: https://www.freedesktop.org/software/systemd/man/org.freedesktop.hostname1.html
* hostname: Add '' around printed stringsBastien Nocera2022-11-161-3/+3
| | | | Otherwise we can't see whether the string is nul, or empty.
* sixaxis: Fix fliping device.trusted automaticallyLuiz Augusto von Dentz2022-08-021-6/+3
| | | | | | | | device.trusted is a user preference which controls if the devices needs to be authorized or not so the plugin shall not overwrite it and instead just honor what user has set and skip authorizing if already trusted. Fixes: https://github.com/bluez/bluez/issues/372
* sixaxis: Fix memory leaksGopal Tiwari2022-05-311-2/+7
| | | | | | | | | | | | While performing static tool analysis using coverity found following reports for resouse leak bluez-5.64/plugins/sixaxis.c:425: alloc_arg: "get_pairing_type_for_device" allocates memory that is stored into "sysfs_path". bluez-5.64/plugins/sixaxis.c:428: leaked_storage: Variable "sysfs_path" going out of scope leaks the storage it points to.
* policy: Change AutoEnable default to trueLuiz Augusto von Dentz2022-04-141-1/+5
| | | | | | | This changes the default of AutoEnable to true so controllers are power up by default. Fixes: https://github.com/bluez/bluez/issues/328
* neard: Fix reading State messageNicolas Fella2022-02-241-2/+0
| | | | | | dbus_message_iter_recurse only makese sense for container types, this is a string. Fixes: https://github.com/bluez/bluez/issues/300
* build: Fix errors with glibc < 2.25Fabrice Fontaine2022-02-151-2/+2
| | | | | | | | | | | | | | | | | | getrandom and sys/random.h are only available since glibc 2.25: https://www.gnu.org/software/gnulib/manual/html_node/sys_002frandom_002eh.html resulting in the following build failures since version 5.63 and https://git.kernel.org/pub/scm/bluetooth/bluez.git/log/?qt=grep&q=getrandom: plugins/autopair.c:20:24: fatal error: sys/random.h: No such file or directory #include <sys/random.h> ^ To fix this build failure, add util_getrandom and a fallback (borrowed from pipewire and licensed under MIT): https://gitlab.freedesktop.org/pipewire/pipewire/-/blob/master/src/pipewire/utils.c Fixes: - http://autobuild.buildroot.org/results/6b8870d12e0804d6154230a7322c49416c1dc0e2
* build: Replace use of g_memdup with util_memdupLuiz Augusto von Dentz2022-01-062-7/+9
| | | | | | | | | | | This replaces the uses of g_memdup with util_memdup since the former has been deprecated: warning: ‘g_memdup’ is deprecated: Use 'g_memdup2' instead [-Wdeprecated-declarations] g_memdup2 requires bumping glib version which would likely have its own problems thus why util_memdup was introduced.
* plugins: Replace random number generation functionTedd Ho-Jeong An2021-12-081-1/+7
| | | | | | | | This patch replaces the rand() function to the getrandom() syscall. It was reported by the Coverity scan rand() should not be used for security-related applications, because linear congruential algorithms are too easy to break
* 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.
* plugins/sixaxis: Inclusive language changesArchie Pusaka2021-09-211-22/+22
| | | | | | | BT core spec 5.3 promotes the usage of inclusive languages. This CL uses "central" as it is deemed to be more appropriate. Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
* 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)
* policy: Use btd_service_is_initiatorLuiz Augusto von Dentz2021-09-171-3/+3
| | | | | | | | Instead of using BTD_SERVICE_STATE_CONNECTING use btd_service_is_initiator to determine if the service initiated the connection and then proceed to connect other service immediately. Fixes: https://github.com/bluez/bluez/issues/205
* 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>
* plugin: Fix memory leaksSteve Grubb2021-05-141-2/+1
| | | | | g_file_get_contents allocates memory. It needs to be freed on any function exit.
* plugins: Use timeout_add_secondsFrédéric Danis2021-03-161-45/+46
| | | | | Replace calls to g_timeout_add_seconds() by the timeout_add_seconds() wrapper which takes care of 0 delay.
* sixaxis: Fix Bluetooth PS3 clone joypad being named like the originalSzymon Janc2021-02-221-1/+4
| | | | | | | | | | | When cable pairing a PS3 clone device, we should try and keep the USB device name to create a new btd_device so that the joypad is named after its USB name when connecting through Bluetooth. If that isn't done, "Shanwan" clone joypads are named like the genuine joypads, and kernel Bluetooth quirks aren't applied. gh-issue: https://github.com/bluez/bluez/issues/46
* core: Rename hcid.h to btd.hLuiz Augusto von Dentz2020-10-292-2/+2
| | | | | Since we use btd term for daemon APIs it makes sense to use it also for the header name instead of hcid.
* core: Rename main_opts to btd_optsLuiz Augusto von Dentz2020-10-291-3/+3
| | | | Use btd_ prefix since this is a daemon API.
* plugins: Add SPDX License IdentifierTedd Ho-Jeong An2020-09-217-98/+7
| | | | | | | | | | | | | | | | | | This patch adds SPDX License Identifier and removes the license text. ------------------------------------- License COUNT ------------------------------------- GPL-2.0-or-later : 7 License: GPL-2.0-or-later plugins/autopair.c plugins/hostname.c plugins/neard.c plugins/policy.c plugins/sixaxis.c plugins/wiimote.c plugins/external-dummy.c
* sixaxis: Fix crash caused by return of udev_device_get_property_valueMiao-chen Chou2020-09-161-1/+1
| | | | This adds a NULL check before calling sscanf().
* adapter: Add btd_ prefix to has_kernel_featureLuiz Augusto von Dentz2020-09-151-1/+1
| | | | APIs exposed to plugins shall have btd_ prefix.
* policy: Reconnect audio on controller resumeAbhishek Pandit-Subedi2020-09-141-13/+68
| | | | | | | | During system suspend, all peer devices are disconnected. On resume, HID devices will reconnect but audio devices stay disconnected. As a quality of life improvement, mark audio devices that were disconnected due to suspend and attempt to reconnect them when the controller resumes (after a delay for better co-existence with Wi-Fi).
* policy: Enable reconnect for a2dp-sink in defaultsAbhishek Pandit-Subedi2020-09-141-1/+2
| | | | Add a2dp-sink to default reconnects list.
* autopair: Fix compiler warningSonny Sasaka2020-03-261-1/+1
| | | | | | With clang, comparing an array with NULL generates a warning because the value is always non-NULL. With maintainer mode enabled, this becomes a compilation error.
* sixaxis: Throw an error when cable setup failsBastien Nocera2019-06-131-0/+6
| | | | | If btd_request_authorization_cable_configured() fails, throw an error and free resources.
* sixaxis: Fix another problem with already setup devicesBastien Nocera2019-06-131-0/+1
| | | | | | | If the device went through any kind of pairing once, it might have been set as trusted. Make sure to set the device as untrusted before starting the cable pairing authorization so that we don't exit early from process_auth_queue() (which considers trusted devices to be paired).
* autopair: Add pin codes to try for gaming input devicesBastien Nocera2019-03-261-0/+12
| | | | As well as remote controls.
* autopair: Add more common PIN codes for audio devicesBastien Nocera2019-03-261-4/+14
| | | | | | PIN codes "1111", and "1234" are fairly common PIN codes used for audio devices such as speakers and headsets. This replaces similar quirks already present in gnome-bluetooth's PIN database.
* build: Move declaration of _GNU_SOURCE back into individual source filesMarcel Holtmann2018-12-062-0/+2
|
* policy: Add logic to connect a SinkLuiz Augusto von Dentz2018-06-261-0/+39
| | | | | | If HFP/HSP HS connects and the device also supports a Sink connect it as well since some devices (e.g. Sony MW600) may not connect it automatically.
* plugins/sixaxis: Don't ignore previously setup devicesBastien Nocera2017-11-301-8/+7
| | | | | | | | | | | | | | | 1. Setup PS3 controller through cable pairing 2. Remove device from BlueZ's database 3. Plug original PS3 controller back As we don't change the master bdaddr on the device itself, the joypad will likely be trying to connect to BlueZ, and fail to connect after a small period of time. But the device will appear connected just long enough for the cable pairing to say "hey, I already have this setup". Ideally, we would test for whether the device is temporary, or already trusted, but testing for whether we've setup its internal services *and* it's connected, rather than *or*, is sufficient.
* plugins/sixaxis: Provide DualShock 3 SDP record while adding new deviceBastien Nocera2017-11-091-0/+18
| | | | | | | | | | | | This allows to skip SDP search for DualShock 3 devices, since some DS3 clones do not provide any SDP record. This allows them to operate nonetheless. The HID SDP record is lifted straight off an original DualShock 3 controller. The PNPID SDP record is not set as not required to provide a working device. Tested with a "SHANWAN" clone controller.
* sixaxis: Fix compilation and various coding style issuesLuiz Augusto von Dentz2017-10-271-50/+33
| | | | | | | | | | | | | | | | | | | | This fixes the following problems: plugins/sixaxis.c:443:7: error: ‘version’ may be used uninitialized in this function [-Werror=maybe-uninitialized] if (!setup_device(fd, sysfs_path, name, source, vid, pid, version, type, adapter)) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ plugins/sixaxis.c:409:34: note: ‘version’ was declared here uint16_t bus, vid, pid, source, version; ^~~~~~~ plugins/sixaxis.c:443:7: error: ‘source’ may be used uninitialized in this function [-Werror=maybe-uninitialized] if (!setup_device(fd, sysfs_path, name, source, vid, pid, version, type, adapter)) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ plugins/sixaxis.c:409:26: note: ‘source’ was declared here uint16_t bus, vid, pid, source, version; ^~~~~~ cc1: all warnings being treated as errors And many instances of code going over 80 columns.
* plugins/sixaxis: Cancel cable pairing if unpluggedBastien Nocera2017-10-271-15/+122
| | | | | Cancel pending authorization requests when the device is unplugged while a request is pending.
* plugins/sixaxis: Add support for DualShock 4/PS4 cable pairingJuha Kuikka2017-10-271-1/+72
| | | | | | | | | | | | This patch adds support for "pairing" a Dualshock4 controller over USB into the sixaxis plugin, similarly to what the Sixaxis/PS3 controller supported. Actual bonding happens on first connection, but the device will be marked as trusted when the agent replies. This patch is based on DS4 supprt for sixpair tool by t0xicCode: https://github.com/t0xicCode/sixpair/commit/975c38cb6cd61a2f0be350714f0f64cef5f0432c
* plugins/sixaxis: Rename sixaxis specific functionsBastien Nocera2017-10-271-7/+32
| | | | And provide wrappers to prepare for the addition of other device types.