BlueZ d-bus issue registering a BLE peripheral

Hi - in the past, before I used Resin, I wrote some Bluetooth Low Energy Peripheral code for the Raspberry Pi using a library from Github called bluezero which is basically a wrapper around the BlueZ dbus stuff.

It worked well and I’d like to re-use it in my Resin container but I am having some trouble getting it running.

In case its important, I am also using dbus to communicate with NetworkManager, so I have the following in my dockerfile:

ENV DBUS_SYSTEM_BUS_ADDRESS=unix:path=/host/run/dbus/system_bus_socket

In order for the library to work, a peripheral application needs to be registered on the d-bus using the bus name of ukBaz.bluezero. (From what I understand, this is required by any application wishing to create a peripheral using BLE).

The library provides ukBaz.bluezero.conf to do this and it needs to be copied to /etc/dbus-1/system.d/..

<?xml version="1.0" encoding="UTF-8"?> <!-- -*- XML -*- -->
<!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 context="default">
    <allow own="ukBaz.bluezero"/>
    <allow send_destination="ukBaz.bluezero"
           send_interface="org.freedesktop.DBus.Introspectable"/>
    <allow send_type="method_call" log="true"/>
  </policy>
</busconfig>

I tried this in the container and when running I get the following error:

dbus.exceptions.DBusException: org.freedesktop.DBus.Error.AccessDenied: Connection ":1.17" is not allowed to own the service "ukBaz.bluezero" due to security policies in the configuration file

Does anyone know how I make this work?

1 Like

My guess here is that I actually probably need this in the host os as I my d-bus is set to communicate with the host os… is it possible to do that as it is a read-only filesystem?

1 Like