Git Product home page Git Product logo

Comments (9)

muka avatar muka commented on July 29, 2024

Hi David
have you added the dbus permissions definition files ?

Samples are here https://github.com/muka/go-bluetooth/tree/master/scripts

If not the case, can you try to have a setup with 5.50 and run a plain example to see if this is still happening?

Let me know so we can investigate further

Thanks

from go-bluetooth.

davidknezic avatar davidknezic commented on July 29, 2024

Hi @muka, thanks for helping out!

Yes, I have removed the standard bluetooth permissions file and replaced it with the two that are in the scripts folder (with some additions):

/etc/dbus-1/system.d/dbus-go-bluetooth-service.conf
<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
  <policy user="root">
    <allow own="go.bluetooth"/>
    <allow send_destination="go.bluetooth"/>
    <allow send_destination="org.bluez"/>
  </policy>
  <policy at_console="true">
    <allow own="go.bluetooth"/>
    <allow send_destination="go.bluetooth"/>
    <allow send_destination="org.bluez"/>
  </policy>
  <policy context="default">
    <deny send_destination="go.bluetooth"/>
  </policy>
</busconfig>
/etc/dbus-1/system.d/dbus-go-bluetooth-dev.conf
<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">

<busconfig>

    <policy user="root">

        <allow own="go.bluetooth"/>
        <allow own_prefix="go.bluetooth"/>
        <allow send_destination="go.bluetooth" send_interface="go.bluetooth"/>
        <allow send_destination="go.bluetooth" send_interface="org.freedesktop.DBus.Introspectable"/>
        <allow send_destination="go.bluetooth" send_interface="org.freedesktop.DBus.Properties"/>
        <allow send_destination="go.bluetooth" send_interface="org.freedesktop.DBus.ObjectManager"/>
        <allow send_destination="go.bluetooth"/>

        <allow own="org.bluez"/>
        <allow own_prefix="org.bluez"/>
        <allow send_destination="org.bluez" send_interface="org.bluez"/>
        <allow send_destination="org.bluez" send_interface="org.freedesktop.DBus.Introspectable"/>
        <allow send_destination="org.bluez" send_interface="org.freedesktop.DBus.Properties"/>
        <allow send_destination="org.bluez" send_interface="org.freedesktop.DBus.ObjectManager"/>
        <allow send_destination="org.bluez"/>

        <allow send_interface="org.freedesktop.DBus.ObjectManager"/>
        <allow send_interface="org.freedesktop.DBus.Properties"/>
        <allow send_interface="org.freedesktop.DBus.Introspectable"/>
        <allow send_interface="org.bluez.GattCharacteristic1"/>
        <allow send_interface="org.bluez.GattDescriptor1"/>
        <allow send_interface="org.bluez.GattService1"/>
        <allow send_interface="org.bluez.GattManager1"/>

        <allow send_interface="org.bluez.LEAdvertisement1"/>
        <allow send_interface="org.bluez.Agent1"/>
        <allow send_interface="org.bluez.MediaEndpoint1"/>
        <allow send_interface="org.bluez.MediaPlayer1"/>
        <allow send_interface="org.bluez.Profile1"/>
        <allow send_interface="org.bluez.LEAdvertisingManager1"/>
    </policy>
    <policy at_console="true">
     <allow send_destination="org.bluez"/>
    </policy>

    <policy context="default">
    </policy>

</busconfig>

I've extended the dev file a little, trying to resolve my issue, adding the following lines to the user=root policy:

        <allow send_interface="org.bluez.LEAdvertisement1"/>
        <allow send_interface="org.bluez.Agent1"/>
        <allow send_interface="org.bluez.MediaEndpoint1"/>
        <allow send_interface="org.bluez.MediaPlayer1"/>
        <allow send_interface="org.bluez.Profile1"/>
        <allow send_interface="org.bluez.LEAdvertisingManager1"/>

I run the app as root.

The following was the original that was added by the yocto build. I've replaced it entirely because I got a couple of permission errors while using go-bluetooth:

/etc/dbus-1/system.d/bluetooth.conf
<!-- This configuration file specifies the required security policies
     for Bluetooth core daemon to work. -->

<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
 "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>

  <!-- ../system.conf have denied everything, so we just punch some holes -->

  <policy user="root">
    <allow own="org.bluez"/>
    <allow send_destination="org.bluez"/>
    <allow send_interface="org.bluez.Agent1"/>
    <allow send_interface="org.bluez.MediaEndpoint1"/>
    <allow send_interface="org.bluez.MediaPlayer1"/>
    <allow send_interface="org.bluez.Profile1"/>
    <allow send_interface="org.bluez.GattCharacteristic1"/>
    <allow send_interface="org.bluez.GattDescriptor1"/>
    <allow send_interface="org.bluez.LEAdvertisement1"/>
    <allow send_interface="org.freedesktop.DBus.ObjectManager"/>
    <allow send_interface="org.freedesktop.DBus.Properties"/>
  </policy>

  <policy at_console="true">
    <allow send_destination="org.bluez"/>
  </policy>

  <!-- allow users of lp group (printing subsystem) to 
       communicate with bluetoothd -->
  <policy group="lp">
    <allow send_destination="org.bluez"/>
  </policy>

  <policy context="default">
    <deny send_destination="org.bluez"/>
  </policy>

</busconfig>

from go-bluetooth.

muka avatar muka commented on July 29, 2024

Can you have a try with an example from the repository? It could be easier for me to replicate.

from go-bluetooth.

davidknezic avatar davidknezic commented on July 29, 2024

Yes, sure! Just tried the service example. It leads to the same error.

root@raspberrypi0-wifi:/data# ./service 
INFO[0000] Application started, waiting for connections 
DEBU[0000] Registering app /go_bluetooth/example/service 
DEBU[0000] Registering service on hci0 (/org/bluez/advertisement/hci0) 
WARN[0000] Advertisment limit of 31 bytes may have been exceeded. Consider not exposing all services IDs with `CreateService(props, false)` 
error time=1552893110.036474 sender=org.freedesktop.DBus -> destination=:1.0 error_name=org.freedesktop.DBus.Error.ServiceUnknown reply_serial=491
   string "The name :1.16 was not provided by any .service files"
error time=1552893110.044188 sender=:1.16 -> destination=:1.0 error_name=org.freedesktop.DBus.Error.UnknownInterface reply_serial=492
   string "Object does not implement the interface"
error time=1552893110.073839 sender=:1.16 -> destination=:1.0 error_name=org.freedesktop.DBus.Error.UnknownMethod reply_serial=494
   string "Unknown / invalid method"
error time=1552893110.074099 sender=org.freedesktop.DBus -> destination=:1.16 error_name=org.freedesktop.DBus.Error.AccessDenied reply_serial=17
   string "Rejected send message, 1 matched rules; type="error", sender=":1.16" (uid=0 pid=498 comm="./service ") interface="(unset)" member="(unset)" error name="org.freedesktop.DBus.Error.UnknownMethod" requested_reply="0" destination=":1.0" (uid=0 pid=317 comm="/usr/libexec/bluetooth/bluetoothd ")"
INFO[0000] Application registered and advertising.

from go-bluetooth.

muka avatar muka commented on July 29, 2024

Seems an issue in the configuration of the system / yocto build.

To recap, your user is root (matching user=root policy) and your exposed service map in dbus to go.bluetooth.

In the code you could try to play with the object name / object path
https://github.com/the-lightning-land/sweetd/pull/14/files#diff-2650556a5ae8d1b4833240d0c10b6238R15

and ensure they match with the one in your config eg.

     <allow own="go.bluetooth"/> 
        <allow own_prefix="go.bluetooth"/>

Nice project the blockchain based candy dispenser, I want one of them! πŸ‘

from go-bluetooth.

davidknezic avatar davidknezic commented on July 29, 2024

In the code you could try to play with the object name / object path

That's a good suggestion, I will try to adjust the object name / object path and see if the policies match.

I find it very hard to find information regarding the dbus gatt API and how to use it to expose BLE services.

Is there anything I have to keep in mind when selecting objectName and objectPath? In the example the objectName is set to org.bluez, is that mandatory? Also the objectPath in the example is set to /go_bluetooth/example/service. Does that map to the <allow own="go.bluetooth"/> in some way?

I really appreciate your help @muka πŸ™Œ

Nice project the blockchain based candy dispenser

Thank you!

I want one of them! πŸ‘

I think we can make that happen ☺️

from go-bluetooth.

davidknezic avatar davidknezic commented on July 29, 2024

Hi @muka, just wanted to update you that I wasn't able to identify the problem so far. That's why I've tried downgrading the bluez5 package to 5.47. With that everything works very well.

I hope I'll have time again to investigate what changes between 5.47 and 5.50 there were that caused my problems, it won't be a huge priority though.

If someone stumbles over this issue and has had experience with go-bluetooth and bluez 5.50, it would be interesting to learn how it went!

from go-bluetooth.

muka avatar muka commented on July 29, 2024

from go-bluetooth.

muka avatar muka commented on July 29, 2024

Hi, after upgrading to ubuntu 19.04 I was having the same issue on 5.50.

To overcome I updated go deps (just updated in master) and added back the links for dbus configurations (as described in README)

I am closing the issue, please reopen if needed

Thank you

from go-bluetooth.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.