Discussion:
[BackupPC-devel] bug in BackupPC_sendEmail (sysadmin mail sent to wrong user)
Stefan Fleischmann
2015-07-04 21:44:14 UTC
Permalink
In many host configuration files I have an override for EMailAdminUserName.
What happens now is that backuppc's sysadmin mail is sent to the user
specified in EMailAdminUserName of the last host I added.
foreach my $host ( sort(keys(%Status)) ) {
#
# read any per-PC config settings (allowing per-PC email settings)
#
$bpc->ConfigRead($host);
%Conf = $bpc->Conf();
The problem is that after the loop is done $Conf{EMailAdminUserName} will
contain the username specified as an override in the host configuration
processed last and not the value from the main configuration anymore. But
if ( $adminMesg ne "" && $Conf{EMailAdminUserName} ne "" ) {
my $headers = $Conf{EMailHeaders};
$headers .= "\n" if ( $headers !~ /\n$/ );
$adminMesg = <<EOF;
To: $Conf{EMailAdminUserName}
Subject: BackupPC administrative attention needed
$headers
${adminMesg}Regards,
PC Backup Genie
EOF
SendMail($adminMesg);
}
I inserted a line to read the main configuration again after the loop (see
attached patch). That fixes the issue for me but since I'm not familiar with
Perl I wonder if that's the correct way to do it.

Best,
Stefan

Loading...