Mozilla AutoConfig ****************** Jehan Procaccia MCI INT-EVRY- jehan.procaccia@int-evry.fr ========================================================= May 23, 2006 ============= Table of Contents *=*=*=*=*=*=*=*=* - 1 Situation - 2 Objective - 3 Central configuration file - 3.1 file location - 3.2 Warnings - 3.3 file encoding - 3.4 file API - 4 Thunderbird - 4.1 Support of autoconfig and ldap calls - 4.1.1 Autoconfig option and ldap support in thunderbird 1.5.X - 4.1.2 Add the autoconfig option for old thunderbird 1.0.X - 4.2 configure autoconfig - 4.3 Autoconfig directives - 4.3.1 thunderbird.cfg - 4.3.2 Test autoconfig - 4.4 Bugs reports related - 4.4.1 Unwanted white space reappeared - 5 Firefox - 5.1 Autoconfig (pref) and ldap support in packages - 5.1.1 Add ldap support in firefox 1.5 - 5.1.2 Add autoconfig and ldap support in firefox 1.0.X - 5.2 all.js - 5.3 firefox.cfg - 5.4 Debug - 6 Referecences - 6.1 Other docs about autoconfig - 6.2 Related bugzilla - 7 OLD Mozilla1.X, possibly Netscape 6/7 - 7.1 Changes - 7.2 Mozilla new features in regard to netscape - 7.3 Locating the file on a web server - 7.3.1 Call file - 7.4 Encoding mozilla.js file to mozilla.cfg - 7.5 Location of mci-mozilla-web-tux.cfg - 7.6 Call to mci-mozilla-web-tux.cfg - 7.7 Web base cgi javascript preferences generator file - 7.8 Windows particularities - 7.8.1 Windows Call file - 7.8.2 Windows all.js file - 7.8.3 Windows cgi file - 7.9 Versions tested - 8 Debuging - bugzilla - 8.1 Run time messages - 8.2 Blank space bug - 8.3 Documentation - 8.4 defeultPref for homepage - 8.5 greprefs right access - 8.6 cgi base config file - 9 Mail folders - 10 reliabilty - 10.1 failover and uniqueness - 10.2 Ldap failover - 10.3 Unique script for windows and linux - 10.4 Final production script - 10.5 for the record, old reliabily scripts ... - 10.5.1 Enhence netscape.cfg - 10.5.2 LDAP web server list subtree - 10.5.3 netscape.cfg - 11 OLD Netscape 4.X - 11.1 call file, netscape.cfg - 11.2 LockPref configuration file Abstract: This document is a concret example of a centralized auto-configuration of mozilla 1.X.X , firefox `&' thunderbird, and the old netscape 4.X . Its original inspiration comes from http://www.cs.colorado.edu/~dowdy/netscape_cfg/readme.txt and http://www.alain.knaff.lu/howto/MozillaCustomization/ . It has been recently reordered , putting thunderbird and firefox in the begening, but for history, I've keept mozilla and netscape chapters, that are in certain points complementary, principaly on the web base autoconfig file. 1 Situation *=*=*=*=*=*= INT-Evry (http://www.int-evry.fr/) manages about 2000 users (mostly students) who shares computers in labs and self service computer rooms. Hence a single computer might connect many different users all day long. Computers are dualboot (windows XP and Linux Fedora Core 4/5 ), hence all users have a personal account on a windows server and an LDAP account for linux authentification (see http://www.int-evry.fr/mci/user/procacci/ldap/) 2 Objective *=*=*=*=*=*= The objective is to provide users with a mailer agent, a web browser, and a news reader which are automatically configured (preferences) at its invocation to the particular user connected at this momment on the computer. Choosing Mozilla products allows us to use the same program (and hence autoconfiguration feature) either while running Windows or Unix (Linux in our case). Instead of configuring user by user individual preference files (`~/.mozilla/default/randomdir/prefs.js') we will centralized those preferences. This centralized preference file can lock preferences (`lockPref') or initialized them (`defaultPref') based on environement variables (`USER, HOME ...') and/or LDAP queries (for fetching email address, Common Name etc ...) . 3 Central configuration file *=*=*=*=*=*=*=*=*=*=*=*=*=*=* That feature is provided through a javascript file. 3.1 file location ================== For the old netscape 4.X the file is encoded (byteshift/rotary is 7), and the presence of that file (`netscape.cfg') in the `MOZILLA_HOME' directory sufices for it to be read and executed. For Mozilla 1.X.X , firefox, thunderbird or Netscape7 it is still a javascript file, the byteshift is 13 by default, but can be removed using the `pref("general.config.obscure_value", 0);' preference in `all.js'. The name of the file can be anything because it is named by a `general.config' preference that should be added at the end of file `MOZILLA_HOME/default/pref/all.js or MOZILLA_HOME/greprefs/all.js' : `pref(``general.config.filename'', ``mozilla.cfg'');' . 3.2 Warnings ============= Beware of the location on the `all.js' file, `all.js' file has moved to `MOZILLA_HOME/greprefs/all.js', and I noticed the same for thunderbird and firefox ! 3.3 file encoding ================== If needed, the encoding can be done with the perl script: moz-byteshift.pl gotten from http://www.alain.knaff.lu/howto/MozillaCustomization/moz-byteshift.pl. For Netscape 4.X the convert fonction from the Client Customization Kit (CCK) could also do that (and other things like personnalize autoinstallation ...): http://developer.netscape.com/docs/manuals/deploymt/config.htm 3.4 file API ============= That centralized preference file uses a javascript API that allows us to do what we need. The fonctions available are defined in `MOZILLA_HOME/default/autoconfig/prefcalls.js'. Actually the presence of `pref(``general.config.filename'', ``mozilla.cfg'');' in `all.js' as described above, enable the read and execution of `prefcalls.js'. Avalaible functions are (see file for details): << function getPrefBranch() function pref(prefName, value) function defaultPref(prefName, value) function lockPref(prefName, value) function unlockPref(prefName) function getPref(prefName) function getLDAPAttributes(host, base, filter, attribs) function getLDAPValue(str, key) function displayError(funcname, message) function getenv(name) >> 4 Thunderbird *=*=*=*=*=*=*= 4.1 Support of autoconfig and ldap calls ========================================= 4.1.1 Autoconfig option and ldap support in thunderbird 1.5.X -------------------------------------------------------------- Fortunatly,autoconfig is now part of thunderbird public packages. ` MOZ_LDAP_XPCOM=1 and MOZ_EXTENSIONS_DEFAULT=" wallet spellcheck xmlextras pref webservices universalchardet auth ' are now present in the default `configure' script. see https://bugzilla.mozilla.org/show_bug.cgi?id=295329 for details. 4.1.2 Add the autoconfig option for old thunderbird 1.0.X ---------------------------------------------------------- By default, autoconfig did not made part of the binaries distribution of thunderbird (1.0.X) . It was apparently supposed to increasing the load of the binary for a feature not used by lots of individuals . Howerver for entrerpise deployement, it is vital !. So we needed to recompile thunderbird with autoconfig support, it's just a matter of adding `--enable-extensions=pref' in `mozconfig' file . On my fedora core 3 system, I took the thunderbird source package `thunderbird-1.0.2-1.3.3.src.rpm' installed it (rpm -i) then modified `/usr/src/redhat/SOURCES/thunderbird-mozconfig' by adding : << ac_add_options --enable-extensions=pref >> Compile and install : << $ rpmbuild -ba /usr/src/redhat/SPECS/thunderbird.spec $ rpm -Uvh /usr/src/redhat/RPMS/i386/thunderbird-1.0.2-1.3.3.i386.rpm >> After istallation, autoconfig is finally back here : << $ rpm -ql thunderbird | grep autoconfig /usr/lib/thunderbird-1.0.2/chrome/en-US/locale/autoconfig /usr/lib/thunderbird-1.0.2/components/autoconfig.xpt /usr/lib/thunderbird-1.0.2/components/libautoconfig.so /usr/lib/thunderbird-1.0.2/defaults/autoconfig /usr/lib/thunderbird-1.0.2/defaults/autoconfig/platform.js /usr/lib/thunderbird-1.0.2/defaults/autoconfig/prefcalls.js >> 4.2 configure autoconfig ========================= Two directives ask thunderbird to use autoconfig at startup : << [root@b008-02 /usr/lib/thunderbird-1.5] $tail -2 greprefs/all.js pref("general.config.obscure_value", 0); // for MCD .cfg files pref('general.config.filename', 'thunderbird.cfg'); // for MCD .cfg files >> the first one just tells that we won't encode the file (no more rotary 13 or 7 ... :-) ), the second one is the name of the file to be read: `/usr/lib/thunderbird-1.5/thunderbird.cfg'. 4.3 Autoconfig directives ========================== Here we want to set users central mail preferences: Create one account from their login name, get their email adresse from an ldap request and set the entreprise imap and smtp servers. Hence, when working on multiuser workstations, one person gets automatically thunderbird configured for himself . 4.3.1 thunderbird.cfg ---------------------- Here's the complete file, first we get the user login name from environement variables, then configure the ldap adress book , create an mail account, configure imap and smtp : << [root@b008-02 /usr/lib/thunderbird-1.5] $ cat thunderbird.cfg //put everything in a try/catch try { // 1) env variables if(getenv("USER") != "") { // *NIX settings var env_user = getenv("USER"); var env_home = getenv("HOME"); } else { // Windows settings var env_user = getenv("USERNAME"); var env_home = getenv("HOMEPATH"); } var env_mozdebug= getenv("MOZILLA_DEBUG"); // var env_user = prompt("indiquez votre login", toto); // 2) lock general preferences //LDAP address book lockPref("ldap_2.prefs_migrated", true); lockPref("ldap_2.servers.LDAPINT.auth.savePassword", true); lockPref("ldap_2.servers.LDAPINT.description", "LDAP INT"); lockPref("ldap_2.servers.LDAPINT.filename", "abook-1.mab"); lockPref("ldap_2.servers.LDAPINT.uri", "ldap://ldap1.int-evry.Fr:389/ou=people,dc=int-evry,dc=fr??sub"); lockPref("ldap_2.servers.history.filename", "history.mab"); lockPref("ldap_2.servers.history.replication.lastChangeNumber", 0); lockPref("ldap_2.servers.pab.filename", "abook.mab"); lockPref("ldap_2.servers.pab.replication.lastChangeNumber", 0); //Account lockPref("mail.account.account1.server", "server1"); lockPref("mail.account.account2.identities", "id1"); lockPref("mail.account.account2.server", "server2"); lockPref("mail.accountmanager.accounts", "account1,account2"); lockPref("mail.accountmanager.defaultaccount", "account2"); lockPref("mail.accountmanager.localfoldersserver", "server1"); lockPref("mail.identity.id1.directoryServer", "ldap_2.servers.LDAPINT"); lockPref("mail.identity.id1.draft_folder", "imap://" + env_user + "@imap-int.int-evry.fr/Drafts"); lockPref("mail.identity.id1.drafts_folder_picker_mode", "0"); lockPref("mail.identity.id1.fcc_folder", "imap://" + env_user + "@imap-int.int-evry.fr/Sent"); lockPref("mail.identity.id1.fcc_folder_picker_mode", "0"); lockPref("mail.identity.id1.organization", "INT Evry France"); lockPref("mail.identity.id1.overrideGlobal_Pref", true); lockPref("mail.identity.id1.reply_to", ""); //IMAP lockPref("mail.server.server2.hostname", "imap-int.int-evry.fr"); lockPref("mail.server.server2.isSecure", true); lockPref("mail.server.server2.login_at_startup", true); lockPref("mail.server.server2.max_cached_connections", 5); //lockPref("mail.server.server2.name", "jehan.procaccia@int-evry.fr"); lockPref("mail.server.server2.type", "imap"); lockPref("mail.server.server2.userName", env_user ); //SMTP lockPref("mail.identity.id1.smtpServer", "smtp1"); lockPref("mail.identity.id1.stationery_folder", "imap://" + env_user + "@imap-int.int-evry.fr/Templates"); lockPref("mail.identity.id1.tmpl_folder_picker_mode", "0"); lockPref("mail.identity.id1.valid", true); //SMTP general lockPref("mail.smtp.defaultserver", "smtp1"); lockPref("mail.smtpserver.smtp1.auth_method", 0); lockPref("mail.smtpserver.smtp1.hostname", "smtp-int.int-evry.fr"); lockPref("mail.smtpserver.smtp1.port", 25); lockPref("mail.smtpserver.smtp1.try_ssl", 0); lockPref("mail.smtpserver.smtp1.username", ""); lockPref("mail.smtpservers", "smtp1"); lockPref("mail.startup.enabledMailCheckOnce", true); lockPref("mailnews.quotingPrefs.version", 1); lockPref("mailnews.ui.threadpane.version", 5); /* 3) define here (because if set after "4)" below it doesn't work !) processLDAPValues which is eventually called by getLDAPAttributes() just below, check getLDAPAttributes() code from $MOZILLA_HOME/defaults/autoconfig/prefcalls.js to see the inside call to "user defined" processLDAPValues */ function processLDAPValues (values) { if(values) { // set the global var with the values returned from the LDAP query ldap_values = values; var uid = getLDAPValue ( values ,"uid" ); var cn = getLDAPValue ( values ,"cn" ); var mail = getLDAPValue ( values ,"mail" ); var URL = getLDAPValue ( values ,"labeledURI" ); // Those ldap variables are only available is this processLDAPValues context ! // so we set the preferences that need them here . lockPref("mail.identity.id1.useremail", mail); lockPref("mail.server.server2.name", mail ); lockPref("mail.identity.id1.fullName", cn ); //Debug with popup error messages doesn't work anymore :-( !! var env_mozdebug= getenv("MOZILLA_DEBUG"); if (env_mozdebug) {displayError("NO ERROR , just a debug, cn =" + cn + " and mail = " + mail ); } } } // 4) Call Ldap servers to get Ldap Attributes (mail & cn) , this will finally call processLDAPValues , "3)" just above. getLDAPAttributes("ldap2.int-evry.fr","ou=people,dc=int-evry,dc=fr","uid =" + env_user,"uid,cn,mail,labeledURI"); // Close the try, and call the catch() } catch(e) { displayError("lockedPref", e); } >> 4.3.2 Test autoconfig ---------------------- Debug To check that our autoconfig works fine, we just set to env variable to check the read of thunderbird.cfg file: << $ export NSPR_LOG_MODULES=MCD:5 $ export NSPR_LOG_FILE=/tmp/thunderbird-log.txt >> When thunderbird has started , you should read: << $ cat /tmp/thunderbird-log.txt -1209403040[808a788]: general.config.filename = thunderbird.cfg -1209403040[808a788]: evaluating .cfg file thunderbird.cfg with obscureValue 0 >> Clean Then, to be sure to start with a fresh thunderbird account , don't do that if you already have one and want to preserve you mails and preferences !! << $ rm -rf ~/.thunderbird >> Start it << $ thunderbird >> If thunderbird ask you to import your profile from netscape/mozilla depending on you mail client history, don't import anything, to check the autoconfig job alone !. That should work, just restart the process by setting a different USER variable (USER=procacci, USER=test etc... anyone in you ldap directory ...) to check multiuser autoconfig . 4.4 Bugs reports related ========================= for the record, for old 1.0.X releases ... 4.4.1 Unwanted white space reappeared --------------------------------------- Unfortunatly the 'blank space bug' has reapered in thunderbird 1.0.2 . see: https://bugzilla.mozilla.org/show_bug.cgi?id=229271 Although it was corected in mozilla mainstream : `ozilla/extensions/pref/autoconfig/src/nsLDAPSyncQuery.cpp 1.7.2.1' by late 2004, it is still present in thunderbird 1.0.2 at least :-( , so I applied the workaround I proposed in that bug report (`start_pos '=1;+). 5 Firefox *=*=*=*=*= It's the same principle as above for thunderbird. Binaries ditributions now include support for autoconfig (pref extension !) but unfortunatly not for ldap calls :-( (cf `MOZ_LDAP_XPCOM=1') . It is not vital in firefox as it is for us in thunderbird (need to get the cn and email address to set email account, which are not available by default in the environement viriables ). However I could be usefull to get ldap values for firefox extra config , for example to set the default homepage to the `labeledURI' ldap attribute of the user. 5.1 Autoconfig (pref) and ldap support in packages =================================================== 5.1.1 Add ldap support in firefox 1.5 -------------------------------------- A least from firefox 1.5, autonfig is compiled by default (cf browser, `MOZ_EXTENSIONS_DEFAULT="pref..."') but not ldap (`MOZ_LDAP_XPCOM=1') . You need to recompile the package to get it, cf https://bugzilla.mozilla.org/show_bug.cgi?id=295329 . 5.1.2 Add autoconfig and ldap support in firefox 1.0.X ------------------------------------------------------- Add pref extension (--enable-extensions=pref) and remove --disable-ldap from mozconfig file . One can check how firefox has been compiled by opening `about:buildconfig' (don't know the equivalent for thunderbird!, how as it been compile ??) << about:buildconfig Build platform target i686-pc-linux-gnu Build tools Compiler Version Compiler flags gcc gcc version 3.4.3 20050227 (Red Hat 3.4.3-22.fc3) -Wall -W -Wno-unused -Wpointer-arith -Wcast-align -Wno-long-long -pedantic -pthread -pipe c++ gcc version 3.4.3 20050227 (Red Hat 3.4.3-22.fc3) -fno-rtti -fno-exceptions -Wall -Wconversion -Wpointer-arith -Wcast-align -Woverloaded-virtual -Wsynth -Wno-ctor-dtor-privacy -Wno-non-virtual-dtor -Wno-long-long -pedantic -fshort-wchar -pthread -pipe -I/usr/X11R6/include Configure arguments --disable-mailnews --enable-extensions=cookie,xml-rpc,xmlextras,pref,transformiix,universal chardet,webservices,inspector,gnomevfs,negotiateauth --enable-crypto --disable-composer --enable-single-profile --disable-profilesharing --with-system-jpeg --with-system-zlib --with-system-png --with-pthreads --disable-tests --disable-jsd --disable-installer '--enable-optimize=-Os -g -pipe -m32 -march=i386 -mtune=pentium4' --enable-xft --enable-xinerama --enable-default-toolkit=gtk2 --enable-official-branding --disable-xprint --disable-strip --enable-pango >> 5.2 all.js =========== << [root@b008-02 /usr/lib/firefox-1.5.0.2] $tail -4 greprefs/all.js // autoconfig jehan pref('general.config.obscure_value', 0); pref('general.config.filename', 'firefox.cfg'); >> 5.3 firefox.cfg ================ This file will set the browser home page to the labeledURI page defined in the user's ldap entry , hence it both check that autoconfig + ldap works fine . << [root@b008-02 /usr/lib/firefox-1.5.0.2] $cat firefox.cfg //put everything in a try/catch try { //Privacy & Security defaultPref("signon.rememberSignons", false); // 1) env variables if(getenv("USER") != "") { // *NIX settings var env_user = getenv("USER"); var env_home = getenv("HOME"); } else { // Windows settings var env_user = getenv("USERNAME"); var env_home = getenv("HOMEPATH"); } var env_mozdebug= getenv("MOZILLA_DEBUG"); /* 2) define here (because if set after "3)" below it doesn't work !) processLDAPValues which is eventually called by getLDAPAttributes() just below, check getLDAPAttributes() code from $MOZILLA_HOME/defaults/autoconfig/prefcalls.js to see the inside call to "user defined" processLDAPValues */ function processLDAPValues (values) { if(values) { // set the global var with the values returned from the LDAP query ldap_values = values; var uid = getLDAPValue ( values ,"uid" ); var cn = getLDAPValue ( values ,"cn" ); var mail = getLDAPValue ( values ,"mail" ); var URL = getLDAPValue ( values ,"labeledURI" ); //Debug with popup error messages doesn't work anymore :-( !! var env_mozdebug= getenv("MOZILLA_DEBUG"); if (env_mozdebug) {displayError("NO ERROR , just a debug, cn =" + cn + " and mail = " + mail + " ,labeledURI= " + URL ); } lockPref("browser.startup.homepage", URL ); } } //lockPref("browser.startup.homepage", "http://www.renater.fr/" ); // 3) Call Ldap servers to get Ldap Attributes (mail & cn) , this will finally call processLDAPValues , "2)" just above. getLDAPAttributes("ldap2.int-evry.fr","ou=people,dc=int-evry,dc=fr","uid =" + env_user,"uid,cn,mail,labeledURI"); // Close the try, and call the catch() } catch(e) {displayError("lockedPref", e);} >> 5.4 Debug ========== If you set a username and the `MOZILLA_DEBUG' variable (`$export MOZILLA_DEBUG=1; export USER=procacci'), then the `displayError()' will show you this popup : 14cm!firefox-autoconf-debug.ps That's a popup titled as ``error'', but it's just a debug tool for me as I didn't find any other way to popup information. cf https://bugzilla.mozilla.org/show_bug.cgi?id=206294 : << ------- Comment #14 From Daniel Wang 2003-11-06 09:06 PDT [reply] ------- Jehan Procaccia, you need to change 5.8 to reflect what I said in comment 21. Preference files and config files are special js files with limited scopes. They can only call the get/set pref/env methods and have no access to other objects (need to investigate what exactly are allowed). alert() is a method of the Window object. >> cf also related post in Newsgroups: mozilla.dev.tech.js-engine << Date: Wed, 17 May 2006 19:06:28 +0200 From: jehan procaccia Newsgroups: mozilla.dev.tech.js-engine Subject: scope of js file functions in firefox/thunderbird autoconfig context >> 6 Referecences *=*=*=*=*=*=*=* 6.1 Other docs about autoconfig ================================ http://mit.edu/~firefox/www/maintainers/autoconfig.html http://www.alain.knaff.lu/howto/MozillaCustomization/index.html http://thegoldenear.org/toolbox/windows/docs/mozilla-pre-config.html http://ilias.ca/blog/2005/03/locking-mozilla-firefox-settings.html compile on windows : http://forums.mozillazine.org/viewtopic.php?t=276014 http://www.mozilla.org/community/developer-forums.html http://forums.mozillazine.org/viewtopic.php?p=2090731&highlight=autoco nfig#2090731 http://forums.mozillazine.org/viewtopic.php?p=1354355&highlight=autoco nfig#1354355 http://forums.mozillazine.org/viewtopic.php?p=32783&highlight=autoconf ig#32783 6.2 Related bugzilla ===================== https://bugzilla.mozilla.org/show_bug.cgi?id=295329 https://bugzilla.mozilla.org/show_bug.cgi?id=222973 https://bugzilla.mozilla.org/show_bug.cgi?id=225288 https://bugzilla.mozilla.org/show_bug.cgi?id=178685 https://bugzilla.mozilla.org/show_bug.cgi?id=272970 https://bugzilla.mozilla.org/show_bug.cgi?id=206294 https://bugzilla.mozilla.org/show_bug.cgi?id=302096 7 OLD Mozilla1.X, possibly Netscape 6/7 *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*= The following is for the record ... it also contain an interesting feature that I did not use anymore -> autoconfig from an web server ! 7.1 Changes ============ Between 2002 and 2003, we needed to upgrade the old netscape 4.X (4.79) version to Mozilla 1.X (1.4), and now (2004-2005) mozilla 1.7. The autoconfiguration subsystem is quite the same as described the section on 'old' Netscape 4.X , but also slightly different. 7.2 Mozilla new features in regard to netscape =============================================== In Mozilla, we don't use anymore the convert function from netscape 4.5 CCK, but `moz-byteshift.pl' perl script, to encode `mozilla.cfg' file. The use of the `getLDAPAttributes()' function by calling inside itself the processLDAPValues() as a user defined function (see prefcalls.js) forces us to slighlty change these calls in our original web-cgi javascript (here `mci-mozilla-glob-prefs-tux.cgi' ). The variable generated (mail, cn , uid) are defined only inside the processLDAPValues() function, that explains why lockPref related to these variables are located inside that function. I also couldn't use anymore the alert() fonction, so I changed to displayerror() function ! 7.3 Locating the file on a web server ====================================== That was the case in the Netscape 4.X description above, however, it first was a hard thing to do in Mozilla , cf bug report: http://bugzilla.mozilla.org/show_bug.cgi?id=206294. So now you only need to create a small encoded ` cfg ' file making a call to a web located cgi script which will actually generate the javascript configuration directives to the mozilla client. Hence you can change all of your mozilla clients preferences by simply modifying a single file on a web server, great !. 7.3.1 Call file ---------------- This file calls a cgi on a web server, the cgi generating the javascript code that will set preferences. Here the ` vendor' name (mci-mozilla-web-tux) must match the name of the ` cfg ' file (mci-mozilla-web-tux.cfg). << $ cat mci-mozilla-web-tux.js lockPref("general.config.vendor", "mci-mozilla-web-tux"); lockPref("autoadmin.global_config_url","http://corbeau.int-evry.fr/cgi -bin/mci-mozilla-glob-prefs-tux.cgi"); >> 7.4 Encoding mozilla.js file to mozilla.cfg ============================================ Just use the moz-byteshift.pl perl script which for mozilla1.X and Netscape 6/7 uses a shift of 13, in netscape 4.X it was 7. << $ more moz-byteshift.pl #!/usr/bin/perl # Byteshifting program for mozilla's netscape.cfg files # Old netscape 4.x uses a bytechift of 7 # To decode: moz-byteshift.pl -s -7 netscape.cfg.txt # To encode: moz-byteshift.pl -s 7 netscape.cfg # Mozilla uses a byteshift of 13 # To decode: moz-byteshift.pl -s -13 netscape.cfg.txt # To encode: moz-byteshift.pl -s 13 netscape.cfg # To activate the netscape.cfg file, place the encoded netscape.cfg file # into your C:\Program Files\mozilla.org\Mozilla directory. # Then add the following line to your # C:\Program Files\mozilla.org\Mozilla\defaults\pref\all.js file : # pref("general.config.filename", "mozilla.cfg"); ... $ ./moz-byteshift.pl -s 13 < mci-mozilla-web-tux.js > mci-mozilla-web-tux.cfg >> 7.5 Location of mci-mozilla-web-tux.cfg ========================================= The location of the `netscape.cfg' (here renamed to mci-mozilla-web-tux.cfg) and the way to call it is different from the old netscape 4.X. It's location is in `MOZILLA_HOME ; c:\program files\mozilla.org\mozilla' in windows, or `/usr/lib/mozilla-1.7-3/' in linux Fedora. 7.6 Call to mci-mozilla-web-tux.cfg ===================================== The way to call it is through `all.js' file by adding at the end: << $ tail -2 /usr/lib/mozilla-1.7-3/defaults/pref/all.js pref("general.config.filename", "mci-mozilla-web-tux.cfg"); pref("general.config.vendor", "mci-mozilla-web-tux"); >> 7.7 Web base cgi javascript preferences generator file ======================================================= << [root@corbeau /var/www/cgi-bin] $ cat mci-mozilla-glob-prefs-tux.cgi #!/usr/bin/perl -w print ("Content-type: application/x-javascript-config\n\n"); $page = <<"EOP"; try { var env_user = getenv("USER"); var env_home = getenv("HOME"); var env_mozdebug= getenv("MOZILLA_DEBUG"); function processLDAPValues (values) { var uid = getLDAPValue ( values , "uid" ); var cn = getLDAPValue ( values , "cn" ); var mail = getLDAPValue ( values , "mail" ); lockPref("mail.server.server1.name", mail ); lockPref("mail.identity.id1.fullName", cn); lockPref("mail.identity.id1.useremail", mail); if (env_mozdebug) { displayError("debug mozilla.cfg v2.8", "mail:" + mail + "uid:" + uid + "cn" + cn + "user:" + env_user ); } } //BROWSER /*defaultPref("startup.homepage_override_url", "http://www.int-evry.fr/mci/user/"); lockPref("browser.startup.homepage_override", true); lockPref("browser.startup.page", 1); defaultPref("browser.startup.homepage", "http://www.int-evry.fr/mci/user/"); */ lockPref("browser.startup.homepage", "http://www.int-evry.fr/mci/user/"); lockPref("browser.startup.homepage_override", true); lockPref("general.config.vendor", "mci-mozilla-web-tux"); lockPref("startup.homepage_override_url", "http://www.int-evry.fr/mci/user/"); lockPref("browser.cache.disk.capacity", 0); lockPref("network.cookie.cookieBehavior", 0); lockPref("network.proxy.autoconfig_url", "http://www.int-evry.fr/local/config.proxy"); lockPref("network.proxy.type", 2); //Account lockPref("mail.account.account1.identities", "id1"); lockPref("mail.account.account1.server", "server1"); lockPref("mail.account.account2.server", "server2"); lockPref("mail.account.account3.server", "server3"); lockPref("mail.accountmanager.accounts", "account1,account2,account3"); lockPref("mail.accountmanager.defaultaccount", "account1"); //imap lockPref("mail.server.server1.hostname", "imap-int.int-evry.fr"); lockPref("mail.server.server1.type", "imap"); lockPref("mail.server.server1.login_at_startup", true); lockPref("mail.identity.id1.draft_folder", "imap://" + env_user + "@imap-int.int-evry.fr/Drafts"); lockPref("mail.identity.id1.drafts_folder_picker_mode", "0"); lockPref("mail.identity.id1.fcc_folder", "imap://" + env_user + "@imap-int.int-evry.fr/Sent"); lockPref("mail.identity.id1.fcc_folder_picker_mode", "0"); lockPref("mail.identity.id1.stationery_folder", "imap://" + env_user + "@imap-int.int-evry.fr/Templates"); lockPref("mail.identity.id1.tmpl_folder_picker_mode", "0"); lockPref("mail.identity.id1.valid", true); lockPref("mail.identity.id1.overrideGlobal_Pref", true); lockPref("mail.server.server1.download_on_biff", true); lockPref("mail.server.server1.login_at_startup", true); lockPref("mail.server.server1.userName", env_user ); lockPref("mail.server.server1.delete_model", 0); //SMTP lockPref("mail.identity.id1.smtpServer", "smtp1"); defaultPref("mail.smtpserver.smtp1.auth_method", 0); lockPref("mail.smtpservers", "smtp1"); lockPref("mail.smtpservers", "smtp1"); lockPref("mail.smtp.defaultserver", "smtp1"); lockPref("mail.smtpserver.smtp1.hostname", "smtp-int.int-evry.fr"); lockPref("mail.identity.id1.organization", "INT Evry France"); lockPref("mail.startup.enabledMailCheckOnce", true); lockPref("mail.ui.folderpane.version", 3); lockPref("mailnews.ui.threadpane.version", 2); //LDAP config lockPref("mail.identity.id1.directoryServer", "ldap_2.servers.ldapint"); lockPref("ldap_2.prefs_migrated", true); lockPref("ldap_2.servers.history.filename", "history.mab"); lockPref("ldap_2.servers.history.replication.lastChangeNumber", 0); lockPref("ldap_2.servers.ldapint.auth.savePassword", true); lockPref("ldap_2.servers.ldapint.description", "ldap-int"); lockPref("ldap_2.servers.ldapint.filename", "abook-1.mab"); lockPref("ldap_2.servers.ldapint.position", 3); lockPref("ldap_2.servers.ldapint.uri", "ldap://ldap1.int-evry.fr:389/ou=people,dc=int-evry,dc=fr??sub"); lockPref("ldap_2.servers.pab.filename", "abook.mab"); lockPref("ldap_2.servers.pab.replication.lastChangeNumber", 0); //News config lockPref("mail.server.server3.hostname", "news.int-evry.fr"); lockPref("mail.server.server3.max_cached_connections", 2); lockPref("mail.server.server3.name", "news.int-evry.fr"); lockPref("mail.server.server3.type", "nntp"); lockPref("mail.server.server3.userName", env_user ); //Call to ldap to get user's attribute . getLDAPAttributes ( "ldap2.int-evry.fr", "ou=people,dc=int-evry,dc=fr", "uid=" +env_user , "uid,cn,mail" ); } catch(e) { displayError("lockedPref", e); } EOP print $page; >> 7.8 Windows particularities ============================ Without web base cgi file, beware that in windows, the original (before encoding) mozilla.js file must start with: `//BEGIN CE prefs ' , if not you'll get ``failed to read configuration file ...'' message, and mozilla won't start :-( . In Windows environement variables like USER or HOME, are USERNAME and HOMEPATH, that's why we must create a different pair of configuration files (cfg and cgi) for both systems (linux/windows). Perhaps there's a way in javascript to dectect operating system and hence use either USER or USERNAME, but I'am not that fluent in javascript to do that, let me know if you know ...// 7.8.1 Windows Call file ------------------------ << $ cat mci-mozilla-web-win.js lockPref("general.config.vendor", "mci-mozilla-web-win"); lockPref("autoadmin.global_config_url","http://corbeau.int-evry.fr/cgi -bin/mci-mozilla-glob-prefs-win.cgi"); >> 7.8.2 Windows all.js file -------------------------- To be encoded by moz-byteshift.pl as stated above ... << c:\type c:\program files\mozilla.org\mozilla\defaults\pref\all.js pref("general.config.filename", "mci-mozilla-web-win.cfg"); pref("general.config.vendor", "mci-mozilla-web-win"); >> 7.8.3 Windows cgi file ----------------------- << $ cat mci-mozilla-glob-prefs-win.cgi #!/usr/bin/perl -w print ("Content-type: application/x-javascript-config\n\n"); $page = <<"EOP"; try { var env_user = getenv("USERNAME"); var env_home = getenv("HOMEPATH"); var env_mozdebug= getenv("MOZILLA_DEBUG"); ... >> The rest of the file is identical to the linux version, only env var are different !. 7.9 Versions tested ==================== This configuration was validated on linux with mozilla 1.4 , 1.6 and 1.7, and on windows with mozilla 1.4, 1.5, 1.7. 8 Debuging - bugzilla *=*=*=*=*=*=*=*=*=*=*= 8.1 Run time messages ====================== Notice the presence of `var env_mozdebug=getenv("MOZILLA_DEBUG")' which allows use to print debugging messages if `MOZILLA_DEBUG' is define either in shell for unix (`export MOZILLA_DEBUG=1') or in command.com environement in windows (`set MOZILLA_DEBUG=1') 8.2 Blank space bug ==================== I noticed a problem which is due to be corrected in 1.8 I think ... here's the report and workaround: http://bugzilla.mozilla.org/show_bug.cgi?id=229271 in short add the following : << start_pos += search_key.length; //start start_pos +=1; //end >> to function `getLDAPValue()' in `autoconfig/preffcalls.js'. 8.3 Documentation ================== I also opened a report on the lack of documentation: http://bugzilla.mozilla.org/show_bug.cgi?id=178685 which ended to the wonderfull doc: http://wangrepublic.org/daniel/mozilla/prefs/ . 8.4 defeultPref for homepage ============================= I cannot set the homepage with the defaultPref function, so that is is set by default, but still allow the user to change it !. A bugzilla is openned on this, see https://bugzilla.mozilla.org/show_bug.cgi?id=272970 8.5 greprefs right access ========================== Beware also on Linux that `MOZILLA_HOME/greprefs' directory is closed by default to users and then autoconfig doesn't work properly, I 've opened a bugzilla on this: https://bugzilla.mozilla.org/show_bug.cgi?id=270623. Workaround -> `chmod 755 greprefs' !. 8.6 cgi base config file ========================= there has been a issue about the use of `autoadmin.global_config_url', see : http://bugzilla.mozilla.org/show_bug.cgi?id=206294 9 Mail folders *=*=*=*=*=*=*=* Implementing that solution, we encounter difficulties with mail folder. First idea was to use local mail fodlers from homedirectory of the current user. In unix that would have been `$HOME/nsmail/...' , in windows it would have been a samba mount of that same unix path (ex: `U:\nsmail' ; with `U:' =samba mount: `\\samba-server\%USERNAME'). Unfortunaltly file system writes and/or mail format differs between windows and unix, and folders becomes soon unreadable or even corrupted when read/written from one system and then the other. That's why we finally decided to use IMAP, and hence imap folders. By migrating from University of Whashinghton IMAP server to Cyrus IMAP we also inherited some intersting features like quotas, share folders, ACL, mail only account (no need for /etc/passwd entry !) much better performances, etc ... 10 reliabilty *=*=*=*=*=*=*= 10.1 failover and uniqueness ============================= A contribution from Roberto Aguilar gives to the mozilla autoconfig javascript a way to search through different ldap replicas in case one ldap server is down. It also allow us to use a single javscript for both systems (Linux and Windows) with a subtule `if ... else' test on environement variables. 10.2 Ldap failover =================== Creating an array of possible running ldap servers permits an ldap failover, then a shuffle function allows us to randomly pick up a running ldap server. The suffle function comes from here: << http://www.mickweb.com/javascript/arrays/pureshuffle.html Before publishing the code changes, please add this right before the shuffle function: /** * setup the shuffle method for an array, from "mickweb script * factory" at: * http://www.mickweb.com/javascript/arrays/pureshuffle.html */ >> Here's how the ldap failover works: << // 2) setup multiple LDAP servers for failover var ldap_values; var ldap_servers = new Array('ldap2.int-evry.fr', 'ldap1.int-evry.fr', 'openldap.int-evry.fr' ); // shuffle function to randomize the server array // setup the shuffle method for an array Array.prototype.shuffle = function(times) { var i,j,t,l=this.length; while(times--) { with(Math) { i = floor(random()*l); j = floor(random()*l); } t = this[i]; this[i] = this[j]; this[j] = t; } return this; } // mix up the ldap servers so we don't hit the same one each time ldap_servers.shuffle(10); .... // 4) Call Ldap servers to get Ldap Attributes (mail & cn) , this will finally call processLDAPValues , "3)" just above. // Go through the ldap replicas list for(i = 0; i < ldap_servers.length; i ++) { // Search for attribute mail & cn through ldap servers where uid = $USER|$USERNAME getLDAPAttributes(ldap_servers[i], "ou=people,dc=int-evry,dc=fr", "uid=" + env_user, "uid,cn,mail"); // If we catch a running ldap server, exit the loop, if(ldap_values) { running_ldap_server = ldap_servers[i]; // If $MOZILLA_DEBUG=1 display in a popup the running server if (env_mozdebug) { displayError("getLDAPAttributes: debug 2 running_ldap_server : " + running_ldap_server); } break; } } >> 10.3 Unique script for windows and linux ========================================= an ` if ... else' test permits us to check wether we use linux or windows environement variable for the `USER / USERNAME' << // 1) env variables if(getenv("USER") != "") { // *NIX settings var env_user = getenv("USER"); var env_home = getenv("HOME"); } else { // Windows settings var env_user = getenv("USERNAME"); var env_home = getenv("HOMEPATH"); } var env_mozdebug= getenv("MOZILLA_DEBUG"); >> 10.4 Final production script ============================= Here's the complete final and commented production script: << //Mozilla autoconfiguration, Jehan Procaccia & Roberto Aguilar //put everything in a try/catch try { /* 1) define environement variables, 2) list & randomize ldap replicas, 3) define processLDAPValues(), 4) Call Ldap server to get Ldap Attributes (mail & cn) getLDAPAttributes() 5) set user preferences */ // 1) env variables if(getenv("USER") != "") { // *NIX settings var env_user = getenv("USER"); var env_home = getenv("HOME"); } else { // Windows settings var env_user = getenv("USERNAME"); var env_home = getenv("HOMEPATH"); } var env_mozdebug= getenv("MOZILLA_DEBUG"); // 2) setup multiple LDAP servers for failover var ldap_values; var ldap_servers = new Array('ldap2.int-evry.fr', 'ldap1.int-evry.fr', 'openldap.int-evry.fr' ); // shuffle function to randomize the server array /** * setup the shuffle method for an array, from "mickweb script * factory" at: * http://www.mickweb.com/javascript/arrays/pureshuffle.html */ // setup the shuffle method for an array Array.prototype.shuffle = function(times) { var i,j,t,l=this.length; while(times--) { with(Math) { i = floor(random()*l); j = floor(random()*l); } t = this[i]; this[i] = this[j]; this[j] = t; } return this; } // mix up the ldap servers so we don't hit the same one each time ldap_servers.shuffle(10); /* 3) define here (because if set after "4)" below it doesn't work !) processLDAPValues which is eventually called by getLDAPAttributes() just below, check getLDAPAttributes() code from $MOZILLA_HOME/defaults/autoconfig/prefcalls.js to see the inside call to "user defined" processLDAPValues */ function processLDAPValues (values) { if(values) { // set the global var with the values returned from the LDAP query ldap_values = values; var uid = getLDAPValue ( values ,"uid" ); var cn = getLDAPValue ( values ,"cn" ); var mail = getLDAPValue ( values ,"mail" ); // lock ldap variable (mail & cn) dependant preferences while we have access to them lockPref("mail.server.server1.name",mail); lockPref("mail.identity.id1.fullName",cn); lockPref("mail.identity.id1.useremail",mail); defaultPref("network.ftp.anonymous_password", mail); // if $MOZILLA_DEBUG=1 , popup a debug message if (env_mozdebug) { displayError("NO ERROR -> MCI (jehan.procaccia@int-evry.fr)" + "\nthis message is displayed with displayError() ! \ndebug 1 mozilla.cfg v3.2 , NO FAILED, S2IA again !", "\nmail:" + mail + "\nuid:" +uid + "\ncn:" +cn + "\nuser:" + env_user); } } } // 4) Call Ldap servers to get Ldap Attributes (mail & cn) , this will finally call processLDAPValues , "3)" just above. // Go through the ldap replicas list for(i = 0; i < ldap_servers.length; i ++) { // Search for attribute mail & cn through ldap servers where uid = $USER|$USERNAME getLDAPAttributes(ldap_servers[i], "ou=people,dc=int-evry,dc=fr", "uid=" + env_user, "uid,cn,mail"); // If we catch a running ldap server, exit the loop, if(ldap_values) { running_ldap_server = ldap_servers[i]; // If $MOZILLA_DEBUG=1 display in a popup the running server if (env_mozdebug) { displayError("getLDAPAttributes: debug 2 running_ldap_server : " + running_ldap_server); } break; } } // 5) Set user preferences //BROWSER lockPref("browser.startup.homepage", "http://www.int-evry.fr/s2ia/portail/"); //unlockPref("browser.startup.homepage"); lockPref("browser.startup.homepage_override", true); lockPref("startup.homepage_override_url", "http://www.int-evry.fr/s2ia/portail/"); //unlockPref("startup.homepage_override_url"); lockPref("browser.cache.disk.capacity", 100); lockPref("network.cookie.cookieBehavior", 0); //Network preferences lockPref("network.proxy.autoconfig_url", "http://www.int-evry.fr/local/config.proxy"); lockPref("network.proxy.type", 2); //Privacy & Security defaultPref("signon.rememberSignons", false); //Account lockPref("mail.account.account1.identities", "id1"); lockPref("mail.account.account1.server", "server1"); lockPref("mail.account.account2.server", "server2"); lockPref("mail.account.account3.server", "server3"); lockPref("mail.accountmanager.accounts", "account1,account2,account3"); lockPref("mail.accountmanager.defaultaccount", "account1"); //imap lockPref("mail.server.server1.hostname", "imap-int.int-evry.fr"); lockPref("mail.server.server1.type", "imap"); lockPref("mail.server.server1.login_at_startup", true); lockPref("mail.identity.id1.draft_folder", "imap://" + env_user + "@imap-int.int-evry.fr/Drafts"); lockPref("mail.identity.id1.drafts_folder_picker_mode", "0"); lockPref("mail.identity.id1.fcc_folder", "imap://" + env_user + "@imap-int.int-evry.fr/Sent"); lockPref("mail.identity.id1.fcc_folder_picker_mode", "0"); lockPref("mail.identity.id1.stationery_folder", "imap://" + env_user + "@imap-int.int-evry.fr/Templates"); lockPref("mail.identity.id1.tmpl_folder_picker_mode", "0"); lockPref("mail.identity.id1.valid", true); lockPref("mail.identity.id1.overrideGlobal_Pref", true); lockPref("mail.server.server1.download_on_biff", true); lockPref("mail.server.server1.login_at_startup", true); lockPref("mail.server.server1.userName", env_user ); lockPref("mail.server.server1.delete_model", 0); //SMTP defaultPref("mail.identity.id1.smtpServer", "smtp1"); defaultPref("mail.smtpserver.smtp1.auth_method", 0); defaultPref("mail.smtpservers", "smtp1"); defaultPref("mail.smtpservers", "smtp1"); defaultPref("mail.smtp.defaultserver", "smtp1"); defaultPref("mail.smtpserver.smtp1.hostname", "smtp-int.int-evry.fr"); lockPref("mail.identity.id1.organization", "INT Evry France"); lockPref("mail.startup.enabledMailCheckOnce", true); lockPref("mail.ui.folderpane.version", 3); lockPref("mailnews.ui.threadpane.version", 2); //LDAP config lockPref("mail.identity.id1.directoryServer", "ldap_2.servers.ldapint"); lockPref("ldap_2.prefs_migrated", true); lockPref("ldap_2.servers.history.filename", "history.mab"); lockPref("ldap_2.servers.history.replication.lastChangeNumber", 0); lockPref("ldap_2.servers.ldapint.auth.savePassword", true); lockPref("ldap_2.servers.ldapint.description", "ldap-int"); lockPref("ldap_2.servers.ldapint.filename", "abook-1.mab"); lockPref("ldap_2.servers.ldapint.position", 3); lockPref("ldap_2.servers.ldapint.uri", "ldap://ldap1.int-evry.fr:389/ou=people,dc=int-evry,dc=fr??sub"); lockPref("ldap_2.servers.pab.filename", "abook.mab"); lockPref("ldap_2.servers.pab.replication.lastChangeNumber", 0); //News config lockPref("mail.server.server3.hostname", "news.int-evry.fr"); lockPref("mail.server.server3.max_cached_connections", 2); lockPref("mail.server.server3.name", "news.int-evry.fr"); lockPref("mail.server.server3.type", "nntp"); lockPref("mail.server.server3.userName", env_user ); // Close the try, and call the catch() } catch(e) { displayError("lockedPref", e); } >> 10.5 for the record, old reliabily scripts ... =============================================== At least tested on Netscape4.X In the original files above (in Netscape 4.X section), we hard coded a single web server to retrieve the javascrip preference file, and a single hard coded ldap server to get mail and cn attributes. It would be safer to get secondary servers in case of failure. For the web server name we can use an ldap query to get the list of possible ones. hence we won't have to reencode netscape.cfg file at every changes. We set the netscape.cfg file just once while imaging computers with the operationg system, then any changes hapens in ldap or on the web server javascript preference file (central configuration). 10.5.1 Enhence netscape.cfg ---------------------------- Defining the list of possible web servers to query in `netscape.cfg'. We also set there the javascript preference file names so that `netscape.cfg' doesn't need to be change after imaging the computers at every changes we need to do . 10.5.2 LDAP web server list subtree ------------------------------------ << $ ldapsearch -x * -b "ou=browser,ou=information,dc=int-evry, dc=fr" cn -LLL dn: ou=browser,ou=information,dc=int-evry,dc=fr dn: sn=http_server,ou=browser,ou=information,dc=int-evry, dc=fr cn: web1.int-evry.fr cn: web2.int-evry.fr dn: sn=http_unix_file, ou=browser,ou=information,dc=int-evry, dc=fr cn: /browser/config_file_unix.jsc dn: sn=http_win_file, ou=browser,ou=information,dc=int-evry, dc=fr cn: /browser/config_file_win.jsc >> 10.5.3 netscape.cfg -------------------- Here we select an operational ldap server simply by testing a ldap query, to make sure that our ldap queries for setting preferences will be answered . (again I am not fluent in javascript, there should be a better way to make sure that an ldap server is up and running, as for to check a web server, feel free to optimize this code, and let me know ...) << if ( getLDAPAttributes( "ldap1.int-evry.fr", \ "ou=browser,ou=information,dc=int-evry,dc=fr", \ "sn=http_server", "cn") ) var running_ldap_server = "ldap1.int-evry.fr"; else if ( getLDAPAttributes( "ldap2.int-evry.fr", \ "ou=browser,ou=information,dc=int-evry,dc=fr", \ "sn=http_server", "cn") ) var running_ldap_server = "ldap2.int-evry.fr"; else if ( getLDAPAttributes( "ldap0.int-evry.fr", \ "ou=browser,ou=information,dc=int-evry,dc=fr", \ "sn=http_server", "cn") ) var running_ldap_server = "ldap0.int-evry.fr"; else alert("No LDAP server availaible !!"); >> Here's a complete exemple of the unix netscape.cfg file. << with (PrefConfig) { // Must be done inside the PrefConfig module // create some variables we might want to use later on... var env_user = getenv("USER"); // Windows username var env_home = getenv("HOME"); // User HomeDir var env_mozilla_home = getenv("MOZILLA_HOME"); var env_mozdebug = getenv("MOZILLA_DEBUG"); //check which ldap server is running (needs a better procedure !) if ( getLDAPAttributes( "ldap1.int-evry.fr", \ "ou=browser,ou=information,dc=int-evry,dc=fr", \ "sn=http_server", "cn") ) var running_ldap_server = "ldap1.int-evry.fr"; else if ( getLDAPAttributes( "ldap2.int-evry.fr", \ "ou=browser,ou=information,dc=int-evry,dc=fr", \ "sn=http_server", "cn") ) var running_ldap_server = "ldap2.int-evry.fr"; else if ( getLDAPAttributes( "ldap0.int-evry.fr", \ "ou=browser,ou=information,dc=int-evry,dc=fr", \ "sn=http_server", "cn") ) var running_ldap_server = "ldap0.int-evry.fr"; else alert("No LDAP server availaible !!"); if (running_ldap_server){ var ldap_http_server_values = getLDAPAttributes( running_ldap_server, \ "ou=browser,ou=information,dc=int-evry,dc=fr", "sn=http_server", "cn"); var ldap_http_server = getLDAPValue(ldap_http_server_values, "cn"); var ldap_http_unix_uri_values = getLDAPAttributes( running_ldap_server, \ "ou=browser,ou=information,dc=int-evry,dc=fr", "sn=http_unix_file", "cn"); var ldap_http_unix_uri = getLDAPValue(ldap_http_unix_uri_values, "cn"); var values = getLDAPAttributes( running_ldap_server, \ "ou=people,dc=int-evry,dc=fr", "uid="+env_user, "cn,mail" ); var ldap_email = getLDAPValue(values, "mail"); var ldap_gecos = getLDAPValue(values, "cn"); env_user=env_user.toLowerCase(); } else alert("No LDAP server available, autoconfig impossible !"); //popup debug message if export MOZILLA_DEBUG=1 if (env_mozdebug) { alert("MOZILLA_DEBUG\nrunning ldap server: " + running_ldap_server ); alert("MOZILLA_DEBUG\nExecuting " + ldap_http_server + \ ldap_http_unix_uri ); alert("MOZILLA_DEBUG\nfetching http://" + ldap_http_server \ + ldap_http_unix_uri + "" ); } //go fetch the prefence file in a HTTP server //needs a way to check if http server is running ! config( "autoadmin.global_config_url", "http://" + ldap_http_server + \ ldap_http_unix_uri + "" ); // Since we use a file, if it's not accessible, something is // terribly wrong anyway config( "autoadmin.failover_to_cached", false ); // don't use ?useremail=email-addr to cgi URL request config( "autoadmin.append_emailaddr", false ); } // with (PrefConfig) >> For the windows version of that `netscape.cfg' file, we replace ```sn=http_unix_file''' by ``` sn=http_win_file''' in the ldap query . 11 OLD Netscape 4.X *=*=*=*=*=*=*=*=*=*= 11.1 call file, netscape.cfg ============================= In the following example, that file is a ``call'' file, because it will actually be used to only redirect call to an even more centralized file, a file that will be located on a web server. That allows us first to encode (byteshift) just once that file (`netscape.cfg') because it will call an non encoded javascript file `config_file_system.jsc' (or whatever name) on the web server. Second, as that latest javascript file is located on a web server, there's no need to recopy it on every station at every single changes !. That feature is available through `autoadmin.global_config_url' directive as in `config("autoadmin.global_config_url","http://www/browser/config-file-sy stem.jsc");' for example. Unfortunaltly I am unable to run that really usefull directive with Netscape6/7 or Mozilla1.X :-( , if anyone knows how, please let me known !. In windows that encoded `netscape.cfg' file is located in `NETSCAPE_HOME\Communicator\Program' (`C:\Program Files\netscape\Communicator\Programs') , in RedHat 7.3 it is in `/usr/lib/X11/app-defaults' . Beware that in windows, that file is already there, hence it must be saved before beeing replaced by our one, in order to come back to a normal state in case of problem. If neither original or personalized netscape.cfg is there, netscape won't start !. << // This file is not usable in its present form. it must be encoded // with the ``convert'' fonction of the CCK ``file'' menu // Netscapes' Flow of preference configuration: // configure defaults from internal javascript file in ns executable // global prefs from netscape.cfg (this file) // executes ~/.netscape/preferences.js file // executes ~/.netscape/user.js // (somewhere in here liprefs.js is run, but i haven't yet figured out // what liprefs is for....) //==================================================================== ===== with (PrefConfig) { // Must be done inside the PrefConfig module // create some variables we might want to use later on... var platform = getPlatform(); // E.G. SunOS4.1.3_U1 var env_user = getenv("USER"); // Unix username var env_home = getenv("HOME"); // User HomeDir var env_display = getenv("DISPLAY"); // X11 Display var env_editor = getenv("EDITOR"); // use in mail edit? var env_visual = getenv("VISUAL"); // use in mail edit? var env_mozilla_home = getenv("MOZILLA_HOME") var env_mozdebug = getenv("MOZILLA_DEBUG") // For ease of update... We use the AutoAdmin operation to redirect // netscape.cfg to read the plain-text "config-file-unix.jsc" file. // Any changes // from now on can be made here w/o re-encoding the netscape.jsc file to // netscape.cfg. config( "autoadmin.global_config_url", \ "http://lugdunum.int-evry.fr/browser/config-file-unix.jsc" ); // How often (in minutes) to update // Every 6 hours seems a good interval to keep hosers who don't ever // exit netscape updated on current changes. config( "autoadmin.refresh_interval", 360 ); // Since we use a file, if it's not accessible, something is // terribly wrong anyway config( "autoadmin.failover_to_cached", false ); // don't use ?useremail=email-addr to cgi URL request config( "autoadmin.append_emailaddr", false ); >> 11.2 LockPref configuration file ================================= That file ( on the web server:http://www/browser/config-file-system.jsc ) is where we set and lock Preferences. Because computers are shared, we need to personnalize preferences base on the user login. The login is taken from environement variable, `USER' in unix, `USERNAME' in Windows. Different environement name and different path between windows and unix, explain why we need 2 different configuration file. There might be a way to manage those differences within a same file, but I am not very fluent in javascript :-( . Here is an example of a lockPref preference configuration file for unix (`config_file_unix.jsc'). We lock (`lockPref') some preferences (imap server name, companie name, cache location and size ...), others can be just set as default (`defaultPref'); startup.homepage ... We also use LDAP functions (from prefcalls.js) to get the current user (USER or USERNAME) email address and common name, respectively `mail' and `cn' in ldap. << [root@lugdunum /var/www/html/browser] $ more config_file_unix.jsc // Functions you can use: // lockPref(name,value) user is disallowed from changing // (aka lock_pref() ) // defaultPref(name,value) unless user overrides, this is value // (aka default_pref() ) // unlockPref(name) unlock previously "lockPref"-ed name // config(name,value) usually for menus... // value = getPref(name) gets current setting // getLDAPAttributes( host, base, filter, attributes ) // getLDAPValue( values, attribute ) // .mime.type, .begin_mime_def, .end_mime_def.. // .plat // alert(message); // var = prompt(message); // var = getPlatform() returns Win32,... // getPlatform().contains("UNIX")... // var = getenv(envvar) // var = putenv(envvar) // // Objects/Functions you *can't* use because they aren't defined // navigator.* (argh, this *REALLY* bites) //==================================================================== ===== // Preferences Configuration //==================================================================== ===== with (PrefConfig) { var values = getLDAPAttributes( "ldap2.int-evry.fr", \ "ou=people,dc=int-evry,dc=fr", "uid="+env_user, "cn,mail" ); var ldap_email = getLDAPValue(values, "mail"); var ldap_gecos = getLDAPValue(values, "cn"); //var toto = prompt("email"); //alert("ldap_mail = " + ldap_email + "toto="+toto ); if (env_mozdebug) { alert("env_user:" + env_user + "\nenv_home:" + env_home + \ "\nldap_email:" + ldap_email + "\nldap_gecos:" + ldap_gecos + "\n"); } //-------------------------------------------------------------------- --- // [ General Browser configuration ] //-------------------------------------------------------------------- --- config( "autoadmin.refresh_interval", 1440); // auto-update every 24 hours defaultPref("browser.startup.page",1); //0=blank page, 1=homepage, 2=last visited defaultPref("browser.startup.homepage", "http://www/mci/mode-d-emploi.shtml" ); lockPref("browser.cache.directory", "/tmp"); lockPref("browser.cache.memory_cache_size", 0); lockPref("mail.server_type",1); // POP=0 IMAP=1 lockPref("network.hosts.imap_servers", "pop-int"); lockPref("mail.imap.server.pop-int.using_subscription",true); lockPref("mail.imap.server.pop-int.userName", env_user); lockPref("mail.identity.useremail", ldap_email); lockPref("mail.identity.username", ldap_gecos); lockPref("mail.check_new_mail", false); lockPref("mail.directory", env_home+"/nsmail"); lockPref("mail.identity.defaultdomain", "int-evry.fr"); lockPref("mail.identity.organization", "INT Evry Essonne "); // Ldap lockPref("ldap_2.autoComplete.useDirectory", true); lockPref("ldap_2.servers.LDAPINT.autoComplete.enabled", true); lockPref("ldap_2.servers.LDAPINT.csid", "UTF-8"); lockPref("ldap_2.servers.LDAPINT.description", "LDAP INT"); lockPref("ldap_2.servers.LDAPINT.filename", "LDAPINT.na2"); lockPref("ldap_2.servers.LDAPINT.position", 2); lockPref("ldap_2.servers.LDAPINT.searchBase", "ou=people,dc=int-evry,dc=fr"); lockPref("ldap_2.servers.LDAPINT.serverName", "ldap1.int-evry.fr"); //news lockPref("news.directory", "/tmp"); //proxy lockPref("network.proxy.autoconfig_url", \ "http://www.int-evry.fr/local/config.proxy"); } // with (PrefConfig) >> ----------------------------------------------------------------------- This document was translated from LaTeX by HeVeA (http://pauillac.inria.fr/~maranget/hevea/index.html).