Fix <directory> when updating document root

This commit is contained in:
Jamie Cameron
2008-09-09 17:38:34 +00:00
parent 0f4a526534
commit e0ccebdcf3
3 changed files with 24 additions and 1 deletions

View File

@@ -39,3 +39,5 @@ Available Apache modules are now fully automatically detected on all operating s
Moved the SSL password option to the global settings level, to correspond with the way Apache expects it.
---- Changes since 1.410 ----
Added support for the funny ${APACHE_RUN_USER} and ${APACHE_PID_FILE} variables seen in apache2.conf on Ubuntu 8.04.
---- Changes since 1.430 ----
When a virtual host's base directory is changed, all <directory> blocks under it are updated too.

View File

@@ -106,7 +106,26 @@ else {
&save_directive("ServerName", $name ? [ $name ] : [ ],
$vconf->{'members'}, $conf);
# write out file
# Update any <Directory> blocks under the old path
if ($in{'root'} ne $in{'old_root'}) {
@dirs = &find_directive_struct("Directory", $vmembers);
foreach $dir (@dirs) {
if ($dir->{'words'}->[0] eq $in{'old_root'}) {
# Same dir
$dir->{'value'} = $in{'root'};
}
elsif ($dir->{'words'}->[0] =~ /^\Q$in{'old_root'}\E(\/.*)$/) {
# Under the dir
$dir->{'value'} = $in{'root'}.$1;
}
else {
next;
}
&save_directive_struct($dir, $dir, $vconf, $vconf, 1);
}
}
# Write out file
&flush_file_lines();
&after_changing();
&unlock_file($vconf->{'file'});

View File

@@ -102,6 +102,7 @@ if ($in{'virt'} && $access{'vaddr'}) {
else { $addr = $val; }
if ($addrs) {
# Multiple addresses and ports
print &ui_table_row($text{'vserv_addrs'},
&ui_textarea("addrs", join("\n", split(/\s+/, $addrs)),
4, 30));
@@ -130,6 +131,7 @@ if ($in{'virt'} && $access{'vaddr'}) {
&opt_input($root->{'words'}->[0], "root",
$text{'vserv_default'}, 50).
&file_chooser_button("root", 1, 1));
print &ui_hidden("old_root", $root->{'words'}->[0]);
# Server name
$name = &find_directive("ServerName", $v->{'members'});