Respect allowed user list for logging to email

This commit is contained in:
Jamie Cameron
2021-12-10 23:52:44 -08:00
parent d7915e785b
commit b3cb270cca
3 changed files with 15 additions and 25 deletions
+15 -8
View File
@@ -6488,12 +6488,17 @@ foreach my $k (keys %{$_[3]}) {
}
# Construct description if one is needed
my $logemail = $gconfig{'logemail'} &&
(!$gconfig{'logmodulesemail'} ||
&indexof($m, split(/\s+/, $gconfig{'logmodulesemail'})) >= 0) &&
&foreign_check("mailboxes");
my $lm = $m || "global";
my $lu = $base_remote_user || $remote_user;
my $logemail =
$gconfig{'logemail'} &&
(!$gconfig{'logmodulesemail'} ||
&indexof($lm, split(/\s+/, $gconfig{'logmodulesemail'})) >= 0) &&
(!$gconfig{'logusersemail'} ||
&indexof($lu, split(/\s+/, $gconfig{'logusersemail'})) >= 0) &&
&foreign_check("mailboxes");
my $msg = undef;
my %minfo = &get_module_info($m);
my %minfo = $lm eq "global" ? { 'desc' => 'None' } : &get_module_info($m);
if ($logemail || $gconfig{'logsyslog'}) {
my $mod = &get_module_name();
my $mdir = module_root_directory($mod);
@@ -6521,11 +6526,13 @@ if ($logemail) {
# Construct an email message
&foreign_require("mailboxes");
my $mdesc;
if ($m && $m ne "global") {
$mdesc = $minfo{'desc'} || $m;
if ($lm ne "global") {
$mdesc = $minfo{'desc'} || $lm;
}
my $body = $text{'log_email_desc'}."\n\n";
$body .= &text('log_email_mod', $m || "global")."\n";
if ($lm ne "global") {
$body .= &text('log_email_mod', $lm)."\n";
}
if ($mdesc) {
$body .= &text('log_email_moddesc', $mdesc)."\n";
}
-3
View File
@@ -57,9 +57,6 @@ $gconfig{'logperms'} = $miniserv{'logperms'};
!$in{'logfiles'} || &has_command("diff") ||
&error(&text('log_ediff', "diff"));
$gconfig{'logsyslog'} = $in{'logsyslog'} if (defined($in{'logsyslog'}));
$gconfig{'logemail'} = $in{'email_def'} ? undef : $in{'email'};
$gconfig{'logmodulesemail'} =
$in{'mallemail'} ? '' : join(" ", split(/\0/, $in{'modulesemail'}));
&lock_file("$config_directory/config");
&write_file("$config_directory/config", \%gconfig);
&unlock_file("$config_directory/config");
-14
View File
@@ -93,20 +93,6 @@ if (!$@) {
&ui_yesno_radio("logsyslog", int($gconfig{'logsyslog'})));
}
# Log via email?
print &ui_table_row($text{'log_email'},
&ui_opt_textbox("email", $gconfig{'logemail'}, 40,
$text{'log_emailnone'}));
# Modules for email log
print &ui_table_row($text{'log_inmodsemail'},
&ui_radio("mallemail", $gconfig{'logmodulesemail'} ? 0 : 1,
[ [ 1, $text{'log_mall'} ], [ 0, $text{'log_modules'} ] ]).
"<br>\n".
&ui_select("modulesemail",
[ split(/\s+/, $gconfig{'logmodulesemail'}) ],
\@logmods, 5, 1));
print &ui_table_end();
print &ui_form_end([ [ "save", $text{'save'} ] ]);