package MozConfig; use strict; use CGI; use vars qw($VERSION @ISA @EXPORT @EXPORT_OK); use Apache::Constants qw(:common); use Apache::Reload; require Exporter; @ISA = qw(Exporter AutoLoader); @EXPORT = qw( ); $VERSION = '0.21'; my $confserver = "mozconfig.komi.mts.ru"; my $ldapserver = "ldap.komi.mts.ru"; my $newsserver = "news.komi.mts.ru"; my $basedn = "ou=People,dc=komi,dc=mts,dc=ru"; my (undef,undef,undef,$newsers) = getgrnam('newsers'); my (undef,undef,undef,$lfolders) = getgrnam('lf'); my $page = <<"EOF"; try { var env_user = getenv("USERNAME"); var env_home = getenv("HOMEPATH"); var env_profile = getenv("USERPROFILE"); var env_mozdebug = getenv("MOZILLA_DEBUG"); var newsers = "$newsers"; var lfolders = "$lfolders"; var useringroup = new RegExp("\\\\b" + env_user + "\\\\b"); var lckaccounts = "account1"; function utf8 (text) { var decoded_text; var first_byte,second_byte, first_byte_decoded, second_byte_decoded; decoded_text = ""; for(var pos = 0; pos < text.length; pos++) { var c = text.charCodeAt(pos); if (c > 128) { first_byte = parseInt(c/256); second_byte = c % 256; first_byte_decoded = 192 + first_byte * 4 + parseInt(second_byte/64); second_byte_decoded = 128 + second_byte % 64; decoded_text =decoded_text + String.fromCharCode(first_byte_decoded) + String.fromCharCode(second_byte_decoded); } else { decoded_text = decoded_text + String.fromCharCode(c); } } return decoded_text; } function processLDAPValues (values) { var cn = getLDAPValue(values, "cn"); var uid = getLDAPValue(values, "uid"); var gecos = getLDAPValue(values, "gecos"); var mail = getLDAPValue(values, "mail"); var mailHost = getLDAPValue(values, "mailHost"); var org = getLDAPValue(values, "o"); cn = cn.replace(/^\\s+/, ""); uid = uid.replace(/^\\s+/, ""); gecos = gecos.replace(/^\\s+/, ""); mail = mail.replace(/^\\s+/, ""); mailHost = mailHost.replace(/^\\s+/, ""); if (env_mozdebug) { displayError( "AutoConfig", "$VERSION\\n" + "env_user: [" + env_user + "]\\n" + "gecos: [" + gecos + "]\\n" + "uid: [" + uid + "]\\n" + "cn: [" + cn + "]\\n" + "mail: [" + mail + "\\n" + "mailHost: [" + mailHost + "]\\n" + "org: [" + org + "]\\n" ); } /* preferences */ /* browser */ lockPref("browser.bookmarks.added_static_root", true); lockPref("browser.cache.disk.capacity", 0); lockPref("browser.download.dir", env_profile); lockPref("browser.display.use_system_colors", true); lockPref("browser.startup.page", 0); lockPref("general.config.vendor", "mozweb32"); lockPref("browser.tabs.loadGroup", 0); lockPref("browser.tabs.loadInBackground", true); lockPref("browser.tabs.opentabfor.middleclick", true); lockPref("browser.tabs.opentabfor.urlbar", true); lockPref("browser.tabs.warnOnClose", false); lockPref("general.skins.selectedSkin", "modern/1.0"); lockPref("intl.charsetmenu.browser.cache", "windows-1251"); /* ldap */ lockPref("ldap_2.autoComplete.directoryServer", "ldap_2.servers.MTSKomi"); lockPref("ldap_2.autoComplete.useDirectory", true); lockPref("ldap_2.prefs_migrated", true); lockPref("ldap_2.servers.MTSKomi.auth.savePassword", true); lockPref("ldap_2.servers.MTSKomi.description", utf8(org)); lockPref("ldap_2.servers.MTSKomi.filename", "abook-1.mab"); lockPref("ldap_2.servers.MTSKomi.maxHits", 500); lockPref("ldap_2.servers.MTSKomi.position", 3); lockPref("ldap_2.servers.MTSKomi.uri", "ldap://$ldapserver:389/$basedn??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); /* imap */ lockPref("mail.account.account1.identities", "id1"); lockPref("mail.account.account1.server", "server1"); lockPref("mail.accountmanager.defaultaccount", "account1"); lockPref("mail.forward_message_mode", 2); lockPref("mail.identity.id1.doBcc", false); lockPref("mail.identity.id1.doBccList", ""); lockPref("mail.identity.id1.draft_folder", "imap://" + uid + "@" + mailHost + "/INBOX/&BCcENQRABD0EPgQyBDgEOgQ4-"); lockPref("mail.identity.id1.drafts_folder_picker_mode", "1"); lockPref("mail.identity.id1.encryption_cert_name", ""); lockPref("mail.identity.id1.encryptionpolicy", 0); lockPref("mail.identity.id1.fcc_folder", "imap://" + uid + "@" + mailHost + "/INBOX/&BB4EQgQ,BEAEMAQyBDsENQQ9BD0ESwQ1-"); lockPref("mail.identity.id1.fcc_folder_picker_mode", "1"); lockPref("mail.identity.id1.fullName", utf8(cn)); lockPref("mail.identity.id1.organization", utf8(org)); lockPref("mail.identity.id1.sig_file", "H:\\\\.signature"); lockPref("mail.identity.id1.attach_signature", true); lockPref("mail.identity.id1.reply_to", ""); lockPref("mail.identity.id1.sign_mail", false); lockPref("mail.identity.id1.signing_cert_name", ""); lockPref("mail.identity.id1.smtpServer", "smtp1"); lockPref("mail.identity.id1.stationery_folder", "imap://" + uid + "@" + mailHost + "/INBOX/&BCgEMAQxBDsEPgQ9BEs-"); lockPref("mail.identity.id1.tmpl_folder_picker_mode", "1"); lockPref("mail.identity.id1.useremail", mail); lockPref("mail.identity.id1.valid", true); lockPref("mail.server.server1.ageLimit", 30); lockPref("mail.server.server1.capability", 418609); lockPref("mail.server.server1.daysToKeepBodies", 30); lockPref("mail.server.server1.daysToKeepHdrs", 30); lockPref("mail.server.server1.download_on_biff", true); lockPref("mail.server.server1.hostname", mailHost); lockPref("mail.server.server1.login_at_startup", true); lockPref("mail.server.server1.max_cached_connections", 5); lockPref("mail.server.server1.name", utf8(cn)); lockPref("mail.server.server1.namespace.other_users", "\\"user.\\""); lockPref("mail.server.server1.namespace.personal", "\\"INBOX.\\""); lockPref("mail.server.server1.namespace.public", "\\"\\""); lockPref("mail.server.server1.numHdrsToKeep", 30); lockPref("mail.server.server1.port", 143); lockPref("mail.server.server1.realhostname", mailHost); lockPref("mail.server.server1.realuserName", uid); lockPref("mail.server.server1.type", "imap"); lockPref("mail.server.server1.useSecAuth", true); lockPref("mail.server.server1.userName", uid); /* smtp */ lockPref("mail.smtp.defaultserver", "smtp1"); lockPref("mail.smtpserver.smtp1.auth_method", 1); lockPref("mail.smtpserver.smtp1.hostname", mailHost); lockPref("mail.smtpserver.smtp1.port", 25); lockPref("mail.smtpserver.smtp1.try_ssl", 0); lockPref("mail.smtpserver.smtp1.username", uid); lockPref("mail.smtpservers", "smtp1"); lockPref("mail.startup.enabledMailCheckOnce", true); lockPref("mail.toolbars.showbutton.junk", false); lockPref("mail.ui.folderpane.version", 3); lockPref("mailnews.quotingPrefs.version", 1); lockPref("mailnews.start_page.url", "http://$confserver/MozillaMail/"); lockPref("mailnews.ui.threadpane.version", 3); /* proxy */ lockPref("network.proxy.autoconfig_url", "http://$confserver/proxy.js"); lockPref("network.proxy.type", 2); lockPref("prefs.converted-to-utf8", true); lockPref("signon.SignonFileName", "70968020.s"); lockPref("wallet.caveat", true); /* local folders */ if (lfolders.match(useringroup)) { lckaccounts = lckaccounts + ",account2"; lockPref("mail.account.account2.server", "server2"); lockPref("mail.accountmanager.localfoldersserver", "server2"); lockPref("mail.server.server2.hostname", "Local Folders"); lockPref("mail.server.server2.name", "Local Folders"); lockPref("mail.server.server2.type", "none"); lockPref("mail.server.server2.userName", "nobody"); } /* news */ if (newsers.match(useringroup)) { lckaccounts = lckaccounts + ",account3"; lockPref("mail.account.account3.identities", "id2"); lockPref("mail.account.account3.server", "server3"); lockPref("mail.identity.id2.compose_html", false); lockPref("mail.identity.id2.doBcc", false); lockPref("mail.identity.id2.doBccList", ""); lockPref("mail.identity.id2.draft_folder", "imap://" + uid + "@" + mailHost + "/INBOX/&BCcENQRABD0EPgQyBDgEOgQ4-"); lockPref("mail.identity.id2.drafts_folder_picker_mode", "1"); lockPref("mail.identity.id2.fcc_folder", "imap://" + uid + "@" + mailHost + "/INBOX/&BB4EQgQ,BEAEMAQyBDsENQQ9BD0ESwQ1-"); lockPref("mail.identity.id2.fcc_folder_picker_mode", "1"); lockPref("mail.identity.id2.fullName", utf8(cn)); lockPref("mail.identity.id2.organization", utf8(org)); lockPref("mail.identity.id2.sig_file", "H:\\\\.signature"); lockPref("mail.identity.id2.attach_signature", true); lockPref("mail.identity.id2.reply_to", ""); lockPref("mail.identity.id2.smtpServer", "smtp1"); lockPref("mail.identity.id2.stationery_folder", "imap://" + uid + "@" + mailHost + "/INBOX/&BCgEMAQxBDsEPgQ9BEs-"); lockPref("mail.identity.id2.tmpl_folder_picker_mode", "1"); lockPref("mail.identity.id2.useremail", mail); lockPref("mail.identity.id2.valid", true); lockPref("mail.server.server3.ageLimit", 30); lockPref("mail.server.server3.always_authenticate", true); lockPref("mail.server.server3.check_new_mail", true); lockPref("mail.server.server3.hostname", "$newsserver"); lockPref("mail.server.server3.max_cached_connections", 2); lockPref("mail.server.server3.numHdrsToKeep", 30); lockPref("mail.server.server3.type", "nntp"); } lockPref("mail.accountmanager.accounts", lckaccounts); /* end preferences */ } getLDAPAttributes("$ldapserver", "$basedn", "uid="+env_user, "uid,cn,gecos,mail,mailHost,o"); } catch(e) { displayError("lockedPref", e); } EOF sub handler { my $q = new CGI; print $q->header( -type=>'application/x-javascript-config', -expires=>'0' ); print $page; } 1; __END__