Support MAILFROMADDRESS, per longstanding user requests. Documented in twconfig man page.

This commit is contained in:
Brian Cox 2016-04-11 11:43:45 -07:00
parent c136c5b398
commit 12cef61f40
4 changed files with 33 additions and 12 deletions

View File

@ -274,6 +274,11 @@ However, mailing no violations reports will increase the amount of data
that must be processed.
.br
Initial value: \fItrue\fR
.IP \f(CWMAILFROMADDRESS\fP
Specifies the value of the "From:" field in email reports.
.br
Initial value: \fItripwire@hostname\fP, where 'hostname' is the local
machine name.
.SH VERSION INFORMATION
This man page describes
.IR "Tripwire 2.4" "."

View File

@ -409,6 +409,9 @@ static void FillOutConfigInfo(cTWModeCommon* pModeInfo, const cConfigFile& cf)
else
pModeInfo->mMailNoViolations = true; // MAILPROGRAM is not required to be specified
if(cf.Lookup(TSTRING(_T("MAILFROMADDRESS")), str))
pModeInfo->mMailFrom = str;
// SYSLOG reporting
if(cf.Lookup(TSTRING(_T("SYSLOGREPORTING")), str))
{

View File

@ -181,6 +181,7 @@ class cTWModeCommon
unsigned short mSmtpPort; // port number of that SMTP host
TSTRING mMailProgram; // full path to executable to use for piped mail
bool mMailNoViolations; // Email out reports with no violations?
TSTRING mMailFrom;
cTWModeCommon() : mVerbosity(1),
mLocalProvided(false),

View File

@ -590,9 +590,15 @@ static bool EmailReportTo(const TSTRING &toAddress, const cFCOReportHeader& head
cDisplayEncoder::EncodeInline( toAddress ).c_str());
reportMail->AddRecipient(toAddress);
TSTRING machineName;
iFSServices::GetInstance()->GetMachineNameFullyQualified(machineName);
reportMail->SetFrom(TSS_GetString( cTripwire, tripwire::STR_EMAIL_FROM) + machineName);
if (!modeCommon->mMailFrom.empty())
reportMail->SetFrom(modeCommon->mMailFrom);
else
{
TSTRING machineName;
iFSServices::GetInstance()->GetMachineNameFullyQualified(machineName);
reportMail->SetFrom(TSS_GetString( cTripwire, tripwire::STR_EMAIL_FROM) + machineName);
}
reportMail->SetFromName(TSS_GetString(cTW, tw::STR_TSS_PRODUCT_NAME));
reportMail->SetSubject( trv.SingleLineReport() );
@ -729,17 +735,23 @@ bool cTWCmdLineUtil::SendEmailTestMessage(const TSTRING &mAddress, const cTWMode
// send the report
try
{
// set up the cMailMessage class, and send it
reportMail->AddRecipient(mAddress);
// set up the cMailMessage class, and send it
reportMail->AddRecipient(mAddress);
TSTRING machineName;
iFSServices::GetInstance()->GetMachineNameFullyQualified(machineName);
reportMail->SetFrom(TSS_GetString( cTripwire, tripwire::STR_EMAIL_FROM) + machineName);
reportMail->SetFromName(TSS_GetString(cTW, tw::STR_TSS_PRODUCT_NAME));
if (!modeCommon->mMailFrom.empty())
reportMail->SetFrom(modeCommon->mMailFrom);
else
{
TSTRING machineName;
iFSServices::GetInstance()->GetMachineNameFullyQualified(machineName);
reportMail->SetFrom(TSS_GetString( cTripwire, tripwire::STR_EMAIL_FROM) + machineName);
}
reportMail->SetFromName(TSS_GetString(cTW, tw::STR_TSS_PRODUCT_NAME));
reportMail->SetSubject (TSS_GetString( cTripwire, tripwire::STR_TEST_EMAIL_SUBJECT));
reportMail->SetBody (TSS_GetString( cTripwire, tripwire::STR_TEST_EMAIL_BODY));
reportMail->Send();
reportMail->SetSubject (TSS_GetString( cTripwire, tripwire::STR_TEST_EMAIL_SUBJECT));
reportMail->SetBody (TSS_GetString( cTripwire, tripwire::STR_TEST_EMAIL_BODY));
reportMail->Send();
}
catch(eError& e)
{