]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Merge pull request #2452 in SNORT/snort3 from ~SATHIRKA/snort3:dump_user_appid_conf_r...
authorShravan Rangarajuvenkata (shrarang) <shrarang@cisco.com>
Tue, 8 Sep 2020 17:11:16 +0000 (17:11 +0000)
committerShravan Rangarajuvenkata (shrarang) <shrarang@cisco.com>
Tue, 8 Sep 2020 17:11:16 +0000 (17:11 +0000)
Squashed commit of the following:

commit 53760dc07886359c1b1cb39b583c4a9bc66ddf26
Author: Sreeja Athirkandathil Narayanan <sathirka@cisco.com>
Date:   Wed Sep 2 16:26:58 2020 -0400

    appid: Dump user appid configuration on reload detectors

src/network_inspectors/appid/app_info_table.cc
src/network_inspectors/appid/app_info_table.h
src/network_inspectors/appid/appid_module.cc

index 58b3ef081f93f9b98faaa063f5c97c7d6dcd75cd..55c4b484cadcb8dcd9cea374d4b1eb48bbb05da6 100644 (file)
@@ -26,6 +26,7 @@
 #include "app_info_table.h"
 
 #include <climits>
+#include <fstream>
 #include <string>
 #include <unistd.h>
 
@@ -616,6 +617,23 @@ void AppInfoManager::load_odp_config(OdpContext& odp_ctxt, const char* path)
     fclose(config_file);
 }
 
+void AppInfoManager::dump_appid_configurations(std::string file_path)
+{
+    std::ifstream conf_file(file_path);
+    if (!conf_file.is_open())
+    {
+        ParseError("appid: could not open %s", file_path.c_str());
+        return;
+    }
+
+    LogMessage("AppId: Configuration file %s\n", file_path.c_str());
+    std::string line;
+    while (getline(conf_file, line))
+        LogMessage("%s\n", line.c_str());
+
+    conf_file.close();
+}
+
 SnortProtocolId AppInfoManager::add_appid_protocol_reference(const char* protocol,
     SnortConfig* sc)
 {
index f3c0c53916f7a9b86cc0e5bf09bd018e6e37695f..0d30e6cfb6f25e5b89159ba104fd51f3388b3ffb 100644 (file)
@@ -138,6 +138,7 @@ public:
     void cleanup_appid_info_table();
     void dump_app_info_table();
     SnortProtocolId add_appid_protocol_reference(const char* protocol, snort::SnortConfig*);
+    void dump_appid_configurations(std::string);
 
 private:
     void load_odp_config(OdpContext&, const char* path);
index 9c25c92a0ae44f68d7814998b824838aad800a1e..ee4e24678cba03c6dd690726cbfd55ec07d296ab 100644 (file)
@@ -240,6 +240,14 @@ ACOdpContextSwap::~ACOdpContextSwap()
 {
     odp_ctxt.get_app_info_mgr().cleanup_appid_info_table();
     delete &odp_ctxt;
+    AppIdContext& ctxt = inspector.get_ctxt();
+    if (ctxt.config.app_detector_dir)
+    {
+        std::string file_path = std::string(ctxt.config.app_detector_dir) + "/custom/userappid.conf";
+        if (access(file_path.c_str(), F_OK))
+            file_path = std::string(ctxt.config.app_detector_dir) + "/../userappid.conf";
+        ctxt.get_odp_ctxt().get_app_info_mgr().dump_appid_configurations(file_path);
+    }
     LogMessage("== reload detectors complete\n");
     request.respond("== reload detectors complete\n", from_shell, true);
     Swapper::set_reload_in_progress(false);