emericg / toolBLEx

A multiplatform Bluetooth Low Energy (and Classic) device scanner and analyzer.
GNU General Public License v3.0
149 stars 13 forks source link

toolBLEx flathub flatpak version does not work with Bluetooth out of the box #21

Open Abdull opened 2 months ago

Abdull commented 2 months ago

Describe the bug I have installed the 0.12 toolBLEx flatpak version from Flathub (IMHO it should be the flatpak version at commit 121003c55b9c52223b4545af5210457aaddc9eca).

Out-of-the-box / without any flatpak security changes, this flatpak version did not work with Bluetooth, i.e. did not list Bluetooth devices (which on the other hand my operating system (Debian 12 bookworm under KDE 5 Plasma, Wayland) can see and interact with):

$ flatpak run io.emeric.toolblex
qt.bluetooth.bluez: Missing CAP_NET_ADMIN permission. Cannot determine whether a found address is of random or public type.
qrc:/qml/PanelDeviceInfos.qml:94:21: QML TextSelectable: Binding loop detected for property "implicitWidth"
qrc:/qml/AdapterWidget.qml:137:13: QML TextSelectable: Binding loop detected for property "implicitWidth"
qrc:/qml/AdapterWidget.qml:83:13: QML TextSelectable: Binding loop detected for property "implicitWidth"
qrc:/qml/PanelDeviceInfos.qml:266: TypeError: Cannot read property 'pairingStatus' of null
qrc:/qml/PanelDeviceInfos.qml:346: TypeError: Cannot read property 'majorClass' of null
qrc:/qml/PanelDeviceInfos.qml:371: TypeError: Cannot read property 'majorClass' of null
qrc:/qml/PanelDeviceInfos.qml:386: TypeError: Cannot read property 'servicesCount' of null
qrc:/qml/PanelDeviceInfos.qml:396: TypeError: Cannot read property 'serviceClass' of null
qrc:/qml/PanelDeviceInfos.qml:629: TypeError: Cannot read property 'mtu' of null
qrc:/qml/PanelDeviceInfos.qml:675: TypeError: Cannot read property 'rssi' of null
qrc:/qml/PanelDeviceInfos.qml:821: TypeError: Cannot read property 'servicesCount' of null

qt.bluetooth.bluez: Cannot open HCI socket: "Address family not supported by protocol"
qt.bluetooth.bluez: Cannot determine bluetoothd version and required Bluetooth HCI ioctols
qt.bluetooth.bluez: Disabling Qt Bluetooth LE feature
qt.bluetooth.bluez: Cannot open HCI socket
qrc:/qml/ButtonScanMenu.qml:44: ReferenceError: getDeviceStatusIcon is not defined
qrc:/qml/ButtonScanMenu.qml:44: ReferenceError: getDeviceStatusIcon is not defined
qt.bluetooth.bluez: l2cp socket not initialised
Device::deviceErrored( "XX:XX:XX:XX:XX:XX" ) error: QLowEnergyController::ConnectionError

Using Flatseal, I gave toolBLEx a bunch of additional permissions. The additional permissions are:

share=network
socket=session-bus
socket=system-bus
device=all

With the permissions already set up in the flathub version release, in sum the permissions look like this:

$ flatpak info --show-permissions io.emeric.toolblex
[Context]
shared=network;ipc;
sockets=x11;wayland;session-bus;system-bus;fallback-x11;
devices=dri;all;
features=bluetooth;

[System Bus Policy]
org.bluez=talk

Also, for portals, I allowed "can run in the backgorund" and "can send notifications":

$ flatpak permission-show io.emeric.toolblex
Table         Object       App                Permissions Data
background    background   io.emeric.toolblex yes         0x00
notifications notification io.emeric.toolblex yes         0x00

With these additional permissions, toolBLEx does find Bluetooth devices:

$ flatpak run io.emeric.toolblex
qt.bluetooth.bluez: Missing CAP_NET_ADMIN permission. Cannot determine whether a found address is of random or public type.
qrc:/qml/PanelDeviceInfos.qml:94:21: QML TextSelectable: Binding loop detected for property "implicitWidth"
qrc:/qml/AdapterWidget.qml:137:13: QML TextSelectable: Binding loop detected for property "implicitWidth"
qrc:/qml/AdapterWidget.qml:83:13: QML TextSelectable: Binding loop detected for property "implicitWidth"
qrc:/qml/PanelDeviceInfos.qml:266: TypeError: Cannot read property 'pairingStatus' of null
qrc:/qml/PanelDeviceInfos.qml:346: TypeError: Cannot read property 'majorClass' of null
qrc:/qml/PanelDeviceInfos.qml:371: TypeError: Cannot read property 'majorClass' of null
qrc:/qml/PanelDeviceInfos.qml:386: TypeError: Cannot read property 'servicesCount' of null
qrc:/qml/PanelDeviceInfos.qml:396: TypeError: Cannot read property 'serviceClass' of null
qrc:/qml/PanelDeviceInfos.qml:629: TypeError: Cannot read property 'mtu' of null
qrc:/qml/PanelDeviceInfos.qml:675: TypeError: Cannot read property 'rssi' of null
qrc:/qml/PanelDeviceInfos.qml:821: TypeError: Cannot read property 'servicesCount' of null

That is, the following error messages no longer show up:

qt.bluetooth.bluez: Cannot open HCI socket: "Address family not supported by protocol"
qt.bluetooth.bluez: Cannot determine bluetoothd version and required Bluetooth HCI ioctols
qt.bluetooth.bluez: Disabling Qt Bluetooth LE feature
qt.bluetooth.bluez: Cannot open HCI socket
qrc:/qml/ButtonScanMenu.qml:44: ReferenceError: getDeviceStatusIcon is not defined
qrc:/qml/ButtonScanMenu.qml:44: ReferenceError: getDeviceStatusIcon is not defined
qt.bluetooth.bluez: l2cp socket not initialised
Device::deviceErrored( "XX:XX:XX:XX:XX:XX" ) error: QLowEnergyController::ConnectionError

The error messages qt.bluetooth.bluez: Missing CAP_NET_ADMIN permission. ... and all qrc:/qml/... error messages are probably irrelevant for this issue;

Expected behavior toolBLEx flatpak version works with Bluetooth out of the box

To Reproduce Steps to reproduce the behavior:

# DON'T have lingering flatpak toolBLEx configurations from previous installations

flatpak install flathub io.emeric.toolblex
flatpak run io.emeric.toolblex

Screenshots If applicable, add screenshots to help explain your problem.

(I don't add a screenshot, because I don't want to jinx my working installation)

Your environment Please describe the environment you are using:

Operating System: Debian GNU/Linux 12
KDE Plasma Version: 5.27.5
KDE Frameworks Version: 5.103.0
Qt Version: 5.15.8
Kernel Version: 6.7.12+bpo-rt-amd64 (64-bit)
Graphics Platform: Wayland
Processors: 12 × AMD Ryzen 5 7640U w/ Radeon 760M Graphics
Memory: 27,2 GiB of RAM
Graphics Processor: AMD Radeon Graphics
Manufacturer: Framework
Product Name: Laptop 13 (AMD Ryzen 7040Series)
System Version: A5
  1. Where did you download/bought the application from flathub ( https://flathub.org/apps/io.emeric.toolblex ) via flatpak install flathub io.emeric.toolblex

  2. The version of the application you are running

    
    $ flatpak info io.emeric.toolblex

toolBLEx - Bluetooth device scanner and analyzer

      ID: io.emeric.toolblex
     Ref: app/io.emeric.toolblex/x86_64/stable
    Arch: x86_64
  Branch: stable
 Version: 0.12
 License: GPL-3.0+
  Origin: flathub

Collection: org.flathub.Stable Installation: system Installed: 136.2 MB Runtime: org.freedesktop.Platform/x86_64/23.08 Sdk: org.freedesktop.Sdk/x86_64/23.08

  Commit: 3bbe0b9bd4b84b93b456f6926f15c5968424daa2245eb354e20dd19d2213e3c0
  Parent: b1acbc3de4fc93cc3191e1ef7be22d625ecbfd2090255435d1c4a84aa0e90aa6
 Subject: Add back shadertools (121003c5)
    Date: 2024-06-20 11:24:11 +0000


**Additional context**
Add any other context about the problem here.
emericg commented 2 months ago

Hi, and first of all thanks for investigating this issue!

I'm not entirely sure if this is a widespread issue or something related to your installation. The flatpak version supposedly has 40k installs and this is the first bug report stating the app doesn't work at all :/

What permission actually allow the software to work? Does it need all the adjustments you mentioned to start working?

share=network

The application doesn't use internet at the moment, so this shouldn't be necessary (and that permission mark the flatpak as "unsafe").

socket=session-bus socket=system-bus device=all

Is session-bus enough? The other two shouldn't be needed AFAIK, and are also marking the app as "unsafe" (and potentially even more). Maybe device=all for USB Bluetooth adapter? That would be weird though...

"can run in the background" and "can send notifications" capabilities should not be necessary either for this application, that neither runs in the background nor send notifications ^^

vulpes2 commented 1 week ago

This might be a Debian-specific issue, the default permissions seem to work fine on Fedora 40. I am also seeing the same type errors, however they don't seem to affect functionality of the application. session-bus access and device=all are definitely not required as we are not accessing the hci device directly, and bluez is on the system dbus. share=network might be what made it work on your machine, because there are similar issues with docker where setting network=host will fix Bluetooth support within the containers.

$ flatpak run io.emeric.toolblex
qt.bluetooth.bluez: Missing CAP_NET_ADMIN permission. Cannot determine whether a found address is of random or public type.
qrc:/qml/PanelDeviceInfos.qml:94:21: QML TextSelectable: Binding loop detected for property "implicitWidth"
qrc:/qml/PanelDeviceInfos.qml:266: TypeError: Cannot read property 'pairingStatus' of null
qrc:/qml/PanelDeviceInfos.qml:346: TypeError: Cannot read property 'majorClass' of null
qrc:/qml/PanelDeviceInfos.qml:371: TypeError: Cannot read property 'majorClass' of null
qrc:/qml/PanelDeviceInfos.qml:386: TypeError: Cannot read property 'servicesCount' of null
qrc:/qml/PanelDeviceInfos.qml:396: TypeError: Cannot read property 'serviceClass' of null
qrc:/qml/PanelDeviceInfos.qml:629: TypeError: Cannot read property 'mtu' of null
qrc:/qml/PanelDeviceInfos.qml:675: TypeError: Cannot read property 'rssi' of null
qrc:/qml/PanelDeviceInfos.qml:821: TypeError: Cannot read property 'servicesCount' of null
emericg commented 1 week ago

Thanks for your feedbacks! Let's see if we can get some more.