snort.spec 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. ##
  2. ## snort.spec -- OpenPKG RPM Package Specification
  3. ## Copyright (c) 2000-2006 OpenPKG Foundation e.V. <http://openpkg.net/>
  4. ## Copyright (c) 2000-2006 Ralf S. Engelschall <http://engelschall.com/>
  5. ##
  6. ## Permission to use, copy, modify, and distribute this software for
  7. ## any purpose with or without fee is hereby granted, provided that
  8. ## the above copyright notice and this permission notice appear in all
  9. ## copies.
  10. ##
  11. ## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  12. ## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  13. ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  14. ## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
  15. ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  16. ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  17. ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  18. ## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  19. ## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  20. ## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  21. ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  22. ## SUCH DAMAGE.
  23. ##
  24. # package version
  25. %define V_snort 2.6.0
  26. %define V_rules 2.4
  27. %define V_oinkmaster 2.0
  28. # package information
  29. Name: snort
  30. Summary: Network Intrusion Detection System
  31. URL: http://www.snort.org/
  32. Vendor: B. Caswell, M. Roesch
  33. Packager: OpenPKG
  34. Distribution: OpenPKG
  35. Class: BASE
  36. Group: Network
  37. License: GPL
  38. Version: %{V_snort}
  39. Release: 20060606
  40. # package options
  41. %option with_fsl yes
  42. %option with_mysql no
  43. %option with_pgsql no
  44. # list of sources
  45. Source0: http://www.snort.org/dl/current/snort-%{V_snort}.tar.gz
  46. Source1: http://www.snort.org/pub-bin/downloads.cgi/Download/vrt_pr/snortrules-pr-%{V_rules}.tar.gz
  47. Source2: http://switch.dl.sourceforge.net/sourceforge/oinkmaster/oinkmaster-%{V_oinkmaster}.tar.gz
  48. Source3: snort.conf
  49. Source4: rc.snort
  50. Source5: fsl.snort
  51. Source6: snort-update.sh
  52. Patch0: snort.patch
  53. # build information
  54. Prefix: %{l_prefix}
  55. BuildRoot: %{l_buildroot}
  56. BuildPreReq: OpenPKG, openpkg >= 20040130, make, gcc
  57. PreReq: OpenPKG, openpkg >= 20040130, perl, perl-www, perl-sys, perl-comp
  58. BuildPreReq: libpcap, libnet, pcre
  59. PreReq: libpcap, libnet, pcre
  60. %if "%{with_fsl}" == "yes"
  61. BuildPreReq: fsl >= 1.2.0
  62. PreReq: fsl >= 1.2.0
  63. %endif
  64. %if "%{with_mysql}" == "yes"
  65. BuildPreReq: mysql
  66. PreReq: mysql
  67. %endif
  68. %if "%{with_pgsql}" == "yes"
  69. BuildPreReq: postgresql
  70. PreReq: postgresql
  71. %endif
  72. AutoReq: no
  73. AutoReqProv: no
  74. %description
  75. Snort is an open source network intrusion detection system,
  76. capable of performing real-time traffic analysis and packet
  77. logging on IP networks. It can perform protocol analysis, content
  78. searching/matching and can be used to detect a variety of attacks
  79. and probes. Snort uses a flexible rules language to describe traffic
  80. that it should collect or pass, as well as a detection engine that
  81. utilizes a modular plugin architecture. Snort has a real-time
  82. alerting capability as well. Snort has three primary uses. It can be
  83. used as a straight packet sniffer like tcpdump(1), a packet logger
  84. (useful for network traffic debugging, etc), or as a full blown
  85. network intrusion detection system.
  86. %track
  87. prog snort = {
  88. version = %{V_snort}
  89. url = http://www.snort.org/dl/
  90. regex = snort-(\d+\.\d+\.\d+)\.tar\.gz
  91. }
  92. prog snort:rules = {
  93. version = %{V_rules}
  94. url = http://www.snort.org/pub-bin/downloads.cgi
  95. regex = snortrules-pr-(\d+\.\d+)\.tar\.gz
  96. }
  97. prog snort:oinkmaster = {
  98. version = %{V_oinkmaster}
  99. url = http://prdownloads.sourceforge.net/oinkmaster/
  100. regex = oinkmaster-(__VER__)\.tar\.gz
  101. }
  102. %prep
  103. %setup -q
  104. %setup -q -D -T -a 2
  105. %patch -p0
  106. %{l_shtool} subst %{l_value -s -a} \
  107. src/snort.h
  108. %build
  109. # configure program
  110. LIBS=""
  111. %if "%{with_pgsql}" == "yes"
  112. LIBS="$LIBS -lpq -lcrypt -lssl -lcrypto"
  113. %endif
  114. case "%{l_platform -t}" in
  115. *-sunos* ) LIBS="$LIBS -lresolv" ;;
  116. esac
  117. CC="%{l_cc}" \
  118. CFLAGS="%{l_cflags -O}" \
  119. CPPFLAGS="%{l_cppflags}" \
  120. LDFLAGS="%{l_ldflags} %{l_fsl_ldflags}" \
  121. LIBS="$LIBS %{l_fsl_libs}" \
  122. ./configure \
  123. --prefix=%{l_prefix} \
  124. --sysconfdir=%{l_prefix}/etc/snort \
  125. %if "%{with_mysql}" == "yes"
  126. --with-mysql=%{l_prefix} \
  127. %else
  128. --without-mysql \
  129. %endif
  130. %if "%{with_pgsql}" == "yes"
  131. --with-postgresql=%{l_prefix} \
  132. %else
  133. --without-postgresql \
  134. %endif
  135. --with-libpcap-includes=%{l_prefix}/include \
  136. --with-libpcap-libraries=%{l_prefix}/lib \
  137. --with-libnet-includes=%{l_prefix}/include \
  138. --with-libnet-libraries=%{l_prefix}/lib \
  139. --with-libpcre-includes=%{l_prefix}/include \
  140. --with-libpcre-libraries=%{l_prefix}/lib \
  141. --enable-perfmonitor
  142. # build program
  143. %{l_make} %{l_mflags -O}
  144. %install
  145. # create installation hierarchy
  146. rm -rf $RPM_BUILD_ROOT
  147. %{l_shtool} mkdir -f -p -m 755 \
  148. $RPM_BUILD_ROOT%{l_prefix}/sbin \
  149. $RPM_BUILD_ROOT%{l_prefix}/man/man8 \
  150. $RPM_BUILD_ROOT%{l_prefix}/etc/fsl \
  151. $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d \
  152. $RPM_BUILD_ROOT%{l_prefix}/etc/snort \
  153. $RPM_BUILD_ROOT%{l_prefix}/share/snort \
  154. $RPM_BUILD_ROOT%{l_prefix}/var/snort/rules \
  155. $RPM_BUILD_ROOT%{l_prefix}/var/snort/tmp
  156. # install program and manual page
  157. %{l_shtool} install -c -s -m 755 \
  158. src/snort $RPM_BUILD_ROOT%{l_prefix}/sbin/
  159. %{l_shtool} install -c -m 644 \
  160. snort.8 $RPM_BUILD_ROOT%{l_prefix}/man/man8/
  161. # install default configuration
  162. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  163. %{SOURCE snort.conf} $RPM_BUILD_ROOT%{l_prefix}/etc/snort/
  164. # install default ruleset tarball
  165. %{l_shtool} install -c -m 644 \
  166. %{SOURCE snortrules-pr-%{V_rules}.tar.gz} \
  167. $RPM_BUILD_ROOT%{l_prefix}/share/snort/rules.tar.gz
  168. # install run-command script
  169. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  170. %{SOURCE rc.snort} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
  171. # install OSSP fsl configuration
  172. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  173. %{SOURCE fsl.snort} $RPM_BUILD_ROOT%{l_prefix}/etc/fsl/
  174. # install optional/additional files
  175. %if "%{with_mysql}" == "yes"
  176. %{l_shtool} install -c -m 644 \
  177. schemas/create_mysql \
  178. $RPM_BUILD_ROOT%{l_prefix}/share/snort/
  179. %endif
  180. %if "%{with_pgsql}" == "yes"
  181. %{l_shtool} install -c -m 644 \
  182. schemas/create_postgresql \
  183. $RPM_BUILD_ROOT%{l_prefix}/share/snort/
  184. %endif
  185. # install oinkmaster utility
  186. ( cd oinkmaster-%{V_oinkmaster}
  187. %{l_shtool} install -c -m 755 \
  188. -e 's;#!/usr/bin/perl;#!%{l_prefix}/bin/perl;g' \
  189. -e 's;/etc/oinkmaster\.conf;%{l_prefix}/etc/snort/oinkmaster.conf;' \
  190. oinkmaster.pl $RPM_BUILD_ROOT%{l_prefix}/sbin/oinkmaster
  191. %{l_shtool} install -c -m 644 \
  192. oinkmaster.1 $RPM_BUILD_ROOT%{l_prefix}/man/man8/oinkmaster.8
  193. %{l_shtool} install -c -m 644 \
  194. -e 's;^\(path = \);\1%{l_prefix}/bin:;' \
  195. -e 's;^# tmpdir = /home/oinkmaster/tmp/;tmpdir = %{l_prefix}/var/snort/tmp;' \
  196. -e 's;^\(use_external_bins = 0\);\1;' \
  197. -e 's;^\(skipfile snort\.conf\);# \1;' \
  198. oinkmaster.conf $RPM_BUILD_ROOT%{l_prefix}/etc/snort/
  199. ) || exit $?
  200. # install rule update utility
  201. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  202. -e 's;@V_rules@;%{V_rules};g' \
  203. %{SOURCE snort-update.sh} \
  204. $RPM_BUILD_ROOT%{l_prefix}/sbin/snort-update
  205. # determine installation files
  206. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
  207. %{l_files_std} \
  208. '%config %{l_prefix}/etc/fsl/*' \
  209. '%config %{l_prefix}/etc/snort/*' \
  210. '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/snort' \
  211. '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/snort/rules' \
  212. '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/snort/tmp'
  213. %files -f files
  214. %clean
  215. rm -rf $RPM_BUILD_ROOT
  216. %post
  217. if [ $1 -eq 1 ]; then
  218. # display final hints on initial installation
  219. ( echo "Before starting Snort IDS, please set the configuration variable"
  220. echo "\"snort_if\" in $RPM_INSTALL_PREFIX/etc/rc.conf to the name of the"
  221. echo "used network interface."
  222. ) | %{l_rpmtool} msg -b -t notice
  223. ( echo "To use Snort as an IDS, its rules HAVE to be ALWAYS up to date."
  224. echo "But this package just ships with the latest PUBLIC version of the"
  225. echo "\"Sourcefire VRT Certified Rules\" for UNREGISTERED Snort users."
  226. echo "This means your rules are NOT covering the latest known attacks."
  227. echo ""
  228. echo "Hence, we strongly recommend to become at least a REGISTERED Snort"
  229. echo "user (see http://www.snort.org/ for details). This way you receive"
  230. echo "a so-called \"oinkcode\" (a sequence of 40 hexadecimal numbers)"
  231. echo "which you can configure in the file"
  232. echo " $RPM_INSTALL_PREFIX/etc/rc.conf"
  233. echo "via the directives"
  234. echo " snort_update_time=\"daily\""
  235. echo " snort_update_source=\"oinkcode:XXXX...\""
  236. echo "to update your Snort rules in"
  237. echo " $RPM_INSTALL_PREFIX/var/snort/rules/"
  238. echo "automatically once per day with the latest version of the"
  239. echo "\"Sourcefire VRT Certified Rules\" for REGISTERED Snort users."
  240. ) | %{l_rpmtool} msg -b -t notice
  241. fi
  242. # trigger a ruleset update
  243. snort_update_source=`%{l_rc} -q snort_update_source`
  244. if [ ".$snort_update_source" != . ]; then
  245. su - %{l_rusr} -c "$RPM_INSTALL_PREFIX/sbin/snort-update \"$snort_update_source\""
  246. fi
  247. # after upgrade, restart service
  248. [ $1 -eq 2 ] || exit 0
  249. eval `%{l_rc} snort status 2>/dev/null`
  250. [ ".$snort_active" = .yes ] && %{l_rc} snort restart
  251. exit 0
  252. %preun
  253. # before erase, stop service and remove log files
  254. [ $1 -eq 0 ] || exit 0
  255. %{l_rc} snort stop 2>/dev/null
  256. rm -f $RPM_INSTALL_PREFIX/var/snort/*.pid >/dev/null 2>&1 || true
  257. rm -f $RPM_INSTALL_PREFIX/var/snort/*.log >/dev/null 2>&1 || true
  258. rm -f $RPM_INSTALL_PREFIX/var/snort/*.cap >/dev/null 2>&1 || true
  259. rm -f $RPM_INSTALL_PREFIX/var/snort/rules/* >/dev/null 2>&1 || true
  260. rm -f $RPM_INSTALL_PREFIX/var/snort/tmp/* >/dev/null 2>&1 || true
  261. exit 0