Ublock: Issue with adminSettings on FireFox.

Created on 6 Sep 2017  路  24Comments  路  Source: gorhill/uBlock

I am having issues with the adminSettings config option in Firefox. I am trying to disable the uBlock filters - Privacy and EasyPrivacy filters. The string I am using works fine in Chrome (60.0.3112.113, uBlock Origin version 1.14.8) but does not appear to do anything in Firefox.
Chrome:
I have this text in the registry location for policies:
{"selectedFilterLists":["plowe-0","malware-1","malware-0","easylist","ublock-unbreak","ublock-badware","ublock-filters","user-filters"]}

Firefox:
I have this line in my cck2.cfg file:
defaultPref("extensions.ublock0.adminSettings", "{\"selectedFilterLists\":[\"plowe-0\",\"malware-1\",\"malware-0\",\"easylist\",\"ublock-unbreak\",\"ublock-badware\",\"ublock-filters\",\"user-filters\"],\"filterLists\":{\"assets/thirdparties/pgl.yoyo.org/as/serverlist\":{\"off\":false},\"assets/thirdparties/mirror1.malwaredomains.com/files/justdomains\":{\"off\":false},\"assets/thirdparties/www.malwaredomainlist.com/hostslist/hosts.txt\":{\"off\":false},\"assets/thirdparties/easylist-downloads.adblockplus.org/easylist.txt\":{\"off\":false},\"assets/ublock/unbreak.txt\":{\"off\":false},\"assets/ublock/badware.txt\":{\"off\":false},\"assets/ublock/filters.txt\":{\"off\":false},\"assets/user/filters.txt\":{\"off\":false},\"assets/ublock/privacy.txt\":{\"off\":true},\"assets/ublock/experimental.txt\":{\"off\":true},\"assets/thirdparties/easylist-downloads.adblockplus.org/easyprivacy.txt\":{\"off\":true}}}");

I have also tried going to about:config and pasting the string I have in the registry for chrome into the adminSettings preference then restarting the browser.

  • OS/version: Windows 10 1607
  • Browser/version: Firefox ESR 52.3.0
  • uBlock Origin version: 1.14.4

I tested downgrading to uBlock Origin version 1.13.8 (on Firefox) and the settings were properly applied. Did the method of configuration change in the newer version?

Sorry if this has been addressed elsewhere.

browser bug

Most helpful comment

Okay, I've got it working finally!

OS/version: Windows 7 Pro x64 SP1
Browser/version: Firefox 58.0.2 (64-bit)
uBlock Origin version: 1.15.4

First create a json file eg. in:

C:\Program Files\Mozilla Firefox\browser\extensions\[email protected]

with content:

{
 "name": "[email protected]",
 "description": "ignored",
 "type": "storage",
 "data": {
    "adminSettings": "{\"userFilters\":\"www.test.de##script:contains(!de.test.cmsKonfig)\\n\"}"
 }
}

add following reg-key:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Mozilla\ManagedStorage\[email protected]]
@="C:\\Program Files\\Mozilla Firefox\\browser\\extensions\\[email protected]"

and start FireFox

image

So the json file and reg-key, can now easily deployed via AD extensions.

Example files: json+regkey.zip

All 24 comments

uBO is now a webext extension in AMO. This means it no longer fetches its adminSettings value from about:config, it has no knowledge of about:config. The adminSettings value for a webext is supposed to be in browser.storage.managed, but Firefox does not support this API yet: https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/storage.

This is the related bugzilla entry: https://bugzilla.mozilla.org/show_bug.cgi?id=1230802.

Hmm... Alright. So is there no way to set those settings in the new version? Would there be any major issues if we installed 1.13.8 and turned off auto update?

There is no way that I know -- but I am no reference regarding admin stuff. 1.13.8 is just fine, it still is a recent version.

Fyi, somebody posted some sort of custom solution i the bugzilla entry: https://bugzilla.mozilla.org/show_bug.cgi?id=1230802#c13.

Maybe similar issue? 1.14.4 stopped working here, settings are gone, block list is gone. Maybe no blocking at all? 52.3.0 (64-bit) ESR. I try to use older version and disable auto-update.

Edit: 1.13.4 is the last version working here on ESR.

gorhill, I saw that, though it looks like that is something to be implemented in the addon itself?

I have this line in my cck2.cfg file:

Where is that cck2.cfg file? Is it a local file, or is it accessed through some URL?

cck2.cfg is a config file used by the CCK2 wizard for some customization. It's loaded through pref("general.config.filename", "cck2.cfg") in the autoconfig.js. It is included in our package source files for installing Firefox.

So if I understand correctly it's a local file once Firefox is installed? If there was a URL uBO could use to fetch something in a standard way until the storage.managed becomes available, I could implement a workaround. Since it would be a built-in URL, this really would have to be a URL which makes sense for typical deployment of Firefox everywhere. Something like uBO trying to read http://localhost/uBlock0.cfg (assuming localhost is not forbifdden by webext of course).

Yes, once installed, the file exists here: "C:\Program Files (x86)\Mozilla Firefoxcck2.cfg". It is technically a javascript file, not just a text config, I'm not sure if that would cause any issues. We would also be able to include any additional files we need to during the install. (Linking this because it seems possibly related: https://bugzilla.mozilla.org/show_bug.cgi?id=1386427)

the file exists here: "C:\Program Files (x86)\Mozilla Firefoxcck2.cfg". It is technically a javascript file, not just a text config, I'm not sure if that would cause any issues.

uBO can't read that file, webext does not allow to fetch using file:/// URL. This would have to be http:///https://.

Hmm... I did some looking and I might be able to create a login script to modify "C:\Users\\AppData\Roaming\Mozilla\Firefox\Profiles\\browser-extension-data\[email protected]"

I don't think we'd be able to provide the file via http:// without having a local webserver running.

This is definitely not an ideal solution, so if you have any other ideas that would be amazing.

if you have any other ideas

Well your idea of modifying storage.js seems the most sensible. It's a json file, so I suppose it's just a matter of writing a python script to import values.

Update about storage.manged: https://bugzilla.mozilla.org/show_bug.cgi?id=1230802

Also, for anyone else in this situation, I managed to work around it by deploying the extension using a registry key (https://developer.mozilla.org/en-US/Add-ons/Adding_extensions_using_the_Windows_registry) and then wrote a script that runs on first logon to delete any old versions of the extension from the user's profile and to create/overwrite the storage.js in the profile.

If you aren't working with existing profiles, you should just be able to put the storage.js file in \core\defaults\profile\browser-extension-data\[email protected]
to have it be copied over when any new profile is created.

Update, https://blog.mozilla.org/addons/2017/09/28/webextensions-in-firefox-57/:

A basic implementation of chrome.storage.managed has landed. This allows administrators or other applications to configure extensions for users. In Firefox you can place a JSON file in a directory, just like for native messaging. For example, a file called [email protected] could be placed in the appropriate place:

{
 "name": "[email protected]",
 "description": "ignored",
 "type": "storage",
 "data": {
    "colour": "blue!"
 }
}

Then in the [email protected] extension:

 browser.storage.managed.get('colour').then((colour) => {
   console.log(colour);
 });

So for uBO I am totally guessing this would look like:

{
 "name": "[email protected]",
 "description": "ignored",
 "type": "storage",
 "data": {
    "adminSettings": "[settings as JSON-encoded string]"
 }
}

Double-encoding to JSON can be tricky, so this tool should be helpful: http://raymondhill.net/ublock/adminSetting.html.

Hello Gorhill, this sounds great.

In Firefox you can place a JSON file in a directory

Any idea which directory this is?

By the way, whoever succeeds using that basic implementation of storage.managed in Firefox, that would be nice to provide feedback about it in this bugzilla issue:

Please note that bug 1386427 contains a basic implementation of chrome.storage.managed and I've successfully used this to configure extensions. A test of uBlock Origin would be appreciated.

Hello Gorhill, I cant make it work, here the steps I did:

Created a [email protected] file and put it in

C:\Program Files\Mozilla Firefox\browser\extensions

with following content:

{
 "name": "[email protected]",
 "description": "ignored",
 "type": "storage",
 "data": {
    "adminSettings": "{\"userFilters\":\"www.bild.de##script:contains(!de.bild.cmsKonfig)\\n\"}"
 }
}

and added this reg-key:

[HKEY_LOCAL_MACHINE\SOFTWARE\Mozilla\ManagedStorage]
"[email protected]"="C:\\Program Files\\Mozilla Firefox\\browser\\extensions\\[email protected]"

But userFilters is empty, do I miss something?

FF 57.0 b3 x64
uBlock 1.14.10

Best is to provide feedback in the bugzilla issue, I know nothing about administration stuff, and even less about Windows stuff.

I tried your file with Linux and all worked fine here -- using 58.0a1 (2017-10-01) (64-bit).

No luck here, also tried it with the nightly 58.0a1 and reg-keys in HKEY_CURRENT_USER and
HKEY_LOCAL_MACHINE. Maybe this function is not implemented in the windows version yet?

Okay, I've got it working finally!

OS/version: Windows 7 Pro x64 SP1
Browser/version: Firefox 58.0.2 (64-bit)
uBlock Origin version: 1.15.4

First create a json file eg. in:

C:\Program Files\Mozilla Firefox\browser\extensions\[email protected]

with content:

{
 "name": "[email protected]",
 "description": "ignored",
 "type": "storage",
 "data": {
    "adminSettings": "{\"userFilters\":\"www.test.de##script:contains(!de.test.cmsKonfig)\\n\"}"
 }
}

add following reg-key:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Mozilla\ManagedStorage\[email protected]]
@="C:\\Program Files\\Mozilla Firefox\\browser\\extensions\\[email protected]"

and start FireFox

image

So the json file and reg-key, can now easily deployed via AD extensions.

Example files: json+regkey.zip

Maybe close the ticket when your issue is solved?

Was this page helpful?
0 / 5 - 0 ratings