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. that must be processed.
.br .br
Initial value: \fItrue\fR 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 .SH VERSION INFORMATION
This man page describes This man page describes
.IR "Tripwire 2.4" "." .IR "Tripwire 2.4" "."

View File

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

View File

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

View File

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