Bladeren bron

snort: initial import from old-packages

Signed-off-by: Luka Perkov <luka@openwrt.org>
Luka Perkov 10 jaren geleden
bovenliggende
commit
155398e723
4 gewijzigde bestanden met toevoegingen van 350 en 0 verwijderingen
  1. 202
    0
      net/snort/Makefile
  2. 3
    0
      net/snort/files/snort.config
  3. 40
    0
      net/snort/files/snort.init
  4. 105
    0
      net/snort/patches/001-compile.patch

+ 202
- 0
net/snort/Makefile Bestand weergeven

@@ -0,0 +1,202 @@
1
+#
2
+# Copyright (C) 2006-2015 OpenWrt.org
3
+#
4
+# This is free software, licensed under the GNU General Public License v2.
5
+# See /LICENSE for more information.
6
+#
7
+
8
+include $(TOPDIR)/rules.mk
9
+
10
+PKG_NAME:=snort
11
+PKG_VERSION:=2.9.7.0
12
+PKG_RELEASE:=1
13
+
14
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
15
+PKG_SOURCE_URL:=https://www.snort.org/downloads/snort/
16
+PKG_MD5SUM:=c2a45bc56441ee9456478f219dd8d1e2
17
+
18
+PKG_BUILD_DEPENDS:=librpc
19
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION)
20
+PKG_FIXUP:=autoreconf
21
+PKG_INSTALL:=1
22
+
23
+include $(INCLUDE_DIR)/package.mk
24
+
25
+define Package/snort/Default
26
+  SUBMENU:=Firewall
27
+  SECTION:=net
28
+  CATEGORY:=Network
29
+  DEPENDS:=+libdaq +libdnet +libopenssl +libpcap +libpcre +libpthread +libuuid +zlib
30
+  TITLE:=Lightweight Network Intrusion Detection System
31
+  URL:=http://www.snort.org/
32
+endef
33
+
34
+define Package/snort/Default/description
35
+  Snort is an open source network intrusion detection and prevention system.
36
+  It is capable of performing real-time traffic analysis, alerting, blocking
37
+  and packet logging on IP networks.  It utilizes a combination of protocol
38
+  analysis and pattern matching in order to detect anomalies, misuse and
39
+  attacks.
40
+endef
41
+
42
+define Package/snort
43
+  $(call Package/snort/Default)
44
+  VARIANT:=basic
45
+endef
46
+
47
+define Package/snort/description
48
+  $(call Package/snort/Default/description)
49
+endef
50
+
51
+define Package/snort-mysql
52
+  $(call Package/snort/Default)
53
+  DEPENDS+= +libmysqlclient
54
+  TITLE+= (MySQL)
55
+  VARIANT:=mysql
56
+endef
57
+
58
+define Package/snort-mysql/description
59
+  $(call Package/snort/Default/description)
60
+  This package contains snort with support for logging to a MySQL database.
61
+endef
62
+
63
+define Package/snort-pgsql
64
+  $(call Package/snort/Default)
65
+  DEPENDS+= +libpq +libuuid
66
+  TITLE+= (PostgreSQL)
67
+  VARIANT:=pgsql
68
+endef
69
+
70
+define Package/snort-pgsql/description
71
+  $(call Package/snort/Default/description)
72
+  This package contains snort with support for logging to a PostgreSQL database.
73
+endef
74
+
75
+CONFIGURE_ARGS += \
76
+	--prefix="/usr" \
77
+	--enable-flexresp \
78
+	--with-dnet-includes="$(STAGING_DIR)/usr/include" \
79
+	--with-dnet-libraries="$(STAGING_DIR)/usr/lib" \
80
+	--with-libpcap-includes="$(STAGING_DIR)/usr/include" \
81
+	--with-libpcap-libraries="$(STAGING_DIR)/usr/lib" \
82
+	--with-libpcre-includes="$(STAGING_DIR)/usr/include" \
83
+	--with-libpcre-libraries="$(STAGING_DIR)/usr/lib" \
84
+	--with-daq-includes="$(STAGING_DIR)/usr/include" \
85
+	--with-daq-libraries="$(STAGING_DIR)/usr/lib" \
86
+	--disable-static-daq
87
+
88
+CONFIGURE_VARS += \
89
+	CPPFLAGS="$$$$CPPFLAGS -I$(STAGING_DIR)/usr/include/mysql" \
90
+	LDFLAGS="$$$$LDFLAGS -L$(STAGING_DIR)/usr/lib/mysql" \
91
+	PATH="$(STAGING_DIR)/usr/lib/libnet-1.0.x/bin:$$$$PATH"
92
+
93
+MAKE_FLAGS += \
94
+	extra_incl=""
95
+
96
+ifeq ($(BUILD_VARIANT),basic)
97
+  CONFIGURE_ARGS += \
98
+	--without-mysql \
99
+	--without-postgresql
100
+endif
101
+ifeq ($(BUILD_VARIANT),mysql)
102
+  CONFIGURE_VARS += \
103
+	mysql_has_reconnect=yes
104
+  CONFIGURE_ARGS += \
105
+	--with-mysql="$(STAGING_DIR)/usr" \
106
+	--without-postgresql
107
+endif
108
+ifeq ($(BUILD_VARIANT),pgsql)
109
+  CONFIGURE_ARGS += \
110
+	--without-mysql \
111
+	--with-postgresql="$(STAGING_DIR)/usr"
112
+endif
113
+
114
+define Build/InstallDev
115
+	$(INSTALL_DIR) $(STAGING_DIR)/usr/include/snort/dynamic_preproc
116
+	$(CP) \
117
+		$(PKG_INSTALL_DIR)/usr/include/snort/dynamic_preproc/* \
118
+		$(STAGING_DIR)/usr/include/snort/dynamic_preproc/
119
+	$(INSTALL_DIR) $(STAGING_DIR)/usr/lib/snort/dynamic_preproc
120
+	$(CP) \
121
+		$(PKG_INSTALL_DIR)/usr/lib/snort/dynamic_preproc/* \
122
+		$(STAGING_DIR)/usr/lib/snort/dynamic_preproc/
123
+	$(INSTALL_DIR) $(STAGING_DIR)/usr/lib/snort_dynamicengine
124
+	$(CP) \
125
+		$(PKG_INSTALL_DIR)/usr/lib/snort_dynamicengine/* \
126
+		$(STAGING_DIR)/usr/lib/snort_dynamicengine/
127
+	$(INSTALL_DIR) $(STAGING_DIR)/usr/lib/snort_dynamicpreprocessor
128
+	$(CP) \
129
+		$(PKG_INSTALL_DIR)/usr/lib/snort_dynamicpreprocessor/* \
130
+		$(STAGING_DIR)/usr/lib/snort_dynamicpreprocessor/
131
+endef
132
+
133
+define Package/snort/conffiles
134
+/etc/config/snort
135
+/etc/snort/snort.conf
136
+endef
137
+
138
+Package/snort-mysql/conffiles = $(Package/snort/conffiles)
139
+Package/snort-mysql/install = $(Package/snort/install)
140
+
141
+Package/snort-pgsql/conffiles = $(Package/snort/conffiles)
142
+Package/snort-pgsql/install = $(Package/snort/install)
143
+
144
+define Package/snort/install
145
+	$(INSTALL_DIR) $(1)/usr/bin
146
+	$(INSTALL_BIN) \
147
+		$(PKG_INSTALL_DIR)/usr/bin/snort  \
148
+		$(1)/usr/bin/snort
149
+
150
+	$(INSTALL_BIN) \
151
+		$(PKG_INSTALL_DIR)/usr/bin/u2{boat,spewfoo} \
152
+		$(1)/usr/bin
153
+
154
+	$(INSTALL_DIR) $(1)/usr/lib/snort_dynamicengine
155
+	$(CP) \
156
+		$(PKG_INSTALL_DIR)/usr/lib/snort_dynamicengine/libsf_engine.so* \
157
+		$(1)/usr/lib/snort_dynamicengine/
158
+
159
+	$(INSTALL_DIR) $(1)/usr/lib/snort_dynamicpreprocessor
160
+	$(CP) \
161
+		$(PKG_INSTALL_DIR)/usr/lib/snort_dynamicpreprocessor/libsf*.so* \
162
+		$(1)/usr/lib/snort_dynamicpreprocessor/
163
+
164
+	$(INSTALL_DIR) $(1)/etc/snort
165
+	$(INSTALL_CONF) \
166
+		$(PKG_BUILD_DIR)/etc/snort.conf \
167
+		$(1)/etc/snort/
168
+	$(INSTALL_CONF) \
169
+		$(PKG_BUILD_DIR)/etc/attribute_table.dtd \
170
+		$(1)/etc/snort/
171
+	$(INSTALL_CONF) \
172
+		$(PKG_BUILD_DIR)/etc/classification.config \
173
+		$(1)/etc/snort/
174
+	$(INSTALL_CONF) \
175
+		$(PKG_BUILD_DIR)/etc/gen-msg.map \
176
+		$(1)/etc/snort/
177
+	$(INSTALL_CONF) \
178
+			$(PKG_BUILD_DIR)/etc/reference.config \
179
+			$(1)/etc/snort/
180
+	$(INSTALL_CONF) \
181
+		$(PKG_BUILD_DIR)/etc/unicode.map \
182
+		$(1)/etc/snort/
183
+
184
+	$(INSTALL_DIR) $(1)/etc/snort/preproc_rules
185
+	$(INSTALL_CONF) \
186
+		$(PKG_BUILD_DIR)/preproc_rules/*.rules \
187
+		$(1)/etc/snort/preproc_rules/
188
+
189
+	$(INSTALL_DIR) $(1)/etc/init.d
190
+	$(INSTALL_BIN) \
191
+		./files/snort.init \
192
+		$(1)/etc/init.d/snort
193
+
194
+	$(INSTALL_DIR) $(1)/etc/config
195
+	$(INSTALL_CONF) \
196
+		./files/snort.config \
197
+		$(1)/etc/config/snort
198
+endef
199
+
200
+$(eval $(call BuildPackage,snort))
201
+$(eval $(call BuildPackage,snort-mysql))
202
+$(eval $(call BuildPackage,snort-pgsql))

+ 3
- 0
net/snort/files/snort.config Bestand weergeven

@@ -0,0 +1,3 @@
1
+config snort 'snort'
2
+	option config_file '/etc/snort/snort.conf'
3
+	option interface 'lo'

+ 40
- 0
net/snort/files/snort.init Bestand weergeven

@@ -0,0 +1,40 @@
1
+#!/bin/sh /etc/rc.common
2
+# Copyright (C) 2015 OpenWrt.org
3
+
4
+START=90
5
+STOP=10
6
+
7
+USE_PROCD=1
8
+PROG=/usr/bin/snort
9
+
10
+validate_snort_section() {
11
+	uci_validate_section snort snort "${1}" \
12
+		'config_file:string' \
13
+		'interface:string'
14
+}
15
+
16
+start_service() {
17
+	local config_file interface
18
+
19
+	validate_snort_section snort || {
20
+		echo "validation failed"
21
+		return 1
22
+	}
23
+
24
+	procd_open_instance
25
+	procd_set_param command $PROG "-q" "--daq-dir" "/usr/lib/daq/" "-i" "$interface" "-s" "-N"
26
+	procd_set_param file $CONFIGFILE
27
+	procd_set_param respawn
28
+	procd_close_instance
29
+}
30
+
31
+stop_service()
32
+{
33
+	service_stop ${PROG}
34
+}
35
+
36
+service_triggers()
37
+{
38
+	procd_add_reload_trigger "snort"
39
+	procd_add_validation validate_snort_section
40
+}

+ 105
- 0
net/snort/patches/001-compile.patch Bestand weergeven

@@ -0,0 +1,105 @@
1
+--- /dev/null
2
++++ b/acinclude.m4
3
+@@ -0,0 +1 @@
4
++sinclude(m4/libprelude.m4)
5
+--- a/configure.in
6
++++ b/configure.in
7
+@@ -285,21 +285,7 @@ AC_CHECK_TYPES([int8_t,int16_t,int32_t,i
8
+ AC_CHECK_TYPES([boolean])
9
+ 
10
+ # In case INADDR_NONE is not defined (like on Solaris)
11
+-have_inaddr_none="no"
12
+-AC_MSG_CHECKING([for INADDR_NONE])
13
+-AC_RUN_IFELSE(
14
+-[AC_LANG_PROGRAM(
15
+-[[
16
+-#include <sys/types.h>
17
+-#include <netinet/in.h>
18
+-#include <arpa/inet.h>
19
+-]],
20
+-[[
21
+-	if (inet_addr("10,5,2") == INADDR_NONE);
22
+-    return 0;
23
+-]])],
24
+-[have_inaddr_none="yes"],
25
+-[have_inaddr_none="no"])
26
++have_inaddr_none="yes"
27
+ AC_MSG_RESULT($have_inaddr_none)
28
+ if test "x$have_inaddr_none" = "xno"; then
29
+ 	AC_DEFINE([INADDR_NONE],[-1],[For INADDR_NONE definition])
30
+@@ -433,16 +419,7 @@ if test "x$LPCAP" = "xno"; then
31
+ fi
32
+ 
33
+ AC_MSG_CHECKING([for pcap_lex_destroy])
34
+-AC_RUN_IFELSE(
35
+-[AC_LANG_PROGRAM(
36
+-[[
37
+-#include <pcap.h>
38
+-]],
39
+-[[
40
+-   pcap_lex_destroy();
41
+-]])],
42
+-[have_pcap_lex_destroy="yes"],
43
+-[have_pcap_lex_destroy="no"])
44
++have_pcap_lex_destroy="yes"
45
+ AC_MSG_RESULT($have_pcap_lex_destroy)
46
+ if test "x$have_pcap_lex_destroy" = "xyes"; then
47
+     AC_DEFINE([HAVE_PCAP_LEX_DESTROY],[1],[Can cleanup lex buffer stack created by pcap bpf filter])
48
+@@ -727,54 +704,21 @@ if test "x$ac_cv_func_daq_dp_add_dc" = "
49
+ 
50
+ fi
51
+ 
52
+-AC_MSG_CHECKING([for daq address space ID])
53
+-AC_RUN_IFELSE(
54
+-[AC_LANG_PROGRAM(
55
+-[[
56
+-#include <daq.h>
57
+-]],
58
+-[[
59
+-   DAQ_PktHdr_t hdr;
60
+-   hdr.address_space_id = 0;
61
+-]])],
62
+-[have_daq_address_space_id="yes"],
63
+-[have_daq_address_space_id="no"])
64
++have_daq_address_space_id="yes"
65
+ AC_MSG_RESULT($have_daq_address_space_id)
66
+ if test "x$have_daq_address_space_id" = "xyes"; then
67
+     AC_DEFINE([HAVE_DAQ_ADDRESS_SPACE_ID],[1],
68
+         [DAQ version supports address space ID in header.])
69
+ fi
70
+ 
71
+-AC_MSG_CHECKING([for daq flow ID])
72
+-AC_RUN_IFELSE(
73
+-[AC_LANG_PROGRAM(
74
+-[[
75
+-#include <daq.h>
76
+-]],
77
+-[[
78
+-   DAQ_PktHdr_t hdr;
79
+-   hdr.flow_id = 0;
80
+-]])],
81
+-[have_daq_flow_id="yes"],
82
+-[have_daq_flow_id="no"])
83
++have_daq_flow_id="yes"
84
+ AC_MSG_RESULT($have_daq_flow_id)
85
+ if test "x$have_daq_flow_id" = "xyes"; then
86
+     AC_DEFINE([HAVE_DAQ_FLOW_ID],[1],
87
+         [DAQ version supports flow ID in header.])
88
+ fi
89
+ 
90
+-AC_MSG_CHECKING([for DAQ_VERDICT_RETRY])
91
+-AC_RUN_IFELSE(
92
+-[AC_LANG_PROGRAM(
93
+-[[
94
+-#include <daq.h>
95
+-]],
96
+-[[
97
+-   DAQ_Verdict verdict;
98
+-   verdict = DAQ_VERDICT_RETRY;
99
+-]])],
100
+-[have_daq_verdict_retry="yes"],
101
+-[have_daq_verdict_retry="no"])
102
++have_daq_verdict_retry="yes"
103
+ AC_MSG_RESULT($have_daq_verdict_retry)
104
+ if test "x$have_daq_verdict_retry" = "xyes"; then
105
+     AC_DEFINE([HAVE_DAQ_VERDICT_RETRY],[1],