ispman/lib/ISPMan ApacheMan.pm,1.73,1.74
Joerg Delker <[email protected]>
| Newsgroups | gmane.comp.isp.ispman.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/ispman/ispman/lib/ISPMan
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24249/lib/ISPMan
Modified Files:
ApacheMan.pm
Log Message:
multi-port vhost patch
(use "vhost:port" for multiple vhost with same name but different ports)
fixes [ 987800 ] Port 80 is written to DNS zone
Index: ApacheMan.pm
===================================================================
RCS file: /cvsroot/ispman/ispman/lib/ISPMan/ApacheMan.pm,v
retrieving revision 1.73
retrieving revision 1.74
diff -u -d -r1.73 -r1.74
--- ApacheMan.pm 20 Jun 2004 11:21:25 -0000 1.73
+++ ApacheMan.pm 9 Jul 2004 22:19:12 -0000 1.74
@@ -82,8 +82,8 @@
my $self = shift;
my $r = shift;
- $self->{'vhost'} = $self->getVhostInfo($r->param("ispmanVhostName"),
- $r->param("ispmanDomain"));
+ $self->{'vhost'} = $self->getVhostInfo( $r->param("ispmanVhostName"),
+ $r->param("ispmanDomain") );
my $template;
my $tmpl;
@@ -209,7 +209,7 @@
}
$data->{'ispmanVhostExtraConf'} =
- HTML::Entities::encode($r->param("ispmanVhostExtraConf"));
+ HTML::Entities::encode( $r->param("ispmanVhostExtraConf") );
$data->{'userPassword'} =
$self->encryptPassWithMethod( $r->param("userPassword"),
@@ -267,11 +267,15 @@
my $self = shift;
my $r = shift;
- # filter vhostname for invalid chars
- my $ispmanVhostName = $r->param("ispmanVhostName");
- $ispmanVhostName = lc($ispmanVhostName);
- $ispmanVhostName =~ s/[^a-zA-Z0-9\.-]//g;
- $r->param( "ispmanVhostName", $ispmanVhostName );
+ # split vhostname into vhost and port
+ my ( $vhost, $port ) = split ":", $r->param("ispmanVhostName");
+
+ # filter for invalid chars
+ $vhost = lc($vhost);
+ $vhost =~ s/[^a-zA-Z0-9\.-]//g;
+ $port =~ s/[^0-9]//g;
+
+ $r->param( "ispmanVhostName", $vhost . ( $port ? ":$port" : "" ) );
my $domain = $r->param("ispmanDomain");
@@ -286,7 +290,7 @@
}
# determine DN for new vhost
- my $dn = $self->getVhostDN( $domain, $ispmanVhostName );
+ my $dn = $self->getVhostDN( $domain, $r->param("ispmanVhostName") );
$r->param( "dn", $dn );
#check homeDirectory for reseller/client
@@ -326,8 +330,9 @@
# finaly check if webhosts are set
if ( $#webhosts < 0 ) {
- print
-"The webhost for $ispmanVhostName cannot be determined!<br>Please check DefaultFileHost for domain $domain!\n";
+ print "The webhost for "
+ . $r->param("ispmanVhostName")
+ . " cannot be determined!<br>Please check DefaultFileHost for domain $domain!\n";
return;
}
@@ -354,7 +359,8 @@
$self->addDataFromLdif( "templates/vhost.ldif.template", $r );
# read back vhost entry to fill processes
- my $vhost_info = $self->getVhostInfo($ispmanVhostName,$domain);
+ my $vhost_info =
+ $self->getVhostInfo( $r->param("ispmanVhostName"), $domain );
# add new A-record for webhost(s) if domain is primary
if ( $domain_info->{'ispmanDomainType'} eq "primary" ) {
@@ -363,13 +369,14 @@
# only single webhost is defined
# (use webhost's IP if no explicit was supplied)
my $ip = (
- ( !$r->param("ispmanVhostIpAddress") ||
- $r->param("ispmanVhostIpAddress") eq "*" )
+ (
+ !$r->param("ispmanVhostIpAddress")
+ || $r->param("ispmanVhostIpAddress") eq "*"
+ )
? $self->getHostIp( $webhosts[0] )
: $r->param("ispmanVhostIpAddress")
);
- $self->addVhostDNSRecord( $r->param("ispmanDomain"),
- $r->param("ispmanVhostName"), $ip );
+ $self->addVhostDNSRecord( $r->param("ispmanDomain"), $vhost, $ip );
}
else {
@@ -379,11 +386,8 @@
if ( $self->getConf("apacheVhostsVIP") =~
/^(\d+)\.(\d+)\.(\d+)\.(\d+)$/ )
{
- $self->addVhostDNSRecord(
- $r->param("ispmanDomain"),
- $r->param("ispmanVhostName"),
- $self->getConf("apacheVhostsVIP")
- );
+ $self->addVhostDNSRecord( $r->param("ispmanDomain"),
+ $vhost, $self->getConf("apacheVhostsVIP") );
}
else {
@@ -391,11 +395,8 @@
# will act as simple round-robin loadbalancing.
# Change them manually for proper hardware loadbalancing!
for (@webhosts) {
- $self->addVhostDNSRecord(
- $r->param("ispmanDomain"),
- $r->param("ispmanVhostName"),
- $self->getHostIp($_)
- );
+ $self->addVhostDNSRecord( $r->param("ispmanDomain"),
+ $vhost, $self->getHostIp($_) );
}
}
}
@@ -529,9 +530,10 @@
my $ispmanVhostName = shift;
my $domain = shift;
- my $dn = "ispmanVhostName=$ispmanVhostName,".
- "ou=httpdata,ispmanDomain=$domain,".
- $self->getConf("ldapBaseDN");
+ my $dn =
+ "ispmanVhostName=$ispmanVhostName,"
+ . "ou=httpdata,ispmanDomain=$domain,"
+ . $self->getConf("ldapBaseDN");
#uncomment this block if you want it to cache the result
#unless ($self->{'vhostInfo'}{$domain}{$ispmanVhostName}){
-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 -
digital self defense, top technical experts, no vendor pitches,
unmatched networking opportunities. Visit www.blackhat.com