Clients of the WebExtensions portal see the FDs as closed when the portal is used for the first time

Bug #1982340 reported by Olivier Tilloy
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
xdg-desktop-portal (Ubuntu)
Fix Released
High
Olivier Tilloy
Jammy
Fix Released
High
Olivier Tilloy

Bug Description

[Impact]

 * Without this patch, the WebExtensions portal won't allow native connectors to communicate with a browser the first time they are spawned by the portal. Closing and restarting the browser won't do, only killing the portal and letting it restart.

 * This patch is being backported to jammy as this is currently the primary target for the effort of enabling native messaging in the firefox snap (not widely available yet, but the portal is available in jammy, and once the firefox implementation lands in the snap, we want this to work seamlessly).

 * The patch is trivial, it adds a missing variable initialization, which fixes the problem.

[Test Plan]

 * Steps to reproduce the bug:
   - in a fully up-to-date jammy VM, install the chrome-gnome-shell package, and download and side-load the latest test snap from https://launchpad.net/~osomon/+snap/firefox-native-messaging (because the firefox implementation hasn't landed upstream yet)
   - if it exists, delete ~/.local/share/flatpak/db/webextensions and reboot to ensure a pristine state
   - run the firefox snap, browse to https://addons.mozilla.org/firefox/addon/gnome-shell-integration/, and click the "Add to Firefox" blue button
   - accept the firefox prompt to install the extension
   - you will soon be prompted by GNOME Shell (with a modal dialog) to allow firefox to use the WebExtensions portal to start the native connector, click "Allow"
   - browse to https://extensions.gnome.org/local/
   - without the patch, you'll get a message that "an unexpected error occurred"
   - with the patch, firefox is able to talk to the native connector and displays a page with the currently installed GNOME Shell extensions

 * Note that this can also be tested with another extension that uses native messaging to talk to a native connector on the system, e.g. https://github.com/keepassxreboot/keepassxc-browser

[Where problems could occur]

 * The patch is trivial and it's hard to imagine that initializing an uninitialized variable could have undesirable side effects.

 * In any case, the WebExtensions portal isn't currently used by any piece of software (this is being tested for firefox but isn't merged and therefore not widely available yet), so possible side effects wouldn't be noticed until the native messaging portal support lands in the firefox snap (see https://phabricator.services.mozilla.com/D140803).

[Other Info]

 * We are still hoping to get the native messaging portal support in the firefox snap in time for Ubuntu 22.04.1, so for it to be a seamless experience this patch needs to land for the .1 release too.

[Original Description]

(this was initially reported here: https://github.com/flatpak/xdg-desktop-portal/pull/705#issuecomment-1123392120)

When testing the WebExtensions portal against the only known client so far (firefox snap + the corresponding upstream patch https://phabricator.services.mozilla.com/D140803), I'm consistently seeing the following problem: the first time the user is prompted for authorization and accepts, the portal will spawn the native connector and pass the file descriptors to the client (firefox snap), but the client sees the file descriptors as closed. Closing the client and re-opening it doesn't help. Only when the portal is terminated and restarted does communication through FDs start working normally.

It turns out this is caused by a missing variable initialization, which is trivially fixed by https://github.com/jhenstridge/xdg-desktop-portal/pull/2.

ProblemType: Bug
DistroRelease: Ubuntu 22.04
Package: xdg-desktop-portal 1.14.4-1ubuntu1~22.04.1
ProcVersionSignature: Ubuntu 5.15.0-41.44-generic 5.15.39
Uname: Linux 5.15.0-41-generic x86_64
NonfreeKernelModules: zfs zunicode zcommon znvpair zavl icp
ApportVersion: 2.20.11-0ubuntu82.1
Architecture: amd64
CasperMD5CheckResult: unknown
CurrentDesktop: ubuntu:GNOME
Date: Wed Jul 20 14:03:15 2022
InstallationDate: Installed on 2020-09-16 (671 days ago)
InstallationMedia: Ubuntu 20.10 "Groovy Gorilla" - Alpha amd64 (20200910)
SourcePackage: xdg-desktop-portal
UpgradeStatus: Upgraded to jammy on 2022-03-19 (122 days ago)

Revision history for this message
Olivier Tilloy (osomon) wrote :
Olivier Tilloy (osomon)
Changed in xdg-desktop-portal (Ubuntu):
assignee: nobody → Olivier Tilloy (osomon)
importance: Undecided → High
status: New → In Progress
Changed in xdg-desktop-portal (Ubuntu Jammy):
assignee: nobody → Olivier Tilloy (osomon)
importance: Undecided → High
milestone: none → ubuntu-22.04.1
status: New → In Progress
Olivier Tilloy (osomon)
description: updated
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package xdg-desktop-portal - 1.14.4-1ubuntu2

---------------
xdg-desktop-portal (1.14.4-1ubuntu2) kinetic; urgency=medium

  * Update the native messaging portal patch to pick up a new commit
    (LP: #1982340)
    - debian/patches/webextensions-portal.patch

 -- Olivier Tilloy <email address hidden> Wed, 20 Jul 2022 14:16:21 +0200

Changed in xdg-desktop-portal (Ubuntu):
status: In Progress → Fix Released
Revision history for this message
Robie Basak (racb) wrote : Please test proposed package

Hello Olivier, or anyone else affected,

Accepted xdg-desktop-portal into jammy-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/xdg-desktop-portal/1.14.4-1ubuntu2~22.04.1 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, what testing has been performed on the package and change the tag from verification-needed-jammy to verification-done-jammy. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-jammy. In either case, without details of your testing we will not be able to proceed.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance for helping!

N.B. The updated package will be released to -updates after the bug(s) fixed by this package have been verified and the package has been in -proposed for a minimum of 7 days.

Changed in xdg-desktop-portal (Ubuntu Jammy):
status: In Progress → Fix Committed
tags: added: verification-needed verification-needed-jammy
Revision history for this message
Olivier Tilloy (osomon) wrote :

Successfully tested xdg-desktop-portal 1.14.4-1ubuntu2~22.04.1 from jammy-proposed using the test plan in the bug description, in a clean and up-to-date jammy amd64 VM.

I first reproduced the problem without the update from jammy-proposed, then installed the updated xdg-desktop-portal and reverted to a pristine state by deleting ~/.local/share/flatpak/db/webextensions and ~/snap/firefox, and rebooting the machine. After enabling the chrome-gnome-shell extension, it worked OOTB without the need to restart the portal.

tags: added: verification-done-jammy
removed: verification-needed-jammy
Revision history for this message
Mateusz Stachowski (stachowski-mateusz) wrote :

I didn't exactly follow the test plan but I can confirm that WebExtensions work in the firefox-native-messaging.

I already had the xdg-desktop-portal from proposed and had Firefox snap from latest/beta channel and that didn't work. I installed that testing snap manually with the --dangerous flag

snap install firefox_103.0b9-1_amd64.snap --dangerous

and when I opened it under GNOME Shell there was the modal dialog. I clicked allow and then opened the local extensions page and I can see all the extensions. Also I can enable or disable them and also change their settings.

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package xdg-desktop-portal - 1.14.4-1ubuntu2~22.04.1

---------------
xdg-desktop-portal (1.14.4-1ubuntu2~22.04.1) jammy; urgency=medium

  * Update the native messaging portal patch to pick up a new commit
    (LP: #1982340)
    - debian/patches/webextensions-portal.patch

 -- Olivier Tilloy <email address hidden> Wed, 20 Jul 2022 14:02:36 +0200

Changed in xdg-desktop-portal (Ubuntu Jammy):
status: Fix Committed → Fix Released
Revision history for this message
Brian Murray (brian-murray) wrote : Update Released

The verification of the Stable Release Update for xdg-desktop-portal has completed successfully and the package is now being released to -updates. Subsequently, the Ubuntu Stable Release Updates Team is being unsubscribed and will not receive messages about this bug report. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regressions.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.