From 3135aaea4f25aa6204c61bfad6b4ea4219b0ad97 Mon Sep 17 00:00:00 2001 From: Brian Cox Date: Wed, 22 Jun 2016 23:45:46 -0700 Subject: [PATCH] More dead code removal: Remaining MAPI stuff, & integration code for the long-defunct GeoPlex/GMMS. --- src/tripwire/mailmessage.h | 6 - src/tripwire/tripwireerrors.cpp | 11 -- src/tripwire/tripwirestrings.cpp | 54 -------- src/tripwire/tripwirestrings.h | 39 ------ src/tripwire/twcmdline.cpp | 106 ---------------- src/tripwire/twcmdline.h | 6 - src/tripwire/twcmdlineutil.cpp | 203 ------------------------------- src/tripwire/twcmdlineutil.h | 11 -- src/tw/configfile.cpp | 4 - 9 files changed, 440 deletions(-) diff --git a/src/tripwire/mailmessage.h b/src/tripwire/mailmessage.h index ac95c9f..ac826e8 100644 --- a/src/tripwire/mailmessage.h +++ b/src/tripwire/mailmessage.h @@ -61,11 +61,6 @@ TSS_EXCEPTION( eMailSMTPOpenConnection, eMailMessageError ); TSS_EXCEPTION( eMailSMTPCloseConnection, eMailMessageError ); TSS_EXCEPTION( eMailSMTPServer, eMailMessageError ); -// MAPI -TSS_EXCEPTION( eMailMAPINotAvailable, eMailMessageError ); -TSS_EXCEPTION( eMailMAPIUnload, eMailMessageError ); -TSS_EXCEPTION( eMailMAPISend, eMailMessageError ); - // piped TSS_EXCEPTION( eMailPipedOpen, eMailMessageError ); TSS_EXCEPTION( eMailPipedWrite, eMailMessageError ); @@ -100,7 +95,6 @@ public: INVALID_METHOD, MAIL_BY_SMTP, MAIL_BY_PIPE, - MAIL_BY_MAPI, MAIL_NUM_ITEMS }; diff --git a/src/tripwire/tripwireerrors.cpp b/src/tripwire/tripwireerrors.cpp index 553734e..4aa927e 100644 --- a/src/tripwire/tripwireerrors.cpp +++ b/src/tripwire/tripwireerrors.cpp @@ -60,11 +60,6 @@ TSS_REGISTER_ERROR( eMailSMTPOpenConnection(), _T("The SMTP connection coul TSS_REGISTER_ERROR( eMailSMTPCloseConnection(), _T("The SMTP connection could not be properly closed.") ); TSS_REGISTER_ERROR( eMailSMTPServer(), _T("The SMTP server returned an error.") ); -// MAPI -TSS_REGISTER_ERROR( eMailMAPINotAvailable(), _T("MAPI is not available.") ); -TSS_REGISTER_ERROR( eMailMAPIUnload(), _T("MAPI32.DLL could not be loaded.") ); -TSS_REGISTER_ERROR( eMailMAPISend(), _T("Sending message via MAPI failed.") ); - // Piped TSS_REGISTER_ERROR( eMailPipedOpen(), _T("Problem opening mail pipe.") ); TSS_REGISTER_ERROR( eMailPipedWrite(), _T("Problem writing to mail pipe.") ); @@ -104,10 +99,4 @@ TSS_REGISTER_ERROR( eTWInvalidReportLevelCfg(), _T("Invalid reporting level TSS_REGISTER_ERROR( eTWInvalidPortNumber(), _T("Invalid SMTP port number.\nValid ports: [0-65535]\n") ); TSS_REGISTER_ERROR( eTWInvalidTempDirectory(), _T("Cannot access temp directory.") ); -// GMMS -TSS_REGISTER_ERROR( eGmmsError(), _T("GMMS error.") ); -TSS_REGISTER_ERROR( eGmmsCouldntOpenPipe(), _T("GMMS executable not found: ") ); -TSS_REGISTER_ERROR( eGmmsCouldntWritePipe(), _T("There was a problem writing to gmms: ") ); -TSS_REGISTER_ERROR( eGmmsCmdFailed(), _T("GMMS exited with non-zero status: ") ); - TSS_END_ERROR_REGISTRATION() diff --git a/src/tripwire/tripwirestrings.cpp b/src/tripwire/tripwirestrings.cpp index 2e88fb0..12cffdf 100644 --- a/src/tripwire/tripwirestrings.cpp +++ b/src/tripwire/tripwirestrings.cpp @@ -34,19 +34,6 @@ #include "stdtripwire.h" #include "tripwirestrings.h" - -#ifdef GMMS -#define GMMS_OPTION _T(" -g --gmms\n") -#define GMMS_VERBOSITY_OPTION _T(" -b 1|2 --gmms-verbosity 1|2\n") -#else -#define GMMS_OPTION -#define GMMS_VERBOSITY_OPTION -#endif - -#if IS_UNIX -#define MAPI_OPTION -#endif - #ifdef __AROS__ # define VERSION_PREFIX "$VER: " #else @@ -115,13 +102,6 @@ TSS_BeginStringtable( cTripwire ) _T(" -i list --ignore list\n") _T(" -M --email-report\n") _T(" -t { 0|1|2|3|4 } --email-report-level { 0|1|2|3|4 }\n") - - // Only insert the description of these two options if GMMS is defined. - // Otherwise these two lines will be blank. You cannot have #ifdef in - // the middle of this big concatenated string. - GMMS_OPTION - GMMS_VERBOSITY_OPTION - _T("[object1 [object2...]]\n") _T("\n") _T("The -v and -s options are mutually exclusive.\n") @@ -178,8 +158,6 @@ TSS_BeginStringtable( cTripwire ) _T(" -m t --test\n") _T(" -e user@domain.com --email user@domain.com\n") _T("\n") - // Only insert the MAPI option under NT. - MAPI_OPTION _T("Only one address may be entered.\n") _T("\n") ), @@ -207,31 +185,6 @@ TSS_BeginStringtable( cTripwire ) TSS_StringEntry( tripwire::STR_PU_BAD_PROPS, _T("Conflicting properties for object ") ), TSS_StringEntry( tripwire::STR_PROCESSING_GENRE, _T("*** Processing %s ***\n") ), - // gmms reporting, these strings are for the gmms command line - TSS_StringEntry( tripwire::STR_GMMS_START, _T("alert Tripwire: ")), - TSS_StringEntry( tripwire::STR_GMMS_END, _T(")")), - TSS_StringEntry( tripwire::STR_GMMS_VERBOSITY1A, _T(", Violations found (")), - TSS_StringEntry( tripwire::STR_GMMS_VERBOSITY1B, _T("), Max severity (")), - TSS_StringEntry( tripwire::STR_GMMS_VERBOSITY2A, _T(", Rule Violated (")), - TSS_StringEntry( tripwire::STR_GMMS_VERBOSITY2B, _T("), File (")), - TSS_StringEntry( tripwire::STR_GMMS_VERBOSITY2C, _T("), Severity (")), - - - TSS_StringEntry( tripwire::STR_ERR2_MAIL_MESSAGE_MAPI_SEND_ERRROR1, _T("A recipient matched more than one of the recipient descriptor structures. No message was sent.\n(MAPI error: MAPI_E_AMBIGUOUS_RECIPIENT)")), - TSS_StringEntry( tripwire::STR_ERR2_MAIL_MESSAGE_MAPI_SEND_ERRROR2, _T("The specified attachment was not found. No message was sent.\n(MAPI error: MAPI_E_ATTACHMENT_NOT_FOUND)")), - TSS_StringEntry( tripwire::STR_ERR2_MAIL_MESSAGE_MAPI_SEND_ERRROR3, _T("The specified attachment could not be opened. No message was sent.\n(MAPI error: MAPI_E_ATTACHMENT_OPEN_FAILURE)")), - TSS_StringEntry( tripwire::STR_ERR2_MAIL_MESSAGE_MAPI_SEND_ERRROR4, _T("The type of a recipient was not MAPI_TO, MAPI_CC, or MAPI_BCC. No message was sent.\n(MAPI error: MAPI_E_BAD_RECIPTYPE)")), - TSS_StringEntry( tripwire::STR_ERR2_MAIL_MESSAGE_MAPI_SEND_ERRROR5, _T("One or more unspecified errors occurred. No message was sent.\n(MAPI error: MAPI_E_FAILURE)")), - TSS_StringEntry( tripwire::STR_ERR2_MAIL_MESSAGE_MAPI_SEND_ERRROR6, _T("There was insufficient memory to proceed. No message was sent.\n(MAPI error: MAPI_E_INSUFFICIENT_MEMORY)")), - TSS_StringEntry( tripwire::STR_ERR2_MAIL_MESSAGE_MAPI_SEND_ERRROR7, _T("One or more recipients were invalid or did not resolve to any address.\n(MAPI error: MAPI_E_INVALID_RECIPS)")), - TSS_StringEntry( tripwire::STR_ERR2_MAIL_MESSAGE_MAPI_SEND_ERRROR8, _T("There was no default logon, and the user failed to log on successfully when the logon dialog box was displayed. No message was sent.\n(MAPI error: MAPI_E_LOGIN_FAILURE)")), - TSS_StringEntry( tripwire::STR_ERR2_MAIL_MESSAGE_MAPI_SEND_ERRROR9, _T("The text in the message was too large. No message was sent.\n(MAPI error: MAPI_E_TEXT_TOO_LARGE)")), - TSS_StringEntry( tripwire::STR_ERR2_MAIL_MESSAGE_MAPI_SEND_ERRROR10, _T("There were too many file attachments. No message was sent.\n(MAPI error: MAPI_E_TOO_MANY_FILES)")), - TSS_StringEntry( tripwire::STR_ERR2_MAIL_MESSAGE_MAPI_SEND_ERRROR11, _T("There were too many recipients. No message was sent.\n(MAPI error: MAPI_E_TOO_MANY_RECIPIENTS)")), - TSS_StringEntry( tripwire::STR_ERR2_MAIL_MESSAGE_MAPI_SEND_ERRROR12, _T("A recipient did not appear in the address list. No message was sent.\n(MAPI error: MAPI_E_UNKNOWN_RECIPIENT)")), - TSS_StringEntry( tripwire::STR_ERR2_MAIL_MESSAGE_MAPI_SEND_ERRROR13, _T("The user canceled one of the dialog boxes. No message was sent.\n(MAPI error: MAPI_E_USER_ABORT)")), - TSS_StringEntry( tripwire::STR_ERR2_MAIL_MESSAGE_MAPI_SEND_ERRROR14, _T("MAPI returned a unrecognized error (")), - TSS_StringEntry( tripwire::STR_ERR2_MAIL_MESSAGE_MAPI_SEND_ERRROR14_1, _T(").")), TSS_StringEntry( tripwire::STR_ERR2_MAIL_MESSAGE_SERVER, _T("Server: ")), TSS_StringEntry( tripwire::STR_ERR2_MAIL_MESSAGE_SERVER_RETURNED_ERROR, _T("Error Number:")), @@ -243,7 +196,6 @@ TSS_BeginStringtable( cTripwire ) TSS_StringEntry( tripwire::STR_ERR_IC_EMAIL_AND_FILES, _T("Email reporting cannot be specified when checking a list of objects.")), TSS_StringEntry( tripwire::STR_ERR_NO_MAIL_METHOD, _T("No mail method specified in configuration file.")), TSS_StringEntry( tripwire::STR_ERR_INVALID_MAIL_METHOD, _T("Invalid mail method in configuration file.")), - TSS_StringEntry( tripwire::STR_ERR_MAPI_NOT_SUPPORTED, _T("Configuration option MAILMETHOD=MAPI is not supported on this platform.")), TSS_StringEntry( tripwire::STR_ERR_MISSING_MAILPROGRAM, _T("Mail method is set to SENDMAIL but MAILPROGRAM was not defined in configuration file")), TSS_StringEntry( tripwire::STR_ERR_NO_TEST_MODE, _T("No test area specified.")), TSS_StringEntry( tripwire::STR_GENERATING_DB, _T("Generating the database...\n")), @@ -290,12 +242,6 @@ TSS_BeginStringtable( cTripwire ) TSS_StringEntry( tripwire::STR_EMAIL_SUBJECT_OK, _T("Tripwire found no violations")), TSS_StringEntry( tripwire::STR_ERR_EMAIL_REPORT, _T("Email reporting failed.")), TSS_StringEntry( tripwire::STR_ERR_EMAIL_TEST, _T("Email test failed.")), - // - // Gmms errors - // - TSS_StringEntry( tripwire::STR_ERR_BAD_GMMS_VERBOSITY, _T("Error: gmms verbosity must be 1 or 2. ")), - TSS_StringEntry( tripwire::STR_ERR_GMMS_VERBOSITY_ONLY, _T("Error: --gmms-verbosity specified without --gmms. ")), - TSS_StringEntry( tripwire::STR_NOTIFY_PROCESSING, _T("Processing: ")), TSS_StringEntry( tripwire::STR_NOTIFY_CHECKING, _T("Checking: ")), diff --git a/src/tripwire/tripwirestrings.h b/src/tripwire/tripwirestrings.h index d2d1196..db805c6 100644 --- a/src/tripwire/tripwirestrings.h +++ b/src/tripwire/tripwirestrings.h @@ -67,36 +67,6 @@ TSS_BeginStringIds( tripwire ) STR_PU_ADDING_GENRE, STR_PU_BAD_PROPS, STR_PROCESSING_GENRE, - - // - // GMMS specific - // - STR_GMMS_START, - STR_GMMS_END, - STR_GMMS_VERBOSITY1A, - STR_GMMS_VERBOSITY1B, - STR_GMMS_VERBOSITY2A, - STR_GMMS_VERBOSITY2B, - STR_GMMS_VERBOSITY2C, - - // - // MAPI error messages - // - STR_ERR2_MAIL_MESSAGE_MAPI_SEND_ERRROR1, - STR_ERR2_MAIL_MESSAGE_MAPI_SEND_ERRROR2, - STR_ERR2_MAIL_MESSAGE_MAPI_SEND_ERRROR3, - STR_ERR2_MAIL_MESSAGE_MAPI_SEND_ERRROR4, - STR_ERR2_MAIL_MESSAGE_MAPI_SEND_ERRROR5, - STR_ERR2_MAIL_MESSAGE_MAPI_SEND_ERRROR6, - STR_ERR2_MAIL_MESSAGE_MAPI_SEND_ERRROR7, - STR_ERR2_MAIL_MESSAGE_MAPI_SEND_ERRROR8, - STR_ERR2_MAIL_MESSAGE_MAPI_SEND_ERRROR9, - STR_ERR2_MAIL_MESSAGE_MAPI_SEND_ERRROR10, - STR_ERR2_MAIL_MESSAGE_MAPI_SEND_ERRROR11, - STR_ERR2_MAIL_MESSAGE_MAPI_SEND_ERRROR12, - STR_ERR2_MAIL_MESSAGE_MAPI_SEND_ERRROR13, - STR_ERR2_MAIL_MESSAGE_MAPI_SEND_ERRROR14, - STR_ERR2_MAIL_MESSAGE_MAPI_SEND_ERRROR14_1, STR_ERR2_MAIL_MESSAGE_SERVER, STR_ERR2_MAIL_MESSAGE_SERVER_RETURNED_ERROR, @@ -108,7 +78,6 @@ TSS_BeginStringIds( tripwire ) STR_ERR_IC_EMAIL_AND_FILES, STR_ERR_NO_MAIL_METHOD, STR_ERR_INVALID_MAIL_METHOD, - STR_ERR_MAPI_NOT_SUPPORTED, STR_ERR_MISSING_MAILPROGRAM, STR_ERR_NO_TEST_MODE, STR_GENERATING_DB, @@ -155,14 +124,6 @@ TSS_BeginStringIds( tripwire ) STR_ERR_EMAIL_REPORT, STR_ERR_EMAIL_TEST, - - // - // Gmms errors - // - STR_ERR_BAD_GMMS_VERBOSITY, - STR_ERR_GMMS_VERBOSITY_ONLY, - - STR_NOTIFY_PROCESSING, STR_NOTIFY_CHECKING, STR_NOTIFY_CHECKING_RULE, diff --git a/src/tripwire/twcmdline.cpp b/src/tripwire/twcmdline.cpp index fa92ba9..21f4162 100644 --- a/src/tripwire/twcmdline.cpp +++ b/src/tripwire/twcmdline.cpp @@ -798,22 +798,12 @@ public: TSTRING mGenreName; // if not empty, specifies the genre to check bool mbSecureMode; // are we in extra-pedantic mode? (only valid with mbUpdate == true) -#ifdef GMMS - bool mbGmms; // Send violation reports via gmms? - TSTRING mGmmsProg; // full path to gmms executable - TSTRING mGmmsOptions; // additional options for gmms command line - int mGmmsVerbosity; // level 1 or 2 verbosity? -#endif - //TSTRING mCmdLine; // entire command line std::vector mFilesToCheck; // ctor can set up some default values cTWModeIC_i() : cTWModeCommon(), mbUpdate(false), mbPrintToStdout(true), mbEmail(false), mbEncryptReport(false), mSeverityLevel(-1), mbTrimBySeverity(false), mbSecureMode(false) -#ifdef GMMS - , mbGmms(false), mGmmsVerbosity(2) -#endif {} }; @@ -855,14 +845,6 @@ void cTWModeIC::InitCmdLineParser(cCmdLineParser& cmdLine) // multiple levels of reporting cmdLine.AddArg(cTWCmdLine::REPORTLEVEL, TSTRING(_T("t")), TSTRING(_T("email-report-level")), cCmdLineParser::PARAM_ONE); -#ifdef GMMS - // gmms command line options - cmdLine.AddArg(cTWCmdLine::USE_GMMS, TSTRING(_T("g")), TSTRING(_T("gmms")), cCmdLineParser::PARAM_NONE); - cmdLine.AddArg(cTWCmdLine::GMMS_VERBOSITY, TSTRING(_T("b")), TSTRING(_T("gmms-verbosity")), cCmdLineParser::PARAM_ONE); -#endif - - - // mutual exclusion... // you can't specify any of these 3 things together... cmdLine.AddMutEx(cTWCmdLine::SEVERITY_LEVEL, cTWCmdLine::RULE_NAME); @@ -882,33 +864,6 @@ bool cTWModeIC::Init(const cConfigFile& cf, const cCmdLineParser& cmdLine) // We will use this to access the parsed cmdLine. cCmdLineIter iter(cmdLine); -#ifdef GMMS - - // Get path to gmms executable from config file - TSTRING str; - if(cf.Lookup(TSTRING(_T("GMMS")), str)) - { - // Path was specified in the configuration file - mpData->mGmmsProg = str; - } - else - { - // Path was not specified in the configuration file, try environment variable - const TCHAR *gmmsDeploy = _tgetenv(_T("GEOPLEX_DEPLOY")); - if (gmmsDeploy) - mpData->mGmmsProg = TSTRING(gmmsDeploy) + _T("/bin/gmms"); // Assign by env.var. - else - mpData->mGmmsProg = _T("/home/geoplex/bin/gmms"); // No env.var., Take a wild guess. - } - - // Get any additional command line options for running gmms from config file - if(cf.Lookup(TSTRING(_T("GMMSOPTIONS")), str)) - mpData->mGmmsOptions = str; - - bool bGmmsSpecified=false, bGmmsVerbositySpecified=false; - -#endif - // First, fill out everything with the config file info... FillOutConfigInfo(mpData, cf); @@ -916,7 +871,6 @@ bool cTWModeIC::Init(const cConfigFile& cf, const cCmdLineParser& cmdLine) // this takes care of the common stuff... FillOutCmdLineInfo(mpData, cmdLine); - // now do the stuff specific to this mode.. for(iter.SeekBegin(); ! iter.Done(); iter.Next()) @@ -1004,36 +958,7 @@ bool cTWModeIC::Init(const cConfigFile& cf, const cCmdLineParser& cmdLine) mpData->mFilesToCheck.push_back(iter.ParamAt(i)); } } -#ifdef GMMS - case cTWCmdLine::USE_GMMS: - mpData->mbGmms = true; - bGmmsSpecified = true; - break; - case cTWCmdLine::GMMS_VERBOSITY: - { - const TCHAR* psz = iter.ParamAt(0).c_str(); - if ( psz != 0 ) - while ( _istdigit( *psz ) ) ++psz; - /// NOTE:RAD -- Come on man! There isn't even a pStr!!! - // if ( !cStringUtil::StringIsInteger( pStr ) ) - if ( *psz != 0x00 ) - { - TCERR << TSS_GetString( cTripwire, tripwire::STR_ERR_BAD_GMMS_VERBOSITY ) << std::endl; - return false; - } - else - { - mpData->mGmmsVerbosity = _ttoi(iter.ParamAt(0).c_str()); - if (mpData->mGmmsVerbosity < 1 || mpData->mGmmsVerbosity > 2) { - TCERR << TSS_GetString( cTripwire, tripwire::STR_ERR_BAD_GMMS_VERBOSITY ) << std::endl; - return false; - } - bGmmsVerbositySpecified = true; - } - break; - } -#endif default: // should I do anything, or just ignore this? ; @@ -1062,14 +987,6 @@ bool cTWModeIC::Init(const cConfigFile& cf, const cCmdLineParser& cmdLine) TEST_INIT_REQUIREMENT((! mpData->mReportFile.empty()), cTW, tw::STR_ERR_MISSING_REPORT); TEST_INIT_REQUIREMENT((! (mpData->mEditor.empty() && mpData->mbUpdate)),cTW, tw::STR_ERR_MISSING_EDITOR); -#ifdef GMMS - if (bGmmsSpecified==false && bGmmsVerbositySpecified==true) - { - TCERR << TSS_GetString( cTripwire, tripwire::STR_ERR_GMMS_VERBOSITY_ONLY ) << std::endl; - return false; - } -#endif - /////////////////////////////////////////// // do some email-related verifications /////////////////////////////////////////// @@ -1085,10 +1002,6 @@ bool cTWModeIC::Init(const cConfigFile& cf, const cCmdLineParser& cmdLine) // error if method is SENDMAIL and no MAILPROGRAM TEST_INIT_REQUIREMENT( ( cMailMessage::MAIL_BY_PIPE != mpData->mMailMethod || !mpData->mMailProgram.empty()), cTripwire, tripwire::STR_ERR_MISSING_MAILPROGRAM ); - -#if !SUPPORTS_MAPI - TEST_INIT_REQUIREMENT( ( cMailMessage::MAIL_BY_MAPI != mpData->mMailMethod ), cTripwire, tripwire::STR_ERR_MAPI_NOT_SUPPORTED ); -#endif } // make sure that the config file and site key file are in sync... @@ -1413,22 +1326,6 @@ int cTWModeIC::Execute(cErrorQueue* pQueue) cFCOReportUtil::FinalizeReport( report ); -#ifdef GMMS - // gmms reporting? - if (mpData->mbGmms) - { - try - { - cTWCmdLineUtil::GmmsReport(reportHeader, report, mpData->mGmmsProg, mpData->mGmmsOptions, mpData->mGmmsVerbosity); - } - catch(eGmmsError& e) - { - cTWUtil::PrintErrorMsg(e); - // Do not return. Gmms errors are not fatal. - } - } -#endif - // email the report if that is desired... if(mpData->mbEmail) { @@ -2373,9 +2270,6 @@ bool cTWModeTest::Init(const cConfigFile& cf, const cCmdLineParser& cmdLine) // make sure that we have a valid mail method TEST_INIT_REQUIREMENT( ( cMailMessage::NO_METHOD != mpData->mMailMethod ), cTripwire, tripwire::STR_ERR_NO_MAIL_METHOD ); TEST_INIT_REQUIREMENT( ( cMailMessage::INVALID_METHOD != mpData->mMailMethod ), cTripwire, tripwire::STR_ERR_INVALID_MAIL_METHOD ); -#if !SUPPORTS_MAPI - TEST_INIT_REQUIREMENT( ( cMailMessage::MAIL_BY_MAPI != mpData->mMailMethod ), cTripwire, tripwire::STR_ERR_MAPI_NOT_SUPPORTED ); -#endif } return true; diff --git a/src/tripwire/twcmdline.h b/src/tripwire/twcmdline.h index b5bb844..8345890 100644 --- a/src/tripwire/twcmdline.h +++ b/src/tripwire/twcmdline.h @@ -138,12 +138,6 @@ public: TEST_EMAIL, REPORTLEVEL, HEXADECIMAL, - -#ifdef GMMS - USE_GMMS, - GMMS_VERBOSITY, -#endif - PARAMS, // the final parameters NUM_CMDLINEARGS diff --git a/src/tripwire/twcmdlineutil.cpp b/src/tripwire/twcmdlineutil.cpp index bab7a0f..244a75d 100644 --- a/src/tripwire/twcmdlineutil.cpp +++ b/src/tripwire/twcmdlineutil.cpp @@ -67,15 +67,6 @@ #include -#ifdef GMMS - -// local helper functions for GMMS notification -static TSTRING FormatGmmsReportSummary(int32 date, int violationCount, int maxSeverity); -static TSTRING FormatGmmsViolationSummary(int32 date, const TSTRING& rulename, const TSTRING& filename, int severity); -static void SendGmmsAlert(const TSTRING& gmmsProg, const TSTRING& gmmsOptions, const TSTRING& alerts); // throw (eGmmsError) - -#endif - /////////////////////////////////////////////////////////////////////////////// // ParsePolicyFile @@ -554,9 +545,6 @@ static bool EmailReportTo(const TSTRING &toAddress, const cFCOReportHeader& head case cMailMessage::MAIL_BY_PIPE: reportMail = std::auto_ptr(new cPipedMailMessage(modeCommon->mMailProgram)); break; - case cMailMessage::MAIL_BY_MAPI: - ASSERT(false); - return false; } TSTRING strTempFilename; @@ -711,9 +699,6 @@ bool cTWCmdLineUtil::SendEmailTestMessage(const TSTRING &mAddress, const cTWMode case cMailMessage::MAIL_BY_PIPE: reportMail = std::auto_ptr(new cPipedMailMessage(modeCommon->mMailProgram)); break; - case cMailMessage::MAIL_BY_MAPI: - ASSERT(false); - return false; } @@ -754,193 +739,5 @@ bool cTWCmdLineUtil::SendEmailTestMessage(const TSTRING &mAddress, const cTWMode } -#ifdef GMMS - -// -// Use gmms to send violation notification -// -// verbosity==1 One line summary of whole report -// verbosity==2 One line summary of each violation -// -bool cTWCmdLineUtil::GmmsReport(const cFCOReportHeader& header, const cFCOReport& report, - const TSTRING &gmmsProg, const TSTRING &gmmsOptions, int verbosity) // throw (eGmmsError) -{ - int violationCount = 0, maxSeverity = 0; - TSTRING alerts; - - // loop through all generes - cFCOReportGenreIter genreIter(report); - for (genreIter.SeekBegin(); !genreIter.Done(); genreIter.Next()) - { - // loop through all specs - cFCOReportSpecIter specIter(report, genreIter.GetGenre()); - for (specIter.SeekBegin(); ! specIter.Done(); specIter.Next()) - { - - ASSERT(true); - - // Get severity - int32 severity = specIter.GetAttr()->GetSeverity(); - - // Get rulename - TSTRING rulename = specIter.GetAttr()->GetName(); - - // Go through all of the added file rule violations - cIterProxy addedIter(specIter.GetAddedSet()->GetIter()); - for (addedIter->SeekBegin(); !addedIter->Done(); addedIter->Next()) - { - if (severity > maxSeverity) - maxSeverity = severity; - - if (verbosity == 2) - { - // get filename, send one line summary of this violation - TSTRING filename = addedIter->FCO()->GetName().AsString(); - alerts += FormatGmmsViolationSummary(header.GetCreationTime(), rulename, filename, severity); - alerts += _T("\n"); - } - - violationCount++; - } - - // Go through all of the removed file rule violations - cIterProxy removedIter(specIter.GetRemovedSet()->GetIter()); - for (removedIter->SeekBegin(); !removedIter->Done(); removedIter->Next()) - { - if (severity > maxSeverity) - maxSeverity = severity; - - if (verbosity == 2) - { - // get filename, send one line summary of this violation - TSTRING filename = removedIter->FCO()->GetName().AsString(); - alerts += FormatGmmsViolationSummary(header.GetCreationTime(), rulename, filename, severity); - alerts += _T("\n"); - } - - violationCount++; - } - - // Go through all of the changed file rule violations - cFCOReportChangeIter changedIter(specIter); - for (changedIter.SeekBegin(); !changedIter.Done(); changedIter.Next()) - { - if (severity > maxSeverity) - maxSeverity = severity; - - if (verbosity == 2) - { - // get filename, send one line summary of this violation - TSTRING filename = changedIter.GetOld()->GetName().AsString(); - alerts += FormatGmmsViolationSummary(header.GetCreationTime(), rulename, filename, severity); - alerts += _T("\n"); - } - - violationCount++; - } - } - } - - // Send one line summary of the whole report if that's what they want, - // or if there were no violations and the verbosity level is 2. That way - // verbosity level 2 and no violations will still send an all-is-well notification. - if (verbosity == 1 || (verbosity == 2 && violationCount==0)) - { - alerts += FormatGmmsReportSummary(header.GetCreationTime(), violationCount, maxSeverity); - alerts += _T("\n"); - } - - ASSERT(!alerts.empty()); - SendGmmsAlert(gmmsProg, gmmsOptions, alerts); - - return true; -} -// -// Use this with gmms verbosity level 1 -// -TSTRING FormatGmmsReportSummary(int32 date, int violationCount, int maxSeverity) -{ - TSTRING strDate; - cTWLocale::FormatTime(date, strDate); - - TOSTRINGSTREAM summary; - summary << TSS_GetString( cTripwire, tripwire::STR_GMMS_START); - summary << strDate; - summary << TSS_GetString( cTripwire, tripwire::STR_GMMS_VERBOSITY1A); - summary << violationCount; - summary << TSS_GetString( cTripwire, tripwire::STR_GMMS_VERBOSITY1B); - summary << maxSeverity; - summary << TSS_GetString( cTripwire, tripwire::STR_GMMS_END); - - return summary.str(); -} - - -// -// Use this with gmms verbosity level 2 -// -TSTRING FormatGmmsViolationSummary(int32 date, const TSTRING& rulename, const TSTRING& filename, int severity) -{ - TSTRING strDate; - cTWLocale::FormatTime(date, strDate); - - TOSTRINGSTREAM summary; - summary << TSS_GetString( cTripwire, tripwire::STR_GMMS_START); - summary << strDate; - summary << TSS_GetString( cTripwire, tripwire::STR_GMMS_VERBOSITY2A); - summary << rulename; - summary << TSS_GetString( cTripwire, tripwire::STR_GMMS_VERBOSITY2B); - summary << filename; - summary << TSS_GetString( cTripwire, tripwire::STR_GMMS_VERBOSITY2C); - summary << severity; - summary << TSS_GetString( cTripwire, tripwire::STR_GMMS_END); - - return summary.str(); -} - -static void SendGmmsAlert(const TSTRING& gmmsProg, const TSTRING& gmmsOptions, const TSTRING& alerts) // throw (eGmmsError) -{ -#if IS_UNIX - - // construct the command line for starting gmms - TSTRING command = gmmsProg + _T(" ") + gmmsOptions; - - // preserve environment variables necessary for gmms to run - le_set("GEOPLEX_DEPLOY"); - le_set("LD_LIBRARY_PATH"); - le_set("PATH"); - - // open the process - FILE *mpFile = mpopen((char*)command.c_str(), _T("w")); - if(!mpFile) - throw eGmmsError(eGmmsError::ERR_COULDNT_OPEN_PIPE, gmmsProg); - - // write the alert(s) to the process's standard-in. - if (_ftprintf(mpFile, "%s", alerts.c_str()) < 0) - throw eGmmsError(eGmmsError::ERR_COULDNT_WRITE_TO_PIPE, gmmsProg); - - // end the process by closing standard-in - int result = mpclose( mpFile ); - if (result != 0) - { - // complain about gmms returning an error code. - throw eGmmsError(eGmmsError::ERR_CMD_FAILED, gmmsProg); - } - - // unset environment variables necessary for gmms to run - le_unset("GEOPLEX_DEPLOY"); - le_unset("LD_LIBRARY_PATH"); - le_unset("PATH"); - -#else - - // GMMS is not for NT, so just do something cheap and easy for debugging purposes. - std::cerr << cStringUtil::TstrToStr(alerts); - -#endif -} - -#endif - diff --git a/src/tripwire/twcmdlineutil.h b/src/tripwire/twcmdlineutil.h index ce070b8..8de0508 100644 --- a/src/tripwire/twcmdlineutil.h +++ b/src/tripwire/twcmdlineutil.h @@ -48,11 +48,6 @@ class cTWModeCommon; class cErrorBucket; class cFCODatabaseFile; -TSS_EXCEPTION( eGmmsError, eError ); -TSS_EXCEPTION( eGmmsCouldntOpenPipe, eGmmsError ); -TSS_EXCEPTION( eGmmsCouldntWritePipe, eGmmsError ); -TSS_EXCEPTION( eGmmsCmdFailed, eGmmsError ); - class cTWCmdLineUtil { public: @@ -102,12 +97,6 @@ public: static void VerifySpecs( const cFCOSpecList& parsedList, const cFCOSpecList& dbList );//throw (eError) // determines whether the policy in the policy file (parsedList) is equal to the database's current // policy (dbList). If it is not, an exception is thrown - -#ifdef GMMS - static bool GmmsReport(const cFCOReportHeader& header, const cFCOReport& report, - const TSTRING &gmmsProg, const TSTRING &gmmsOptions, int verbosity); // throw (eGmmsError) - // Use gmms to send violation notification -#endif }; #endif diff --git a/src/tw/configfile.cpp b/src/tw/configfile.cpp index 7302564..c6dc7a4 100644 --- a/src/tw/configfile.cpp +++ b/src/tw/configfile.cpp @@ -650,10 +650,6 @@ void cConfigFile::CheckThatAllMandatoryKeyWordsExists() // throw( eConfigFile ) _T("REPORTFILE"), _T("SITEKEYFILE"), _T("LOCALKEYFILE"), -#ifdef GMMS - _T("GMMS"), - _T("GMMSOPTIONS") -#endif };