Last Comment Bug 206294 - Autoconfig via a URL appears to be missing. (autoadmin.global_config_url)
: Autoconfig via a URL appears to be missing. (autoadmin.global_config_url)
Status: VERIFIED WORKSFORME
:
Product: Core
Classification: Components
Component: Preferences: Backend (show other bugs)
: Trunk
: x86 All
: -- enhancement with 2 votes (vote)
: ---
Assigned To: Conrad Carlen (not reading bugmail)
: sairuh (rarely reading bugmail)
: Benjamin Smedberg [:bsmedberg]
Mentors:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2003-05-19 10:06 PDT by Cory Jaeger
Modified: 2006-05-16 06:56 PDT (History)
13 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments

Description Cory Jaeger 2003-05-19 10:06:44 PDT
User-Agent:       Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3a) Gecko/20021207 Phoenix/0.5
Build Identifier: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3a) Gecko/20021207 Phoenix/0.5

The setting autoadmin.global_config_url available in Netscape v4.x doesn't
appear to have made it into any of the mozilla series of browsers.  This was a
VERY useful option for those of us who manage a large number of "locked down"
systems such as in schools.  The purpose of this setting was to allow an
administrator to put a config file on a web server and automatically change or
update browser settings for all of the systems which use it.

I've written an article on locking down Mozilla/Phoenix and would really like to
be able to include instructions for maintaining a central configuration as well.
 The article can be found at
http://archives.seul.org/seul/edu/Jan-2003/msg00049.html

Reproducible: Always

Steps to Reproduce:
1. Set the value for autoadmin.global_config_url in the browser configuration file.
2. Make sure a valid config file is available at the URL used in #1
3. Exit and restart Mozilla

Actual Results:  
Error complaining of unknown option autoadmin.global_config_url.  No change in
browser configuration.

Expected Results:  
Browser should have taken on some of the lockPref settings in the online config
file.

I have had several people respond to my article asking about this feature as
well. For some, this is blocking adoption of Mozilla or Phoenix in their schools.
Comment 1 Hans Deragon 2003-10-02 10:06:44 PDT
This is an essential feature required for large base installation.  Anybody
within the Mozilla group want to comment on the state of this bug/feature
enhancement?
Comment 2 Daniel Wang 2003-10-20 09:57:05 PDT
The pref is present, see my attachment in bug 178685. But it must be set in a
.cfg file.
Comment 3 Gokhan Topalhan 2003-10-24 09:30:31 PDT
Hi,
Even though preference is there, I do not think it's working.  I have modified 
all.js and added 

pref("general.config.filename", "vendor.cfg");
pref("general.config.vendor", "vendor");
pref("autoadmin.global_config_url","http://myserver/autoconfig.jsc");

This caused Mozilla (1.5) to hit the webserver and download the configuration 
file, which looked like :

Content-type: application/x-javascript-config


with (PrefConfig) {
lockPref("browser.startup.homepage", "http://www.google.com");
lockPref("browser.startup.homepage_override", true);
lockPref("general.config.vendor", "vendor");
lockPref("startup.homepage_override_url", "http://www.google.com");
} // End with prefconfig

No home page change is observed.

Either there is something missing in the documentation, as to how this feature 
should be used, or it is simply broken.  Lack of this feature is a show 
stopper for a large scale deployment.
Comment 4 Cory Jaeger 2003-10-27 15:40:08 PST
I agree.. this still is not functional.  It does indeed read the config file
from the web server, however, it doesn't seem to use any of the options set there.

This is my .js file from the web server:
# Mozilla User Preferences
lockPref("browser.startup.homepage", "http://ourserver/");
lockPref("network.image.imageBehavior", 0);
lockPref("network.proxy.autoconfig_url", "http://ourserver/proxy/srhigh.proxy");
lockPref("network.proxy.type", 2);
... many more lockPrefs

No change to home page or proxy settings and no preferences were locked.
No errors were generaged either.   Tested on Linux and Windows v0.6.1 and v0.7.0.
Comment 5 Cory Jaeger 2003-10-27 15:42:03 PST
This is preventing us from deploying to 2000+ systems.
Comment 6 Daniel Wang 2003-10-28 22:51:17 PST
autoadmin.global_config_url must be in vendor.cfg (not all.js) to take effect.
The .cfg file must be 13-bit shift encoded. The script on Alain Knaff's site is
not working. I was told in bug 222973 that the script needs Perl 5.8.0+, maybe
it will work for you.
Comment 7 Cory Jaeger 2003-10-29 05:52:24 PST
It was in the .cfg file.  The .cfg file was 13-bit shift encoded, and the .cfg
file was specified in all.js.  In fact, the browser actually retrieves the
remote config from the web site.  The retrieved javascript file doesn't have any
affect on the browser's configuration.

According to info at
http://bugzilla.mozilla.org/attachment.cgi?id=125500&action=view#00052 the file
on the web server is plain javascript.  If this is not the case, some
documenatation somewhere needs to say this.  Once we have a working solution,
I'll update my instructions at
http://archives.seul.org/seul/edu/Jan-2003/msg00049.html to reflect the correct
way to use the remote config URL.

At least in Firebird 0.6.1 and 0.7 this still does not appear to be functional.
Comment 8 Gokhan Topalhan 2003-10-29 16:32:28 PST
I think I solved the mystery. The problem seems to be with (PrefConfig) 
directive.

I have simplified my vendor.cfg, and autoconfig.jsc (which is a CGI output in 
our environment) and it seems to be working now.
I'd appreciate if people can try this and report the results.

----- vendor.jsc --- below should be hashed using moz-byteshift.pl and saved 
as vendor.cfg under mozilla home------------
lockPref("general.config.vendor", "vendor");
lockPref("autoadmin.global_config_url","http://server/mcontrol/mconfig.cgi");
lockPref("autoadmin.append_emailaddr",true);
-------------
------ all.js should have the following : ------
pref("general.config.filename", "vendor.cfg");
pref("general.config.vendor", "vendor");
---------------------------------------------------

---------- Output of the mconfig.cgi should generate something like this ------
Content-type: application/x-javascript-config

defaultPref("browser.search.defaultengine", "engine://C%3A%5CProgram%20Files%
5Cmozilla%5Cbin%5Csearchplugins%5Cgoogle.src");
defaultPref("browser.search.opensidebarsearchpanel", false);
lockPref("browser.startup.homepage", "http://www.google.com");
lockPref("startup.homepage_override_url", "http://www.google.com");
lockPref("browser.startup.homepage_override", true);
lockPref("editor.author", "Your Name");
------------------------------------------

Whatever you choose as the vendor, filename should agree with that. (e.g.: x, 
x.cfg )


Right now I am able to change homepages etc by pushing the config from the 
server. This also works with FireBird. Haven't tested thunderbird yet.

Comment 9 Jehan Procaccia 2003-11-05 09:29:15 PST
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 ...
Comment 10 Daniel Wang 2003-11-05 10:28:27 PST
-> WFM :-)
Comment 11 Cory Jaeger 2003-11-05 10:31:17 PST
It works as advertised (for Linux AND Windows.)  I found the problem I was
having was that I had left some comments in.  Apparently comments starting with
# will cause Mozilla to abandon the rest of the config file.  

If you must use comments, use the C style of comment.  ie:
/*  Comment  */
or 
/*  Multi
    line
    comment
*/

Also, I was able to completely leave out the general.config.vendor and
autoadmin.append_emailaddr settings.  No rights changes to the install dir or
subdirs were required.

The config online can be a cgi/php,etc. script or just a simple config file.  My
preference is to use a cgi/php so laptop users can have a different config when
using their system while off site.
Comment 12 Daniel Wang 2003-11-05 11:26:44 PST
> It works as advertised (for Linux AND Windows.)  I found the problem I was
> having was that I had left some comments in.  Apparently comments starting
> with # will cause Mozilla to abandon the rest of the config file.

A preference file is a JavaScript file. If there is a syntax error, than the
application will abort reading it and none of the preferences defined take
effect. With exception of user.js, however, the first line is never read. The
first line is usually non-parseable and begins with # (not a valid js syntax).
This prevents inadvertant loading of preference files from the outside.

for more info, see bug 178685
Comment 13 Jehan Procaccia 2003-11-06 08:54:29 PST
Ok, i've tested on mozilla 1.4 and 1.5 on windows and linux and it works fine.
I've explained everything in my updated doc:
http://www.int-evry.fr/mci/user/procacci/netscape/en/mozilla-autoconfig-en.html
cf particularly chapter 5 dedicated to mozilla !. I hope this could be a
reference to all who wants to use that unvaluable feature (autoconfig !) of
mozilla . 

However I'am still questionning on how to make this service reliable (cf chapter
8) that is to say, how to move to a different web server if one is down, same
question for the ldap server !
I also don't know why alert() javascript function don't work, is was very
usefull in netscape to use it to popup messages as mozilla start (debug/info
...), I use displayError now but it's not very clean ... 

Thanks to all for your help.
Comment 14 Daniel Wang 2003-11-06 09:06:47 PST
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.
Comment 15 Jehan Procaccia 2003-11-26 03:30:28 PST
New problem :-( 
Don't know if it's a bug or a misconfiguration ... however I use this "channel"
to join you all (let me know if there's a better place to post that).

I realized that my ldap based lockPref gets a white space in front of every
variables fetches from ldap. I didn't noticed that before because it doesn't
matter for standard smtp mail, however our mailling list server (sympa)
complains about a bad address when the email address contains a white space;
here's the symptoms:
Return-Path: <" jehan.procaccia"@int-evry.fr>
So mail is rejected :-(
indeed in users prefs.js there's:
user_pref("mail.identity.id1.useremail", " Jehan.Procaccia@int-evry.fr");
                                          ^
Why I get this white space ?

Recall how I lock the useremail pref:

try {
// Get Shell env varirables
  var env_user    = getenv("USER");
  var env_home    = getenv("HOME");
  var env_mozdebug= getenv("MOZILLA_DEBUG");
// Call ldap
function processLDAPValues (values) {
    var ldapuid = getLDAPValue ( values ,"uid" );
    var ldapcn = getLDAPValue ( values ,"cn" );
    var ldapmail = getLDAPValue ( values ,"mail" );
//Debug for me ... (there was alert() before, not availaible anymore :-( )
if (env_mozdebug) {
        displayError("debug 1 mozilla.cfg v2.22", "\nmail:" + ldapmail +
"\nuid:" +ldapuid + "\ncn" +ldapcn + "\nuser:" + env_user );
        }
lockPref("mail.server.server1.name",mail);
lockPref("mail.identity.id1.fullName",cn);
defaultPref("mail.identity.id1.useremail",mail);

//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" );

The problem in that either mail, cn or uid, gets a white space in front ,
env_user which doesn't need the any of the getLDAP* function call works fine (no
white space)

How can I solve that ? search why a white space is added, or keep on with it and
find a javascript function that removes it , kind of chop() in perl, i don't
know javascript, I've also been told that all this autoconfig runs in a very
closed scope, not all of the javascript object/library is available :-(
How can I debug javascripts calls, variable better than using the displayError()
call ?

help would be grealty appreciated, I've hundreds of mozilla mail user autoconfig
running here ...

Thanks.




Comment 16 Jehan Procaccia 2003-11-28 09:01:46 PST
OK, found a workaround, not clean but working, I added the following line to
/usr/lib/mozilla-1.4.1/defaults/autoconfig/prefcalls.js in the getLDAPValue
function:

start_pos +=1;

so now it removes the preblematic "white space" in front of my ldap fetched
variables.

Here's the whole function debuged by me using displayError function (don't know
a better way to debug :-( )

function getLDAPValue(str, key) {

    try {
        if (str == null || key == null)
            return null;

        var search_key = "\n" + key + "=";

        displayError("Jehan getLDAPValue:\nsearch_key:"+search_key+"\nstr"+str);


        var start_pos = str.indexOf(search_key);
        if (start_pos == -1)
            return null;

        start_pos += search_key.length;
//start 
        start_pos +=1;
//end
        var end_pos = str.indexOf("\n", start_pos);
        if (end_pos == -1)
            end_pos = str.length;

        var attrib = str.substring(start_pos, end_pos);
        displayError("Jehan
getLDAPValue:\nattrib:"+attrib+"\nstart_pos:"+start_pos+"\nend_pos:"+end_pos);

        return str.substring(start_pos, end_pos);

    }
    catch(e) {
        displayError("getLDAPValue", e);
    }
}

Is this a bug ? let me know ...
Comment 17 Mats Larsson 2003-12-16 03:24:43 PST
Will this bug be fixed?
Comment 18 Jehan Procaccia 2003-12-22 01:55:31 PST
Don't even know if it's a bug, at least the workaround I presented above worked
for me (others ? let me know ...), but if it is a bug, should I open a new bug
report ?
Comment 19 Cory Jaeger 2003-12-22 07:42:12 PST
I would open a new bug report.  This one is really about URL autoconfig and not
LDAP config issues.  Also, this bug has been effectively closed with a
"WORKSFORME" status.
Comment 20 Jehan Procaccia 2003-12-23 08:56:01 PST
OK, I opened a new bug report :
http://bugzilla.mozilla.org/show_bug.cgi?id=229271
Comment 21 Jehan Procaccia 2004-02-19 08:12:34 PST
I'am glad you finally made it work

we are about to form a community that use mozilla autoconfig, and hopefully
we'll be enough to assure that developpers keeps make this unvaluaible feature
work, and maybe more documented ....

there are several bug reports opened related to autoconfig, feel free to
contribute and/or vote !

http://bugzilla.mozilla.org/show_bug.cgi?id=229271
http://bugzilla.mozilla.org/show_bug.cgi?id=206294
http://bugzilla.mozilla.org/show_bug.cgi?id=222973
http://www.mail-archive.com/mozilla-documentation@mozilla.org/msg02784.html

aschroe1 wrote:

> jehan.procaccia schrieb:
>
>> getenv OK , just check in shell that the value of USER is what is expected :
echo $USER
>> your locPref above is wrong , don't add the "+" sign ! you (an I !) use +
sign in the the javascript file to concatenate strings, here you just have to
call the string:
>> lockPref("mail.identity.id1.useremail", env_user );
>
>
>
> Hello,
> I've got the solution; I dont't believe really   
>
> -the first line of my js/cfg script has to begin with   //
> -your tip leaving out the "+" sign in fornt of the variable
>  (I tried this before, but without the first comment line)
> that's it!     zzzz..zzzz..zzzzz
>
> Thank you very much for your support,
> merci bien  (just another two of my few french words)     :- ))
>
> -------------------------------------------------------------
> Alfred Schroeder - Lernstatt Paderborn -
>
> aschroe1@lspb.de
> -------------------------------------------------------------
>

Note You need to log in before you can comment on or make changes to this bug.