Improved procmail checking support

This commit is contained in:
Jamie Cameron
2008-03-25 19:15:24 +00:00
parent bea259346c
commit 839a41bf2e
5 changed files with 77 additions and 7 deletions

View File

@@ -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.

View File

@@ -30,10 +30,13 @@ if ($module_info{'usermin'}) {
print &text('index_desc', "<tt>$procmailrc</tt>"),"<p>\n";
}
else {
$ms = &foreign_installed("qmailadmin") ? "qmail" :
&foreign_installed("postfix") ? "postfix" :
&foreign_installed("sendmail") ? "sendmail" : "other";
print &text('index_desc_'.$ms, "<tt>$procmailrc</tt>"),"<p>\n";
($ms, $mserr) = &check_mailserver_config();
if ($mserr) {
print "<b>",&text('index_mserr', $mserr),"</b><p>\n";
}
elsif (!$ms) {
print &text('index_desc_other', "<tt>$procmailrc</tt>"),"<p>\n";
}
}
# Build links for adding things

22
procmail/install_check.pl Normal file
View File

@@ -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;
}
}

View File

@@ -1,8 +1,6 @@
index_title=Procmail Mail Filter
index_desc_sendmail=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 the Sendmail <tt>local_procmail</tt> feature is enabled.
index_desc_postfix=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 Postfix is configured to use it for mailbox delivery.
index_desc_qmail=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 Qmail is configured to use it as the delivery program.
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_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 <tt>$2</tt> must have the <tt>$1</tt> option set to <tt>$3</tt>.
check_esendmail=Sendmail is not setup to use Procmail for local delivery. This can be configured in Webmin's <a href='$1'>Sendmail Mail Server</a> module.

View File

@@ -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;