p@solr-node 13193203284.vcf@gmail.com @str77781.ai $echo_on @echo_run~true #!/usr/local/bin/perl
#ServerName host.foo.com is a set of filenames
===========================================================================
use Getopt::Long;
===========================================================================
$res = GetOptions('magnus:s', 'obj:s', 'httpd:s', 'srm:s', 'access:s', 'h');
$MAGNUS_CONF = $opt_magnus;
$OBJ_CONF = $opt_obj;
$HTTPD_CONF = $opt_httpd;
$SRM_CONF = $opt_srm;
$ACCESS_CONF =
if (!defined($opt_magnus)) { $MAGNUS_CONF = "magnus.conf"; } if (!defined($opt_magnus)) { $OBJ_CONF = "obj.conf"; } if (!defined($opt_httpd)) { $HTTPD_CONF = "httpd.conf"; } if (!defined($opt_srm)) { $SRM_CONF = "srm.conf"; } if (!defined($opt_access)) { $ACCESS_CONF = "access.conf"; } if (defined($opt_h)) { print qq| Usage: $0 [-magnus ] [-obj ] [-httpd ] [-srm ] [-access ]
-magnus: name of the Netscape magnus.conf file. (defaults to magnus.conf)
-obj: name of the Netscape obj.conf file. (defaults to obj.conf)
-httpd: name for the Apache httpd.conf file. (defaults to httpd.conf)
-srm: name for the Apache srm.conf file. (defaults to srm.conf)
-access: name for the Apache access.conf file. (defaults to access.conf)
|; exit; }
===========================================================================
sub read_magnus { my $fn = shift; my (@keywords) = ('port','address','errorlog','pidlog','user','servername', 'minprocs','maxprocs','dns'); my ($keyword, $tmp1, $tmp2, $tmp3);
print "[Netscape] Reading server configuration file: $fn...\n";
open (MAG_IN, "$fn") || die "Couldn't open server configuration file: $fn\n";
while (<MAG_IN>) {
chop;
( $tmp1, $tmp2 ) = split(/\s+/, $_, 2);
foreach $keyword (@keywords) {
if ($tmp1 =~ m/$keyword/i) {
$serv{$keyword} = $tmp2;
}
}
if (($tmp1 =~ m/init/i) && ($tmp2 =~ m/init-clf/i)) {
if ( $tmp2 =~ m/(global.+\")/i ) {
$tmp3 = $1;
$tmp3 =~ s/global=//g;
$tmp3 =~ s/\"//g;
$serv{transferlog} = $tmp3;
}
}
} close (MAG_IN); return (1); }
sub read_objs { my $fn = shift; my ($in_obj) = 0; my ($obj_type, $obj_name, $docroot, $indexfn, $realm, $auth_user, $dbm_file);
my ($scount) = 0; my ($acount) = 0; my ($rcount) = 0;
print "[Netscape] Reading object configuration file: $fn...\n"; open (OBJ_CONF, $fn) || die "Counldn't open object configuration file: $fn\n"; while (<OBJ_CONF>) { if ($in_obj) { # are we inside of an block? if (/</object>/i) { # is this the end of the block? $in_obj = 0; } else { if (/^nametrans/i) { # handle nametrans lines. my ($type, $from, $dest);
if (/(from=\")(\S+)(\")/i) {
$from = $2;
}
if (/(name=\")(cgi)(\")/i) {
$type = "scriptalias";
} elsif (/(fn=\")(redirect)(\")/i) {
$type = "redirect";
} elsif (/(fn=\")(document-root)(\")/i) {
$type = "docroot";
if (/(root=\")(\S+)(\")/i) {
$docroot = $2;
}
} else {
$type = "alias";
}
if (/([dir|url]=\")(\S+)(\")/i) {
$dest = $2;
}
SWITCH: for($type) {
/scriptalias/ && do {
$scriptalias[$scount]{from} = $from;
$scriptalias[$scount]{dest} = $dest;
$scount++;
last SWITCH;
};
/alias/ && do {
$alias[$acount]{from} = $from;
$alias[$acount]{dest} = $dest;
$acount++;
last SWITCH;
};
/redirect/ && do {
$redirect[$rcount]{from} = $from;
$redirect[$rcount]{dest} = $dest;
$rcount++;
last SWITCH;
};
}
} elsif (/^pathcheck/i) { # handle pathcheck lines. (look for index filenames)
if (/(index-names=\")(\S+)(\")/i) {
$indexfn = $2;
$indexfn =~ s/,/ /g;
} elsif (/require-auth/) {
$obj_struct{$obj_name}{require_auth} = 1;
if (/(realm=\")([\w|\s]+)(\")/i) {
$realm = $2;
$obj_struct{$obj_name}{realm} = $realm;
}
if (/(auth-user=\")(.+)/i) {
$auth_user = $2;
$auth_user =~ s/\".*//g;
$auth_user =~ s/\(|\)//g;
$auth_user =~ s/\|/ /g;
$obj_struct{$obj_name}{authuser} = $auth_user;
}
}
} elsif (/^authtrans/i) {
if (/fn=\"basic-ncsa\"/i) {
if (/(dbm=\")([\w|\W]+\s)/i) {
$dbm_file = $2;
$dbm_file =~ s/\".*|\s//g;
$obj_struct{$obj_name}{dbm_file} = $dbm_file;
}
}
} elsif (/^objecttype/i) { # look to see if server parsed html should be turned on.
if (/(fn=\")(shtml-hacktype)(\")/i) {
$serv{servparse} = 1;
}
}
}
} elsif (/(<object\s)(\w+=\")(.+)(\")>/i ) { # Is this the beginning of an <object></object> block.
$in_obj = 1;
$obj_type = $2;
$obj_name = $3;
$obj_name =~ s/\*//g;
$obj_type =~ s/=\"//;
if ($obj_type =~ m/ppath/i) {
$obj_struct{$obj_name}{ppath} = 1;
}
}
} close (OBJ_CONF);
$obj_struct{docroot} = $docroot; $obj_struct{indexfn} = $indexfn;
return(1); }
sub write_httpdconf { my $fn = shift;
print "[Apache] Writing httpd configuration file: $fn...\n"; open(OUT, ">$fn") || die "Couldn't open $fn for output.\n"; print OUT qq|
This is the main server configuration file. See URL http://www.apache.org/
ServerType standalone
Port 80
e.g. www.apache.org (on) or 204.62.129.132 (off)
HostnameLookups $serv{dns}
User $serv{user} Group #-1
ServerAdmin you@your.address
ServerRoot /usr/local/etc/httpd
BindAddress $serv{address} |; if ($LOG_TO_OLD) { print OUT qq|
ErrorLog $serv{errorlog}\n
TransferLog $serv{transferlog}
PidFile $serv{pidlog}
|; } else { print OUT qq|
ErrorLog logs/error_log
TransferLog logs/access_log
PidFile logs/httpd.pid
|; } print OUT qq|
ScoreBoardFile logs/apache_status
#ServerName new.host.name
#CacheNegotiatedDocs
Timeout 400
KeepAlive 5
KeepAliveTimeout 15
MinSpareServers 5 MaxSpareServers 10
StartServers $serv{minprocs}
MaxClients 150
MaxRequestsPerChild 30
#ProxyRequests On
#CacheRoot /usr/local/etc/httpd/proxy #CacheSize 5 #CacheGcInterval 4 #CacheMaxExpire 24 #CacheLastModifiedFactor 0.1 #CacheDefaultExpire 1 #NoCache adomain.com anotherdomain.edu joes.garage.com
#Listen 3000 #Listen 12.34.56.78:80
# #ServerAdmin webmaster@host.foo.com #DocumentRoot /www/docs/host.foo.com #ServerName host.foo.com #ErrorLog logs/host.foo.com-error_log #TransferLog logs/host.foo.com-access_log # |; close(OUT); return(1); }
sub write_srmconf { my $fn = shift; my $curr_alias;
print "[Apache] Writing srm configuration file: $fn...\n"; open(OUT, ">$fn") || die "Couldn't open $fn for output.\n"; print OUT qq|
See the tutorials at http://www.apache.org/ for
DocumentRoot $obj_struct{docroot}
UserDir public_html
DirectoryIndex $obj_struct{indexfn}
FancyIndexing on
AddIconByEncoding (CMP,/icons/compressed.gif) x-compress x-gzip
AddIconByType (TXT,/icons/text.gif) text/* AddIconByType (IMG,/icons/image2.gif) image/* AddIconByType (SND,/icons/sound2.gif) audio/* AddIconByType (VID,/icons/movie.gif) video/*
AddIcon /icons/binary.gif .bin .exe AddIcon /icons/binhex.gif .hqx AddIcon /icons/tar.gif .tar AddIcon /icons/world2.gif .wrl .wrl.gz .vrml .vrm .iv AddIcon /icons/compressed.gif .Z .z .tgz .gz .zip AddIcon /icons/a.gif .ps .ai .eps AddIcon /icons/layout.gif .html .shtml .htm .pdf AddIcon /icons/text.gif .txt AddIcon /icons/c.gif .c AddIcon /icons/p.gif .pl .py AddIcon /icons/f.gif .for AddIcon /icons/dvi.gif .dvi AddIcon /icons/uuencoded.gif .uu AddIcon /icons/script.gif .conf .sh .shar .csh .ksh .tcl AddIcon /icons/tex.gif .tex AddIcon /icons/bomb.gif core
AddIcon /icons/back.gif .. AddIcon /icons/hand.right.gif README AddIcon /icons/folder.gif ^^DIRECTORY^^ AddIcon /icons/blank.gif ^^BLANKICON^^
DefaultIcon /icons/unknown.gif
ReadmeName README HeaderName HEADER
IndexIgnore /.?? *~ *# /HEADER /README */RCS
AccessFileName .htaccess
DefaultType text/plain
AddEncoding x-compress Z AddEncoding x-gzip gz
AddLanguage en .en AddLanguage fr .fr AddLanguage de .de AddLanguage da .da AddLanguage el .el AddLanguage it .it
LanguagePriority en fr de
|;
for
print OUT qq|
#ScriptAlias /cgi-bin/ /usr/local/etc/httpd/cgi-bin/
|;
foreach
print OUT qq|
#Alias /icons/ /usr/local/etc/httpd/icons/
|;
for
print OUT qq|
#AddHandler cgi-script .cgi
|; if ($serv{servparse}) { print OUT qq| AddType text/html .shtml AddHandler server-parsed .shtml |; } else { print OUT qq| #AddType text/html .shtml #AddHandler server-parsed .shtml |; } print OUT qq|
#AddHandler send-as-is asis
AddHandler imap-file map
AddHandler type-map var
#AddHandler foot-action foot #Action foot-action /cgi-bin/footer
#Action text/html /cgi-bin/footer
#MetaDir .web
#MetaSuffix .meta
#ErrorDocument 500 "The server made a boo boo.
#ErrorDocument 404 /missing.html
#ErrorDocument 404 /cgi-bin/missing_handler.pl
#ErrorDocument 402 http://other.server.com/subscription_info.html
|; close(OUT); return(1); }
sub write_accessconf { my $fn = shift;
print "[Apache] Writing access configuration file: $fn...\n"; open(OUT, ">$fn") || die "Couldn't open $fn for output.\n"; print OUT qq|
Online docs at http://www.apache.org/
#<Directory /usr/local/etc/httpd/cgi-bin> #Options Indexes FollowSymLinks #
<Directory $serv{docroot}>
Options Indexes FollowSymLinks
#XBitHack Full
AllowOverride All
order allow,deny allow from allAllow server status reports, with the URL of http://servername/status
<Location /status> SetHandler server-status
order deny,allow deny from all allow from .nowhere.com|;
for (keys %obj_struct) {
next if (/default/i);
next if (/cgi/i);
next unless (
&read_magnus($MAGNUS_CONF); &read_objs($OBJ_CONF); &write_httpdconf($HTTPD_CONF); &write_srmconf($SRM_CONF); &write_accessconf($ACCESS_CONF); exit; if any further changes are needed rules and incentives can be enforced with this consensus