jlesage / docker-firefox

Docker container for Firefox
MIT License
1.42k stars 266 forks source link

Native Messenger extensions not working #166

Open Pilfer opened 1 year ago

Pilfer commented 1 year ago

Hey there! Firstly, thank you for working on this suite of images and containers. They're supremely useful!

I'm working on a browser extension that uses the native messenger API for RPC. The issue is that Firefox can't seem to find the native manifest files or the associated binaries, and returns a no such native application <native app name here> error. Initially I thought it was just my code, but said code works on my own OS X machine, but Ubuntu install, and my Windows machine.

I tested two of your docker-firefox images - the latest alpine and ubuntu. I even tried with a Nightly (firefox-trunk) build on the latter, but I still received the same error. I installed, built, and configured two other native extensions within the container (just alpine this time), and they produced the same error as well.

I'm thinking it's either a path or permission error, since the same Firefox versions work on my own machines but not in the docker container. I've tried changing the export HOME=/config to /root/.mozilla (while running as root), as well as configuring a native manifest JSON file in every single path associated with any known Firefox and/or Nightly install.

Snap/Flatpak installations of Firefox have been prone to sandboxing issues that effectively killed native extensions on them for awhile. I'm not super familiar with Alpine, but maybe this is a familiar culprit.

The extensions I tested were:

Have you run into this issue before, or do you have any idea what the potential cause could be?

I can provide a basic kitchen sink application if you're interested in digging into this!

Thanks!

jlesage commented 1 year ago

If I understand correctly, the native messenger API is used as a communication mechanism between the browser and and application outside the browser. I guess that in your case this application is also running inside the container ?

Pilfer commented 1 year ago

If I understand correctly, the native messenger API is used as a communication mechanism between the browser and and application outside the browser. I guess that in your case this application is also running inside the container ?

That is correct, yes. Although Firefox spawns the native application so it isn’t already running (communication is done via stdin and stdout). Extension sends bytes to the stdin of the native app (which can be a binary or script), and the native app responds with bytes in a similar uleb-esque/c string format (length byte, then data).

I’ve since rebuilt my native code as a gRPC service that runs in the container itself, so this issue isn’t pressing anymore. It may bite someone who tries to install an extension with a native component though.

jlesage commented 1 year ago

Was the the native binary you were using compiled with musl ?

Pilfer commented 1 year ago

Was the the native binary you were using compiled with musl ?

It was a Go binary, compiled within the container. I confirmed it was functional by running it myself with a test script + byte payload, which then logged to the local FS. That test was successful.