-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DBus.Error.AccessDenied - not allowed to own the service "org.bluez.TestService" #60
Comments
Thanks @Jakeler for reporting this! I agree that switching to dubs-next in order to conform to siimilar bleak development is preferable to keep development for clients and servers similar. If you'd like to adjust the code and attempt to implement a switch to dubs-next or python-dbus, go for it. Otherwise, I'll probably get started on this in the next week or so. |
Yeah, I think |
@Jakeler, I made an attempt to switch to dbus-next. See the 60-dbus-next branch. I'm still unsure whether this switch will actually address the issue you came across on permissions though. Let me know if you still see that behavior with this change. Any additions you have on your end are also welcome still. |
Nice, thanks! <!-- Holes must be punched in service configuration files for
name ownership and sending method calls -->
<deny own="*"/>
<!-- ../system.conf have denied everything, so we just punch some holes -->
<policy user="root">
<allow own="org.bluez"/>
... It is actually important for security, so not any unprivileged program can take over names of system services. I found 4 calls to So I tried patching it out, but then I have problems with
Which also makes sense, because sending on the system bus is only allowed to whitelisted destinations. But again I don't understand why this is even done in bless, should the local object (self) not already contain all data? Then these remote calls that basically do introspection on itself could also be removed. PS: A workaround would be to change the system config, adding something like this: <policy user="jake">
<allow own="org.bluez.TestService"/>
<allow send_destination="org.bluez.TestService"/>
</policy> With that I can get it to start up, would not recommend it though, as it should not be required. |
Having this problem on rpi, untill a better solution is available, this workaround is fine for me. Thanks!! Question: I would expect the client to see the service TestService, but my client sees the ble-ADDRESS. |
@Jakeler thanks for that run down. I'm certainly not well versed in D-bus, the current dbus-next implementation was a quick spin up based on experimenting and putting together a bluez advertisement using the command line, so the calls to Security Issue I'll see if I can get the implementation working not he Session bus as opposed to the system bus. Will need to ensure that access to the hardware bluetooth hci adapter on the D-Bus is still accessible with a Self introspection & Virtualization Perhaps keeping all the GATT service and characteristic information off the D-Bus will release the need to place the services on the D-Bus at all (via |
@Jakeler Alright, I think I've got this resolved. The app now exposes all services and characteristics on the primary |
Good news, I will test Monday |
Hi @kevincar With @Jakeler's solution:
/etc/dbus-1/system.d/bluetooth.conf
|
@WouterJD are you able to share your fulll log of that exception? |
The logging (only) provides: INFO:root:clsBleServer.Open() Note that my "main" contains, is that not correct? |
Sorry, I meant if you could show your error trace? Similar to Jakeler's above Also, just to double check, your |
I install with You main the stack trace ... I will remove the try and get it for you |
|
Stack trace now integrated in logging for future issues
|
I saw that you got rid off the most |
I found I had extra permissions in my
I switched this back to deny. However, have you both added your users to be apart of the |
No, I did not add my user to a bluetooth group (on Arch it does not even exist). Also I am running the default config from the bluez package, which directly takes the dbus config from upstream: https://github.com/bluez/bluez/blob/5.63/src/bluetooth.conf Otherwise sending (method calls) are globally denied on the system bus, you can see this in the <deny send_type="method_call"/>
The system config is well commented in general, for example everyone can receive: <!-- All messages may be received by default -->
<allow receive_type="method_call"/>
<allow receive_type="method_return"/> Back to the <policy user="root">
...
<allow send_interface="org.bluez.GattCharacteristic1"/>
... root/bluez is allowed to send to specific interfaces, that explains why this works:
Here bluez was setup as server and a client read/writes a value, bluez forwards the event to the actual application. I hope this explanation helps a bit. dbus is indeed quite confusing, but I can recommend to launch some working programs and watch with The setup from bless is fine I think, just have to figure out why it does not handle the received method calls. |
Apologies for the hiatus. Just removed the remaining request name call. I also found that my permissions issue was related to running bless as an ssh user is different than running it otherwise and fixed that. I can read, write, request, and notify now. If there are no issues remaining with the security here, I'll push this through. |
I can confirm that this fixed the error and runs with default config (without security implications), thank you so much! |
The problem
Bless fails to launch on Linux with the error:
txdbus.error.RemoteError: org.freedesktop.DBus.Error.AccessDenied: Connection ":1.136" is not allowed to own the service "org.bluez.TestService" due to security policies in the configuration file
Not sure if this is an invalid call, or if it actually needs a system config change. In addition I did run it as root one time, but no difference.
Reproduction
Simply run an example script:
server.py
orgattserver.py
.Expected behavior
Working bless on Linux.
Full log
Desktop (please complete the following information):
Additional context
Tried it in addition on Ubuntu 21.10 and got exactly the same error.
It works flawlessly on Windows 10, so my hardware definitely supports it.
Also I see that it is a DBus error, thrown by txdbus. Since bleak switched away from it (see issue here) now to dbus-next, might it make sense to switch here too?
Edit: It works on my system with this code, which uses standard python-dbus.
The text was updated successfully, but these errors were encountered: