Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bleak/backends/bluezdbus/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
from .characteristic import BleakGATTCharacteristicBlueZDBus
from .manager import get_global_bluez_manager
from .scanner import BleakScannerBlueZDBus
from .utils import assert_reply, get_dbus_authenticator
from .utils import assert_reply, get_dbus_authenticator, should_negotiate_unix_fd
from .version import BlueZFeatures

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -144,7 +144,7 @@ async def connect(self, dangerous_use_bleak_cache: bool = False, **kwargs) -> bo
# BlueZ quirk where notifications are automatically enabled on reconnect.
self._bus = await MessageBus(
bus_type=BusType.SYSTEM,
negotiate_unix_fd=True,
negotiate_unix_fd=should_negotiate_unix_fd(),
auth=get_dbus_authenticator(),
).connect()

Expand Down
11 changes: 10 additions & 1 deletion bleak/backends/bluezdbus/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import os
import re

from dbus_fast.auth import AuthExternal
from dbus_fast.auth import AuthExternal, AuthAnnonymous
from dbus_fast.constants import MessageType
from dbus_fast.message import Message

Expand Down Expand Up @@ -57,5 +57,14 @@ def get_dbus_authenticator():
auth = None
if uid is not None:
auth = AuthExternal(uid=uid)

if 'tcp' in os.environ.get('DBUS_SYSTEM_BUS_ADDRESS', None):
auth=AuthAnnonymous()

return auth

def should_negotiate_unix_fd():
if 'tcp' in os.environ.get('DBUS_SYSTEM_BUS_ADDRESS', None):
return False
else:
return True