Author: mzugec Date: Wed Mar 25 14:07:57 2009 New Revision: 56387 URL: http://svn.opensuse.org/viewcvs/yast?rev=56387&view=rev Log: for name-based vhosts split configuration files (bnc#427427) Modified: branches/tmp/SLE-11-SP1-Stash/http-server/VERSION branches/tmp/SLE-11-SP1-Stash/http-server/agents/ag_http_server branches/tmp/SLE-11-SP1-Stash/http-server/package/yast2-http-server.changes branches/tmp/SLE-11-SP1-Stash/http-server/src/YaPI/HTTPD.pm Modified: branches/tmp/SLE-11-SP1-Stash/http-server/VERSION URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/SLE-11-SP1-Stash/http-server/VERSION?rev=56387&r1=56386&r2=56387&view=diff ============================================================================== --- branches/tmp/SLE-11-SP1-Stash/http-server/VERSION (original) +++ branches/tmp/SLE-11-SP1-Stash/http-server/VERSION Wed Mar 25 14:07:57 2009 @@ -1 +1 @@ -2.17.10 +2.17.11 Modified: branches/tmp/SLE-11-SP1-Stash/http-server/agents/ag_http_server URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/SLE-11-SP1-Stash/http-server/agents/ag_http_server?rev=56387&r1=56386&r2=56387&view=diff ============================================================================== --- branches/tmp/SLE-11-SP1-Stash/http-server/agents/ag_http_server (original) +++ branches/tmp/SLE-11-SP1-Stash/http-server/agents/ag_http_server Wed Mar 25 14:07:57 2009 @@ -121,15 +121,16 @@ foreach my $vhost ( @$conf ) { if ($file eq 'default-server.conf'){ $hash_table{'main'} = $vhost; -# foreach my $data ( @{$vhost->{'DATA'}} ) -# { if ($data->{'KEY'} eq 'NameVirtualHost'){ $hash_table{ $data->{'VALUE'} } = []; } -# } } else { - my $based='ip-based'; - $based='name-based' if (defined($vhost->{'VirtualByName'}) && $vhost->{'VirtualByName'} == 1); + my $key='ip-based'; + if (defined($vhost->{'VirtualByName'}) && $vhost->{'VirtualByName'} eq '1'){ + foreach my $row ( @{$vhost->{'DATA'}} ){ + $key=$row->{'VALUE'} if($row->{'KEY'} eq 'ServerName'); + } + } if (exists $vhost->{'HostIP'}){ - if ( exists $hash_table{ $vhost->{'HostIP'}} ){ push(@{$hash_table{ $vhost->{'HostIP'}}}, $vhost); } - else { push(@{$hash_table{$based}}, $vhost); } + if ( defined $hash_table{ $key} ){ push(@{$hash_table{ $key }}, $vhost); } + else { push(@{$hash_table{$key}}, $vhost); } } } } @@ -156,41 +157,6 @@ } } -#sub parse_module_selection() { -# my $class = shift; -# my $dir = Directory::vardir(); -# my $dir = "/var/lib/YaST2/"; # FIXME: calling Directory::vardir later -# my @ret = (); - -# if( open(FILE, "< $dir/httpd_active_module_selections.conf") ) { -# @ret = <FILE>; -# chomp(@ret); -# close(FILE); -# } ELse { -# return $class->SetError( summary => sprintf(_("unable to open file %s/httpd_active_module_selections.conf for reading: %s"),$dir,$!), -# code => "OPEN_FAILED" -# ); -# } - -# return \@ret; -#} - -sub write_module_selection { - my $class = shift; - my $newSelection = shift; - my $dir = "/var/lib/YaST2/"; # FIXME: calling Directory::vardir later - - if( open(FILE, "> $dir/httpd_active_module_selections.conf") ) { - print FILE join("\n",@$newSelection); - close(FILE); - } else { - return $class->SetError( summary => sprintf(_("unable to open file %s/httpd_active_module_selections.conf for writing: %s"),$dir,$!), - code => "OPEN_FAILED" - ); - } - return 1; -} - # generic apache2 configfile format parser sub sectionParser { my $keys = []; @@ -248,6 +214,11 @@ my $class = shift; my $data = shift; + # remove old files first + for my $remove ( ) { + unlink $remove; + } + foreach my $file ( keys(%{$data}) ) { next if( $file eq 'default-server.conf' ); # skip the default server here open( FILE, "> /etc/apache2/vhosts.d/$file" ) or do { @@ -413,10 +384,6 @@ } return $class->write_listen_conf(); } - } elsif( $path eq '.moduleselection' ) { - if( ref($args[0]) eq 'ARRAY' ) { - return $class->write_module_selection( $args[0] ); - } } else { # not implemented } Modified: branches/tmp/SLE-11-SP1-Stash/http-server/package/yast2-http-server.changes URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/SLE-11-SP1-Stash/http-server/package/yast2-http-server.changes?rev=56387&r1=56386&r2=56387&view=diff ============================================================================== --- branches/tmp/SLE-11-SP1-Stash/http-server/package/yast2-http-server.changes (original) +++ branches/tmp/SLE-11-SP1-Stash/http-server/package/yast2-http-server.changes Wed Mar 25 14:07:57 2009 @@ -1,4 +1,10 @@ ------------------------------------------------------------------- +Wed Mar 25 14:06:28 CET 2009 - mzugec@suse.cz + +- for name-based vhosts split configuration files (bnc#427427) +- 2.17.11 + +------------------------------------------------------------------- Mon Mar 23 16:54:23 CET 2009 - mzugec@suse.de - improved IP addr. validation for ip-based vhosts (bnc#486476) Modified: branches/tmp/SLE-11-SP1-Stash/http-server/src/YaPI/HTTPD.pm URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/SLE-11-SP1-Stash/http-server/src/YaPI/HTTPD.pm?rev=56387&r1=56386&r2=56387&view=diff ============================================================================== --- branches/tmp/SLE-11-SP1-Stash/http-server/src/YaPI/HTTPD.pm (original) +++ branches/tmp/SLE-11-SP1-Stash/http-server/src/YaPI/HTTPD.pm Wed Mar 25 14:07:57 2009 @@ -526,7 +526,7 @@ if ($byname eq 0){ push(@{$vhost_files->{'ip-based'}}, {HOSTID => "$ip/$servername", HostIP => $ip, DATA => \@newdata}); } else { - $vhost_files->{$ip} = [{HOSTID => "$ip/$servername", HostIP => $ip, DATA => \@newdata}]; + $vhost_files->{$servername} = [{HOSTID => "$ip/$servername", HostIP => $ip, DATA => \@newdata}]; } @@ -556,12 +556,11 @@ } } case "main" { delete $vhost_files->{'main'} if ($hostid eq 'main'); } - else { - foreach my $hostList ( $vhost_files->{$key} ) { - foreach my $hostentryHash ( @$hostList ) { delete ($vhost_files->{$key}) if ($hostentryHash->{HOSTID} eq $hostid); } - } - } - } + else { + my $vhost = $vhost_files->{$key}->[0]->{'HOSTID'}; + delete $vhost_files->{$key} if ($vhost eq $hostid); + } + } } } @@ -898,28 +897,21 @@ sub writeHosts (){ my $self = shift; - my @vhosts = (); - @vhosts = @{$vhost_files->{'ip-based'}} if (defined $vhost_files->{'ip-based'}); + # default server + my %data = ( 'default-server.conf' =>$vhost_files->{'main'}); - foreach my $key ( keys(%{$vhost_files}) ) { - switch($key) - { - case "ip-based" { - } - case "main" {} - else { - foreach my $hostList ( $vhost_files->{$key} ) { - foreach my $hostentryHash ( @$hostList ) { - push( @vhosts, $hostentryHash ) ; - } - } - } - } - } - - my %data = ( 'default-server.conf' =>$vhost_files->{'main'}); - $data{'yast2_vhosts.conf'} = \@vhosts ; + #ip based vhost + my @ip_vhosts = @{$vhost_files->{'ip-based'}} if (defined $vhost_files->{'ip-based'}); + my $size = @ip_vhosts; + $data{'ip-based_vhosts.conf'} = \@ip_vhosts if ($size>0); + + #name based vhost + foreach my $vhost ( keys(%{$vhost_files}) ) { + next if ($vhost eq 'main' || $vhost eq 'ip-based'); + my @name_vhost = @{$vhost_files->{$vhost}}; + $data{"$vhost.conf"} = \@name_vhost; + } SCR->Write(".http_server.vhosts", \%data); } -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org