Call for testing: native messaging support in the Firefox snap

I just tested again the KeepassXC integration in a fully up-to-date 22.04 VM, and I was able to get it to work after following the official instructions for initial connection. In particular, it seems you need to make sure that the native application is running and the database is unlocked when requesting the initial connection from the browser (and you need to explicitly allow the browser extension from the app’s settings).

1 Like

You shouldn’t have needed to copy over any config file. Unless you’re using the KeepassXC snap, which cannot write the manifest to ~/.mozilla/native-messaging-hosts/ ?

Can you share the output of flatpak permissions webextensions ?

1 Like

Does this message help? Are you using KeepassXC installed as a deb or as a snap?

1 Like

Unfortunately, it still does not work here.

I now tested with a fresh Firefox profile and a fresh KeePassXC database, same result.
With MOZ_LOG=NativeMessagingPortal:5 set, the following output is printed:

[Parent 701511: Main Thread]: D/NativeMessagingPortal NativeMessagingPortal::NativeMessagingPortal()
[Parent 701511: Main Thread]: D/NativeMessagingPortal will be used
[Parent 701511: Main Thread]: D/NativeMessagingPortal NativeMessagingPortal::DelayedCall::DelayedCall()
[Parent 701511: Main Thread]: D/NativeMessagingPortal D-Bus proxy ready for name org.freedesktop.portal.Desktop, path /org/freedesktop/portal/desktop, interface org.freedesktop.portal.WebExtensions
[Parent 701511: Main Thread]: D/NativeMessagingPortal is available
[Parent 701511: Main Thread]: D/NativeMessagingPortal NativeMessagingPortal::DelayedCall::~DelayedCall()
[Parent 701511: Main Thread]: D/NativeMessagingPortal creating session with handle suffix firefox_org_keepassxc_keepassxc_browser_2915241622
[Parent 701511: Main Thread]: D/NativeMessagingPortal session created with handle /org/freedesktop/portal/desktop/session/1_2232/firefox_org_keepassxc_keepassxc_browser_2915241622
[Parent 701511: Main Thread]: D/NativeMessagingPortal starting org.keepassxc.keepassxc_browser, requested by keepassxc-browser@keepassxc.org in session /org/freedesktop/portal/desktop/session/1_2232/firefox_org_keepassxc_keepassxc_browser_2915241622
[Parent 701511: Main Thread]: D/NativeMessagingPortal native application start requested in session /org/freedesktop/portal/desktop/session/1_2232/firefox_org_keepassxc_keepassxc_browser_2915241622, pending response for /org/freedesktop/portal/desktop/request/1_2232/firefox/1661947729
[Parent 701511: Main Thread]: D/NativeMessagingPortal got response signal for /org/freedesktop/portal/desktop/request/1_2232/firefox/1661947729 in session /org/freedesktop/portal/desktop/session/1_2232/firefox_org_keepassxc_keepassxc_browser_2915241622
[Parent 701511: Main Thread]: D/NativeMessagingPortal native application start canceled by user in session /org/freedesktop/portal/desktop/session/1_2232/firefox_org_keepassxc_keepassxc_browser_2915241622
[Parent 701511: Main Thread]: D/NativeMessagingPortal session /org/freedesktop/portal/desktop/session/1_2232/firefox_org_keepassxc_keepassxc_browser_2915241622 was closed by the portal
[Parent 701511: Main Thread]: D/NativeMessagingPortal cannot close session /org/freedesktop/portal/desktop/session/1_2232/firefox_org_keepassxc_keepassxc_browser_2915241622, unknown handle

I also made sure that I stopped my regular Firefox before starting the snap Firefox. KeePassXC was running and unlocked before starting Firefox. Browser integration is enabled in KeePassXC (after all, it works fine with my regular Firefox).

Any idea what else I could try? Can I provide more helpful information somehow?

Can you share the output of flatpak permissions webextensions ?

1 Like

Sure:

Table         Object                          App          Permissions Data
webextensions org.keepassxc.keepassxc_browser snap.firefox no          0x00
webextensions org.gnome.chrome_gnome_shell    snap.firefox yes         0x00

It seems the no in the Permissions column is likely a problem, right? How can I change that?

Yes indeed. Try:

flatpak permission-set webextensions org.keepassxc.keepassxc_browser snap.firefox yes
2 Likes

Thanks, now it works fine!

2 Likes

Turns out I was missing flatpak permissions just like the everyone else xD Both extensions are working great now, thanks for the help! I would still be happy to post that output if you’d like it.

(Not really on-topic but I didn’t even know that flatpak was on my system, let alone that it was running those permissions. I just got my head around the differences between snap and apt-get xD)

I am using the KeepassXC snap, yes. Did I mis-assume that this (inter-snap native communication) was supported now? I thought that was the main benefit, as you could have used it all along if either side was not a snap?

Oh yeah, and having installed flatpak, I can’t see KeepassXC in there at all:

$ LANG=C flatpak permissions webextensions
Table         Object                       App          Permissions Data
webextensions org.gnome.chrome_gnome_shell snap.firefox yes         0x00
1 Like

In fact flatpak is not the owner of these permissions, xdg-desktop-portal is. But the flatpak command-line tool is a convenient way to inspect and change them. I guess it would be less confusing if it was an external tool, e.g. something called “xdg-desktop-portal-permissions”.

4 Likes

No, the expectation is correct. The intention is to make it work for both browsers and native host connectors as snaps. In the case of KeepassXC I had to jump through a few hoops to make it work, but I did manage to make it work:

  • make sure the application is running and unlocked
  • make sure the browsers integration checkbox is ticked in the app’s settings
  • download and run the KeePassXC-Browser Helper Script, but tell it that firefox is not installed as a snap, otherwise it will bail out
  • verify that the script installed a manifest for the keepassxc proxy in ~/.mozilla/native-messaging-hosts/, pointing to /snap/bin/keepassxc.proxy
  • restart firefox
2 Likes

Another successful test:

Ubuntu 22.04
FF snap (beta)
KeepassXC snap

Did have to manually install the flatpak with apt, since it was not installed.

Your remark regarding the fact that flatpak was not the owner of the permissions gave the final push :smile:

I just tested the ff2mpv extension and I can confirm that it works as expected. This is in an up-to-date Ubuntu 22.04 VM, with firefox from the beta channel.

1 Like

Ah! So I went ahead of myself and moved the file into ~/snap/, which was the wrong step. Now I’ve moved it back it’s working fine, thanks!

2 Likes

if one has accidentally dismissed the initial “enable native messaging” popup… how do I enable it manually?

You can check the saved permissions with this command:

flatpak permissions webextensions

And then you can change a saved permission with e.g.:

flatpak permission-set webextensions org.keepassxc.keepassxc_browser snap.firefox yes

(replace org.keepassxc.keepassxc_browser with the name of your extension)

1 Like

Here my experience:

I had better results using systemctl --user restart xdg-desktop-portal, instead of killing the process.

On my personal computer it didn’t worked immediately. I use normally KeePassXC (Appimage) and Gnome-Shell-Integration with firefox-esr from mozteam-ppa. I installed Firefox from Snap beta channel and checked xdg-desktop-portal version.

When I installed the extension, I got a request for permission, but neither KeepassXC nor extensions.gnome.org worked in Snap-Firefox.

I could get both running with your command flatpak permission-set … snap.firefox.

With Snap-Firefox KeepassXC-extension can’t connect with Keepassxc from AppImage (2.7.1). Works with KeepassXC 2.6.1 from universe (APT/deb). AppImage-KeepassXC restarted each time I clicked on “Reload” in the extension-popup. I got a “Key exchange error”

snap list firefox:
firefox 104.0b2-1 1624 latest/beta

apt list xdg-desktop-portal:
xdg-desktop-portal/jammy-updates,now 1.14.4-1ubuntu2~22.04.1 amd64

Thanks for the feedback!
I didn’t test with KeePassXC installed as an AppImage, but I did test with the deb and the snap, and both worked. The snap has the same version as the AppImage (2.7.1), so that rules out a version mismatch problem.
Maybe the native manifest installed in ~/.mozilla/native-messaging-hosts/ didn’t point to the right binary?

1 Like

Hi,

I didn’t tried Keepassxc from Snap, because I never used the proxy-script and my intention was to exclude possible unrelated errors.

I use AppImage Keepassxc for a long time with no problems with Firefox from deb, since jammy Firefox-ESR. I downloaded yesterday Firefox as tar.gz, excluded it and test it. No problem with Keepassxc from AppImage. The manifest is correct, points to /home/keywan/.local/bin/keepassxc. I copied the AppImage to my home and tried that, but still doesn’t work.

I installed Keepassxc 2.7.1 from PPA and it worked with Firefox-Snap and Firefox-ESR. Although Keepassxc from Flathub worked without any problem with Firefox ESR or downloaded tar.gz.

Maybe it is a AppImage specific problem?!

Let me know, if I can help and should test anything.