[K12OSN] Locking down browser proxy settings and homepage

Andy Rabagliati andyr at wizzy.com
Fri Aug 13 17:28:18 UTC 2004


Folks,

  I need to arrange that students have their proxy settings and
  home page are preconfigured on startup.

  The following is a hack to the mozbyteshift perl program to
  do all the settings.

  You can see the changes that will be made - after the __DATA__
  line in the perl script.

  As root, invoke it as

	# proxy.pl hostname.example.com

Cheers,    Andy!

http://wizzy.org.za/


-------------- next part --------------
#!/usr/bin/perl

# lock down browser homepage and proxy settings
# Andy Rabagliati <andyr at wizzy.com>
# http://wizzy.org.za/

use encoding 'latin1';
use strict;

sub usage() {
   print "Usage: $0 <hostname>\n";
   exit 1;
}

usage() if (@ARGV != 1);

my $hostname = $ARGV[0];

# 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 >netscape.cfg.txt
#   To encode: moz-byteshift.pl -s  7 <netscape.cfg.txt >netscape.cfg

# Mozilla uses a byteshift of 13
#   To decode: moz-byteshift.pl -s -13 <netscape.cfg >netscape.cfg.txt
#   To encode: moz-byteshift.pl -s  13 <netscape.cfg.txt >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");

my $buffer;
my $mozillacfg;

while ($_ = <DATA>) {
    $_ =~ s/_WIZZY_HOSTNAME_/$hostname/g;
    $buffer .= $_;
}

# lazy - but chop is convenient

$buffer = reverse ($buffer);

binmode(STDOUT, ":raw");

while(length($buffer)) {
  my $byte = ord(chop($buffer));
  $byte += 512 + 13;
  $mozillacfg .= pack("c", $byte);
}

# calling all browsers ..
my @all = glob("/usr/lib/*/defaults/pref/all.js");

for my $f (@all) {
    # read in file, skipping anything that mentions general.config.filename
    open(FILE, $f) || die "Cannot read $f: $!";
    undef ($buffer);
    while ($_ = <FILE>) {
        if ($_ !~ /general.config.filename/) {
	    $buffer .= $_;
	}
    }
    close (FILE);
    # add our version of general.config.filename
    $buffer .= 'pref("general.config.filename","mozilla.cfg");//WIZZY' . "\n";
    # write it out again
    open (FILE, "> $f") || die "Cannot write to $f: $!";
    print FILE $buffer;
    close (FILE);
    # get path to mozilla.cfg
    $f =~ s:defaults/pref/all.js::;
    $f .= 'mozilla.cfg';
    # write it
    open (FILE, "> $f") || die "Cannot write to $f: $!";
    print FILE $mozillacfg;
    close (FILE);
}
    
__DATA__
// Wizzy mozilla defaults lockdown for _WIZZY_HOSTNAME_

lockPref("browser.cache.disk.capacity", 0);
defaultPref("security.warn_entering_secure", false);
defaultPref("security.warn_submit_insecure", false);

lockPref("browser.cache.enable",false);
lockPref("network.proxy.type",1);
lockPref("network.proxy.ftp","_WIZZY_HOSTNAME_");
lockPref("network.proxy.ftp_port",8080);
lockPref("network.proxy.http","_WIZZY_HOSTNAME_");
lockPref("network.proxy.http_port",8080);
lockPref("network.proxy.ssl","_WIZZY_HOSTNAME_");
lockPref("network.proxy.ssl_port",8080);
lockPref("browser.startup.homepage","http://_WIZZY_HOSTNAME_/");


More information about the K12OSN mailing list