parent
13c0a8de88
commit
3d987b6dae
6 changed files with 460 additions and 0 deletions
@ -0,0 +1,32 @@ |
||||
package : fws-wapt-firefox-config |
||||
version : 1 |
||||
architecture : all |
||||
section : base |
||||
priority : optional |
||||
maintainer : Daniel Berteaud |
||||
description : Configuration management for Firefox |
||||
depends : |
||||
conflicts : |
||||
maturity : DEV |
||||
locale : |
||||
target_os : |
||||
min_os_version : |
||||
max_os_version : |
||||
min_wapt_version : |
||||
sources : |
||||
installed_size : |
||||
impacted_process : |
||||
description_fr : Gestion de configuration pour Firefox |
||||
description_pl : |
||||
description_de : |
||||
description_es : |
||||
audit_schedule : 4w |
||||
editor : |
||||
keywords : |
||||
licence : MIT |
||||
homepage : https://www.firewall-services.com/ |
||||
package_uuid : |
||||
signer : |
||||
signer_fingerprint: |
||||
signature_date : |
||||
signed_attributes : |
@ -0,0 +1,3 @@ |
||||
// Autoconfig
|
||||
pref("general.config.obscure_value", 0); |
||||
pref("general.config.filename", "firefox.cfg"); |
@ -0,0 +1,84 @@ |
||||
// Autoconf |
||||
|
||||
|
||||
|
||||
if(getenv("USER") != "") { |
||||
var user = getenv("USER"); |
||||
} else { |
||||
var env_user = getenv("USERNAME"); |
||||
} |
||||
|
||||
{% if firefox_config_append_domain is defined and firefox_config_append_domain != '' %} |
||||
var mail = env_user + '@{{ firefox_config_append_domain }}'; |
||||
{% else %} |
||||
var mail = env_user; |
||||
{% endif %} |
||||
|
||||
lockPref("mail.identity.useremail", mail); |
||||
lockPref("autoadmin.append_emailaddr", true); |
||||
lockPref("autoadmin.global_config_url", "{{ firefox_config_url }}"); |
||||
lockPref("autoadmin.failover_to_cached", true); |
||||
lockPref("autoadmin.offline_failover", true); |
||||
|
||||
// Javascript to enable the distribution/bundles directory |
||||
|
||||
const {classes: Cc, interfaces: Ci, utils: Cu} = Components; |
||||
|
||||
var gBundlePrefFiles = []; |
||||
|
||||
Cu.import("resource://gre/modules/Services.jsm"); |
||||
|
||||
function loadBundleDirs() { |
||||
var distributionBundleDir = Services.dirsvc.get("GreD", Ci.nsIFile); |
||||
distributionBundleDir.append("distribution"); |
||||
distributionBundleDir.append("bundles"); |
||||
if (!distributionBundleDir.exists() || !distributionBundleDir.isDirectory()) { |
||||
return; |
||||
} |
||||
|
||||
var enumerator = distributionBundleDir.directoryEntries; |
||||
while (enumerator.hasMoreElements()) { |
||||
var file = enumerator.getNext().QueryInterface(Ci.nsIFile); |
||||
var dirName = file.leafName; |
||||
|
||||
file.append("chrome.manifest"); |
||||
Components.manager.QueryInterface(Ci.nsIComponentRegistrar).autoRegister(file); |
||||
file.leafName = "defaults"; |
||||
file.append("preferences"); |
||||
if (!file.exists() || !file.isDirectory()) { |
||||
continue; |
||||
} |
||||
var resource = Services.io.getProtocolHandler("resource") |
||||
.QueryInterface(Components.interfaces.nsIResProtocolHandler); |
||||
|
||||
// We can't use a file URL to load prefs. |
||||
// Create a resource URL that maps to the prefs directory. |
||||
var prefAlias = Services.io.newFileURI(file); |
||||
resource.setSubstitution(dirName + "_prefs", prefAlias); |
||||
var prefEnumerator = file.directoryEntries; |
||||
while (prefEnumerator.hasMoreElements()) { |
||||
var prefFile = prefEnumerator.getNext().QueryInterface(Ci.nsIFile); |
||||
gBundlePrefFiles.push("resource://" + dirName + "_prefs/" + prefFile.leafName); |
||||
} |
||||
} |
||||
} |
||||
|
||||
var loadPrefObserver = { |
||||
observe: function observe(subject, topic, data) { |
||||
if (gBundlePrefFiles.length > 0) { |
||||
// Create a temporary scope so the pref function works |
||||
var temp = {}; |
||||
temp.pref = function(a, b) { |
||||
defaultPref(a, b); |
||||
} |
||||
gBundlePrefFiles.forEach(function(prefFile) { |
||||
Services.scriptloader.loadSubScript(prefFile, temp); |
||||
}); |
||||
} |
||||
} |
||||
} |
||||
Services.obs.addObserver(loadPrefObserver, "load-extension-defaults", false); |
||||
|
||||
try { |
||||
loadBundleDirs(); |
||||
} catch(e) {} |
@ -0,0 +1,2 @@ |
||||
[XRE] |
||||
EnableProfileMigrator=false |
@ -0,0 +1,44 @@ |
||||
# -*- coding: utf-8 -*- |
||||
from setuphelpers import * |
||||
import json |
||||
from cryptography.fernet import Fernet |
||||
import os |
||||
from jinja2 import Environment, FileSystemLoader |
||||
|
||||
uninstallkey = [] |
||||
variables = { |
||||
'firefox_config_url': 'https://server/mcd/firefox.cfg', |
||||
'firefox_config_append_domain': '' |
||||
} |
||||
|
||||
# Read local variables file if available |
||||
if isfile(makepath(programfiles32,'wapt','private','symetric.txt')) and isfile(makepath(programfiles32,'wapt','private','variables.txt')): |
||||
print('Reading local encrypted variables file') |
||||
f = Fernet(open(makepath(programfiles32,'wapt','private','symetric.txt'),'r').read()) |
||||
variables.update(json.loads(f.decrypt(open(makepath(programfiles32,'wapt','private','variables.txt'),'r').read()))) |
||||
|
||||
def install(): |
||||
filecopyto('autoconf.js',makepath(programfiles,'Mozilla Firefox','defaults','pref')) |
||||
filecopyto('override.ini',makepath(programfiles,'Mozilla Firefox')) |
||||
jinja2 = Environment(loader=FileSystemLoader(os.path.dirname(os.path.abspath(__file__))),trim_blocks=True) |
||||
open(makepath(programfiles,'Mozilla Firefox','firefox.cfg'),'w').write( |
||||
jinja2.get_template('firefox.cfg.j2').render( |
||||
firefox_config_url = variables['firefox_config_url'], |
||||
firefox_config_append_domain = variables['firefox_config_append_domain'] |
||||
) |
||||
) |
||||
|
||||
def uninstall(): |
||||
os.unlink(makepath(programfiles,'Mozilla Firefox','defaults','pref','autoconf.js')) |
||||
os.unlink(makepath(programfiles,'Mozilla Firefox','override.ini')) |
||||
os.unlink(makepath(programfiles,'Mozilla Firefox','firefox.cfg')) |
||||
|
||||
def audit(): |
||||
if ( |
||||
not isfile(makepath(programfiles,'Mozilla Firefox','defaults','pref','autoconf.js')) or |
||||
not isfile(makepath(programfiles,'Mozilla Firefox','override.ini')) or |
||||
not isfile(makepath(programfiles,'Mozilla Firefox','firefox.cfg')) |
||||
): |
||||
print('At least one config file is missing') |
||||
return "ERROR" |
||||
return "OK" |
Loading…
Reference in new issue