]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Set default paths to Lua includes and Snort config (#51)
authorJonathan McDowell <noodles-github@earth.li>
Tue, 26 Jun 2018 13:20:11 +0000 (14:20 +0100)
committersnortadmin <snortadmin@users.noreply.github.com>
Tue, 26 Jun 2018 13:20:11 +0000 (09:20 -0400)
For most installs LUA_PATH and SNORT_LUA_PATH are known at build time;
they are the directories that we have configured the appropriate files
to be installed in. Set these as defaults in the installed snort.lua
config file. The environment variables will take precedence if set.

lua/CMakeLists.txt
lua/snort.lua.in [moved from lua/snort.lua with 97% similarity]

index ea75ed52f16be98017059f6ff819ef38e25448bb..1a9fabd5759442cf6a471ab26866fffcdae52156 100644 (file)
@@ -1,10 +1,12 @@
 
 set (LUA_SCRIPTS
     file_magic.lua
-    snort.lua
     snort_defaults.lua
 )
 
-install (FILES ${LUA_SCRIPTS}
+configure_file(snort.lua.in
+    snort.lua)
+
+install (FILES ${LUA_SCRIPTS} ${CMAKE_CURRENT_BINARY_DIR}/snort.lua
     DESTINATION "${CMAKE_INSTALL_SYSCONFDIR}/snort"
 )
similarity index 97%
rename from lua/snort.lua
rename to lua/snort.lua.in
index 2c4af5368a9454d8b79a753a4a823f1e34ea0587..36f2c358d78704b883d6e18a2da73456005e08b7 100644 (file)
 -- export LUA_PATH=$DIR/include/snort/lua/?.lua\;\;
 -- export SNORT_LUA_PATH=$DIR/etc/snort
 
+lua_path = os.getenv('LUA_PATH')
+if ( not lua_path ) then
+    package.path = '${CMAKE_INSTALL_FULL_INCLUDEDIR}/${INSTALL_SUFFIX}/lua/?.lua;?;'
+end
+
 -- this depends on LUA_PATH
 -- used to load this conf into Snort
 require('snort_config')
@@ -37,7 +42,7 @@ require('snort_config')
 conf_dir = os.getenv('SNORT_LUA_PATH')
 
 if ( not conf_dir ) then
-    conf_dir = '.'
+    conf_dir = '${CMAKE_INSTALL_FULL_SYSCONFDIR}/snort'
 end
 
 ---------------------------------------------------------------------------