diff --git a/procmail/CHANGELOG b/procmail/CHANGELOG index 54332e5ad..80676a7b1 100644 --- a/procmail/CHANGELOG +++ b/procmail/CHANGELOG @@ -2,3 +2,5 @@ Added a button for deleting multiple recipes at once. ---- Changes since 1.390 ---- Converted all code to use the new Webmin UI library, for a more consistent look. +---- Changes since 1.400 ---- +Improved checking for Procmail support in Sendmail and Postfix. diff --git a/procmail/index.cgi b/procmail/index.cgi index 4c9423bb6..440258174 100755 --- a/procmail/index.cgi +++ b/procmail/index.cgi @@ -30,10 +30,13 @@ if ($module_info{'usermin'}) { print &text('index_desc', "$procmailrc"),"
\n"; } else { - $ms = &foreign_installed("qmailadmin") ? "qmail" : - &foreign_installed("postfix") ? "postfix" : - &foreign_installed("sendmail") ? "sendmail" : "other"; - print &text('index_desc_'.$ms, "$procmailrc"),"
\n"; + ($ms, $mserr) = &check_mailserver_config(); + if ($mserr) { + print "",&text('index_mserr', $mserr),"
\n"; + } + elsif (!$ms) { + print &text('index_desc_other', "$procmailrc"),"
\n"; + } } # Build links for adding things diff --git a/procmail/install_check.pl b/procmail/install_check.pl new file mode 100644 index 000000000..1fce9759b --- /dev/null +++ b/procmail/install_check.pl @@ -0,0 +1,22 @@ +# install_check.pl + +do 'procmail-lib.pl'; + +# is_installed(mode) +# For mode 1, returns 2 if Procmail is installed and configured for use by +# Webmin, 1 if installed but not configured, or 0 otherwise. +# For mode 0, returns 1 if installed, 0 if not +sub is_installed +{ +# Check for procmail binary +return 0 if (!&has_command($config{'procmail'})); +if ($_[0]) { + # Check if configured too + local ($mod, $err) = &check_mailserver_config(); + return $err ? 1 : 2; + } +else { + return 1; + } +} + diff --git a/procmail/lang/en b/procmail/lang/en index 76c9ae9d4..e13928cfe 100644 --- a/procmail/lang/en +++ b/procmail/lang/en @@ -1,8 +1,6 @@ index_title=Procmail Mail Filter -index_desc_sendmail=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 the Sendmail local_procmail feature is enabled. -index_desc_postfix=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 Postfix is configured to use it for mailbox delivery. -index_desc_qmail=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 Qmail is configured to use it as the delivery program. 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_action=Action to take index_conds=Conditions index_move=Move @@ -127,3 +125,5 @@ log_down=Moved an entry down delete_err=Failed to delete actions delete_enone=None selected +check_epostfix=Procmail is not enabled in your Postfix configuration. The configuration file $2 must have the $1 option set to $3. +check_esendmail=Sendmail is not setup to use Procmail for local delivery. This can be configured in Webmin's Sendmail Mail Server module. diff --git a/procmail/procmail-lib.pl b/procmail/procmail-lib.pl index ff2c961c2..83bf44627 100644 --- a/procmail/procmail-lib.pl +++ b/procmail/procmail-lib.pl @@ -308,6 +308,49 @@ $_[1] =~ /^(.*)\/[^\/]+$/; return "$1/$_[0]"; } +# check_mailserver_config() +# Works out which mail server appears to be installed, and returns the +# module name and possibly an error message if Procmail is not setup +sub check_mailserver_config +{ +local $ms = &foreign_installed("qmailadmin") ? "qmailadmin" : + &foreign_installed("postfix") ? "postfix" : + &foreign_installed("sendmail") ? "sendmail" : undef; +return () if (!$ms); +local $err; +local $procmail_cmd = &has_command($config{'procmail'}); +if ($ms eq "qmailadmin") { + # Don't know how to check for this + $err = undef; + } +elsif ($ms eq "postfix") { + # Check mailbox_command + &foreign_require("postfix", "postfix-lib.pl"); + local $cmd = &postfix::get_real_value("mailbox_command"); + if ($cmd !~ /procmail/) { + $err = &text('check_epostfix', "mailbox_command", + $postfix::config{'postfix_config_file'}, + $procmail_cmd); + } + } +elsif ($ms eq "sendmail") { + # Check for local or procmail mailer + &foreign_require("sendmail", "sendmail-lib.pl"); + local $conf = &sendmail::get_sendmailcf(); + local $found; + foreach my $c (@$conf) { + if ($c->{'type'} eq 'M' && $c->{'value'} =~ /procmail/) { + $found++; + last; + } + } + if (!$found) { + $err = &text('check_esendmail','../sendmail/list_features.cgi'); + } + } +return ($ms, $err); +} + @known_flags = ('H', 'B', 'D', 'h', 'b', 'c', 'w', 'W', 'i', 'r', 'f'); 1;