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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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 specified.
  25. enum CommandEnum {
  26. SetupRepairCommand, ///< Setup or repair the configuration.
  27. UpdateCredentialsCommand, ///< Update the credentials.
  28. IntegrateWithPostfixCommand, ///< Integrate with postfix.
  29. IntegrateWithSendmailCommand, ///< Integrate with sendmail.
  30. IntegrateWithNoneCommand, ///< Unintegrate with all supported MTAs.
  31. StartSnifferCommand, ///< Start the Sniffer.
  32. StopSnifferCommand, ///< Stop the Sniffer.
  33. NoCommand, ///< No command specified.
  34. UnknownCommand ///< Unknown.
  35. };
  36. /// Display usage.
  37. //
  38. // \param[in] Version is the SNFMilter version.
  39. //
  40. void DisplayHelp(std::string Version);
  41. /// Get the command-line input parameters for SNFMilter.
  42. //
  43. // \param[in] argc is the number of parameters.
  44. //
  45. // \param[in] argv is the parameters.
  46. //
  47. // \returns true if all the required command line parameters are
  48. // present and there are no unknown command-line parameters, false
  49. // otherwise.
  50. //
  51. bool GetCommandLineInput(int argc, char* argv[]);
  52. /// Load the configuration, creating default configuration if necessary.
  53. //
  54. // This method load the configuration specified in the command
  55. // line, or the default config file. If the config file to load
  56. // doesn't exit, the config file is created by copying from the
  57. // sample config file.
  58. //
  59. // Side effect: The state of the config file is saved.
  60. //
  61. // Side effect: If the config file doesn't exist, a new config
  62. // file is created.
  63. //
  64. void CreateLoadConfig(void);
  65. /// Execute the command specified by the command-line parameters.
  66. //
  67. void ExecuteCommand(void);
  68. /// Save the state of all files that might be changed, except the
  69. /// config file.
  70. //
  71. void SaveFileState(void); // OBSOLETE.
  72. /// Setup/repair the configuration.
  73. //
  74. // Copy the following files from the sample files if they don't
  75. // exist:
  76. //
  77. // <ol>
  78. // <li> Identity file. </li>
  79. // <li> Ignore list file. </li>
  80. // <li> Rulebase script. </li>
  81. // </ol>
  82. //
  83. // Set the owner/group of each of the above files.
  84. //
  85. // Make sure that the log directory exists and has the correct
  86. // owner and permissions.
  87. //
  88. void SetupRepair();
  89. /// Execute the command to integrate/unintegrate with the MTAs.
  90. void DoIntegrationCommand();
  91. private:
  92. /// Load the socket info (file name) from the <platform> section
  93. /// of the loaded config file.
  94. void LoadSocketInfo();
  95. void CreateSocketDir();
  96. PostfixIntegrate Postfix; ///< Postfix integration object.
  97. /// Unintegrate with MTAs.
  98. //
  99. // Unintegrate with all MTAs except the specified MTA.
  100. //
  101. // \param[in] Except is the MTA to not integrate with. The
  102. // acceptable values are:
  103. //
  104. // <ol>
  105. // <li> "postfix" </li>
  106. // <li> "" </li>
  107. // </ol>
  108. //
  109. // The default value is "", which specifies unintegration with all
  110. // MTAs.
  111. //
  112. void UnintegrateWithAllExcept(std::string Except = "");
  113. CommandEnum Command; ///< Specified command.
  114. static const std::string DefaultConfigFile; ///< Default config file.
  115. static const std::string SampleConfigFile; ///< Sample config file.
  116. static const std::string SampleIdentityFile; ///< Sample identity file.
  117. std::string SocketFileName;
  118. };
  119. #endif