BackupPC-users

[BackupPC-users] bug in BackupPC_sendEmail (sysadmin mail sent to wrong user)

2015-06-29 15:09:12
Subject: [BackupPC-users] bug in BackupPC_sendEmail (sysadmin mail sent to wrong user)
From: Stefan Fleischmann <stefan AT arcticmail DOT com>
To: backuppc-users AT lists.sourceforge DOT net
Date: Mon, 29 Jun 2015 20:54:12 +0200
Hi!

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.

If you have a look in BackupPC_sendEmail starting from line 181:

>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
you use it down in line 386:

>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). Is that the way to do it?

Best,
Stefan

Attachment: BackupPC_sendEmail.diff
Description: Text Data

------------------------------------------------------------------------------
Don't Limit Your Business. Reach for the Cloud.
GigeNET's Cloud Solutions provide you with the tools and support that
you need to offload your IT needs and focus on growing your business.
Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/
_______________________________________________
BackupPC-users mailing list
BackupPC-users AT lists.sourceforge DOT net
List:    https://lists.sourceforge.net/lists/listinfo/backuppc-users
Wiki:    http://backuppc.wiki.sourceforge.net
Project: http://backuppc.sourceforge.net/
<Prev in Thread] Current Thread [Next in Thread>
  • [BackupPC-users] bug in BackupPC_sendEmail (sysadmin mail sent to wrong user), Stefan Fleischmann <=