Fix case where two master entries exist with the same name https://www.virtualmin.com/node/25309

This commit is contained in:
Jamie Cameron
2013-02-07 22:03:37 -08:00
parent 4d1c93d4f1
commit e3670fa2e9
3 changed files with 6 additions and 3 deletions

View File

@ -19,7 +19,8 @@ if ($in{'new'}) {
}
else {
($prog) = grep { $_->{'name'} eq $in{'name'} &&
$_->{'type'} eq $in{'type'} } @$master;
$_->{'type'} eq $in{'type'} &&
$_->{'enabled'} == $in{'enabled'} } @$master;
$prog || &error($text{'master_egone'});
&ui_print_header(undef, $text{'master_edit'}, "");
}
@ -28,6 +29,7 @@ print &ui_form_start("save_master.cgi", "post");
print &ui_hidden("new", $in{'new'}),"\n";
print &ui_hidden("old", $in{'name'}),"\n";
print &ui_hidden("oldtype", $in{'type'}),"\n";
print &ui_hidden("oldenabled", $in{'enabled'}),"\n";
print &ui_table_start($text{'master_header'}, "width=100%", 4);
print &ui_table_row($text{'master_type'},

View File

@ -18,7 +18,7 @@ print &ui_columns_start([ $text{'master_name'},
foreach $m (@$master) {
print &ui_columns_row([
"<a href='edit_master.cgi?name=".&urlize($m->{'name'}).
"&type=".&urlize($m->{'type'})."'>".
"&type=".&urlize($m->{'type'})."&enabled=$m->{'enabled'}'>".
$m->{'name'}."</a>",
$m->{'enabled'} ? $text{'yes'} :
"<font color=#ff0000>$text{'no'}</font>",

View File

@ -11,7 +11,8 @@ if ($in{'new'}) {
}
else {
($prog) = grep { $_->{'name'} eq $in{'old'} &&
$_->{'type'} eq $in{'oldtype'} } @$master;
$_->{'type'} eq $in{'oldtype'} &&
$_->{'enabled'} == $in{'oldenabled'} } @$master;
$prog || &error($text{'master_egone'});
}
&lock_file($config{'postfix_master'});