From feaa6e76c6511887e5fe5eba7c9606d5b844ce75 Mon Sep 17 00:00:00 2001 From: Jamie Cameron Date: Wed, 9 Feb 2022 21:41:52 -0800 Subject: [PATCH] Add warning if Virtualmin manages the procmail config --- procmail/index.cgi | 7 ++++++- procmail/lang/en | 1 + procmail/procmail-lib.pl | 17 +++++++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/procmail/index.cgi b/procmail/index.cgi index 3b3fea02c..9e3a988dd 100755 --- a/procmail/index.cgi +++ b/procmail/index.cgi @@ -39,6 +39,12 @@ else { } } +# Check if config is from Virtualmin +@conf = &get_procmailrc(); +if (&check_virtualmin_config(\@conf)) { + print "",$text{'index_virtualmin'},"

\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"); diff --git a/procmail/lang/en b/procmail/lang/en index 97e760c85..e03722ace 100644 --- a/procmail/lang/en +++ b/procmail/lang/en @@ -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 all 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 diff --git a/procmail/procmail-lib.pl b/procmail/procmail-lib.pl index ee300d357..7505f87ea 100755 --- a/procmail/procmail-lib.pl +++ b/procmail/procmail-lib.pl @@ -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;