Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. // \file SNFMilterConfig.hpp
  2. //
  3. // Copyright (C) 2011 ARM Research Labs, LLC.
  4. // See www.armresearch.com for the copyright terms.
  5. //
  6. // This file defines the SNFMilterConfig interface.
  7. //
  8. // $Id$
  9. //
  10. ///////////////////////////////////////////////////////////////////////////////////////////////////
  11. #ifndef SNFMilterConfighpp_included
  12. #define SNFMilterConfighpp_included
  13. #include <string>
  14. #include "UtilityConfig.hpp"
  15. #include "PostfixIntegrate.hpp"
  16. /// Class to manage the SNFMilter configuration.
  17. //
  18. // This class creates/maintains the sniffer configuration file, and
  19. // integrates/unintegrates with MTAs.
  20. //
  21. //////////////////////////////////////////////////////////////////////////////////////////////////////////
  22. class SNFMilterConfig : public UtilityConfig {
  23. public:
  24. /// Command.
  25. enum MtaCommandEnum {
  26. NoCommand, ///< Take no MTA integration/unintegration action.
  27. IntegrateWithNoneCmd, ///< Remove integration with all MTAs.
  28. IntegrateWithPostfixCmd, ///< Integrate with postfix.
  29. IntegrateWithSendmailCmd ///< Integrate with sendmail.
  30. };
  31. /// Display usage.
  32. //
  33. // \param[in] Version is the SNFMilter version.
  34. //
  35. void DisplayHelp(std::string Version);
  36. /// Get the command-line input parameters for SNFMilter.
  37. //
  38. // \param[in] argc is the number of parameters.
  39. //
  40. // \param[in] argv is the parameters.
  41. //
  42. // \returns true if all the required command line parameters are
  43. // present and there are no unknown command-line parameters, false
  44. // otherwise.
  45. //
  46. bool GetCommandLineInput(int argc, char* argv[]);
  47. /// Load the configuration, creating default configuration if necessary.
  48. //
  49. // This method load the configuration specified in the command
  50. // line, or the default config file. If the config file to load
  51. // doesn't exit, the config file is created by copying from the
  52. // sample config file.
  53. //
  54. // Side effect: The state of the config file is saved.
  55. //
  56. // Side effect: If the config file doesn't exist, a new config
  57. // file is created.
  58. //
  59. void CreateLoadConfig(void);
  60. /// Save the state of all files that might be changed, except the
  61. /// config file.
  62. //
  63. void SaveFileState(void);
  64. /// Create or update the configuration files.
  65. //
  66. // The SNFMilter.xml and GBUdbIgnoreList.txt files are created if
  67. // they don't exist. In any case, the owner/group is changed by
  68. // SetOwnerGroup(), and the permissions are changed to readonly
  69. // for everyone, and read/write for the owner.
  70. //
  71. void UpdateConfigFiles();
  72. /// Execute the command to integrate/unintegrate with the MTAs.
  73. void DoIntegrationCommand();
  74. private:
  75. /// Load the socket info (file name) from the <platform> section
  76. /// of the loaded config file.
  77. void LoadSocketInfo();
  78. void CreateSocketDir();
  79. PostfixIntegrate Postfix; ///< Postfix integration object.
  80. /// Unintegrate with MTAs.
  81. //
  82. // Unintegrate with all MTAs except the specified MTA.
  83. //
  84. // \param[in] Except is the MTA to not integrate with. The
  85. // acceptable values are:
  86. //
  87. // <ol>
  88. // <li> "postfix" </li>
  89. // <li> "" </li>
  90. // </ol>
  91. //
  92. // The default value is "", which specifies unintegration with all
  93. // MTAs.
  94. //
  95. void UnintegrateWithAllExcept(std::string Except = "");
  96. MtaCommandEnum MtaCommand; ///< Specified MTA integration/unintegration command.
  97. static const std::string DefaultConfigFile; ///< Default config file.
  98. static const std::string SampleConfigFile; ///< Sample config file.
  99. static const std::string SampleIdentityFile; ///< Sample identity file.
  100. std::string SocketFileName;
  101. };
  102. #endif