Locked config settings

  • Revision slug: Automatic_Mozilla_Configurator/Locked_config_settings
  • Revision title: Locked config settings
  • Revision id: 165048
  • Created:
  • Creator: Giraldeau
  • Is current revision? No
  • Comment

Revision Content

Putting into place locked configuration settings

This feature exists for Mozilla and Firefox, but not for Thunderbird Locked settings can be put into a mozilla.cfg file in the C:\Program Files\mozilla.org\Mozilla directory. The mozilla.cfg file is an encoded file of javascript commands. The encoding is a simple "byte-shifting" with an offset of 13 (netscape 4 used a similar encoding, but with a of 7 instead). This file also needs to be "called" from C:\Program Files\mozilla.org\Mozilla\defaults\pref\all.js by appending the following line at the end:

pref("general.config.filename", "mozilla.cfg");

Note: Newer versions of Mozilla or Firefox store the all.js file in greprefs rather than defaults\pref

The moz-byteshift.pl script allows to encode...:

moz-byteshift.pl -s 13 <mozilla.cfg.txt >mozilla.cfg

... and to decode mozilla.cfg files:

moz-byteshift.pl -s -13 <mozilla.cfg >mozilla.cfg.txt

Example of an unencoded file: mozilla.cfg.txt. The lockPref command puts into place a locked preference, whereas the defaultPref command merely puts into a place a default value (which the user may override in his prefs.js file). Note that the file must start with //, or else it is not recognized by Mozilla. As the encoding of the file is pretty trivial, the encoding as such does not provide any real security. Instead make sure that file protections make this file unmodifiable by the unprivileged user. Moreover, some settings (such as mail & news configuration) unfortunately seem to be inaccessible to mozilla.cfg, which means that these cannot be locked. If you have trouble getting the moz-byteshift.pl script to work locally, there is also an online version available. Note: In recent versions of mozilla (tested on Windows and Linux, with 1.5, 1.6 and 1.7b), the mozilla.cfg file needs to be placed in mozilla's root directory, rather than default\pref where all.js resides.

If you suspect syntax errors in your config file, you can display the exact error message by enclosing your code in a try-catch block:

try {
 ...
} catch(e) {
 displayError("Test", e);
}


Not using encoded configuration

If you don't care about encoding the mozilla.cfg file, append this config to all.js instead :

pref("general.config.obscure_value", 0);
pref("general.config.filename", "mozilla.cfg");

Revision Source

<p>
</p>
<h2 name="Putting_into_place_locked_configuration_settings">Putting into place locked configuration settings</h2>
<p>This feature exists for Mozilla and Firefox, but not for Thunderbird
Locked settings can be put into a <code>mozilla.cfg</code> file in the <code>C:\Program Files\mozilla.org\Mozilla</code> directory. The <a class="external" href="http://alain.knaff.lu/howto/MozillaCustomization/mozilla.cfg">mozilla.cfg</a> file is an encoded file of javascript commands. The encoding is a simple <a class="external" href="http://groups.google.com/groups?threadm=altjjj%24cd51%40ripley.netscape.com&amp;rnum=1">"byte-shifting" with an offset of 13</a> (netscape 4 used a similar encoding, but with a of 7 instead). This file also needs to be "called" from <code>C:\Program Files\mozilla.org\Mozilla\defaults\pref\all.js</code> by appending the following line at the end:
</p>
<pre>pref("general.config.filename", "mozilla.cfg");
</pre>
<p>Note: Newer versions of Mozilla or Firefox store the <code>all.js</code> file in <code>greprefs</code> rather than <code>defaults\pref</code>
</p><p>The <a class="external" href="http://alain.knaff.lu/howto/MozillaCustomization/moz-byteshift.pl">moz-byteshift.pl</a> script allows to encode...:
</p>
<pre>moz-byteshift.pl -s 13 &lt;mozilla.cfg.txt &gt;mozilla.cfg
</pre>
<p>... and to decode <code>mozilla.cfg</code> files:
</p>
<pre>moz-byteshift.pl -s -13 &lt;mozilla.cfg &gt;mozilla.cfg.txt
</pre>
<p>Example of an unencoded file: <code><a class="external" href="http://alain.knaff.lu/howto/MozillaCustomization/mozilla.cfg.txt">mozilla.cfg.txt</a></code>. The <code>lockPref</code> command puts into place a locked preference, whereas the <code>defaultPref</code> command merely puts into a place a default value (which the user may override in his <code>prefs.js</code> file).
Note that the file <i>must</i> start with <code>//</code>, or else it is not recognized by Mozilla.
As the encoding of the file is pretty trivial, the encoding as such does not provide any real security. Instead make sure that file protections make this file unmodifiable by the unprivileged user.
Moreover, some settings (such as mail &amp; news configuration) unfortunately seem to be inaccessible to <code>mozilla.cfg</code>, which means that these cannot be locked.
If you have trouble getting the <code>moz-byteshift.pl</code> script to work locally, there is also an <a class="external" href="http://www.alain.knaff.lu/~aknaff/howto/MozillaCustomization/cgi/byteshf.cgi">online version</a> available.
Note: In recent versions of mozilla (tested on Windows and Linux, with 1.5, 1.6 and 1.7b), the <code>mozilla.cfg</code> file needs to be placed in mozilla's root directory, rather than <code>default\pref</code> where <code>all.js</code> resides.
</p><p>If you suspect syntax errors in your config file, you can display the exact error message by enclosing your code in a try-catch block: 
</p>
<pre>try {
 ...
} catch(e) {
 displayError("Test", e);
}
</pre>
<p><br>
</p>
<h3 name="Not_using_encoded_configuration"> Not using encoded configuration </h3>
<p>If you don't care about encoding the mozilla.cfg file, append this config to all.js instead : 
</p>
<pre>pref("general.config.obscure_value", 0);
pref("general.config.filename", "mozilla.cfg");
</pre>
Revert to this revision