3 # Run a fetchmail config file
5 require './fetchmail-lib.pl';
8 if ($config{'config_file'}) {
9 $file = $config{'config_file'};
12 &can_edit_user($in{'user'}) || &error($text{'poll_ecannot'});
13 @uinfo = getpwnam($in{'user'});
14 $file = "$uinfo[7]/.fetchmailrc";
15 $uheader = &text('poll_foruser', "<tt>$in{'user'}</tt>");
18 &ui_print_unbuffered_header($uheader, $text{'check_title'}, "");
20 $cmd = "$config{'fetchmail_path'} -v -f '$file'";
21 if ($config{'mda_command'}) {
22 $cmd .= " -m '$config{'mda_command'}'";
24 if (defined($in{'idx'})) {
25 @conf = &parse_config_file($file);
26 $poll = $conf[$in{'idx'}];
27 $cmd .= " $poll->{'poll'}";
30 print &text('check_exec', "<tt>$cmd</tt>"),"<p>\n";
33 # For webmin, switch to the user
34 if ($in{'user'} ne 'root') {
35 $cmd = &command_as_user($in{'user'}, 0, $cmd)
37 open(CMD, "$cmd 2>&1 |");
38 &additional_log("exec", undef, "su '$in{'user'}' -c '$cmd'");
41 # For usermin, which has already switched
42 open(CMD, "$cmd 2>&1 |");
45 print &html_escape($_);
50 if ($? > 256) { print "<b>$text{'check_failed'}</b> <p>\n"; }
51 else { print "$text{'check_ok'} <p>\n"; }
53 &webmin_log("check", defined($in{'idx'}) ? "server" : "file",
54 $config{'config_file'} ? $file : $in{'user'}, $poll);
56 if (!$fetchmail_config && $config{'view_mode'}) {
57 &ui_print_footer("edit_user.cgi?user=$in{'user'}", $text{'user_return'},
58 "", $text{'index_return'});
61 &ui_print_footer("", $text{'index_return'});