Skip to content

Commit

Permalink
snort: fix doc path
Browse files Browse the repository at this point in the history
  • Loading branch information
conraid committed Feb 26, 2015
1 parent d2d42a6 commit cb3355a
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 131 deletions.
76 changes: 1 addition & 75 deletions snort/SLACKWARE.README
Expand Up @@ -84,83 +84,9 @@ This script is included only as an example and without any guarantee.
Basically, you need to
1) put the new rules/* into /etc/snort/rules/
2) put the new preproc_rules/* into /etc/snort/preproc_rules/
3) put the new doc/signatures/* into /usr/doc/snort-*/signatures/
4) put the new etc/* into /etc/snort/ (except for snort.conf)
3) put the new etc/* into /etc/snort/ (except for snort.conf)

After updating your files, restart snort with:

# /etc/rc.d/rc.snort restart

=============================================================================
Sample script to update rules, signatures and configurations
*** USE AT YOUR OWN RISK *** NO GUARANTEES ***
=============================================================================
#!/bin/bash

# snortrules_update
#
# Written by Niels Horn <niels.horn@gmail.com>
# Nothing guaranteed, use at your own risk!
#
# v1.00-2010/09/18 - first attempt
#

CWD=$(pwd)
CONFDIR=/etc/snort

# Exit on most errors
set -e

if [ "x$1" = "x" ]; then
echo "Specify snortrules-snapshot file:"
echo
echo " $0 <snortrules-snapshot>"
echo
exit 1
fi

# Configuration files
echo "*** Updating configuration files..."
for cf in $( tar tf $1 | grep "etc/" ); do
if [ ! "$cf" = "etc/" ]; then
file=$(basename $cf)
tar -xf $1 $cf -O > $CONFDIR/$file.new
# check if it is "snort.conf"
if [ ! "$file" = "snort.conf" ]; then
# OK, it is something else, we can handle this
if [ -r $CONFDIR/$file ]; then
# we have a previous version
if [ "$(cat $CONFDIR/$file | md5sum)" = "$(cat $CONFDIR/$file.new | md5sum)" ]; then
# nothing new, dump previous version
rm $CONFDIR/$file
else
# keep previous version
mv -f $CONFDIR/$file $CONFDIR/$file.old
fi
fi
# move new file over
mv -f $CONFDIR/$file.new $CONFDIR/$file
fi
fi
done

# rules
echo "*** Updating rules..."
cd /etc/snort/rules
tar --strip-components=1 --wildcards -xf $CWD/$1 rules/*
cd - > /dev/null

# preproc-rules
echo "*** Updating preproc_rules..."
cd /etc/snort/preproc_rules
tar --strip-components=1 --wildcards -xf $CWD/$1 preproc_rules/*
cd - > /dev/null

# signatures
echo "*** Updating signatures..."
cd /usr/doc/snort-*/signatures
tar --strip-components=2 --wildcards -xf $CWD/$1 doc/signatures/*
cd - > /dev/null

echo "All done."

101 changes: 45 additions & 56 deletions snort/snort.SlackBuild
Expand Up @@ -2,7 +2,7 @@
#
# Slackware build script for snort
#
# Copyright 2011-2014 Corrado Franco (http://conraid.net)
# Copyright 2011-2015 Corrado Franco (http://conraid.net)
# All rights reserved.
#
# Redistribution and use of this script, with or without modification, is
Expand Down Expand Up @@ -31,31 +31,31 @@ set -eu
CWD=$(pwd)

PRGNAME=${PRGNAME:-snort}
PKGNAME=$(echo $PRGNAME | tr A-Z a-z)
PKGNAME=$(echo ${PRGNAME} | tr A-Z a-z)
VERSION=${VERSION:-2.9.7.0}
PKGVERSION=$(echo $VERSION | tr - _)
BUILD=${BUILD:-1}
PKGVERSION=$(echo ${VERSION} | tr - _)
BUILD=${BUILD:-2}
TAG=${TAG:-cf}
TMP=${TMP:-/tmp/pkg}
PKG=$TMP/package-$PKGNAME
DOCS="$PKG/usr/doc/$PKGNAME-$PKGVERSION"
PKG=${TMP}/package-${PKGNAME}
DOCDIR="${PKG}/usr/doc/${PKGNAME}-${PKGVERSION}"

# Insert document files in this variable
DOCFILES="COPYING ChangeLog LICENSE RELEASE.NOTES"

ARCH=${ARCH:=""} # Set ARCH or leave blank to determine it automatically/
# Automatically determine the architecture we're building on:
if [ -z "$ARCH" ]; then
if [ -z "${ARCH}" ]; then
case "$( uname -m )" in
i?86) ARCH=i686 ;;
arm*) ARCH=arm ;;
# Unless $ARCH is already set, use uname -m for all other archs:
# Unless ${ARCH} is already set, use uname -m for all other archs:
*) ARCH=$( uname -m ) ;;
esac
fi

# Set compiling FLAGS
case "$ARCH" in
case "${ARCH}" in
i486)
SLKCFLAGS="-O2 -march=i486 -mtune=i686"; CHOST="i486"
SLKLDFLAGS=""; LIBDIRSUFFIX=""
Expand All @@ -69,18 +69,18 @@ case "$ARCH" in
SLKLDFLAGS="-L/lib64 -L/usr/lib64"; LIBDIRSUFFIX="64"
;;
*)
SLKCFLAGS="-O2"; CHOST=$ARCH
SLKCFLAGS="-O2"; CHOST=${ARCH}
SLKLDFLAGS=""; LIBDIRSUFFIX=""
;;
esac

# Extract source and prepare:
rm -rf $PKG
mkdir -p $TMP $PKG
cd $TMP
rm -rf $PRGNAME-$VERSION
tar xvf $CWD/$PRGNAME-$VERSION.tar.gz
cd $PRGNAME-$VERSION
rm -rf ${PKG}
mkdir -p ${TMP} ${PKG}
cd ${TMP}
rm -rf ${PRGNAME}-${VERSION}
tar xvf ${CWD}/${PRGNAME}-${VERSION}.tar.gz
cd ${PRGNAME}-${VERSION}

# Make sure ownerships and permissions are sane:
chown -R root:root .
Expand All @@ -92,12 +92,12 @@ for MF in $( find src/ -name Makefile.in ) ; do
done

# Sane --docdir in /doc/Makefile.in
sed -i 's#${datadir}/doc/${PACKAGE}#@docdir@#g' doc/Makefile.in
sed 's#${datadir}/doc/${PACKAGE}#@docdir@#g' -i {doc,tools/u2boat}/Makefile.in

# Configure
LDFLAGS="$SLKLDFLAGS" \
CFLAGS="$SLKCFLAGS" \
CXXFLAGS="$SLKCFLAGS" \
LDFLAGS="${SLKLDFLAGS}" \
CFLAGS="${SLKCFLAGS}" \
CXXFLAGS="${SLKCFLAGS}" \
./configure \
--prefix=/usr \
--libdir=/usr/lib${LIBDIRSUFFIX} \
Expand All @@ -110,33 +110,23 @@ CXXFLAGS="$SLKCFLAGS" \
--enable-shared=yes \
--enable-linux-smp-stats \
--enable-pthread \
--enable-zlib \
--host=$CHOST-slackware-linux \
--build=$CHOST-slackware-linux
--disable-static-daq \
--host=${CHOST}-slackware-linux \
--build=${CHOST}-slackware-linux

# Build and install:
make
make DESTDIR=$PKG install-strip
make DESTDIR=${PKG} install-strip

# Compress and link manpages, if any:
if [ -d $PKG/usr/man ]; then
( cd $PKG/usr/man
find -type f -exec gzip -9 {} \;
for i in $(find -type l); do ln -s $(readlink $i).gz $i.gz; rm $i; done
)
if [ -d ${PKG}/usr/man ]; then
find ${PKG}/usr/man -type f -exec gzip -9 {} \;
for i in $( find ${PKG}/usr/man -type l ) ; do ln -s $( readlink $i ).gz $i.gz ; rm $i ; done
fi

# Add a documentation directory:
mkdir -p ${DOCS}
for i in ${DOCFILES}; do
if [ -e "${i}" ]; then
if ! [ -L "${i}" ]; then
cp -a "${i}" ${DOCS}
else
cp -LRp "${i}" ${DOCS}
fi
fi;
done
mkdir -p ${DOCDIR}
cp -a ${DOCFILES} ${DOCDIR} || true

### Set directory for snort. Thanks to SBo and archlinux
mkdir -p "${PKG}/"{etc/rc.d,etc/snort/rules,etc/snort/preproc_rules,var/log/snort,/usr/lib${LIBDIRSUFFIX}/snort_dynamicrules}
Expand All @@ -146,30 +136,29 @@ mkdir -p "${PKG}/"{etc/rc.d,etc/snort/rules,etc/snort/preproc_rules,var/log/snor
sed -e "s|usr/local/lib|usr/lib${LIBDIRSUFFIX}|g" \
-e "s|PATH ../|PATH |g" \
-e "/^# output unified2*/aoutput unified2: filename snort.log, limit 128" \
etc/snort.conf > $PKG/etc/snort/snort.conf.new
cat etc/threshold.conf > $PKG/etc/snort/threshold.conf.new
cat etc/reference.config > $PKG/etc/snort/reference.config.new
cat etc/classification.config > $PKG/etc/snort/classification.config.new
cat etc/attribute_table.dtd > $PKG/etc/snort/attribute_table.dtd.new
cat etc/gen-msg.map > $PKG/etc/snort/gen-msg.map.new
cat etc/unicode.map > $PKG/etc/snort/unicode.map.new

# Create directories for schemas and signatures
mkdir -p $DOCS/{schemas,signatures}
cat $CWD/SLACKWARE.README > $DOCS/README.SLACKWARE
etc/snort.conf > ${PKG}/etc/snort/snort.conf.new
cat etc/threshold.conf > ${PKG}/etc/snort/threshold.conf.new
cat etc/reference.config > ${PKG}/etc/snort/reference.config.new
cat etc/classification.config > ${PKG}/etc/snort/classification.config.new
cat etc/attribute_table.dtd > ${PKG}/etc/snort/attribute_table.dtd.new
cat etc/gen-msg.map > ${PKG}/etc/snort/gen-msg.map.new
cat etc/unicode.map > ${PKG}/etc/snort/unicode.map.new

# Install Slackware Readme
install -Dm644 ${CWD}/SLACKWARE.README ${DOCDIR}/README.SLACKWARE

# Include the rc.snort file.
install -Dm755 $CWD/rc.snort $PKG/etc/rc.d/rc.snort.new
install -Dm755 ${CWD}/rc.snort ${PKG}/etc/rc.d/rc.snort.new

# Add a slackbuild script:
install -Dm644 $CWD/$PKGNAME.SlackBuild $DOCS/$PKGNAME.SlackBuild
install -Dm644 ${CWD}/${PKGNAME}.SlackBuild ${DOCDIR}/${PKGNAME}.SlackBuild

# Add slack-desc
install -Dm644 $CWD/slack-desc $PKG/install/slack-desc
install -Dm644 ${CWD}/slack-desc ${PKG}/install/slack-desc

# Add a doinst.sh
install -Dm644 $CWD/doinst.sh $PKG/install/doinst.sh
install -Dm644 ${CWD}/doinst.sh ${PKG}/install/doinst.sh

# Create package:
cd $PKG
/sbin/makepkg -l y -c n $CWD/$PKGNAME-$PKGVERSION-$ARCH-${BUILD}${TAG}.txz
cd ${PKG}
/sbin/makepkg -l y -c n ${CWD}/${PKGNAME}-${PKGVERSION}-${ARCH}-${BUILD}${TAG}.txz

0 comments on commit cb3355a

Please sign in to comment.