diff --git a/man/man4/twconfig.4 b/man/man4/twconfig.4 index 80f7d40..38e2ffe 100644 --- a/man/man4/twconfig.4 +++ b/man/man4/twconfig.4 @@ -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" "." diff --git a/src/tripwire/twcmdline.cpp b/src/tripwire/twcmdline.cpp index cfccb72..94e7d6d 100644 --- a/src/tripwire/twcmdline.cpp +++ b/src/tripwire/twcmdline.cpp @@ -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)) { diff --git a/src/tripwire/twcmdline.h b/src/tripwire/twcmdline.h index d571d3f..a5ddc7a 100644 --- a/src/tripwire/twcmdline.h +++ b/src/tripwire/twcmdline.h @@ -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), diff --git a/src/tripwire/twcmdlineutil.cpp b/src/tripwire/twcmdlineutil.cpp index 7bd25af..ac99c03 100644 --- a/src/tripwire/twcmdlineutil.cpp +++ b/src/tripwire/twcmdlineutil.cpp @@ -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) {