igo95862 / bubblejail

Bubblewrap based sandboxing for desktop applications
228 stars 16 forks source link

Librewolf support #107

Open boredsquirrel opened 1 month ago

boredsquirrel commented 1 month ago

Description

I am trying to get Librewolf RPM to work.

Created the instance using bubblejail create Librewolf --profile firefox_wayland --no-desktop-entry

Then edited it in the GUI, here is the services.toml

[common]
executable_name = "/usr/share/librewolf/librewolf"
share_local_time = true
filter_disk_sync = false
dbus_name = "librewolf"

[wayland]

[network]

[home_share]
home_paths = [
    "Downloads",
]

[direct_rendering]
enable_aco = false

[root_share]
paths = []
read_only_paths = [
    "/usr/share/librewolf",
]

[notify]

[pipewire]

I always get

bubblejail run --debug-log-dbus Librewolf /usr/share/librewolf/librewolf                                                                                        ✘ 1
Instance already running.
Sending command to the instance:  ['/usr/share/librewolf/librewolf']
Traceback (most recent call last):
  File "/usr/bin/bubblejail", line 32, in <module>
    bubblejail_main()
  File "/usr/lib64/bubblejail/python_packages/bubblejail/bubblejail_cli.py", line 243, in bubblejail_main
    func(**args_dict)
  File "/usr/lib64/bubblejail/python_packages/bubblejail/bubblejail_cli.py", line 94, in run_bjail
    command_return_text = async_run(
                          ^^^^^^^^^^
  File "/usr/lib64/python3.12/asyncio/runners.py", line 194, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.12/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.12/asyncio/base_events.py", line 687, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/usr/lib64/bubblejail/python_packages/bubblejail/bubblejail_instance.py", line 166, in send_run_rpc
    (reader, writer) = await open_unix_connection(
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.12/asyncio/streams.py", line 97, in open_unix_connection
    transport, _ = await loop.create_unix_connection(
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.12/asyncio/unix_events.py", line 261, in create_unix_connection
    await self.sock_connect(sock, path)
  File "/usr/lib64/python3.12/asyncio/selector_events.py", line 651, in sock_connect
    return await fut
           ^^^^^^^^^
  File "/usr/lib64/python3.12/asyncio/selector_events.py", line 659, in _sock_connect
    sock.connect(address)
ConnectionRefusedError: [Errno 111] Connection refused
igo95862 commented 1 month ago

Hello @boredsquirrel

It looks like your bubblejail instance did not clean-up properly.

You need to manually delete the /run/user/<user_id>/bubblejail/<instance_name> directory.

Most likely this is caused by #100 which was fixed in development version.

boredsquirrel commented 1 month ago

Thanks for the heads up! After a reboot there is no such directory, trying it again I have an issue getting the right dbus name, so the entry is wrong, which might be the issue.

bubblejail run --debug-log-dbus Librewolf /usr/share/librewolf/librewolf      master ◼
'librewolf' is not a valid dbus name
Traceback (most recent call last):
  File "/usr/lib64/python3.12/asyncio/tasks.py", line 520, in wait_for
    return await fut
           ^^^^^^^^^
asyncio.exceptions.CancelledError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/bin/bubblejail", line 32, in <module>
    bubblejail_main()
  File "/usr/lib64/bubblejail/python_packages/bubblejail/bubblejail_cli.py", line 243, in bubblejail_main
    func(**args_dict)
  File "/usr/lib64/bubblejail/python_packages/bubblejail/bubblejail_cli.py", line 111, in run_bjail
    async_run(
  File "/usr/lib64/python3.12/asyncio/runners.py", line 194, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.12/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.12/asyncio/base_events.py", line 687, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/usr/lib64/bubblejail/python_packages/bubblejail/bubblejail_instance.py", line 240, in async_run_init
    async with runner:
  File "/usr/lib64/bubblejail/python_packages/bubblejail/bubblejail_runner.py", line 440, in __aenter__
    await self.setup_dbus_proxy()
  File "/usr/lib64/bubblejail/python_packages/bubblejail/bubblejail_runner.py", line 348, in setup_dbus_proxy
    await wait_for(dbus_proxy_ready_future, timeout=1)
  File "/usr/lib64/python3.12/asyncio/tasks.py", line 519, in wait_for
    async with timeouts.timeout(timeout):
  File "/usr/lib64/python3.12/asyncio/timeouts.py", line 115, in __aexit__
    raise TimeoutError from exc_val
TimeoutError

Do you know how to get the dbus name of an application? I wasnt able to find that online, at least without learning dbus.

This would be useful to document too, for people creating new profiles

igo95862 commented 1 month ago

You can run it outside the sandbox and then use D-Spy to see which D-Bus service name it acquired.

Or just look at the flatpak manifest: https://github.com/flathub/io.gitlab.librewolf-community/blob/1698afc9b77a5ef98403a4979990db196c358125/io.gitlab.librewolf-community.json#L35

Looks like Librewolf uses the io.gitlab.librewolf.* D-Bus service names. This means setting should be dbus_name = "io.gitlab.librewolf.*".

igo95862 commented 1 month ago

The fact that different applications require owning different D-Bus service names kind of undermines the #106 idea.

This is something that my forwarding D-Bus proxy can address there each instance will have a separate D-Bus with bridges to main D-Bus session: https://github.com/igo95862/dbus-forwarding-proxy

boredsquirrel commented 1 month ago

thanks for the tips! I will try d-spy, layering it currently.

Meanwhile, I stopped using Librewolf as the RPM is broken, but I will try to create profiles for other apps.