ispman/lib http.lib,1.57,1.58

Joerg Delker <[email protected]>
Newsgroups gmane.comp.isp.ispman.cvs
Message-ID <[email protected]>
Update of /cvsroot/ispman/ispman/lib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24249/lib

Modified Files:
	http.lib 
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: http.lib
===================================================================
RCS file: /cvsroot/ispman/ispman/lib/http.lib,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -d -r1.57 -r1.58
--- http.lib	7 Jul 2004 20:25:41 -0000	1.57
+++ http.lib	9 Jul 2004 22:19:13 -0000	1.58
@@ -40,40 +40,42 @@
 }
 
 sub add_vhost {
-    my ( $vhost, $domain ) = @_;
-    next unless $vhost and $domain;
+    my ( $ispmanVhostName, $ispmanDomain ) = @_;
+    next unless $ispmanVhostName and $ispmanDomain;
 
-    print "\n\nWorking on $vhost.$domain\n";
+    my ( $vhost, $port ) = split ":", $ispmanVhostName;
 
-    my $vhostInfo = $ispman->getVhostInfo( $vhost, $domain );
+    print "\n\nWorking on $vhost.$ispmanDomain\n" . ( $port ? ":$port" : "" );
 
-    #print Dumper($vhostInfo);
+    my $vhostInfo = $ispman->getVhostInfo( $ispmanVhostName, $ispmanDomain );
 
-    my $domainInfo     = $ispman->getDomainInfo($domain);
-    my $domainReplicas = $ispman->getReplicasOfDomain($domain);
+    my $domainInfo     = $ispman->getDomainInfo($ispmanDomain);
+    my $domainReplicas = $ispman->getReplicasOfDomain($ispmanDomain);
     my $vhostConfFile  = $apacheVhostsFile;
     my $vhostHashFile  = "$apacheVhostsFile.hash";
 
     if ( $ispman->getConf("apacheVhostsStyle") =~ /dir/m ) {
-        $vhostHashFile = "$vhostConfFile/hash/$domain.hash";
-        $vhostConfFile .= "/conf/$domain.conf";
+        $vhostHashFile = "$vhostConfFile/hash/$ispmanDomain.hash";
+        $vhostConfFile .= "/conf/$ispmanDomain.conf";
     }
 
     # this is useful if there is no homedirectory defined
     # can happen when moving from version <=0.5
     $domainInfo->{'homedirectory'} ||= join "/",
-      ( $ispman->getConf("defaultHomeDirectoryPath"), $domain );
+      ( $ispman->getConf("defaultHomeDirectoryPath"), $ispmanDomain );
 
     # create list of vhost aliases
     my @_ispmanVhostServerAliases = ();
 
-    $ispmanVhostServerAliases = $ispman->getAliases( $domain, $vhost );
+    $ispmanVhostServerAliases =
+      $ispman->getAliases( $ispmanDomain, $ispmanVhostName );
     for ( keys %$ispmanVhostServerAliases ) {
         my $alias = $ispmanVhostServerAliases->{$_}{'ispmanVhostServerAlias'};
 
         # Add the domain suffix to the alias for unqualified names
         if ( $alias !~ /\./ ) {
-            push @_ispmanVhostServerAliases, join '.', ( $alias, $domain );
+            push @_ispmanVhostServerAliases, join '.',
+              ( $alias, $ispmanDomain );
 
             # Add vhost aliases to all replica domains, too
             for my $_replica ( keys %$domainReplicas ) {
@@ -105,7 +107,7 @@
 
     my $vhostHash = read_vhosts_hash("$vhostHashFile");
     ### delete this vhost from hash if it already exists
-    delete $vhostHash->{$domain}{$vhost};
+    delete $vhostHash->{$ispmanDomain}{$ispmanVhostName};
 
     ### remove some options that we are adding in the interface but there
     ### is no logic for it.
@@ -122,9 +124,10 @@
     $vhostInfo->{'ispmanVhostDocumentRootOption'} =
       [ keys %$_ispmanVhostDocumentRootOption ];
 
-    $vhostHash->{$domain}{$vhost} = {
-        servername             => "$vhost.$domain",
+    $vhostHash->{$ispmanDomain}{$ispmanVhostName} = {
+        servername             => "$vhost.$ispmanDomain",
         vhost                  => $vhost,
+        port                   => $port,
         uidNumber              => $vhostInfo->{'uidNumber'},
         gidNumber              => $vhostInfo->{'gidNumber'},
         homeDirectory          => $vhostInfo->{'homeDirectory'},
@@ -138,13 +141,15 @@
           $vhostInfo->{'ispmanVhostScriptDirOption'},
         ispmanVhostStats => $vhostInfo->{'ispmanVhostStats'},
         ispmanStatus     => $vhostInfo->{'ispmanStatus'},
-        acls             => $ispman->getAcls( $domain, $vhost ),
-        urlredirect      => $ispman->getRedirections( $domain, $vhost ),
+        acls             => $ispman->getAcls( $ispmanDomain, $ispmanVhostName ),
+        urlredirect      =>
+          $ispman->getRedirections( $ispmanDomain, $ispmanVhostName ),
     };
 
     # build ispmanVhostDocumentRoot
     if ( $vhostInfo->{'ispmanVhostDocumentRoot'} !~ /^\// ) {
-        $vhostHash->{$domain}{$vhost}{'documentroot'} = join "/",
+        $vhostHash->{$ispmanDomain}{$ispmanVhostName}{'documentroot'} =
+          join "/",
           (
             $vhostInfo->{'homeDirectory'},
             $vhostInfo->{'ispmanVhostDocumentRoot'}
@@ -152,13 +157,13 @@
     }
     else {
         ### its a static/non-relative directory. It starts with a "/"
-        $vhostHash->{$domain}{$vhost}{'documentroot'} =
+        $vhostHash->{$ispmanDomain}{$ispmanVhostName}{'documentroot'} =
           $vhostInfo->{'ispmanVhostDocumentRoot'};
     }
 
     # build ispmanVhostScriptDir
     if ( $vhostInfo->{'ispmanVhostScriptDir'} !~ /^\// ) {
-        $vhostHash->{$domain}{$vhost}{'scriptdir'} = join "/",
+        $vhostHash->{$ispmanDomain}{$ispmanVhostName}{'scriptdir'} = join "/",
           (
             $vhostInfo->{'homeDirectory'},
             $vhostInfo->{'ispmanVhostScriptDir'}
@@ -166,7 +171,7 @@
     }
     else {
         ### its a static/non-relative directory. It starts with a "/"
-        $vhostHash->{$domain}{$vhost}{'scriptdir'} =
+        $vhostHash->{$ispmanDomain}{$ispmanVhostName}{'scriptdir'} =
           $vhostInfo->{'ispmanVhostScriptDir'};
     }
 
@@ -175,7 +180,7 @@
         if ( $vhostInfo->{'ispmanVhostLogdir'} !~ /^\// ) {
 
             # ispmanVhostLogdir is relative
-            $vhostHash->{$domain}{$vhost}{'logdir'} = join "/",
+            $vhostHash->{$ispmanDomain}{$ispmanVhostName}{'logdir'} = join "/",
               (
                 $vhostInfo->{'homeDirectory'},
                 $vhostInfo->{'ispmanVhostLogdir'}
@@ -184,7 +189,7 @@
         else {
 
             # its a static/non-relative directory. It starts with a "/"
-            $vhostHash->{$domain}{$vhost}{'logdir'} =
+            $vhostHash->{$ispmanDomain}{$ispmanVhostName}{'logdir'} =
               $vhostInfo->{'ispmanVhostLogdir'};
         }
     }
@@ -195,14 +200,15 @@
 
         # don't provide any default because it would cover the error
     }
-    print "Setting logdir to $vhostHash->{$domain}{$vhost}{'logdir'}\n";
+    print
+"Setting logdir to $vhostHash->{$ispmanDomain}{$ispmanVhostName}{'logdir'}\n";
 
     # build ispmanVhostStatdir
     if ( $vhostInfo->{'ispmanVhostStatdir'} =~ /\S/ ) {
         if ( $vhostInfo->{'ispmanVhostStatdir'} !~ /^\// ) {
 
             # ispmanStatdir is relative
-            $vhostHash->{$domain}{$vhost}{'statdir'} = join "/",
+            $vhostHash->{$ispmanDomain}{$ispmanVhostName}{'statdir'} = join "/",
               (
                 $vhostInfo->{'homeDirectory'},
                 $vhostInfo->{'ispmanVhostStatdir'}
@@ -211,7 +217,7 @@
         else {
 
             # its a static/non-relative directory. It starts with a "/"
-            $vhostHash->{$domain}{$vhost}{'statdir'} =
+            $vhostHash->{$ispmanDomain}{$ispmanVhostName}{'statdir'} =
               $vhostInfo->{'ispmanVhostStatdir'};
         }
     }
@@ -222,14 +228,17 @@
 
         # don't provide any default because it would cover the error
     }
-    print "Setting statdir to $vhostHash->{$domain}{$vhost}{'statdir'}\n";
+    print
+"Setting statdir to $vhostHash->{$ispmanDomain}{$ispmanVhostName}{'statdir'}\n";
 
     ### Check for log and stat dir and make them if need be
-    unless ( -d $vhostHash->{$domain}{$vhost}{'logdir'} ) {
+    unless ( -d $vhostHash->{$ispmanDomain}{$ispmanVhostName}{'logdir'} ) {
         print
-"Logdir $vhostHash->{$domain}{$vhost}{'logdir'} did not exist. Creating now.\n";
-        print "mkdir -p $vhostHash->{$domain}{$vhost}{'logdir'} \n";
-        system "mkdir -p $vhostHash->{$domain}{$vhost}{'logdir'} \n";
+"Logdir $vhostHash->{$ispmanDomain}{$ispmanVhostName}{'logdir'} did not exist. Creating now.\n";
+        print
+          "mkdir -p $vhostHash->{$ispmanDomain}{$ispmanVhostName}{'logdir'} \n";
+        system
+          "mkdir -p $vhostHash->{$ispmanDomain}{$ispmanVhostName}{'logdir'} \n";
     }
 
     write_vhosts_hash( "$vhostHashFile", $vhostHash );
@@ -396,9 +405,9 @@
                 $vhostHash->{$domain}{$vh}{'urlredirect'} = $urlredirectText;
             }
 
-            $vhostHash->{$domain}{$vh}{'ispmanDomain'} = $domain;
-            $vhostHash->{$domain}{$vh}{'vhost'}        = $vh;
-            $vhostHash->{$domain}{$vh}{'ldapBaseDN'}   =
+            #$vhostHash->{$domain}{$vh}{'ispmanDomain'} = $domain;
+            #$vhostHash->{$domain}{$vh}{'vhost'}        = $vh;
+            $vhostHash->{$domain}{$vh}{'ldapBaseDN'} =
               $ispman->{'Config'}{'ldapBaseDN'};
             $vhostHash->{$domain}{$vh}{'ldapHost'} =
               $ispman->{'Config'}{'ldapHost'};



-------------------------------------------------------
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.