Disallow editing of virtualmin-controlled settings in APache module https://sourceforge.net/tracker/?func=detail&atid=117457&aid=3511530&group_id=17457

This commit is contained in:
Jamie Cameron
2012-03-27 17:35:28 -07:00
parent ec6405c69f
commit 8184dd3aca
6 changed files with 42 additions and 3 deletions

View File

@@ -49,3 +49,5 @@ Fixed bug that preventing saving of virtual hosts with multiple addresses, one o
Full Bulgarian translation, thanks to King.
---- Changes since 1.510 ----
The default port on the Create virtual host tab is now set to better match the name-based virtual host ports.
---- Changes since 1.580 ----
Apache virtual hosts owned by Virtualmin can no longer have their address, port, name or document directory changed.

View File

@@ -827,7 +827,7 @@ else {
}
}
# generate_inputs(&editors, &directives)
# generate_inputs(&editors, &directives, [&skip])
# Displays a 2-column list of options, for use inside a table
sub generate_inputs
{
@@ -1963,5 +1963,21 @@ else {
}
}
# is_virtualmin_domain(&virt)
# Returns the domain hash if some virtualhost is managed by Virtualmin
sub is_virtualmin_domain
{
local ($virt) = @_;
local $n = &find_directive("ServerName", $virt->{'members'});
return undef if (!$n);
return undef if (!&foreign_check("virtual-server"));
&foreign_require("virtual-server");
local $d = &virtual_server::get_domain_by("dom", $n);
return $d if ($d);
$n =~ s/^www\.//i;
local $d = &virtual_server::get_domain_by("dom", $n);
return $d;
}
1;

View File

@@ -28,7 +28,15 @@ print &ui_hidden("virt", $in{'virt'});
print &ui_hidden("type", $in{'type'});
print &ui_table_start(&text('virt_header2', $text{"type_$in{'type'}"},
&virtual_name($v)), "width=100%", 4);
&generate_inputs(\@dirs, $conf);
if ($in{'type'} == 5 && &is_virtualmin_domain($v)) {
@dirs = grep { $_->{'name'} ne 'DocumentRoot' &&
$_->{'name'} ne 'ServerPath' } @dirs;
}
elsif ($in{'type'} == 1 && &is_virtualmin_domain($v)) {
@dirs = grep { $_->{'name'} ne 'ServerName' &&
$_->{'name'} ne 'ServerAlias' } @dirs;
}
&generate_inputs(\@dirs, $conf, \@skip);
print &ui_table_end();
print &ui_form_end([ [ "", $text{'save'} ] ]);

View File

@@ -124,6 +124,7 @@ virt_euser=You are not allowed to change the user or group for this virtual serv
virt_header2=$1 for $2
vserv_title=Virtual Server Configuration
vserv_virtualmin=This Apache virtual host belongs to the Virtualmin server <tt>$1</tt>, so the address, port, base directory and hostname cannot be changed here.
vserv_ecannot=You cannot edit this virtual server's address
vserv_addr=Address
vserv_addrs=Addresses

View File

@@ -13,6 +13,14 @@ $in{'type'} == 8 && !$access{'vuser'} &&
if (!$in{'virt'}) {
@edit = grep { !$_->{'virtualonly'} } @edit;
}
if ($in{'type'} == 5 && &is_virtualmin_domain($v)) {
@edit = grep { $_->{'name'} ne 'DocumentRoot' &&
$_->{'name'} ne 'ServerPath' } @edit;
}
elsif ($in{'type'} == 1 && &is_virtualmin_domain($v)) {
@edit = grep { $_->{'name'} ne 'ServerName' &&
$_->{'name'} ne 'ServerAlias' } @edit;
}
&error_setup(&text('efailed', $text{"type_$in{'type'}"}));
&parse_inputs(\@edit, $conf, &get_config());

View File

@@ -85,7 +85,8 @@ print &ui_table_row($text{'virt_path'},
print &ui_table_end();
print &ui_form_end([ [ "", $text{'create'} ] ]);
if ($in{'virt'} && $access{'vaddr'}) {
$d = &is_virtualmin_domain($v);
if ($in{'virt'} && $access{'vaddr'} && !$d) {
# Show form for changing virtual server
print &ui_hr();
print &ui_form_start("save_vserv.cgi");
@@ -154,6 +155,9 @@ if ($in{'virt'} && $access{'vaddr'}) {
print &ui_form_end([ [ undef, $text{'save'} ],
[ "delete", $text{'delete'} ] ]);
}
elsif ($in{'virt'} && $access{'vaddr'} && $d) {
print "<b>",&text('vserv_virtualmin', $d->{'dom'}),"</b><p>\n";
}
&ui_print_footer("", $text{'index_return'});