Comment 58 for bug 233901

Revision history for this message
In , Jehan-procaccia (jehan-procaccia) wrote :

After reading comment 8 From Gokhan Topalhan , I did made it work on linux :-)
I don't know what is the vendor.cfg file ? where it should be and how to tell
mozilla to read it, so I kept playing with all.js as follows:

Create the autoamdin.global_config_url file

$ 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");
lockPref("autoadmin.append_emailaddr",true);

Encode it:

$ ./moz-byteshift.pl -s 13 < mci-mozilla-web-tux.js > mci-mozilla-web-tux.cfg

move cfg file to mozilla-home:

$ cp mci-mozilla-web-tux.cfg /usr/lib/mozilla-1.4/

Add the 2 following lines to all.js

$ tail -2 /usr/lib/mozilla-1.4/defaults/pref/all.js
pref("general.config.filename", "mci-mozilla-web-tux.cfg");
pref("general.config.vendor", "mci-mozilla-web-tux");

and here's my perl cgi script on the web server:

$ cat /var/www/cgi-bin/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
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 ( "localhost", "ou=people,dc=int-evry,dc=fr", "uid=" +env_user
, "uid,cn,mail" );

} catch(e) {
  displayError("lockedPref", e);
}
EOP
print $page;

First id didn't worked, mozilla just vanished ... then a strace showed:
open("/usr/lib/mozilla-1.4/components/compreg.dat.tmp",
O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0666) = -1 EACCES (Permission denied)

so i temporarely did:
$ chmod 777 /usr/lib/mozilla-1.4/components/
!? don't know what this pb is about ??

And now it works just fine :-). All of this begin to be a bit of "magic" or
"black box" but it finally do what I want, centralize a lockpref file on a web
server :-) . I'll update my doc
(http://www.int-evry.fr/mci/user/procacci/netscape/en/mozilla-autoconfig-en.html)
as soon as I clarify all this . Any comment on the purpose of the vendor.cfg
file, where it should be, how to call it ? Is my use of all.js wrong ?

I still need to test on windows though ...