Call for testing: native messaging support in the Firefox snap

Alright, this is a bit embarrassing… I even tried to grep through my home folder and /etc for DBUS_SESSION_BUS_ADDRESS, but couldn’t find anything relevant for some reason. Until now when I happened to check the .desktop entry for my terminal application (in ~/.local/share/applications)…

Exec=env DBUS_SESSION_BUS_ADDRESS='' terminator

No recollection of where this comes from, but it has probably been there for 5-10 to years and been retained through backups.

1 Like

I was able to enable native-messaging with my app with the flatpak command to set the permission.

As I want to add the permission without installing flatpak, I’m exploring the DBus route (with org.freedesktop.impl.portal.PermissionStore) but I must restart the user session the be able to activate the permission.

Does anyone know how to refresh the PermissionStore without a session reset?

Yeah this is quite tricky. I can get native messaging starting from krunner only with sh -c 'firefox'. Running firefox or snap run firefox from it’s integrated terminal doesn’t work.

The PermissionStore API is meant for use by portals exclusively, I think. It makes sense that portals aren’t watching for changes in the permission database, because they expect to be the only ones writing there.

1 Like

This sounds like krunner isn’t spawning the portal with the right environment? Could it be a bug in krunner itself?

1 Like

Long awaited update: native messaging support is now available in the stable channel.

If you find issues with the functionality, feel free to either report them here, or file a bug.

Thanks to everyone who helped along the way to get here, the testing and feedback has been very valuable.

15 Likes

this is amazing. Could you include the new canonical way to make KeepassXC (snap or deb) and Firefox (snap) work together?

All you need to do is use keepassxc normally. Just check the box to enable Firefox support and everything will work. For snap deployments we are updating the Helper script now. Thank you @oSoMoN

Long awaited update: native messaging support is now available in the stable channel.

If you find issues with the functionality, feel free to either report them here, or file a bug .

Is this supposed to work out of the box? I have Firefox 106.0.5-1 from latest/stable, my gnome shell integration extension is enabled in about:addons, but https://extensions.gnome.org says something about connector API v6 not being available.

That’s a harmless warning. The extension should be able to talk to the connector regardless, and list your locally installed extensions. Does it?

4 Likes

It does, actually! Neat.

3 Likes

This seems to work with extensions.gnome.org for me, but 1Password and open_with don’t seem to be able to talk to their native apps.

I managed to capture logs from Firefox startup, if that helps

[Parent 12521: Main Thread]: D/NativeMessagingPortal creating session with handle suffix firefox_open_with_540547117
[Parent 12521: Main Thread]: D/NativeMessagingPortal session created with handle /org/freedesktop/portal/desktop/session/1_242/firefox_open_with_540547117
[Parent 12521: Main Thread]: D/NativeMessagingPortal starting open_with, requested by openwith@darktrojan.net in session /org/freedesktop/portal/desktop/session/1_242/firefox_open_with_540547117
[Parent 12521: Main Thread]: D/NativeMessagingPortal native application start requested in session /org/freedesktop/portal/desktop/session/1_242/firefox_open_with_540547117, pending response for /org/freedesktop/portal/desktop/request/1_242/firefox/260106597
[Parent 12521: Main Thread]: D/NativeMessagingPortal got response signal for /org/freedesktop/portal/desktop/request/1_242/firefox/260106597 in session /org/freedesktop/portal/desktop/session/1_242/firefox_open_with_540547117
[Parent 12521: Main Thread]: D/NativeMessagingPortal native application start successful in session /org/freedesktop/portal/desktop/session/1_242/firefox_open_with_540547117, requesting file descriptors
[Parent 12521: Main Thread]: D/NativeMessagingPortal got file descriptors for native application in session /org/freedesktop/portal/desktop/session/1_242/firefox_open_with_540547117: (192, 207, 208)
[Parent 12521: Main Thread]: D/NativeMessagingPortal session /org/freedesktop/portal/desktop/session/1_242/firefox_open_with_540547117 was closed by the portal
[Parent 12521: Main Thread]: D/NativeMessagingPortal cannot close session /org/freedesktop/portal/desktop/session/1_242/firefox_open_with_540547117, unknown handle
[Parent 12521: Main Thread]: D/NativeMessagingPortal will be used
[Parent 12521: Main Thread]: D/NativeMessagingPortal is available
[Parent 12521: Main Thread]: D/NativeMessagingPortal creating session with handle suffix firefox_com_1password_1password_60275599
[Parent 12521: Main Thread]: D/NativeMessagingPortal session created with handle /org/freedesktop/portal/desktop/session/1_242/firefox_com_1password_1password_60275599
[Parent 12521: Main Thread]: D/NativeMessagingPortal starting com.1password.1password, requested by {d634138d-c276-4fc8-924b-40a0ea21d284} in session /org/freedesktop/portal/desktop/session/1_242/firefox_com_1password_1password_60275599
[Parent 12521: Main Thread]: D/NativeMessagingPortal native application start requested in session /org/freedesktop/portal/desktop/session/1_242/firefox_com_1password_1password_60275599, pending response for /org/freedesktop/portal/desktop/request/1_242/firefox/1460337894
[Parent 12521: Main Thread]: D/NativeMessagingPortal got response signal for /org/freedesktop/portal/desktop/request/1_242/firefox/1460337894 in session /org/freedesktop/portal/desktop/session/1_242/firefox_com_1password_1password_60275599
[Parent 12521: Main Thread]: D/NativeMessagingPortal native application start canceled by user in session /org/freedesktop/portal/desktop/session/1_242/firefox_com_1password_1password_60275599
[Parent 12521: Main Thread]: D/NativeMessagingPortal session /org/freedesktop/portal/desktop/session/1_242/firefox_com_1password_1password_60275599 was closed by the portal
[Parent 12521: Main Thread]: D/NativeMessagingPortal cannot close session /org/freedesktop/portal/desktop/session/1_242/firefox_com_1password_1password_60275599, unknown handle
[Parent 12521: Main Thread]: D/NativeMessagingPortal will be used
[Parent 12521: Main Thread]: D/NativeMessagingPortal is available

I have the same problem. The 1Password Firefox extension is not able to communicate with the desktop app (snap version or the one installed via the official PPA). Everything is up-to-date.

I have the latest firefox stable snap and the latest keepassxc stable snap, as well as the keepassxc browser extension in my firefox installed. However, “key exchange is not successful” and in the keepassxc browser extension settings I also don’t see the keepassxc version so I assume it’s not able to talk to it.

I’ve tried running the keepassxc helper script from the keepassxc website, but that tells me that browsers installed as snaps are not supported. What should I do?

Just answer NO when it asks if your browser is installed as snap

Can’t believe I’ve been copy-pasting all this time while I could’ve just lied to a shell script. Thanks a million!

The same result can be achieved with the following DBus call:

qdbus org.freedesktop.impl.portal.PermissionStore /org/freedesktop/impl/portal/PermissionStore org.freedesktop.impl.portal.PermissionStore.SetPermission webextensions true org.keepassxc.keepassxc_browser snap.firefox yes

Hello! I am trying to use the “Progressive Web Apps for Firefox” extension in Firefox on Mantic. It uses native messaging. I have installed it on three different computers, all running Mantic x86_64, all with up-to-date debs and snaps, including Firefox. On two of the computers this extension works just fine, but on the third the native messaging is failing. When I load the development version of the extension as a temporary extension in Firefox, I see that sendNativeMessage is returning an exception with the string An unexpected error occurred and no other explanation for the error.

I created a wrapper script which captures the input and output of the actual native messaging connector executable, installed that wrapper on one of the computers on which the extension is working, and confirmed that the connector is being executed by Firefox, getting expected inputs and generating expected outputs. I installed the same wrapper exactly the same way on the computer where things aren’t working, and it’s never getting called, so whatever is going wrong appears to be inside Firefox.

I looked at the output of snap connections firefox on both one of the computers where it’s working and the computer where it isn’t, and they’re identical.

On the computer where this extension isn’t working, https://extensions.gnome.org/ shows me locally installed extensions, so appears that native messaging is working for at least that extension.

Rebooting the computer where the extension that’s not working didn’t help.

I’ve double-checked that the Firefox snap version is the same on both computers. I also tested the newer beta Firefox release and it didn’t solve the problem.

I’m at a loss to troubleshoot this further. Any advice would be appreciated.

Forgot to mention: the extension works fine in Firefox downloaded from Mozilla, i.e., in the non-snap version.

Did you try the suggestion in the bug linked from the PWA extension’s description page?

https://github.com/filips123/PWAsForFirefox/issues/76#issuecomment-1247300277

I believe the permission set command line tools don’t (didn’t?) exist in snap which is why the recommended fix uses a flatpak command. HOWEVER in order to resolve a printer issue I found I could use the Ubuntu Software utility to adjust permissions, so you might be able to resolve it without installing flatpak on all the affected systems by using Ubuntu Software instead.