34
edits
Changes
Move from firefox page and add WPKG package definition
= Mozilla auto configuration =
== TODO ==
* Improve explanation? the mozilla page and URL in configuration file aren't enough?
* Split the configuration between browser/mailer
* Use file compare for checks
[https://developer.mozilla.org/en/Automatic_Mozilla_Configurator/Locked_config_settings Main mozilla explanation page]
== WPKG package ==
<source lang="xml">
<?xml version='1.0' encoding='utf-8'?>
<packages>
<package
id='firefox-config'
name='Configuration globale de Mozilla Firefox'
revision='3.6.13'
reboot='false'
priority='300'>
<variable name='MOZ_DIR' value='%ProgramFiles%\Mozilla Firefox' />
<!-- my-load-config.js has good size? -->
<check type='file' condition='sizeequals' value='XX'
path='%MOZ_DIR%\defaults\pref\my-load-config.js'/>
<!-- my-config.cfg has good size? -->
<check type='file' condition='sizeequals' value='XX'
path='%MOZ_DIR%\my-config.cfg'/>
<!-- Firefox is default browser? -->
<check type='registry' condition='equals'
path='HKLM\SOFTWARE\Classes\http\shell\open\command'
value='%MOZ_DIR%\Firefox.exe -url "%1"'/>
<install cmd='"%ComSpec% /c copy /Y "%CMD_PATH%\my-load-config.js" "%MOZ_DIR%\defaults\pref\"'/>
<install cmd='"%ComSpec% /c copy /Y "%CMD_PATH%\my-config.cfg" "%MOZ_DIR%\"'/>
<upgrade cmd='"%ComSpec% /c copy /Y "%CMD_PATH%\my-load-config.js" "%MOZ_DIR%\defaults\pref\"'/>
<upgrade cmd='"%ComSpec% /c copy /Y "%CMD_PATH%\my-config.cfg" "%MOZ_DIR%\"'/>
<remove cmd='"%ComSpec% /c del /F /Q "%MOZ_DIR%\defaults\pref\my-load-config.js"'/>
<remove cmd='"%ComSpec% /c del /F /Q "%MOZ_DIR%\my-config.cfg"'/>
</package>
</packages>
</source>
== A file to enable the system wide configuration ==
To enable the system wide configuration, we set <tt>general.config.filename</tt> in a <tt>.js</tt> file under <tt>"%ProgramFiles%\<Mozilla Product>\defaults\pref\"</tt>:
my-load-config.js:
<source lang="javascript">
// -*- java -*-
// put this file in "%ProgramFiles%\<Mozilla Product>\defaults\pref\"
// Load my-config.cfg
pref("general.config.filename", "my-config.cfg");
</source>
== The configuration file ==
The configuration file is cyphered with [[Wikipedia:Rot13]], you can find a perl script [http://alain.knaff.lu/howto/MozillaCustomization/moz-byteshift.pl moz-byteshift.pl] to cypher the configuration.
Thunderbird is configure with <tt>general.config.obscure_value</tt> to 0, so no cyphering is required.
<source lang="javascript">
// -*- java -*-
// Firefox 3.5 autoconfiguration
// Works with 3.0 except for bookmarks
// // put this configuration in a file called mozilla.cfg in mozilla
// // firefox installation directory
// pref("general.config.filename", "firefox.cfg");
// Works based on:
// https://developer.mozilla.org/en/MCD
// https://developer.mozilla.org/en/Automatic_Mozilla_Configurator/Locked_config_settings
// http://mit.edu/~firefox/www/maintainers/autoconfig.html
// https://developer.mozilla.org/en/Places
// https://developer.mozilla.org/en/Manipulating_bookmarks_using_Places
// http://mxr.mozilla.org/firefox/source/netwerk/test/unit/test_permmgr.js
// http://mxr.mozilla.org/firefox/ident?i=nsIPermissionManager
var CC = Components.classes;
var CI = Components.interfaces;
// newURI create an URI object
var ios = CC["@mozilla.org/network/io-service;1"]
.getService(CI.nsIIOService);
// Bookmark service
var bks = CC["@mozilla.org/browser/nav-bookmarks-service;1"]
.getService(CI.nsINavBookmarksService);
// Permission manager service
var pms = CC["@mozilla.org/permissionmanager;1"]
.getService(CI.nsIPermissionManager);
function MyAutoAddBookmark(name, url, index, folder) {
var uri = ios.newURI(url, null, null);
if ( ! bks.isBookmarked(uri) )
return bks.insertBookmark(folder, uri, index, name);
}
function MyAutoDelBookmark(url) {
var uri = ios.newURI(url, null, null);
if ( bks.isBookmarked(uri) ) {
var count = {};
var bkIds = bks.getBookmarkIdsForURI(uri, count);
for (var i = 0; i < bkIds.length; i++) {
bks.removeItem(bkIds[i]);
}
}
}
function MyAutoAddPerm(url, type, action) {
// nsIPermissionManager is an extension
if (! pms)
return;
var uri = ios.newURI(url, null, null);
return pms.add(uri, type, action);
}
////
//// Begin Configuration
////
// Bookmarks and perms management
var bookmarks =
[
// folder = bks.bookmarksMenuFolder | bks.toolbarFolder | bks.tagsFolder | custom
// format: [name, url, index, folder]
["Wikipedia", "http://www.wikipedia.org", 0, bks.toolbarFolder],
["WPKG Silent Installer", "http://wpkg.org/Category:Silent_Installers", 1, bks.toolbarFolder],
];
var bookmarks_del =
[
// With and without trailing /
// HomePage useless in bookmark
"http://www.lwn.net",
"http://www.lwn.net/",
];
var perms =
[
// type = cookie | image | popup
// permission = pms.ALLOW_ACTION (1) | pms.DENY_ACTION (2)
// format: [url, type, permission]
["http://wpkg.org", "cookie", pms.ALLOW_ACTION],
["http://wpkg.org", "popup", pms.ALLOW_ACTION],
["http://wikipedia.org", "cookie", pms.ALLOW_ACTION],
["http://wikipedia.org", "popup", pms.ALLOW_ACTION]
];
for (var i = 0; i < bookmarks.length; i++) {
try {
MyAutoAddBookmark(bookmarks[i][0], bookmarks[i][1], bookmarks[i][2], bookmarks[i][3]);
}
// Try must have a catch or finally
finally {
// Do nothing
null;
}
}
for (var i = 0; i < bookmarks_del.length; i++) {
try {
MyAutoDelBookmark( bookmarks_del[i] );
}
// Try must have a catch or finally
finally {
// Do nothing
null;
}
}
for (var i = 0; i < perms.length; i++) {
try {
MyAutoAddPerm(perms[i][0], perms[i][1], perms[i][2]);
}
// Try must have a catch or finally
finally {
// Do nothing
null;
}
}
//
// about:config settings
//
// pref : user can change
// lockPref: user can not change
//
lockPref("app.update.enabled", false);
lockPref("browser.bookmarks.added_static_root", true);
// Download
lockPref("browser.download.manager.closeWhenDone", true);
lockPref("browser.download.manager.retention", 0);
lockPref("browser.download.useDownloadDir", false);
// Form filling
lockPref("browser.formfill.enable", true);
// History expiration
defaultPref("browser.history_expire_days", 180);
defaultPref("browser.history_expire_days.min", 180);
defaultPref("browser.history_expire_days.mirror", 180);
// Shown mozilla rights
lockPref("browser.rights.3.shown", true);
lockPref("browser.preferences.advanced.selectedTabIndex", 0);
// FF is the default browser
lockPref("browser.shell.checkDefaultBrowser", true);
// HomePage
lockPref("browser.startup.homepage", "http://www.lwn.net/");
defaultPref("general.smoothScroll", true);
// Charset autodetection
lockPref("intl.charset.detector", "universal_charset_detector");
// Proxy
// lockPref("network.proxy.autoconfig_url", "http://proxy.example.org/proxy.pac");
// lockPref("network.proxy.type", 2);
// Do not load links in background
lockPref("network.prefetch-next", false);
//
lockPref("browser.privatebrowsing.autostart", false);
// Sage Browsing on Goole by default
defaultPref("browser.safebrowsing.enabled", true);
defaultPref("browser.safebrowsing.malware.enabled", true);
lockPref("extensions.update.notifyUser", false);
lockPref("general.warnOnAboutConfig", true);
// Disable buttons
// Homepage settings
lockPref("pref.browser.homepage.disable_button.current_page", true);
lockPref("pref.browser.homepage.disable_button.restore_default", true);
lockPref("pref.browser.homepage.disable_button.bookmark_page", true);
// Password viewer
lockPref("pref.privacy.disable_button.view_passwords", true);
// Clear privacy data
// on shutdown
lockPref("privacy.clearOnShutdown.cache", true);
lockPref("privacy.clearOnShutdown.downloads", true);
defaultPref("privacy.clearOnShutdown.formdata", false);
lockPref("privacy.clearOnShutdown.passwords", true);
lockPref("privacy.clearOnShutdown.sessions", true);
lockPref("privacy.clearOnShutdown.siteSettings", true);
defaultPref("privacy.clearOnShutdown.cookies", true);
defaultPref("privacy.clearOnShutdown.history", false);
defaultPref("privacy.clearOnShutdown.offlineApps", true);
lockPref("privacy.sanitize.sanitizeOnShutdown", true);
// With Ctrl-Shift-del
lockPref("privacy.cpd.cache", true);
lockPref("privacy.cpd.downloads", true);
lockPref("privacy.cpd.formdata", false);
lockPref("privacy.cpd.offlineApps", true);
lockPref("privacy.cpd.passwords", true);
lockPref("privacy.cpd.sessions", true);
lockPref("privacy.cpd.siteSettings", true);
defaultPref("privacy.cpd.cookies", true);
defaultPref("privacy.cpd.history", false);
// Reject popup
lockPref("privacy.popups.policy", 2);
lockPref("dom.disable_open_during_load", true);
lockPref("browser.popups.showPopupBlocker", true);
// Even from plugins
lockPref("privacy.popups.disable_from_plugins", 2);
// Security warnings
// defaultPref("security.warn_entering_secure", true);
// defaultPref("security.warn_entering_secure.show", true);
// pref("security.warn_entering_secure.show_once", false);
// Weak encryption
lockPref("security.warn_entering_weak", true);
lockPref("security.warn_entering_weak.show_once", false);
// defaultPref("security.warn_leaving_secure", true);
// defaultPref("security.warn_leaving_secure.show_once", false);
// Submit without https
// defaultPref("security.warn_submit_insecure", true);
// defaultPref("security.warn_submit_insecure.show_once", false);
// Mixed secured/unsecured
// defaultPref("security.warn_viewing_mixed", true);
// defaultPref("security.warn_viewing_mixed.show_once", false);
// Remember form data
lockPref("signon.rememberSignons", false);
lockPref("signon.autofillForms", false);
</source>
== TODO ==
* Improve explanation? the mozilla page and URL in configuration file aren't enough?
* Split the configuration between browser/mailer
* Use file compare for checks
[https://developer.mozilla.org/en/Automatic_Mozilla_Configurator/Locked_config_settings Main mozilla explanation page]
== WPKG package ==
<source lang="xml">
<?xml version='1.0' encoding='utf-8'?>
<packages>
<package
id='firefox-config'
name='Configuration globale de Mozilla Firefox'
revision='3.6.13'
reboot='false'
priority='300'>
<variable name='MOZ_DIR' value='%ProgramFiles%\Mozilla Firefox' />
<!-- my-load-config.js has good size? -->
<check type='file' condition='sizeequals' value='XX'
path='%MOZ_DIR%\defaults\pref\my-load-config.js'/>
<!-- my-config.cfg has good size? -->
<check type='file' condition='sizeequals' value='XX'
path='%MOZ_DIR%\my-config.cfg'/>
<!-- Firefox is default browser? -->
<check type='registry' condition='equals'
path='HKLM\SOFTWARE\Classes\http\shell\open\command'
value='%MOZ_DIR%\Firefox.exe -url "%1"'/>
<install cmd='"%ComSpec% /c copy /Y "%CMD_PATH%\my-load-config.js" "%MOZ_DIR%\defaults\pref\"'/>
<install cmd='"%ComSpec% /c copy /Y "%CMD_PATH%\my-config.cfg" "%MOZ_DIR%\"'/>
<upgrade cmd='"%ComSpec% /c copy /Y "%CMD_PATH%\my-load-config.js" "%MOZ_DIR%\defaults\pref\"'/>
<upgrade cmd='"%ComSpec% /c copy /Y "%CMD_PATH%\my-config.cfg" "%MOZ_DIR%\"'/>
<remove cmd='"%ComSpec% /c del /F /Q "%MOZ_DIR%\defaults\pref\my-load-config.js"'/>
<remove cmd='"%ComSpec% /c del /F /Q "%MOZ_DIR%\my-config.cfg"'/>
</package>
</packages>
</source>
== A file to enable the system wide configuration ==
To enable the system wide configuration, we set <tt>general.config.filename</tt> in a <tt>.js</tt> file under <tt>"%ProgramFiles%\<Mozilla Product>\defaults\pref\"</tt>:
my-load-config.js:
<source lang="javascript">
// -*- java -*-
// put this file in "%ProgramFiles%\<Mozilla Product>\defaults\pref\"
// Load my-config.cfg
pref("general.config.filename", "my-config.cfg");
</source>
== The configuration file ==
The configuration file is cyphered with [[Wikipedia:Rot13]], you can find a perl script [http://alain.knaff.lu/howto/MozillaCustomization/moz-byteshift.pl moz-byteshift.pl] to cypher the configuration.
Thunderbird is configure with <tt>general.config.obscure_value</tt> to 0, so no cyphering is required.
<source lang="javascript">
// -*- java -*-
// Firefox 3.5 autoconfiguration
// Works with 3.0 except for bookmarks
// // put this configuration in a file called mozilla.cfg in mozilla
// // firefox installation directory
// pref("general.config.filename", "firefox.cfg");
// Works based on:
// https://developer.mozilla.org/en/MCD
// https://developer.mozilla.org/en/Automatic_Mozilla_Configurator/Locked_config_settings
// http://mit.edu/~firefox/www/maintainers/autoconfig.html
// https://developer.mozilla.org/en/Places
// https://developer.mozilla.org/en/Manipulating_bookmarks_using_Places
// http://mxr.mozilla.org/firefox/source/netwerk/test/unit/test_permmgr.js
// http://mxr.mozilla.org/firefox/ident?i=nsIPermissionManager
var CC = Components.classes;
var CI = Components.interfaces;
// newURI create an URI object
var ios = CC["@mozilla.org/network/io-service;1"]
.getService(CI.nsIIOService);
// Bookmark service
var bks = CC["@mozilla.org/browser/nav-bookmarks-service;1"]
.getService(CI.nsINavBookmarksService);
// Permission manager service
var pms = CC["@mozilla.org/permissionmanager;1"]
.getService(CI.nsIPermissionManager);
function MyAutoAddBookmark(name, url, index, folder) {
var uri = ios.newURI(url, null, null);
if ( ! bks.isBookmarked(uri) )
return bks.insertBookmark(folder, uri, index, name);
}
function MyAutoDelBookmark(url) {
var uri = ios.newURI(url, null, null);
if ( bks.isBookmarked(uri) ) {
var count = {};
var bkIds = bks.getBookmarkIdsForURI(uri, count);
for (var i = 0; i < bkIds.length; i++) {
bks.removeItem(bkIds[i]);
}
}
}
function MyAutoAddPerm(url, type, action) {
// nsIPermissionManager is an extension
if (! pms)
return;
var uri = ios.newURI(url, null, null);
return pms.add(uri, type, action);
}
////
//// Begin Configuration
////
// Bookmarks and perms management
var bookmarks =
[
// folder = bks.bookmarksMenuFolder | bks.toolbarFolder | bks.tagsFolder | custom
// format: [name, url, index, folder]
["Wikipedia", "http://www.wikipedia.org", 0, bks.toolbarFolder],
["WPKG Silent Installer", "http://wpkg.org/Category:Silent_Installers", 1, bks.toolbarFolder],
];
var bookmarks_del =
[
// With and without trailing /
// HomePage useless in bookmark
"http://www.lwn.net",
"http://www.lwn.net/",
];
var perms =
[
// type = cookie | image | popup
// permission = pms.ALLOW_ACTION (1) | pms.DENY_ACTION (2)
// format: [url, type, permission]
["http://wpkg.org", "cookie", pms.ALLOW_ACTION],
["http://wpkg.org", "popup", pms.ALLOW_ACTION],
["http://wikipedia.org", "cookie", pms.ALLOW_ACTION],
["http://wikipedia.org", "popup", pms.ALLOW_ACTION]
];
for (var i = 0; i < bookmarks.length; i++) {
try {
MyAutoAddBookmark(bookmarks[i][0], bookmarks[i][1], bookmarks[i][2], bookmarks[i][3]);
}
// Try must have a catch or finally
finally {
// Do nothing
null;
}
}
for (var i = 0; i < bookmarks_del.length; i++) {
try {
MyAutoDelBookmark( bookmarks_del[i] );
}
// Try must have a catch or finally
finally {
// Do nothing
null;
}
}
for (var i = 0; i < perms.length; i++) {
try {
MyAutoAddPerm(perms[i][0], perms[i][1], perms[i][2]);
}
// Try must have a catch or finally
finally {
// Do nothing
null;
}
}
//
// about:config settings
//
// pref : user can change
// lockPref: user can not change
//
lockPref("app.update.enabled", false);
lockPref("browser.bookmarks.added_static_root", true);
// Download
lockPref("browser.download.manager.closeWhenDone", true);
lockPref("browser.download.manager.retention", 0);
lockPref("browser.download.useDownloadDir", false);
// Form filling
lockPref("browser.formfill.enable", true);
// History expiration
defaultPref("browser.history_expire_days", 180);
defaultPref("browser.history_expire_days.min", 180);
defaultPref("browser.history_expire_days.mirror", 180);
// Shown mozilla rights
lockPref("browser.rights.3.shown", true);
lockPref("browser.preferences.advanced.selectedTabIndex", 0);
// FF is the default browser
lockPref("browser.shell.checkDefaultBrowser", true);
// HomePage
lockPref("browser.startup.homepage", "http://www.lwn.net/");
defaultPref("general.smoothScroll", true);
// Charset autodetection
lockPref("intl.charset.detector", "universal_charset_detector");
// Proxy
// lockPref("network.proxy.autoconfig_url", "http://proxy.example.org/proxy.pac");
// lockPref("network.proxy.type", 2);
// Do not load links in background
lockPref("network.prefetch-next", false);
//
lockPref("browser.privatebrowsing.autostart", false);
// Sage Browsing on Goole by default
defaultPref("browser.safebrowsing.enabled", true);
defaultPref("browser.safebrowsing.malware.enabled", true);
lockPref("extensions.update.notifyUser", false);
lockPref("general.warnOnAboutConfig", true);
// Disable buttons
// Homepage settings
lockPref("pref.browser.homepage.disable_button.current_page", true);
lockPref("pref.browser.homepage.disable_button.restore_default", true);
lockPref("pref.browser.homepage.disable_button.bookmark_page", true);
// Password viewer
lockPref("pref.privacy.disable_button.view_passwords", true);
// Clear privacy data
// on shutdown
lockPref("privacy.clearOnShutdown.cache", true);
lockPref("privacy.clearOnShutdown.downloads", true);
defaultPref("privacy.clearOnShutdown.formdata", false);
lockPref("privacy.clearOnShutdown.passwords", true);
lockPref("privacy.clearOnShutdown.sessions", true);
lockPref("privacy.clearOnShutdown.siteSettings", true);
defaultPref("privacy.clearOnShutdown.cookies", true);
defaultPref("privacy.clearOnShutdown.history", false);
defaultPref("privacy.clearOnShutdown.offlineApps", true);
lockPref("privacy.sanitize.sanitizeOnShutdown", true);
// With Ctrl-Shift-del
lockPref("privacy.cpd.cache", true);
lockPref("privacy.cpd.downloads", true);
lockPref("privacy.cpd.formdata", false);
lockPref("privacy.cpd.offlineApps", true);
lockPref("privacy.cpd.passwords", true);
lockPref("privacy.cpd.sessions", true);
lockPref("privacy.cpd.siteSettings", true);
defaultPref("privacy.cpd.cookies", true);
defaultPref("privacy.cpd.history", false);
// Reject popup
lockPref("privacy.popups.policy", 2);
lockPref("dom.disable_open_during_load", true);
lockPref("browser.popups.showPopupBlocker", true);
// Even from plugins
lockPref("privacy.popups.disable_from_plugins", 2);
// Security warnings
// defaultPref("security.warn_entering_secure", true);
// defaultPref("security.warn_entering_secure.show", true);
// pref("security.warn_entering_secure.show_once", false);
// Weak encryption
lockPref("security.warn_entering_weak", true);
lockPref("security.warn_entering_weak.show_once", false);
// defaultPref("security.warn_leaving_secure", true);
// defaultPref("security.warn_leaving_secure.show_once", false);
// Submit without https
// defaultPref("security.warn_submit_insecure", true);
// defaultPref("security.warn_submit_insecure.show_once", false);
// Mixed secured/unsecured
// defaultPref("security.warn_viewing_mixed", true);
// defaultPref("security.warn_viewing_mixed.show_once", false);
// Remember form data
lockPref("signon.rememberSignons", false);
lockPref("signon.autofillForms", false);
</source>