ACL option for fetchmail daemon
authorJamie Cameron <jcameron@webmin.com>
Tue, 11 Mar 2008 04:48:47 +0000 (04:48 +0000)
committerJamie Cameron <jcameron@webmin.com>
Tue, 11 Mar 2008 04:48:47 +0000 (04:48 +0000)
fetchmail/CHANGELOG
fetchmail/acl_security.pl
fetchmail/check.pl
fetchmail/defaultacl
fetchmail/edit_cron.cgi
fetchmail/edit_poll.cgi
fetchmail/fetchmail-lib.pl
fetchmail/lang/en
fetchmail/save_cron.cgi
fetchmail/start.cgi
fetchmail/stop.cgi

index 28e1924..b920be6 100644 (file)
@@ -2,3 +2,5 @@
 A new form has been added for creating and scheduling a Cron job to run Fetchmail, as an alternative to running the daemon
 ---- Changes since 1.200 ----
 The Scheduled Checking page is now available even when the module is configured to manage Fetchmail for all users on the system, and can setup a Cron job to fetch mail for all users.
+---- Changes since 1.400 ----
+Added an access control option to limit access to the Fetchmail daemon.
index 42132a8..08a6867 100644 (file)
@@ -23,6 +23,10 @@ printf "<input name=userscannot size=40 value='%s'> %s</td> </tr>\n",
 
 print "<tr> <td valign=top><b>$text{'acl_cron'}</b></td> <td>\n";
 print &ui_radio("cron", $_[0]->{'cron'},
+               [ [ 1, $text{'yes'} ], [ 0, $text{'no'} ] ]),"</td>\n";
+
+print "<td valign=top><b>$text{'acl_daemon'}</b></td> <td>\n";
+print &ui_radio("daemon", $_[0]->{'daemon'},
                [ [ 1, $text{'yes'} ], [ 0, $text{'no'} ] ]),"</td> </tr>\n";
 }
 
@@ -35,6 +39,7 @@ $_[0]->{'users'} = $in{'mode'} == 0 || $in{'mode'} == 3 ? "" :
                   $in{'mode'} == 1 ? $in{'userscan'}
                                    : $in{'userscannot'};
 $_[0]->{'cron'} = $in{'cron'};
+$_[0]->{'daemon'} = $in{'daemon'};
 
 }
 
index f082a8b..0aa8f5e 100755 (executable)
@@ -52,6 +52,11 @@ sub run_fetchmail
 {
 local ($config, $user) = @_;
 
+# Check if we have anything to do
+local @conf = &parse_config_file($config);
+@conf = grep { $_->{'poll'} } @conf;
+return if (!@conf);
+
 # Build the command
 local $cmd = "$config{'fetchmail_path'} -v -f ".quotemeta($config);
 if ($config{'mda_command'}) {
index 81d48cc..552e0c0 100644 (file)
@@ -2,3 +2,4 @@ noconfig=0
 users=
 mode=0
 cron=1
+daemon=1
index 275c53e..d1d3f41 100755 (executable)
@@ -4,7 +4,7 @@
 
 require './fetchmail-lib.pl';
 &foreign_require("cron", "cron-lib.pl");
-$access{'cron'} || &error($text{'cron_ecannot2'});
+$can_cron || &error($text{'cron_ecannot2'});
 &ui_print_header(undef, $text{'cron_title'}, "");
 
 print "$text{'cron_desc'}<p>\n";
index 78b569c..f083394 100755 (executable)
@@ -118,7 +118,7 @@ foreach $u (@users) {
 
        print "<tr> <td><b>$text{'poll_is'}</b></td> <td colspan=3>\n";
        printf "<input name=is_$i size=60 value='%s'></td> </tr>\n",
-               join(" ", @{$u->{'is'}});
+               join(" ", @{$u->{'is'}}) || $remote_user;
 
        print "<tr> <td><b>$text{'poll_keep'}</b></td> <td colspan=3>\n";
        printf "<input type=radio name=keep_$i value=1 %s> %s\n",
index d1c521b..c580dca 100644 (file)
@@ -17,11 +17,15 @@ if ($module_info{'usermin'}) {
        $cron_cmd = "$user_module_config_directory/check.pl";
        $cron_user = $remote_user;
        $fetchmail_config = "$remote_user_info[7]/.fetchmailrc";
+       $can_cron = $config{'can_cron'};
+       $can_daemon = $config{'can_daemon'};
        }
 else {
        $cron_cmd = "$module_config_directory/check.pl";
        $cron_user = "root";
        $fetchmail_config = $config{'config_file'};
+       $can_cron = $access{'cron'};
+       $can_daemon = $access{'daemon'};
        }
 
 # parse_config_file(file, [&global])
@@ -297,6 +301,5 @@ print &ui_links_row(\@links);
 }
 
 
-
 1;
 
index d4aee0f..37ca948 100644 (file)
@@ -105,6 +105,7 @@ acl_this=Current webmin user
 acl_only=Only users
 acl_except=All except users
 acl_cron=Can configure scheduled checking?
+acl_daemon=Can configure Fetchmail daemon?
 
 cron_title=Scheduled Checking
 cron_desc=This page can be used to enable or disable a Cron job to check the mail servers in your Fetchmail configuration on a regular schedule. Using a Cron job superior to running the Fetchmail daemon, as it does not need to be re-started at boot time.
index 3da82b2..0de6d35 100755 (executable)
@@ -4,7 +4,7 @@
 
 require './fetchmail-lib.pl';
 &foreign_require("cron", "cron-lib.pl");
-$access{'cron'} || &error($text{'cron_ecannot2'});
+$can_cron || &error($text{'cron_ecannot2'});
 &error_setup($text{'cron_err'});
 &ReadParse();
 
index e6f7be1..5f5cba0 100755 (executable)
@@ -6,6 +6,7 @@ require './fetchmail-lib.pl';
 &ReadParse();
 &error_setup($text{'start_err'});
 $config{'config_file'} || $< || &error($text{'start_ecannot'});
+$can_daemon || &error($text{'start_ecannot'});
 
 if ($config{'start_cmd'}) {
        $out = &backquote_logged("$config{'start_cmd'} 2>&1");
index f8eb09a..62402b5 100755 (executable)
@@ -6,6 +6,7 @@ require './fetchmail-lib.pl';
 &ReadParse();
 &error_setup($text{'stop_err'});
 $config{'config_file'} || $< || &error($text{'stop_ecannot'});
+$can_daemon || &error($text{'start_ecannot'});
 
 if ($config{'stop_cmd'}) {
        $out = &backquote_logged("$config{'stop_cmd'} 2>&1");