5digits / dactyl

Pentadactyl and other related Gecko extensions
Other
470 stars 98 forks source link

Document how to disable XPI signing in Firefox 49+ #183

Open alphapapa opened 8 years ago

alphapapa commented 8 years ago

Note: Definitive info from this issue is being added to this wiki page.

I just built Firefox 49 on Ubuntu 14.04 Trusty, switching from Gtk3 back to Gtk2 (because there's no Gtk3 version of my Gtk2 theme, QtCurve). Firefox 48 allowed me to install the Pentadactyl XPI I packaged, but Firefox 49 did not. sigh

A bit of googling around led me to this: http://www.ghacks.net/2016/08/14/override-firefox-add-on-signing-requirement/ I followed the instructions, restarted Firefox, and it worked, enabling me to install unsigned XPI extensions without rebuilding Firefox.

I think this should be documented somewhere prominently, as it saves a lot of trouble compared to rebuilding Firefox (until Mozilla kills this avenue, of course...). For posterity, here is a simple version of the instructions for Linux:

try {
    Components.utils.import("resource://gre/modules/addons/XPIProvider.jsm", {})
        .eval("SIGNED_TYPES.clear()");
}
catch(ex) {}
pref("general.config.obscure_value", 0);
pref("general.config.filename", "config.js");

Now you should be able to install unsigned extensions.

If (when?) Mozilla "plugs" this "hole", it should be possible to rebuild Firefox to disable extension signing by doing this:

const SIGNED_TYPES = new Set([
      "webextension",
      "extension",
      "experiment",
  ]);
alphapapa commented 8 years ago

BTW, I tried to post this to the Pentadactyl Google Group, but all I get is, "You do not have permission to access this content. (#554)" I recall getting similar errors when trying to post to the group in the past, a year or two ago. Google Groups appears to be completely useless; we should really move discussion elsewhere.

Thiel commented 8 years ago

Hi,

First thing first, thanks ^^.

For MacOs, the file seems to be placed in /Applications/Firefox.app/Contents/Resources/pref.js /Applications/Firefox.app/Contents/Resources/defaults/pref/config-pref.js

But then I get the error message when I try to install pentadactyl: "Pentadactyl could not be installed because it is not compatible with Firefox 49.0.1.

Did you get the same issue ?

alphapapa commented 8 years ago

@Thiel Where did you get the pentadactyl.xpi file you're trying to install? You need one that was built since the Sep 23 commit that bumped the max version to 49. That's unrelated to extension signing.

Thiel commented 8 years ago

I see, thank you for the info, and sorry for it being un-related to the issue.

mklishevych commented 7 years ago

@Thiel, are you sure about location/names of these files? When I create them, I get the following error message:

Configuration error.
Failed to read the configuration file. Please contact your system administrator.

UPD Looks like I was able to fix it (manually typed above code in the specified files), so now firefox starts, but it doesn't fix the problem, I still cannot activate pentadactyl because of the missing verification. I have firefox 49.0.1. Which version do you guys have?

UPD2 Argh, I've reinstalled the pentadactyl and now it works. God bless you, guys!

nimarb commented 7 years ago

@mklishevych , is that all you did do get it working again? It did not work for me. I also get the same error message:

Configuration Error
Failed to read the configuration file. Please contact your system administrator.

I am running FF 49.0.1 x64 on Windows 7 x64

Which system/version of Firefox are you using or is it reasonable to expect there to be differences between the x86 and x64 versions? Thanks!

alphapapa commented 7 years ago

@likyng What paths did you place the files at? Did you try 1) remove Pentadactyl if it's already installed, 2) quit Firefox, 3) add the files mentioned here, 4) start Firefox, 5) install Pentadactyl?

is it reasonable to expect there to be differences between the x86 and x64 versions?

That shouldn't make any difference.

nimarb commented 7 years ago

@alphapapa 1) I placed the files in C:\Program Files\Mozilla Firefox and C:\Program Files\Mozilla Firefox\defaults\pref. 2)It was a fresh installation of Firefox (only addon which was installed before trying this method was uBlock origin)

and after trying this method the mentioned error popped up upon launching FF and thus I am not able to start it at all (even without any addons installed). When I remove the file in \defaults\pref I can start Firefox again but obviously can only install signed extensions.

alphapapa commented 7 years ago

@likyng I see that those are the paths described in the article I linked, however I wonder if those are actually the correct paths. You might google around and see if there is another directory they should go in, maybe something in an AppData directory, something like that. I'm not sure, because I don't use Windows much; sorry I can't be of more help. Please let us know if you find out so we can add the solution here (and/or on the wiki page).

Thiel commented 7 years ago

In my case I've only tested in MacOS, and since the exact path wasn't specified in the article. I think I've tried to follow the relative path but didn't work, so I've brute-forced until getting something that worked ^^. And posted the result here.

maturanomx commented 7 years ago

screen shot 2016-10-14 at 7 24 23 pm

$ cat /Applications/Firefox.app/Contents/Resources/defaults/pref/config-prefs.js
pref("general.config.obscure_value", 0);
pref("general.config.filename", "config.js");

$ cat /Applications/Firefox.app/Contents/Resources/config.js
try {
    Components.utils.import("resource://gre/modules/addons/XPIProvider.jsm", {})
        .eval("SIGNED_TYPES.clear()")
}
catch(ex) {}

Also I tried with config.js on /Applications/Firefox.app/ and the same result. I can't see what I'm doing wrong 😕

Mac OSX El Capitan (10.11.6) Firefox 49.0.1

cprn commented 7 years ago

Try adding empty lines before and after the pasted content in both files. Make sure you don't have any additional spaces, new line characters, etc., and that you have a comment in the first line of both files. It's needed.

On my new Manjaro installation it was pasting some weird white chars and simply removing them helped with the Failed to read configuration issue.

Still, I can see the changes creating these files made in about:config but can't install unverified add-ons.

Doesn't work with Firefox 49.0.1 and 49.0.2 on Manjaro i3 16.08.

alphapapa commented 7 years ago

@cprn Sorry to hear it doesn't work for you. I wonder if there's something different about the way Ubuntu has the Firefox build configured. If you happen to have the time and inclination, it would be very interesting if you could test Ubuntu in a VM or something and see if this works there. Maybe we could figure out how to adjust the build to make it work on other systems.

@mklishevych Could you tell us what system you're running on, what version and build of the Firefox package you have installed, etc? Since it's working for you, I'd like to compare your system with the ones it isn't working on.

@Thiel Just to clarify, you did get it working on OS X using the paths you mentioned earlier?

cprn commented 7 years ago

@alphapapa Ignore it.

tl;dr: In order to check older version I downgraded to 49.0.1 (the only other one available in Arch repositories without reaching to ALA) and repeated every step. At that point it still didn't work for me so I posted my comment... After upgrading back to 49.0.2, however, Firefox correctly run about:newaddon?id= and so on, installing all unsigned plugins one by one. Unless someone else reports similar issue I'll let myself think it's solved.

alphapapa commented 7 years ago

@cprn Great, glad to hear it works now!

Thiel commented 7 years ago

@cprn thanks for the update ^^.

@alphapapa Sorry I completely missed your previous message. And I just noticed that I made a terrible mistake by writing "pref.js" instead of "config.js" in the first part (sorry guys).

Here is a copy past of what solved my issue:

$ cat /Applications/Firefox.app/Contents/Resources/defaults/pref/test.js
pref("general.config.obscure_value", 0);
pref("general.config.filename", "config.js");
$ cat /Applications/Firefox.app/Contents/Resources/config.js
//
try {
Components.utils.import("resource://gre/modules/addons/XPIProvider.jsm", {})
.eval("SIGNED_TYPES.clear()");
}
catch(ex) {}

@maturano configuration looks correct. So I have no idea it's failing.

haidahaha commented 7 years ago

@Thiel 's method works for me. Don't forget the // before try in config.js

alphapapa commented 7 years ago

@haidahaha You mean that without a // on a line by itself before the try, it doesn't work? And are you also on OS X?

haidahaha commented 7 years ago

@alphapapa yes exactly. I'm on OS X 10.11.3. WIthout a // I got the configuration error like @maturano above

alphapapa commented 7 years ago

@haidahaha Thanks, that's very good info. I'll add it to the wiki page.

Thiel commented 7 years ago

Thanks @haidahaha for figuring that out ^^.

Out of curiosity, does anyone know the reason behind // ?

nimarb commented 7 years ago

@alphapapa the config file from @Thiel (incl. the comment) also works on my windows 7 machine! Thanks a lot!!!!!

insidewhy commented 7 years ago

You can also use the "unbranded" binaries built here: https://archive.mozilla.org/pub/firefox/tinderbox-builds/mozilla-release-linux64-add-on-devel/

On archlinux it's in the AUR.

cprn commented 7 years ago

// is just a comment... It doesn't mean anything but it's needed in the first line for Firefox to parse the file correctly. If it isn't in the first line, it's also possible you've copy&pasted some unprintable character that bugs the interpreter and commenting it solves the issue. Deleting white space will solve it in that case.

alphapapa commented 7 years ago

@ohjames Yeah, here's hoping other Linux distros will also provide builds like that.

@cprn Thanks for pointing that out. That would explain why some people don't have that problem.

hari-rangarajan commented 7 years ago

I got it installed on FF 51 with the techniques noted above and bypassing the max version. The plugin does not seem to load; a stack trace shows up:

1487094198770 addons.xpi WARN Error loading bootstrap.js for

pentadactyl@dactyl.googlecode.com: TypeError: can't convert undefined to object (resource://gre/modules/addons/XPIProvider.jsm -> jar:file:///home/hari/.mozilla/firefox/5sumaxhy.default/extensions/pentadactyl@dactyl.googlecode.com.xpi!/bootstrap.js:20:1) JS Stack trace: @resource://gre/modules/addons/XPIProvider.jsm -> jar:file:///home/hari/.mozilla/firefox/5sumaxhy.default/extensions/pentadactyl@bootstrap.js:20:1 < @XPIProvider.jsm:4796:1 < this.XPIProvider.loadBootstrapScope@XPIProvider.jsm:4796:7 < this.XPIProvider.callBootstrapMethod@XPIProvider.jsm:4875:9 < this.XPIProvider.startup@XPIProvider.jsm:2868:13 < callProvider@AddonManager.jsm:235:12 < _startProvider@AddonManager.jsm:788:5 < AddonManagerInternal.startup@AddonManager.jsm:972:9 < this.AddonManagerPrivate.startup@AddonManager.jsm:3016:5 < amManager.prototype.observe@addonManager.js:71:9 undefined: bootstrap: startup startup 1487094198772 addons.xpi WARN Exception running bootstrap method startup on pentadactyl@dactyl.googlecode.com: ReferenceError: can't access lexical declaration `initialized' before initialization (resource://gre/modules/addons/XPIProvider.jsm -> jar:file:///home/hari/.mozilla/firefox/5sumaxhy.default/extensions/pentadactyl@dactyl.googlecode.com.xpi!/bootstrap.js:361:9) JS Stack trace: startup@resource://gre/modules/addons/XPIProvider.jsm -> jar:file:///home/hari/.mozilla/firefox/5sumaxhy.default/extensions/pentadactyl@bootstrap.js:361:9 < this.XPIProvider.callBootstrapMethod@XPIProvider.jsm:4944:9 < this.XPIProvider.startup@XPIProvider.jsm:2868:13 < callProvider@AddonManager.jsm:235:12 < _startProvider@AddonManager.jsm:788:5 < AddonManagerInternal.startup@AddonManager.jsm:972:9 < this.AddonManagerPrivate.startup@AddonManager.jsm:3016:5 < amManager.prototype.observe@addonManager.js:71:9

alphapapa commented 7 years ago

@hari-rangarajan That would be a different problem that should be discussed in a separate issue. This is only for discussing how to work around XPI signing.

uBlock-magic commented 7 years ago

Any Idea how to install addons with label Compatible with Firefox 57+? For example:

alphapapa commented 7 years ago

@uBlock-magic This is only for discussing how to work around XPI signing for Pentadactyl, not a general extension support forum.

ghost commented 6 years ago

Any Idea how to install addons with label Compatible with Firefox 57+? For example:

ColorZilla Disconnect Evernote Web Clipper Tab Auto Refresh

Script die in Firefox 51+, install no problem :+1:

CoolCmd commented 6 years ago

@cprn

// is just a comment... if you need it in order for this workaround to work, it means you've copy&pasted some unprintable character that bugs the interpreter and commenting it solves the issue. Deleting white space will solve it as well.

No. Comment is needed because Firefox ignores the first line of this file. See MDN.

cprn commented 6 years ago

@CoolCmd Thanks, you're right. @alphapapa Can you update the first post so it would include comments in first line of both config.js and config-prefs.js?