matrix-org / pantalaimon

E2EE aware proxy daemon for matrix clients.
Apache License 2.0
291 stars 41 forks source link

dasbus has different, incompatible interface from dbus-python #177

Open RedChops opened 6 days ago

RedChops commented 6 days ago

After getting pantalaimon set up, attempting to run panctl throws the following error:

$ panctl
Traceback (most recent call last):
  File "/Users/self/Projects/Vendor/pantalaimon/venv/bin/panctl", line 8, in <module>
    sys.exit(main())
             ~~~~^^
  File "/Users/self/Projects/Vendor/pantalaimon/venv/lib/python3.13/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/Users/self/Projects/Vendor/pantalaimon/venv/lib/python3.13/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "/Users/self/Projects/Vendor/pantalaimon/venv/lib/python3.13/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/self/Projects/Vendor/pantalaimon/venv/lib/python3.13/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/Users/self/Projects/Vendor/pantalaimon/venv/lib/python3.13/site-packages/pantalaimon/panctl.py", line 704, in main
    panctl = PanCtl()
  File "<attrs generated init pantalaimon.panctl.PanCtl>", line 2, in __init__
    self.__attrs_post_init__()
    ~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/Users/self/Projects/Vendor/pantalaimon/venv/lib/python3.13/site-packages/pantalaimon/panctl.py", line 408, in __attrs_post_init__
    self.pan_bus = self.bus.get_connection("org.pantalaimon1")
                   ^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'SessionMessageBus' object has no attribute 'get_connection'. Did you mean: 'check_connection'?

I tried to replace get_connection with just connection but then run in to

Traceback (most recent call last):
  File "/Users/self/Projects/Vendor/pantalaimon/venv/bin/panctl", line 8, in <module>
    sys.exit(main())
             ~~~~^^
  File "/Users/self/Projects/Vendor/pantalaimon/venv/lib/python3.13/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/Users/self/Projects/Vendor/pantalaimon/venv/lib/python3.13/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "/Users/self/Projects/Vendor/pantalaimon/venv/lib/python3.13/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/self/Projects/Vendor/pantalaimon/venv/lib/python3.13/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/Users/self/Projects/Vendor/pantalaimon/venv/lib/python3.13/site-packages/pantalaimon/panctl.py", line 704, in main
    panctl = PanCtl()
  File "<attrs generated init pantalaimon.panctl.PanCtl>", line 2, in __init__
    self.__attrs_post_init__()
    ~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/Users/self/Projects/Vendor/pantalaimon/venv/lib/python3.13/site-packages/pantalaimon/panctl.py", line 410, in __attrs_post_init__
    self.ctl = self.pan_bus["org.pantalaimon1.control"]
               ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'DBusConnection' object is not subscriptable

Being completely unfamiliar with dbus, I tried a couple more things to get it running again but I couldn't derive the intention behind this code so I'm not sure what the right dasbus version would be.

My steps to get this set up (on Mac):

  1. Clone repo
  2. python3 -m venv venv
  3. source venv/bin/activate
  4. pip install .
  5. pip install matrix_nio==0.25.2 PyGObject dasbus <- For whatever reason neither PyGObject nor dasbus are installed automatically, I have to install them manually here. I also have to manually upgrade matrix_nio as I mentioned in another ticket
  6. Start pantalaimon, run panctl in another terminal both inside the virtual env
chookity-pokk commented 2 days ago

Sorry for the delayed response. I am looking into this now and am hoping to have a PR out soon. I also updated the README to say that you need to run pip install .[ui] to install the extra packages. Though I also might but add them in with the default packages.

chookity-pokk commented 1 day ago

@RedChops Can you test out #180? It seems to work on my end but I want to make sure that it's working for others.

RedChops commented 1 day ago

@chookity-pokk Ran in to two things while testing:

  1. PyGObject dependency in setup.py is too old, I hit this. Changing the requirement to "PyGObject >= 3.46, < 3.50" fixed it. Basically needed a version of gobject-introspection newer than 4 years
  2. I set up dbus according to the readme, set the environment variables:
echo $DBUS_SESSION_BUS_ADDRESS
unix:path=/private/tmp/com.apple.launchd.jlwg8wqAzH/unix_domain_listener

But then get the error:

panctl> list-servers
Traceback (most recent call last):
  File "/Users/self/Projects/Vendor/pantalaimon/venv/bin/panctl", line 8, in <module>
    sys.exit(main())
             ~~~~^^
  File "/Users/self/Projects/Vendor/pantalaimon/venv/lib/python3.13/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/Users/self/Projects/Vendor/pantalaimon/venv/lib/python3.13/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "/Users/self/Projects/Vendor/pantalaimon/venv/lib/python3.13/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/self/Projects/Vendor/pantalaimon/venv/lib/python3.13/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/Users/self/Projects/Vendor/pantalaimon/venv/lib/python3.13/site-packages/pantalaimon/panctl.py", line 761, in main
    loop.run_until_complete(panctl.loop())
    ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.13/3.13.0_1/Frameworks/Python.framework/Versions/3.13/lib/python3.13/asyncio/base_events.py", line 721, in run_until_complete
    return future.result()
           ~~~~~~~~~~~~~^^
  File "/Users/self/Projects/Vendor/pantalaimon/venv/lib/python3.13/site-packages/pantalaimon/panctl.py", line 648, in loop
    self.list_servers()
    ~~~~~~~~~~~~~~~~~^^
  File "/Users/self/Projects/Vendor/pantalaimon/venv/lib/python3.13/site-packages/pantalaimon/panctl.py", line 566, in list_servers
    servers = self.ctl.ListServers()
  File "/Users/self/Projects/Vendor/pantalaimon/venv/lib/python3.13/site-packages/gi/overrides/Gio.py", line 349, in __call__
    result = self.dbus_proxy.call_sync(self.method_name, arg_variant,
                                       kwargs.get('flags', 0),
                                       kwargs.get('timeout', -1),
                                       None)
gi.repository.GLib.GError: g-dbus-error-quark: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name org.pantalaimon1 was not provided by any .service files (2)

So much closer!