mozilla / policy-templates

Policy Templates for Firefox
Mozilla Public License 2.0
1.15k stars 415 forks source link

ExtensionSettings blocking browser localization #1122

Closed Gabgobie closed 4 months ago

Gabgobie commented 5 months ago

Hi,

I am currently trying to configure Firefox using the /etc/firefox/policies/policies.json but as soon as I have a default rule for the ExtensionSettings section, the browser will loose all localization and lock down to english only. Everything else works as expected.

Broken localization:

        "ExtensionSettings": {
            "langpack-*": {
                "installation_mode": "allowed",
                "allowed_types": [
                    "langpack"
                ]
            },
            "*@dictionaries.addons.mozilla.org": {
                "installation_mode": "allowed",
                "allowed_types": [
                    "dictionary"
                ]
            },
            "*": {
                "blocked_install_message": "\n\nCustom Message Text",
                "install_sources": [
                    "https://addons.mozilla.org/firefox/downloads/latest/*"
                ],
                "installation_mode": "blocked",
                "allowed_types": ["extension", "theme"]
            }
        }

The relevant about:support section:

Internationalization & Localization
-----------------------------------

Application Settings
Requested Locales: ["de-DE"]
Available Locales: ["en-US"]
App Locales: ["en-US"]
Regional Preferences: ["en-US"]
Default Locale: "en-US"
Operating System
System Locales: ["de-DE"]
Regional Preferences: ["de-DE"]

Functional Localization:

        "ExtensionSettings": {
            "langpack-*": {
                "installation_mode": "allowed",
                "allowed_types": [
                    "langpack"
                ]
            },
            "*@dictionaries.addons.mozilla.org": {
                "installation_mode": "allowed",
                "allowed_types": [
                    "dictionary"
                ]
            },
            "*": {
                "blocked_install_message": "\n\nCustom Message Text"
            }
        }

And another version of functional localization:

        "ExtensionSettings": {
          "*": {
            "blocked_install_message": "\n\nCustom Message Text"
          }
        }

The relevant about:support section:

Internationalisierung & Lokalisierung
-------------------------------------

Anwendungseinstellungen
Angeforderte Sprachen: ["de-DE"]
Verfügbare Sprachen: ["ta","te","fy-NL","eo","sl","sv-SE","cak","es-AR","son","el","es-ES","hu","is","an","bs","ca","kn","nl","ru","sq","szl","ach","si","uz","oc","vi","gl","es-CL","gd","ga-IE","az","ko","mr","et","my","pt-BR","en-CA","sco","zh-CN","nb-NO","uk","pt-PT","ro","fa","hi-IN","ia","lv","dsb","gn","hr","fi","de","id","pa-IN","pl","cy","en-GB","eu","tg","th","bg","ar","af","tl","en-US","nn-NO","ur","xh","kab","es-MX","cs","fur","fr","ms","sk","trs","da","lij","hsb","tr","bn","it","sr","km","ja","br","ast","he","kk","lt","zh-TW","sc","gu-IN","be","hy-AM","ka","mk","ff","ne-NP","rm"]
Anwendungssprachen: ["de","en-US"]
Region-Einstellungen: ["de-DE"]
Standardsprache: "en-US"
Betriebssystem
Sprachen des Betriebssystems: ["de-DE"]
Region-Einstellungen: ["de-DE"]

I don't know what I'm doing wrong or if this is a bug. Tried it with Firefox 115.12.0esr on Rockylinux and the most recent flatpak (I think 127, already uninstalled) to make sure it wasn't an issue with my specific version. Any help would be greatly appreciated.

mkaply commented 5 months ago

Addon IDs have to be exact, so none of these things that you've posted will work.

What exactly are you to accomplish?

Block extensions but only allow langpacks?

Gabgobie commented 5 months ago

Hi, thanks for your quick answer. The above state is already me trying to work around the issue. The original configuration was very similar to the example you provide in the repo.

        "ExtensionSettings": {
            "*": {
                "blocked_install_message": "\n\nCustom Error Message",
                "install_sources": [
                    "https://addons.mozilla.org/*"
                ],
                "installation_mode": "blocked",
                "allowed_types": ["extension", "theme"]
            },
            "uBlock0@raymondhill.net": {
                "updates_disabled": false,
                "installation_mode": "force_installed",
                "install_url": "https://addons.mozilla.org/firefox/downloads/latest/ublock-origin/latest.xpi",
                "default_area": "menupanel"
            },
            "jid1-MnnxcxisBPnSXQ@jetpack": {
                "updates_disabled": false,
                "installation_mode": "force_installed",
                "install_url": "https://addons.mozilla.org/firefox/downloads/latest/privacy-badger17/latest.xpi",
                "default_area": "menupanel"
            }
        },

My goal is to install some extensions, allow others (in a later iteration) and block every extension that is not whitelisted, however as soon as the catchall block is present, firefox is reduced to only include the en-US locale.

Application Settings
Requested Locales   ["de-DE"]
Available Locales   ["en-US"]
App Locales     ["en-US"]
Regional Preferences    ["en-US"]
Default Locale  "en-US"
Operating System
System Locales  ["de-DE"]
Regional Preferences    ["de-DE"]

When I remove the catchall block or reduce it to only contain the blocked_install_message, all the locales that are installed by default return.

Anwendungseinstellungen
Angeforderte Sprachen   ["de-DE"]
Verfügbare Sprachen     ["kab","hsb","ms","ka","ro","sr","de","kk","af","tl","es-AR","en-CA","en-US","da","nl","gu-IN","lv","el","fur","be","en-GB","hy-AM","bn","szl","sl","sq","lij","ga-IE","ia","cy","es-MX","eu","ja","mk","my","kn","rm","eo","ru","th","vi","bs","ko","ast","nn-NO","oc","hi-IN","ff","ne-NP","pa-IN","ta","hu","es-CL","bg","ar","es-ES","sc","te","trs","hr","fi","cak","km","pt-BR","cs","pt-PT","si","zh-CN","ach","he","gd","is","az","xh","ca","et","fy-NL","gn","lt","sv-SE","mr","uz","br","dsb","fa","uk","fr","ur","id","tr","zh-TW","pl","nb-NO","tg","an","son","it","sco","sk","gl"]
Anwendungssprachen  ["de","en-US"]
Region-Einstellungen    ["de-DE"]
Standardsprache     "en-US"
Betriebssystem
Sprachen des Betriebssystems    ["de-DE"]
Region-Einstellungen    ["de-DE"]

Thanks again for your help.

Best, Gab

mkaply commented 5 months ago

It's because of this line:

"allowed_types": ["extension", "theme"]

You've blocked langpacks.

I would remove

                "install_sources": [
                    "https://addons.mozilla.org/*"
                ],

and

               "allowed_types": ["extension", "theme"]

and you should be good.

mkaply commented 5 months ago

all the locales that are installed by default return.

I'm unclear why this is a problem?

Are you installing all the langpacks in Firefox?

Gabgobie commented 5 months ago

It's because of this line:

"allowed_types": ["extension", "theme"]

You've blocked langpacks.

I tried with "allowed_types": ["extension", "theme", "dictionary", "locale"], I tried with "allowed_types": [] and I tried without allowed_types. Always the same result. The locales are gone.

I would remove

                "install_sources": [
                    "https://addons.mozilla.org/*"
                ],

and

               "allowed_types": ["extension", "theme"]

and you should be good.

That would leave me with the following catchall block:

            "*": {
                "blocked_install_message": "\n\nCustom Error Message",
                "installation_mode": "blocked"
            }

unfortunately this will still remove all installed locales.

all the locales that are installed by default return.

I'm unclear why this is a problem?

It's not. It's the desired state. I want the locales to be available but they are removed from firefox as soon as my catchall block contains anything besides the blocked_install_message directive.

Are you installing all the langpacks in Firefox?

I'm on Rockylinux 9.4. The locales listed in my above comment are all installed by default and I'd like them to be available.

mkaply commented 4 months ago

Sorry, I missed this response.

You would have to list each locale individually in order to keep them from being uninstalled.

Gabgobie commented 4 months ago

Thanks for your answer.

This is very unfortunate. I was really hoping there was a way to install and restrict extensions without influencing the other plugins -> Disallow extensions without disallowing any locales, themes and dictionaries.

Now I am somewhat confused about the allowed_types though. What are they defining? As soon as the section exists everything that is not explicitly stated below is disallowed so I don't see any point in them if they don't exclude anything categories from the blacklist.

mkaply commented 4 months ago

Actually, maybe we're thinking about this wrong.

What if you remove

          "installation_mode": "blocked",

and change "allowed_types" to

            "allowed_types": ["theme", "langpack", "dictionary"]

What this would do is block all extensions (because we don't have them in allowed_types) but it would still allow ones you specify by ID and allow all your locales.

mkaply commented 4 months ago

allowed_types was copied from Chrome. It's basically "allow users to install themes/langpacks, but no extensions" or something like that.

But I think that if you use it, using installation mode becomes unnecessary.

Gabgobie commented 4 months ago

I'll try that. Brb

Gabgobie commented 4 months ago

That did the trick.

          "installation_mode": "blocked",

seems to block everything. Without it, "allowed_types" works as expected.

Thanks a lot.

mkaply commented 4 months ago

Awesome!