How to Customize the Firefox 3 Installer

By Glen Bettridge on Tuesday, October 21st, 2008 in Technical | Related Software Packages: | Keywords:

With adoption of Firefox on the increase, enterprise IT shops face a challenge: how to provide Firefox to their users while keeping a handle on security. To address this, we suggest creating a customized Firefox installer preconfigured with the extensions and settings approved by your IT department. This tutorial takes you through that process.

Before You Start

Before customizing Firefox, avoid headaches by looking carefully at which extensions best suit your needs. You, or your IT team, should also thoroughly research the Firefox settings and create a list of those you wish to include.

Extensions

One of Firefox’s greatest strengths is its diverse collection of extensions. Extensions such as NoScript or CookieSafe can be used to secure Firefox, while AdBlock or one of its variants could help reduce unwanted traffic to ad servers. Before building a customized installer, you will need to decide which extensions best meet your needs and the needs of your users. With an eye toward security policies and customer requests, browse the Firefox Add-on Repository and download the (Firefox 3-compatible) add-ons that best meet your needs.

Settings

Firefox offers a large number of settings, many of which aren’t accessible through the standard preferences/options dialog window. To see the available options, enter “about:config” in Firefox’s location bar. This will display a list of all settings. While the list is intimidating, Mozilla publishes a reference to all of the settings. Review the  options and collect a list of settings for which you’d either like to set a custom default value or completely lock down to a specific value.

What You Will Need

Once you’ve decided what extensions and settings you’d like in your spiffy custom installer, there are a few components you’ll need.

For a custom Windows installer, grab

  1. A current, standard Firefox 3 installer for Windows.
  2. A current app.tag file from Mozilla’s site (copy the appropriate text from http://lxr.mozilla.org/mozilla/source/browser/installer/windows/app.tag into a text file called app.tag).
  3. A 7zSD.sfx file from Mozilla’s site (download this from http://lxr.mozilla.org/mozilla/source/other-licenses/7zstub/firefox/7zSD.sfx?raw=1).
  4. The 7zip command line utility (currently at http://downloads.sourceforge.net/sevenzip/7za457.zip).

For a custom Linux installer,you’ll need to

  1. Grab a current standard Firefox 3 binary for Linux.
  2. Have familiarity with tar and gzip.

You’ll also need copies of each extension you wish to include in the installer (the xpi files), and the list of settings and values.

Note for Mac users: I’m working on a version of this article for Firefox 3 on the Mac, but I’m still sorting out the details of repackaging a dmg file.

Meat & Potatoes

Creating Your Settings File

The settings file I’m going to describe is basically just a Javascript file with a set of calls to two Firefox-defined JS functions, defaultPref and lockPref. Unsurprisingly, the defaultPref function can be used to specify a default value for a setting and lockPref sets the value for the setting so that it cannot be changed by the user. Each has similar arguments:

function defaultPref(prefName, value)
function lockPref(prefName, value)

so, for example, you could set the default home page using

defaultPref("browser.startup.homepage","http://www.mycompany.com/portal");

or, you could require that the browser always check for updates

lockPref("app.update.enabled",true);

You can find additional information about these and other preference Javascript functions for Firefox in “MCD, Mission Control Desktop AKA AutoConfig” at the Mozilla Developer Center.

Use the list of settings you prepared to build a settings file. For the rest of the article, I’ll refer to this file as “firefox.cfg”, although you can use any name you prefer.

Note: Since the settings file is a Javascript file, there are many sophisticated and clever javascript tricks you can include, but I’m not going to cover any of them.

Making Your Extensions Manually Installable

The next step is to prepare your chosen extensions to be manually installed. For each extension,

  1. Unzip the xpi file (using 7zip, WinZip, Zip-Info or your preferred tool). You’ll end up with a folder probably with the same name as the extension (for example, NoScript)
  2. In the folder, find the file called install.rdf, open it in a text editor and find the <em:id> tag under the <Description> tag. This is the unique ID of the extension ({73a6fe31-595d-460b-a920-fcc0f8843232} for NoScript)
  3. Change the name of the extension folder to the extension’s ID (e.g. Change the “NoScript” folder to “{73a6fe31-595d-460b-a920-fcc0f8843232}”)
Get open source software support

On To the Installer

Now we’re ready to rebuild the installer.

Windows Installer

Let’s walk through the process for the Windows installer and then I’ll describe the somewhat simpler process on Linux.

  1. The Firefox installer is basically a self-extracting 7zip archive. You can open the 3.0.3 installer into a directory called “firefox-win” using

    7za x -ofirefox-win "Firefox Setup 3.0.3.exe"

  2. Copy each of the renamed extension folders into firefox-win\nonlocalized\extensions\ (assuming Windows path style). That’s all that needs to be done for a generic extension installations. If the extensions add new settings, the installer will use the default values for those settings. Those settings could also be added to the firefox.cfg file, if you needed to change them, but I won’t go into details here.
  3. Create a file called firefox.cfg in firefox-win\nonlocalized\ where the firefox.exe file is located. Here’s an example firefox.cfg which provides some basic security settings (note that everything in the example config file is commented out so it can be tested without affecting any settings at all; uncomment the settings you’d like to try).
  4. Open firefox-win\nonlocalized\greprefs\all.js in a text editor and add the following lines
  5. pref('general.config.obscure_value', 0);
    pref('general.config.filename', 'firefox.cfg');

    This causes Firefox 3 to load the settings in the firefox.cfg file.

  6. Build a new exe installer from the firefox-win folder: cd into firefox-win and execute the following commands
    1. 7za a -t7z ..\custom.7z
    2. cd ..
    3. copy /b 7zSD.sfx+app.tag+custom.7z FirefoxCustomInstall.exe

Linux Installer

When you download Firefox for Linux, instead of an installer, you’ll just have a tarball. This means you can untar it, walk through steps 2-4 in the Windows process and re-archive the directory.

Finishing Up

Distribute your newly created .exe to users and you’re set!

Glen Bettridge

Raised by a sasquatch tribe in the mountainous wilds of the western United States, Glen learned programming at the knee of his adopted father Grr'ktch. He is now a great fan of scrumilicious methodologies.

11 Responses to “How to Customize the Firefox 3 Installer”

  1. [...] licenses. Our engineers contributed tips and tutorials on a range of topics including working with Firefox and installing Apache on AIX. Rod Cope reported the results of some experimentation with open [...]

  2. MY says:

    Is it possible to build the custom installer with silent switch so we can push it out with a deployment tool? Thanks.

  3. MY: There are a couple of built-in switches for the installer that you may find useful: /S runs the installer silently; /D=[path] allows you to specify a customer installation directory and /INI=[path to ini] allows you to pick an alternate configuration ini file. For older versions of the installer, you could also use -ms instead of /S, but that’s deprecated in the Firefox 3 installer.

  4. David says:

    Thanks for the article! This is a project I’m working on right now, so I appreciate the time you’ve put into it.

    Two questions:

    1) In one of the early steps you say to download an “app.tag file”. What is this for?
    2) You mention that you’ve attached a sample firefox.cfg file using settings from Firefox 2. Am I missing the attachment, or was that not meant for this audience?

    Thanks again!

    David

  5. David,

    Good questions for which I have some semi-helpful answers.

    1) The installer executable for FF is a self-extracting archive. In order to make it a proper installer, the self extracting code needs to run an executable after the extraction. The app.tag file tells the self extractor which application from the archive to run once the archive has been expanded. In FF, setup.exe is what does the conventional installation tasks.
    2) The curse of copy and paste combined with bad author proofreading. This is a holdover from an early draft, but since it is handy to see a sample config file, I’ll add it to the article. Thanks for catching the mistake.

    Glen

  6. Albert Kam says:

    Hello,

    Is there anyway i can specify the location of the java plugin, and make the custom firefox build to use it ? I’ve scanned for java and jre for the configuration list and found none ..

    If this can be done, that means a lot easier of setting up a java enabled firefox 3 for our programmers and clients ..

    Please share your thoughts

  7. Albert,

    You can copy the java plugin files (dlls, dylibs or so files depending on the platform) into the plugins directory when you crack the installer. However, the Mozilla folks strongly recommend against this since it can screw up Java updates. There’s a nice article about the Java plugin on the Mozilla support site.

    Glen

  8. apaz says:

    I added the
    pref(‘general.config.obscure_value’, 0);
    pref(‘general.config.filename’, ‘firefox.cfg’);
    to all.js
    and created the firefox.cfg with
    “defaultPref(“browser.startup.homepage”,”http://www.test.com/”);
    created the installer and tested it, installs as normal, but it dosent change the homepage?
    I tried to edit the browserconfig.properties instead, and that works, but how comes the cfg doesnt work?

  9. Gerard says:

    hi, there are any way to customize the Firefox 3 installer to include my local root CA?

  10. Hi Gerard,

    Take a look at “View Certificates” on http://support.mozilla.com/en-US/kb/Options+window+-+Advanced+panel. It describes how to import CA certificates. HTH.

    Glen

  11. Gerard says:

    so, how can I prevent import my local root-CA after each installation?, there is no way to build in it just like the other settings from firefox.cfg?

    thank you for your time and help.

Leave a Reply

© 2010 OpenLogic, Inc. | Licensing | Privacy Policy | Terms of Use