As of Firefox 3, Ubuntu stores its user-editable preferences file in /etc/firefox-3.0/pref/firefox.js If you make changes to this file, they will persist even when Ubuntu updates Firefox.
Unfortunately, you can’t use lockPref in /etc/firefox-3.0/pref/firefox.js!!! If you use “pref” it works, but “lockPref” is not recognized. So if you want to lock down the preferences to keep users from being able to change them (like for proxy settings), you have to do the following.
1. Add the following to the end of /etc/firefox-3.0/pref/firefox.js:
// tell firefox to load customized config file
pref("general.config.obscure_value", 0);
pref("general.config.filename", "firefox.cfg");
2. Create a file called firefox.cfg in /etc/firefox-3.0/pref/ with the following content (the first line in both files must start with a comment):
// Lock specific preferences in Firefox so that users cannot edit them
lockPref("app.update.enabled", false);
lockPref("network.proxy.http", "127.0.0.1");
lockPref("network.proxy.http_port", 8080);
lockPref("network.proxy.type", 1);
lockPref("network.proxy.no_proxies_on", "localhost, 127.0.0.1, 192.168.1.0/24");
lockPref("network.proxy.share_proxy_settings", true);
lockPref("browser.startup.homepage", "http://www.desiredhomepage.com/");
3. Create another file in /etc/firefox-3.0/pref/ called copyfirefox.cfg.pl with the following contents (Thanks to Jeffrey LePage for this script):
# start of file
use strict;
# this gets the current firefox version
my $fire_ver = `/usr/bin/firefox -v`;
# this parses the version
chomp($fire_ver);
$fire_ver =~ s/^\s*Mozilla\s+Firefox\s+([\d\.]+).*$/$1/;
#Mozilla Firefox 3.0.13, Copyright (c) 1998 - 2009 mozilla.org
# this looks for firefox.cfg
if( -e "/usr/lib/firefox-$fire_ver/firefox.cfg" )
{
# firefox.cfg exists - this is good, no action is necessary
}
else
{
# make a symlink
symlink("/etc/firefox-3.0/pref/firefox.cfg", "/usr/lib/firefox-$fire_ver/firefox.cfg");
}
# end of file
4. Open the root crontab editor by typing the following in a terminal window:
sudo crontab -e
Add the following to the end of the root crontab in the crontab editor:
# Copy firefox.cfg to the current Firefox binary directory # to keep it working following an upgrade until this bug is fixed. * * * * * /usr/bin/perl /etc/firefox-3.0/pref/copyfirefox.cfg.pl /dev/null 2>&1
This script will create a symlink to firefox.cfg every minute in the current Firefox binary directory (/usr/lib/firefox-3.0.x where x is the version number) to protect againt upgrades where the directory changes to x+1. This is a very short script, so running it every minute will have almost no CPU overhead. But if you want even less CPU overhead, you could change the first asterisk in the crontab entry to */5 to make it run every 5 minutes instead of every minute, or */10 for every 10 minutes, etc.
5. Wait a minute for the crontab to fire. Then restart Firefox, and the preferences should be locked down. You should be able to use this to lock down any setting in about:config.
UPDATED Sept 3, 2009. Thanks to Jeffrey LePage (jglepage) for pointing out a better way to point to the .cfg file and for developing the perl script to create the symlink in the current Firefox installation directory.