Add warning if Virtualmin manages the procmail config

This commit is contained in:
Jamie Cameron
2022-02-09 21:41:52 -08:00
parent 34a6e393ce
commit feaa6e76c6
3 changed files with 24 additions and 1 deletions

View File

@ -39,6 +39,12 @@ else {
}
}
# Check if config is from Virtualmin
@conf = &get_procmailrc();
if (&check_virtualmin_config(\@conf)) {
print "<b>",$text{'index_virtualmin'},"</b><p>\n";
}
# Build links for adding things
@links = ( &ui_link("edit_recipe.cgi?new=1",$text{'index_add'}),
&ui_link("edit_recipe.cgi?new=1&block=1",$text{'index_badd'}),
@ -46,7 +52,6 @@ else {
push(@links, &ui_link("edit_inc.cgi?new=1",$text{'index_iadd'}))
if (!$includes);
@conf = &get_procmailrc();
if (@conf) {
@tds = ( "width=5" );
print &ui_form_start("delete_recipes.cgi", "post");

View File

@ -2,6 +2,7 @@ index_title=Procmail Mail Filter
index_procmail=Procmail mail filter
index_desc_other=The procmail actions below from $1 will apply to <b>all</b> email delivered to users on your system. However, they will only be used if Procmail is installed and your mail server is configured to use it.
index_mserr=Warning - any rules defined below will not be used : $1
index_virtualmin=Warning - your system's procmail configuration was created by Virtualmin to allow per-domain spam and virus filtering. Changing it here may interfere with Virtualmin's functionality.
index_action=Action to take
index_conds=Conditions
index_move=Move

View File

@ -365,6 +365,23 @@ elsif ($ms eq "sendmail") {
return ($ms, $err);
}
# check_virtualmin_config(&config)
# Returns 1 if Virtualmin created this procmail config
sub check_virtualmin_config
{
my ($conf) = @_;
return 0 if (!&foreign_check("virtual-server"));
&foreign_require("virtual-server");
my $gotvirt = 0;
foreach my $r (@$conf) {
if ($r->{'type'} eq '=' &&
$r->{'action'} =~ /^VIRTUALMIN=/) {
$gotvirt++;
}
}
return $gotvirt;
}
@known_flags = ('H', 'B', 'D', 'h', 'b', 'c', 'w', 'W', 'i', 'r', 'f');
1;