snort3: replace complex sed calls with patch

Simplification of Makefile: replace complex sed calls with a patch to
improve readability. This commit also renames an existing patch.

Signed-off-by: John Audia <therealgraysky@proton.me>
This commit is contained in:
John Audia
2025-09-07 07:28:36 -04:00
committed by Hannu Nyman
parent 87d0da8aa2
commit 2bbca5dfa0
2 changed files with 43 additions and 16 deletions

View File

@@ -105,22 +105,6 @@ define Package/snort3/install
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_CONF) ./files/snort.config $(1)/etc/config/snort
sed \
-i \
-e "/^-- HOME_NET and EXTERNAL_NET/ i -- The values for the two variables HOME_NET and EXTERNAL_NET have been" \
-e "/^-- HOME_NET and EXTERNAL_NET/ i -- moved to /etc/config/snort, so do not modify them here without good" \
-e "/^-- HOME_NET and EXTERNAL_NET/ i -- reason.\n" \
-e 's/^\(HOME_NET\s\+=\)/--\1/g' \
-e 's/^\(EXTERNAL_NET\s\+=\)/--\1/g' \
$(1)/etc/snort/snort.lua
sed \
-i -e "s/^\\(RULE_PATH\\s\\+=\\).*/\\1 'rules'/g" \
-e "s/^\\(BUILTIN_RULE_PATH\\s\\+=\\).*/\\1 'builtin_rules'/g" \
-e "s/^\\(PLUGIN_RULE_PATH\\s\\+=\\).*/\\1 'so_rules'/g" \
-e "s/^\\(WHITE_LIST_PATH\\s\\+=\\).*/\\1 'lists'/g" \
-e "s/^\\(BLACK_LIST_PATH\\s\\+=\\).*/\\1 'lists'/g" \
$(1)/etc/snort/snort_defaults.lua
endef
$(eval $(call BuildPackage,snort3))

View File

@@ -0,0 +1,43 @@
--- a/lua/snort.lua
+++ b/lua/snort.lua
@@ -19,13 +19,17 @@
-- 1. configure defaults
---------------------------------------------------------------------------
+-- The values for the two variables HOME_NET and EXTERNAL_NET have been
+-- moved to /etc/config/snort, so do not modify them here without good
+-- reason.
+
-- HOME_NET and EXTERNAL_NET must be set now
-- setup the network addresses you are protecting
-HOME_NET = 'any'
+--HOME_NET = 'any'
-- set up the external network addresses.
-- (leave as "any" in most situations)
-EXTERNAL_NET = 'any'
+--EXTERNAL_NET = 'any'
include 'snort_defaults.lua'
--- a/lua/snort_defaults.lua
+++ b/lua/snort_defaults.lua
@@ -19,13 +19,13 @@
---------------------------------------------------------------------------
-- Path to your rules files (this can be a relative path)
-RULE_PATH = '../rules'
-BUILTIN_RULE_PATH = '../builtin_rules'
-PLUGIN_RULE_PATH = '../so_rules'
+RULE_PATH = 'rules'
+BUILTIN_RULE_PATH = 'builtin_rules'
+PLUGIN_RULE_PATH = 'so_rules'
-- If you are using reputation preprocessor set these
-WHITE_LIST_PATH = '../lists'
-BLACK_LIST_PATH = '../lists'
+WHITE_LIST_PATH = 'lists'
+BLACK_LIST_PATH = 'lists'
---------------------------------------------------------------------------
-- default networks - used in Talos rules