Call for testing: native messaging support in the Firefox snap

That’s an impressive piece of investigation, well done @btasker!

So if I understand correctly, an outdated zoom client was interfering with the portal, making it crash, and that’s the reason why the firefox snap wouldn’t manage to communicate with keepassxc through the WebExtensions portal. Are you using zoom installed as a deb, or the snap?

2 Likes

So if I understand correctly, an outdated zoom client was interfering with the portal, making it crash,

Exactly correct - the crash would only occur when the Keepass extension tried to communicate, I’ve not figured out exactly why as I didn’t fancy delving into Zoom’s inner workings.

Are you using zoom installed as a deb, or the snap?

It’s installed as a .deb - I’ll likely move to the snap now though so it doesn’t end up getting so far out of date again.

KeePassXC is working!!!

I enabled parallel installs via
sudo snap set system experimental.parallel-instances=true

I installed firefox beta in parallel via
sudo snap install --beta --unaliased firefox_beta

I enabled flatpak permissions via
flatpak permission-set webextensions org.keepassxc.keepassxc_browser snap.firefox_beta yes

Started firefox beta via
snap run firefox_beta

And KeePassXC browser extension just worked!

4 Likes

Late reply as I haven’t been using Linux much recently:

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

That command worked for me. KeePassXC now works. Updated output is below:

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

After trying these commands:

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

the extension in firefox still does not work.
I don’t really understand enough about snap except that it keeps causing me difficulties time and time again. I do not know how to proceed. Do I need to wait for updates or should I try migrating my firefox back to a normal version?

The keepassxc-snap-helper.sh script also tells me “Sorry, browsers installed as snaps are not supported at this time”.

Edit - I’ll try this https://www.omgubuntu.co.uk/2022/07/ubuntu-devs-fix-another-frustrating-firefox-snap-flaw
Update: still nope when using firefox beta 106.0b4-1

Edit2:
I never ever get any popup asking me anything. These instructions do not hold: https://www.bentasker.co.uk/posts/blog/general/enabling-nativemessaging-for-keepassxc-on-ubuntus-snap-firefox.html

When I disable all extensions but keepassxc I still get:

[Parent 11301: Main Thread]: D/NativeMessagingPortal will be used
[Parent 11301: Main Thread]: D/NativeMessagingPortal is available
[Parent 11301: Main Thread]: D/NativeMessagingPortal creating session with handle suffix firefox_org_keepassxc_keepassxc_browser_2300902597
[Parent 11301: Main Thread]: D/NativeMessagingPortal session created with handle /org/freedesktop/portal/desktop/session/1_166/firefox_org_keepassxc_keepassxc_browser_2300902597
[Parent 11301: Main Thread]: D/NativeMessagingPortal starting org.keepassxc.keepassxc_browser, requested by keepassxc-browser@keepassxc.org in session /org/freedesktop/portal/desktop/session/1_166/firefox_org_keepassxc_keepassxc_browser_2300902597
[Parent 11301: Main Thread]: D/NativeMessagingPortal native application start requested in session /org/freedesktop/portal/desktop/session/1_166/firefox_org_keepassxc_keepassxc_browser_2300902597, pending response for /org/freedesktop/portal/desktop/request/1_166/firefox/1199416126
[Parent 11301: Main Thread]: D/NativeMessagingPortal got response signal for /org/freedesktop/portal/desktop/request/1_166/firefox/1199416126 in session /org/freedesktop/portal/desktop/session/1_166/firefox_org_keepassxc_keepassxc_browser_2300902597
[Parent 11301: Main Thread]: D/NativeMessagingPortal native application start failed in session /org/freedesktop/portal/desktop/session/1_166/firefox_org_keepassxc_keepassxc_browser_2300902597
[Parent 11301: Main Thread]: D/NativeMessagingPortal session /org/freedesktop/portal/desktop/session/1_166/firefox_org_keepassxc_keepassxc_browser_2300902597 was closed by the portal
[Parent 11301: Main Thread]: D/NativeMessagingPortal cannot close session /org/freedesktop/portal/desktop/session/1_166/firefox_org_keepassxc_keepassxc_browser_2300902597, unknown handle

even when using firefox snap beta.

I even tried manually creating the file snap/firefox/common/.mozilla/native-messaging-hosts/org.keepassxc.keepassxc_browser.json and watching the debug output for the extension, but nothing changes. It doesn’t work… and what really frustrates me about this is how opaque everything is when using snaps… I just can’t figure out where something is failing! :frowning:

Can you please share the output of the following commands?

cat ~/.mozilla/native-messaging-hosts/org.keepassxc.keepassxc_browser.json

and

flatpak permissions webextensions
1 Like

Well, it’s not in .moxilla, but in the snap directory:

$ cat ./snap/firefox/common/.mozilla/native-messaging-hosts/org.keepassxc.keepassxc_browser.json 
{
    "name": "org.keepassxc.keepassxc_browser",
    "description": "KeePassXC integration with native messaging support",
    "path": "/snap/bin/keepassxc.proxy",
    "type": "stdio",
    "allowed_extensions": [
        "keepassxc-browser@keepassxc.org"
    ]
}

and

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

Then that’s what’s wrong: the portal will look for manifests in ~/.mozilla/native-messaging-hosts/ and in /usr/lib/mozilla/native-messaging-hosts/, not under ~/snap/firefox/….

1 Like

ok. thanks. I will try that.
But it is confusing. The file in .mozilla/ is created by the keepassxc-snap-helper.sh script only when you lie and claim that firefox is not installed as a snap.

Edit: still not working. Is it maybe a problem that both firefox and keepassxc are snaps?
Edit 2: restarted everything one more time. now it works.

I just wanted to confirm that I experienced the same behavior in KDE. The KeePassXC browser extension connected when launched from the terminal or from the application menu with Launch Feedback set to No Feedback. When launched from the menu with Bouncing feedback, the KeePassXC browser extension will not connect.

I do not have Zoom installed; perhaps there are other applications that can cause the same issue?

With snap Firefox 106.0b6 and KDE I was able to get tridactyl and plasma-integration working after a reboot. I did more mucking about with flatpak permissions and symlinking ~/.mozilla than was necessary – the key was rebooting

1 Like

finally connector is working i have the compiled connector on my system i used it to install the new version of the connector in opera no more v6 error

I cannot get Firefox as a snap and KeePass from the PPA to work. I guess this :point_down: could be related, but I have no idea how to fix it.

$ flatpak permissions webextensions
error: The given address is empty
[Parent 16163: Main Thread]: D/NativeMessagingPortal NativeMessagingPortal::NativeMessagingPortal()
[Parent 16163: Main Thread]: D/NativeMessagingPortal will be used
[Parent 16163: Main Thread]: D/NativeMessagingPortal NativeMessagingPortal::DelayedCall::DelayedCall()
[Parent 16163: Main Thread]: D/NativeMessagingPortal failed to get a D-Bus proxy: The given address is empty
[Parent 16163, Main Thread] WARNING: OnProxyReady error: The given address is empty: 'glib warning', file /build/firefox/parts/firefox/build/toolkit/xre/nsSigHandlers.cpp:167

** (firefox-beta:16163): WARNING **: 09:49:55.137: OnProxyReady error: The given address is empty
[Parent 16163: Main Thread]: D/NativeMessagingPortal is not available
[Parent 16163: Main Thread]: D/NativeMessagingPortal NativeMessagingPortal::DelayedCall::~DelayedCall()
[Parent 16163: Main Thread]: D/NativeMessagingPortal will be used
[Parent 16163: Main Thread]: D/NativeMessagingPortal is not available

Firefox beta from snap:

$ snap list firefox
Name     Version    Rev   Tracking     Publisher  Notes
firefox  106.0b7-1  1912  latest/beta  mozilla✓   -
$ dpkg -l | grep keepassxc
ii  keepassxc                                                   2.7.1-1ppa1~jammy1                         amd64        KeePass Cross-Platform Community Edition
$ cat ~/.mozilla/native-messaging-hosts/org.keepassxc.keepassxc_browser.json 
{
    "allowed_extensions": [
        "keepassxc-browser@keepassxc.org"
    ],
    "description": "KeePassXC integration with native messaging support",
    "name": "org.keepassxc.keepassxc_browser",
    "path": "/usr/bin/keepassxc-proxy",
    "type": "stdio"
}

Yes, that’s confusing indeed. This is because it is indeed not supported by a stable snap yet. I’m making a note to suggest a change to that script once the support lands in stable.

1 Like

This error is relevant:

Sounds like the portal might not be available? Can you check whether xdg-desktop-portal is installed, and whether there is a process of the same name running?

1 Like

The process seems to be running:

$ ps aux | grep xdg-desktop-portal
slovdahl   14399  0.0  0.0 557844 17012 ?        Ssl  09:49   0:00 /usr/libexec/xdg-desktop-portal
slovdahl   14408  0.0  0.1 1295360 94448 ?       Ssl  09:49   0:05 /usr/libexec/xdg-desktop-portal-gnome
slovdahl   14784  0.0  0.0 348272 26924 ?        Ssl  09:49   0:01 /usr/libexec/xdg-desktop-portal-gtk

Not sure how relevant, but this is an old installation upgraded from Ubuntu 20.04 (and 18.04 before that, and probably 16.04 before that).

Also seeing this in the journal when starting Firefox:

okt 03 15:20:13 desk xdg-desktop-por[13826]: Could not find WebExtensions backend: cannot find native messaging server

And snap.snapd-desktop-integration.snapd-desktop-integration.service fails to start during boot:

okt 03 16:03:41 desk snapd-desktop-integration.snapd-desktop-integration[4620]: Sorry, home directories outside of /home are not currently supported.
okt 03 16:03:41 desk snapd-desktop-integration.snapd-desktop-integration[4620]: See https://forum.snapcraft.io/t/11209 for details.
okt 03 16:03:41 desk systemd[4525]: snap.snapd-desktop-integration.snapd-desktop-integration.service: Main process exited, code=exited, status=1/FAILURE
okt 03 16:03:41 desk systemd[4525]: snap.snapd-desktop-integration.snapd-desktop-integration.service: Failed with result 'exit-code'.

No idea what the error message means, my home directory is not outside /home.

I cannot open URLs with firefox <URL> from the terminal when Firefox is already running either, I wonder if both problems have the same root cause. :thinking:

EDIT: Seems like I’m not completely alone: https://askubuntu.com/questions/1426478/snap-firefox-is-already-running-but-is-not-responding

Now I also got this while starting Firefox, could it be related?

okt 03 19:52:54 desk systemd[5709]: Started snap.firefox.firefox.cf626230-5357-4854-a80d-ea2b7cdda834.scope.
okt 03 19:52:54 desk audit[1304]: USER_AVC pid=1304 uid=106 auid=4294967295 ses=4294967295 subj=? msg='apparmor="DENIED" operation="dbus_method_call"  bus="system" path="/org/freedesktop/DBus" interface="org.freedesktop.DBus" member="ListNames" mask="send" name="org.freedesktop.DBus" pid=17489 label="snap.firefox.firefox" peer_label="unconfined"
                                   exe="/usr/bin/dbus-daemon" sauid=106 hostname=? addr=? terminal=?'
okt 03 19:52:54 desk audit: MAC_TASK_CONTEXTS subj_apparmor=unconfined
okt 03 19:52:54 desk kernel: audit: type=1107 audit(1664815974.938:535): pid=1304 uid=106 auid=4294967295 ses=4294967295 subj=? msg='apparmor="DENIED" operation="dbus_method_call"  bus="system" path="/org/freedesktop/DBus" interface="org.freedesktop.DBus" member="ListNames" mask="send" name="org.freedesktop.DBus" pid=17489 label="snap.firefox.firefox" peer_label="unconfined"
                              exe="/usr/bin/dbus-daemon" sauid=106 hostname=? addr=? terminal=?'
okt 03 19:52:54 desk kernel: audit: type=1420 audit(1664815974.938:536): subj_apparmor=unconfined
okt 03 19:52:55 desk audit[17409]: SECCOMP auid=1000 uid=1000 gid=1000 ses=3 subj=? pid=17409 comm="firefox" exe="/snap/firefox/1912/usr/lib/firefox/firefox" sig=0 arch=c000003e syscall=314 compat=0 ip=0x7f4ad5ad873d code=0x50000
okt 03 19:52:55 desk kernel: audit: type=1326 audit(1664815975.018:537): auid=1000 uid=1000 gid=1000 ses=3 subj=? pid=17409 comm="firefox" exe="/snap/firefox/1912/usr/lib/firefox/firefox" sig=0 arch=c000003e syscall=314 compat=0 ip=0x7f4ad5ad873d code=0x50000
okt 03 19:52:55 desk kernel: audit: type=1107 audit(1664815975.286:540): pid=1304 uid=106 auid=4294967295 ses=4294967295 subj=? msg='apparmor="DENIED" operation="dbus_method_call"  bus="system" path="/org/freedesktop/DBus" interface="org.freedesktop.DBus" member="ListNames" mask="send" name="org.freedesktop.DBus" pid=17409 label="snap.firefox.firefox" peer_label="unconfined"
                              exe="/usr/bin/dbus-daemon" sauid=106 hostname=? addr=? terminal=?'
okt 03 19:52:55 desk kernel: audit: type=1420 audit(1664815975.286:541): subj_apparmor=unconfined
okt 03 19:52:55 desk audit: MAC_TASK_CONTEXTS subj_apparmor=unconfined
okt 03 19:52:55 desk audit[1304]: USER_AVC pid=1304 uid=106 auid=4294967295 ses=4294967295 subj=? msg='apparmor="DENIED" operation="dbus_method_call"  bus="system" path="/org/freedesktop/DBus" interface="org.freedesktop.DBus" member="ListNames" mask="send" name="org.freedesktop.DBus" pid=17409 label="snap.firefox.firefox" peer_label="unconfined"
                                   exe="/usr/bin/dbus-daemon" sauid=106 hostname=? addr=? terminal=?'
okt 03 19:52:55 desk audit: MAC_TASK_CONTEXTS subj_apparmor=unconfined

That at least means that the correct version of the XDG desktop portal is running. But it complains that it cannot find the manifest for a native app that was requested by an extension. It could be that it’s for another manifest that you haven’t installed though, not necessarily for the keepassxc one.

Would you mind filing a separate issue to get this problem investigated?

Can you share details on your desktop environment, whether it’s an X11 or Wayland session, relevant environment variables, etc?

No, it’s normal for a call to the very generic org.freedesktop.DBus.ListNames method to be denied.

1 Like