#!/bin/sh # Slackware build script for dionaea # based on the SBo SlackBuild template # # before building, make sure you have at least python3 and cython installed # i recommend getting the SlackBuilds from http://slackbuilds.org/ # last modified: 2011 May 12 # Written by pyllyukko - http://maimed.org/~pyllyukko/ # NOTES: # - dionaea will install under /opt/dionaea # TODO: # - figure out a way to include *.pyc (bytecode compiled by the python interpreter) # files inside the package, they are generated when dionaea is started # - opt/dionaea/lib/dionaea could be completely removed after uninstall? # - make $VERSION the actual git revision, not current date # - if $VERSION empty, use latest from git, otherwise checkout that revision PRGNAM=dionaea VERSION=${VERSION:-`date +%Y%m%d`} ARCH=${ARCH:-i486} BUILD=${BUILD:-1} # path where python3.2 resides # python3.SlackBuild from SBo defaults to /usr/bin/python3.2 PYTHON3_PATH="/usr/bin" #CYTHON_DIR="/usr/bin" CYTHON_DIR="/opt/dionaea/bin" # we need this if Cython is installed under /opt export PYTHONPATH="/opt/dionaea/lib/python3.2/site-packages" CWD=$(pwd) TMP=${TMP:-/tmp/dionaea} PKG=$TMP/package-$PRGNAM OUTPUT=${OUTPUT:-/tmp} # Drop the package in /tmp [ ! -x "${PYTHON3_PATH}/python3.2" ] && { echo "error: \`${PYTHON3_PATH}/python3.2' does not exist, or is not executable!" echo " if you have python3 installed somewhere else, please change the" echo " PYTHON3_PATH variable accordingly." exit 1 } 1>&2 if [ "$ARCH" = "i486" ]; then SLKCFLAGS="-O2 -march=i486 -mtune=i686" LIBDIRSUFFIX="" elif [ "$ARCH" = "i686" ]; then SLKCFLAGS="-O2 -march=i686 -mtune=i686" LIBDIRSUFFIX="" elif [ "$ARCH" = "x86_64" ]; then SLKCFLAGS="-O2 -fPIC" LIBDIRSUFFIX="64" fi set -e # Exit on most errors rm -rf $PKG mkdir -p $TMP $PKG $OUTPUT cd $TMP rm -rfv $PRGNAM git clone git://git.carnivore.it/dionaea.git $PRGNAM cd $PRGNAM #git checkout 85da727 #git checkout e727d26f GIT_REV=`git rev-parse --verify HEAD` chown -R root:root . find . \ \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \ -exec chmod 755 {} \; -o \ \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \ -exec chmod 644 {} \; # configure notes: # we're trying to conform with FHS 2.3 by using /var/opt/dionaea as localstatedir # instead of the default /opt/dionaea/var/... # Slackware 13.1 comes with libnl 1.1 and dionaea would need 2.0 series, # which has incompatible API. Since libnl IS optional, we'll just skip it # for now. autoreconf -vi #CFLAGS="$SLKCFLAGS" \ #CXXFLAGS="$SLKCFLAGS" \ ./configure \ --localstatedir=/var/opt/dionaea \ --with-lcfg-include=/opt/dionaea/include/ \ --with-lcfg-lib=/opt/dionaea/lib/ \ --with-python=${PYTHON3_PATH}/python3.2 \ --with-cython-dir=${CYTHON_DIR} \ --with-udns-include=/opt/dionaea/include/ \ --with-udns-lib=/opt/dionaea/lib/ \ --with-emu-include=/opt/dionaea/include/ \ --with-emu-lib=/opt/dionaea/lib/ \ --with-ev-include=/opt/dionaea/include \ --with-ev-lib=/opt/dionaea/lib \ --with-curl-config=/usr/bin/ \ --disable-nl \ --build=$ARCH-slackware-linux #cp -f -v ${CWD}/binding.c modules/python/binding.c # Compile the application and install it into the $PKG directory make make install DESTDIR=$PKG # change configuration file to .new mv -v "${PKG}/opt/${PRGNAM}/etc/${PRGNAM}/${PRGNAM}.conf" "${PKG}/opt/${PRGNAM}/etc/${PRGNAM}/${PRGNAM}.conf.new" # Copy program documentation into the package # The included documentation varies from one application to another, so be sure # to adjust your script as needed # Also, include the SlackBuild script in the documentation directory mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION cp -a \ LICENSE README \ $PKG/usr/doc/$PRGNAM-$VERSION cp -R -v modules/python/util ${PKG}/usr/doc/$PRGNAM-$VERSION cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild # sp tool, if available [ -f "${CWD}/sp" ] && { mkdir -p "${PKG}/usr/doc/${PRGNAM}-${VERSION}/util" cp -v "${CWD}/sp" "${PKG}/usr/doc/${PRGNAM}-${VERSION}/util" } # some stuff for the etc # logrotate from http://dionaea.carnivore.it/#configuration mkdir -p ${PKG}/etc/{rc.d,logrotate.d} cat 0<<-EOF 1>${PKG}/etc/logrotate.d/dionaea # logrotate requires dionaea to be started with a pidfile # in this case -p /opt/dionaea/var/run/dionaea.pid # adjust the path to your needs #/opt/dionaea/var/log/dionaea*.log { # notifempty # missingok # rotate 28 # daily # delaycompress # compress # create 660 root root # dateext # postrotate # kill -HUP \`cat /opt/dionaea/var/run/dionaea.pid\` # endscript #} EOF # Copy the slack-desc (and a custom doinst.sh if necessary) into ./install mkdir -p $PKG/install cat 0<<-EOF 1>${PKG}/install/slack-desc # HOW TO EDIT THIS FILE: # The "handy ruler" below makes it easier to edit a package description. Line # up the first '|' above the ':' following the base package name, and the '|' # on the right side marks the last column you can put a character in. You must # make exactly 11 lines for the formatting to be correct. It's also # customary to leave one space after the ':' except on otherwise blank lines. |-----handy-ruler------------------------------------------------------| dionaea: dionaea (a low interaction honeypot) dionaea: dionaea: Dionaea is meant to be a Nepenthes successor, embedding Python dionaea: as scripting language, using libemu to detect dionaea: shellcodes, supporting IPv6 and TLS. dionaea: dionaea: dionaea: dionaea: dionaea: http://dionaea.carnivore.it/ dionaea: EOF # ok this is kinda silly, but i wan't them all included in this one SlackBuild file cat 0<<-EOF 1>${PKG}/install/doinst.sh config() { NEW="\$1" OLD="\$(dirname \$NEW)/\$(basename \$NEW .new)" # If there's no config file by that name, mv it over: if [ ! -r \$OLD ]; then mv \$NEW \$OLD elif [ "\$(cat \$OLD | md5sum)" = "\$(cat \$NEW | md5sum)" ]; then # toss the redundant copy rm \$NEW fi # Otherwise, we leave the .new copy for the admin to consider... } config opt/dionaea/etc/dionaea/dionaea.conf.new ( cd opt/dionaea/lib/dionaea/python/dionaea ; rm -rfv pyev.so ) ( cd opt/dionaea/lib/dionaea/python/dionaea ; ln -sfv /opt/dionaea/lib/dionaea/python.so pyev.so ) ( cd opt/dionaea/lib/dionaea/python/dionaea ; rm -rfv core.so ) ( cd opt/dionaea/lib/dionaea/python/dionaea ; ln -sfv /opt/dionaea/lib/dionaea/python.so core.so ) EOF # Make the package cd $PKG /sbin/makepkg -l n -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.${PKGTYPE:-tgz} exit 0