// \file SNFMilterConfig.hpp // // Copyright (C) 2011 ARM Research Labs, LLC. // See www.armresearch.com for the copyright terms. // // This file defines the SNFMilterConfig interface. // // $Id$ // /////////////////////////////////////////////////////////////////////////////////////////////////// #ifndef SNFMilterConfighpp_included #define SNFMilterConfighpp_included #include #include "UtilityConfig.hpp" #include "PostfixIntegrate.hpp" /// Class to manage the SNFMilter configuration. // // This class creates/maintains the sniffer configuration file, and // integrates/unintegrates with MTAs. // ////////////////////////////////////////////////////////////////////////////////////////////////////////// class SNFMilterConfig : public UtilityConfig { public: /// Command. enum MtaCommandEnum { NoCommand, ///< Take no MTA integration/unintegration action. IntegrateWithNoneCmd, ///< Remove integration with all MTAs. IntegrateWithPostfixCmd, ///< Integrate with postfix. IntegrateWithSendmailCmd ///< Integrate with sendmail. }; /// Display usage. // // \param[in] Version is the SNFMilter version. // void DisplayHelp(std::string Version); /// Get the command-line input parameters for SNFMilter. // // \param[in] argc is the number of parameters. // // \param[in] argv is the parameters. // // \returns true if all the required command line parameters are // present and there are no unknown command-line parameters, false // otherwise. // bool GetCommandLineInput(int argc, char* argv[]); /// Load the configuration, creating default configuration if necessary. // // This method load the configuration specified in the command // line, or the default config file. If the config file to load // doesn't exit, the config file is created by copying from the // sample config file. // // Side effect: The state of the config file is saved. // // Side effect: If the config file doesn't exist, a new config // file is created. // void CreateLoadConfig(void); /// Save the state of all files that might be changed, except the /// config file. // void SaveFileState(void); /// Create or update the configuration files. // // The SNFMilter.xml and GBUdbIgnoreList.txt files are created if // they don't exist. In any case, the owner/group is changed by // SetOwnerGroup(), and the permissions are changed to readonly // for everyone, and read/write for the owner. // void UpdateConfigFiles(); /// Execute the command to integrate/unintegrate with the MTAs. void DoIntegrationCommand(); private: /// Load the socket info (file name) from the section /// of the loaded config file. void LoadSocketInfo(); void CreateSocketDir(); PostfixIntegrate Postfix; ///< Postfix integration object. /// Unintegrate with MTAs. // // Unintegrate with all MTAs except the specified MTA. // // \param[in] Except is the MTA to not integrate with. The // acceptable values are: // //
    //
  1. "postfix"
  2. //
  3. ""
  4. //
// // The default value is "", which specifies unintegration with all // MTAs. // void UnintegrateWithAllExcept(std::string Except = ""); MtaCommandEnum MtaCommand; ///< Specified MTA integration/unintegration command. static const std::string DefaultConfigFile; ///< Default config file. static const std::string SampleConfigFile; ///< Sample config file. static const std::string SampleIdentityFile; ///< Sample identity file. std::string SocketFileName; }; #endif