Skip to contentSkip to conversation

snort: new package

PATCH Superseded Sergio Prado 2 participants 3 messages Jan 10, 2018

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 snort: new package

Tested on Beaglebone Black.

Build-tested with test-pkg.

---
Changes v1 -> v2 (as reviewed by Thomas Petazzoni):
- patching configure.in instead of configure
- using STAGING_DIR to pass libpcap headers location to configure

---
 DEVELOPERS                                         |   1 +
 package/Config.in                                  |   1 +
 .../snort/0001-Fix-cross-compilation-errors.patch  | 290 +++++++++++++++++++++
 package/snort/Config.in                            |  25 ++
 package/snort/snort.hash                           |   6 +
 package/snort/snort.mk                             |  31 +++
 6 files changed, 354 insertions(+)
 create mode 100644 package/snort/0001-Fix-cross-compilation-errors.patch
 create mode 100644 package/snort/Config.in
 create mode 100644 package/snort/snort.hash
 create mode 100644 package/snort/snort.mk
DEVELOPERS +1 -0
index 999e7d3300b6..4a8be05f8825 100644
@@ -1584,6 +1584,7 @@ F:	package/daq/
 F:	package/libgdiplus/
 F:	package/mongodb/
 F:	package/pimd/
+F:	package/snort/
 F:	package/stella/
 F:	package/traceroute/
 F:	package/tunctl/
package/Config.in +1 -0
index 729d660d525b..26e5fc8786a6 100644
@@ -1798,6 +1798,7 @@ endif
 	source "package/shellinabox/Config.in"
 	source "package/smcroute/Config.in"
 	source "package/sngrep/Config.in"
+	source "package/snort/Config.in"
 	source "package/socat/Config.in"
 	source "package/socketcand/Config.in"
 	source "package/softether/Config.in"
package/snort/0001-Fix-cross-compilation-errors.patch new file +290 -0

290 lines not on this page · raw message

package/snort/Config.in new file +25 -0
new file mode 100644
index 000000000000..d1a59d505004
@@ -0,0 +1,25 @@
+config BR2_PACKAGE_SNORT
+	bool "snort"
+	depends on BR2_USE_WCHAR
+	depends on BR2_USE_MMU # fork()
+	depends on !BR2_STATIC_LIBS # daq
+	depends on BR2_TOOLCHAIN_HAS_NATIVE_RPC || BR2_TOOLCHAIN_HAS_THREADS # libtirpc
+	select BR2_PACKAGE_LIBPCAP
+	select BR2_PACKAGE_DAQ
+	select BR2_PACKAGE_PCRE
+	select BR2_PACKAGE_LIBTIRPC if !BR2_TOOLCHAIN_HAS_NATIVE_RPC
+	help
+	  Snort is a free and open source network intrusion
+	  prevention system (IPS) and network intrusion detection
+	  system (IDS). It can perform protocol analysis, content
+	  searching/matching, and can be used to detect a variety
+	  of attacks and probes, such as buffer overflows, stealth
+	  port scans, CGI attacks, SMB probes, OS fingerprinting
+	  attempts, and much more.
+
+	  https://www.snort.org
+
+comment "snort needs a toolchain w/ wchar, threads, dynamic library"
+	depends on BR2_USE_MMU
+	depends on !BR2_USE_WCHAR || BR2_STATIC_LIBS || \
+		!(BR2_TOOLCHAIN_HAS_THREADS || BR2_TOOLCHAIN_HAS_NATIVE_RPC)
package/snort/snort.hash new file +6 -0
new file mode 100644
index 000000000000..211e862b7fc0
@@ -0,0 +1,6 @@
+# Locally computed:
+sha256 9f6b3aeac5a109f55504bd370564ac431cb1773507929dc461626898f33f46cd  snort-2.9.11.1.tar.gz
+
+# Hash for license files:
+sha256 f98260a6d3e5ef4ede8a2a6b698e5ac91d64c09243f7171e1c5b17b920a835c7  LICENSE
+sha256 3f1cbfb20bb2c608e1a474421880d08b8cba6abb00ab7736d22c481d71656a6d  COPYING
package/snort/snort.mk new file +31 -0
new file mode 100644
index 000000000000..e43bced21b89
@@ -0,0 +1,31 @@
+################################################################################
+#
+# snort
+#
+################################################################################
+
+SNORT_VERSION = 2.9.11.1
+SNORT_SOURCE = snort-$(SNORT_VERSION).tar.gz
+SNORT_SITE = https://www.snort.org/downloads/snort
+SNORT_LICENSE = GPL-2.0
+SNORT_LICENSE_FILES = LICENSE COPYING
+
+SNORT_DEPENDENCIES = libpcap daq pcre
+
+# patching configure.in
+SNORT_AUTORECONF = YES
+
+SNORT_CONF_OPTS = \
+	--with-libpcap-includes=$(STAGING_DIR)/usr/include/pcap \
+	--disable-static-daq
+
+ifeq ($(BR2_PACKAGE_LIBTIRPC),y)
+SNORT_DEPENDENCIES += libtirpc host-pkgconf
+SNORT_CFLAGS += `$(PKG_CONFIG_HOST_BINARY) --cflags libtirpc`
+SNORT_LIBS += `$(PKG_CONFIG_HOST_BINARY) --libs libtirpc`
+endif
+
+SNORT_CONF_ENV = \
+	CFLAGS="$(TARGET_CFLAGS) $(SNORT_CFLAGS)" LIBS="$(SNORT_LIBS)"
+
+$(eval $(autotools-package))
Signature · 1 line
1.9.1
#1 lore raw

PATCH v2 1/1 snort: new package

Hello,

Quoted 43 lines · Sergio Prado
package/snort/0001-Fix-cross-compilation-errors.patch new file +37 -0
new file mode 100644
index 000000000000..b3cad44229c3
@@ -0,0 +1,290 @@
+From 0c3d43c5f189b24504a809af9eaa1d2741a18bea Mon Sep 17 00:00:00 2001
+From: Sergio Prado <[email protected]>
+Date: Tue, 9 Jan 2018 22:24:40 -0200
+Subject: [PATCH] Fix cross compilation errors
+
+Prevent configure script from trying to run programs in a cross
+compilation environment.
+
+Also remove unsafe header/library path used in cross-compilation.
+
+Signed-off-by: Sergio Prado <[email protected]>
+---
+ configure.in | 160 +++++------------------------------------------------------
+ 1 file changed, 13 insertions(+), 147 deletions(-)
+
+diff --git a/configure.in b/configure.in
+index 4b3a5dbbf450..13798ce80ae7 100644
+--- a/configure.in
++++ b/configure.in
+@@ -71,7 +71,6 @@ case "$host" in
+     linux="yes"
+     AC_DEFINE([LINUX],[1],[Define if Linux])
+     AC_SUBST(extra_incl)
+-    extra_incl="-I/usr/include/pcap"
+     ;;
+   *-hpux10*|*-hpux11*)
+     AC_DEFINE([HPUX],[1],[Define if HP-UX 10 or 11])
+@@ -282,21 +281,8 @@ AC_CHECK_TYPES([int8_t,int16_t,int32_t,int64_t])
+ AC_CHECK_TYPES([boolean])
+ 
+ # In case INADDR_NONE is not defined (like on Solaris)
+-have_inaddr_none="no"
++have_inaddr_none="yes"
+ AC_MSG_CHECKING([for INADDR_NONE])
+-AC_RUN_IFELSE(
+-[AC_LANG_PROGRAM(
+-[[

package/snort/0001-Fix-cross-compilation-errors.patch line 47

Quoted 10 lines
package/snort/0001-Fix-cross-compilation-errors.patch new file +10 -0
+-#include <sys/types.h>
+-#include <netinet/in.h>
+-#include <arpa/inet.h>
+-]],
+-[[
+-	if (inet_addr("10,5,2") == INADDR_NONE);
+-    return 0;
+-]])],
+-[have_inaddr_none="yes"],
+-[have_inaddr_none="no"])

That's not the right way of fixing the problem, as your patch is not upstreamable. The right way is to use AC_CACHE_CHECK(), so that you can preseed the variable value from the environment to avoid the AC_TRY_RUN() test, and still do the test if no value is preseeded in the environment.

AC_CACHE_CHECK([whether ... is available], [have_inaddr_none],

	[AC_RUN_IFELSE(......, [have_inaddr_none=yes], [have_inaddr_none=no])])

if test "x$have_inaddr_none" = "xno"; then
...
fi

With this in place, you can pass have_inaddr_none=yes in SNORT_CONF_ENV. The configure script will skip the AC_RUN_IFELSE() test and assume have_inaddr_none=yes is correct.

And if you do this, you can send the patch upstream.

Best regards,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
#2 lore raw

PATCH v2 1/1 snort: new package

Hi Thomas,

Quoted 8 lines

That's not the right way of fixing the problem, as your patch is not upstreamable. The right way is to use AC_CACHE_CHECK(), so that you can preseed the variable value from the environment to avoid the AC_TRY_RUN() test, and still do the test if no value is preseeded in the environment.

AC_CACHE_CHECK([whether ... is available], [have_inaddr_none],

        [AC_RUN_IFELSE(......, [have_inaddr_none=yes],

[have_inaddr_none=no])])

Quoted 10 lines

if test "x$have_inaddr_none" = "xno"; then
...
fi

With this in place, you can pass have_inaddr_none=yes in SNORT_CONF_ENV. The configure script will skip the AC_RUN_IFELSE() test and assume have_inaddr_none=yes is correct.

And if you do this, you can send the patch upstream.

Understood. I'll review the patch and send V3.

Best regards,

Sergio Prado
Embedded Labworks
https://e-labworks.com/en
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20180110/90806497/attachment.html>