summaryrefslogtreecommitdiff
path: root/app-forensics/aide
diff options
context:
space:
mode:
authorV3n3RiX <venerix@redcorelinux.org>2018-07-14 21:03:06 +0100
committerV3n3RiX <venerix@redcorelinux.org>2018-07-14 21:03:06 +0100
commit8376ef56580626e9c0f796d5b85b53a0a1c7d5f5 (patch)
tree7681bbd4e8b05407772df40a4bf04cbbc8afc3fa /app-forensics/aide
parent30a9caf154332f12ca60756e1b75d2f0e3e1822d (diff)
gentoo resync : 14.07.2018
Diffstat (limited to 'app-forensics/aide')
-rw-r--r--app-forensics/aide/Manifest10
-rw-r--r--app-forensics/aide/aide-0.16-r1.ebuild142
-rw-r--r--app-forensics/aide/files/aide-0.16-add-missing-include.patch24
-rw-r--r--app-forensics/aide/files/aide-0.16-fix-LIBS-LDFLAGS-mixing.patch23
-rw-r--r--app-forensics/aide/files/aide-0.16-fix-acl-configure-option.patch23
-rw-r--r--app-forensics/aide/files/aide-0.16-support-attr-2.4.48.patch28
-rw-r--r--app-forensics/aide/files/aide.conf115
-rw-r--r--app-forensics/aide/files/aide.cron192
-rw-r--r--app-forensics/aide/files/aideinit145
-rw-r--r--app-forensics/aide/metadata.xml19
10 files changed, 721 insertions, 0 deletions
diff --git a/app-forensics/aide/Manifest b/app-forensics/aide/Manifest
new file mode 100644
index 000000000000..e4dd90e5da59
--- /dev/null
+++ b/app-forensics/aide/Manifest
@@ -0,0 +1,10 @@
+AUX aide-0.16-add-missing-include.patch 512 BLAKE2B c3c25bbad549f8d2864b4ce91f33ee424ba4e64d40c967be23721324f017642557319d12aea980930882a10dbc39c17b0359de31e5cf5b7a1f9ef6a0b6088148 SHA512 084be3c787a19f57bf140cd809df61edfd16a8798a1344adeee0aba0f4207c1e4a9c47c4c6d7606650e20cc202747208c0f0c00c21c0b68e1b739fb9d269da68
+AUX aide-0.16-fix-LIBS-LDFLAGS-mixing.patch 874 BLAKE2B e61f6b269dcc3679d68714c315cfff8e8feb4146028abc33e780cb7429c4466c78b7e50c427fb78ffdc310335450a012f7a08b6ecd5aaf562b8ab18565c5f927 SHA512 930967c1c7be54d10beb26e4281083a0f7cf500a5f161cf2af6c0a7b377e9bce092942a3a88c6cbb080e3eab500ec8a7bec1ff295f774ef70146240837961a8f
+AUX aide-0.16-fix-acl-configure-option.patch 728 BLAKE2B a4edf60d7ffbae5f624645dd48f6cce0da6bd228d2b8aa04b08b1a2270fb9fb420175270a694ea225b2ccca6a1e4524001b042e12eb671b9758653c83893a7ee SHA512 65b93cd01ebfe6696e35872bc012126794e5e1e5756c2ce041d9a914722806f6079274b0fbb64bc795488f530c33106deba204ee2982a5a8d485b7cd88382497
+AUX aide-0.16-support-attr-2.4.48.patch 907 BLAKE2B 9d5c2c13a59c8ea1489e5353a2715926b7c0de2292050de166ea7959955a733487d68d047c23382370ccf2e91ea25dd5e4ffc6c55f47768e58da25775843133b SHA512 ea12a1aadc8ac8720dd5495318a0706f720422cdd0a7e7f6d794db4291b9a735468b7a1783922a1e489b738436a5d6e324d3ec66dc40b9b2b09d08ce4b3409e0
+AUX aide.conf 2713 BLAKE2B c6868a81450bb3e66d73a60df258e0c6e1166fb0126a0664cf78db021fb4c32049d92032f8ba92b0c08b58e0267ccafcc6e948daed69a856db2703991776f977 SHA512 cf6c17ab40b0bf9a0fb21ce015c6c35a8f7a595fdeb7d67e793424ed5243660a56cb33c1169038f4b116463cb055a48232f33db8ed497181be4e084449632b28
+AUX aide.cron 5997 BLAKE2B 2273eb902b9ba8fc5e999375d0dfa59e2c5c56a919bf3bd06e7b638213332b34c4a1240c717c2189f787dc249847f7115e2a21ac139b5db1df2151ade9f5a154 SHA512 0931c1b9185e0b9a563c3589858b0ba20716344f29d6d1fc7226498f3c744af1d3c3fd72824f101f9b3e08710f443c9fdad312e28c0bcb93665d1dcb076f4b47
+AUX aideinit 2949 BLAKE2B 244aaec9a38f19c6a7af706572a896e922215d6321aee4537ef5ce47326f41fd84880331a86ec71dcf7ee4e2ac2a11bf979ce66eff73dd2e8a2072e9eb7e8aab SHA512 a6bce52432251458b977fb363d5801206c273fb9404c55f7bcb82b9d5a65aa19d1660d61d457c9af87f1a8fada95e2f8203489b1876b2b2a259e6374e15cdc57
+DIST aide-0.16.tar.gz 391009 BLAKE2B 8769d8c6bdf72f307b75f3c1feaa2effdeaead00a0c65ab25bbb50dc6f7c7b53fda4d0a3a54dd5030de1444a34a81c294437d45193aeb8aec7ef0af83a173d47 SHA512 29ad97756e3e2fb21dc332ed03b494a1c73e621266f8622ec80bdba23092a38ee975b97f3cff2330e4c16e64e2f672259eea9291ca706a4009e7399b4e14e6a7
+EBUILD aide-0.16-r1.ebuild 3710 BLAKE2B 0be0b1ecc9c7bec42d475c2ccdf79b942572777af15addd5a524affd8dfd329f21ecb2b7fa18238270a9c67cf520127496056f6a7c3dba2682ca064024e3d8af SHA512 5acfa1daa419af465a3c1f2f305f4edddf38e095d18849565d7a41ba55a98c40d3f86bdf6888d48c9f05fd2d71a27086a3577bd78e9ef80947cfb0ebccc11b04
+MISC metadata.xml 631 BLAKE2B f76bc4d2957df7f95c38c3e082ee8b2d211d4822ac7223ba5cb10d35a72e14f092d4ad455a6a96da2a1649e1c2b1f0736c9a58fa18216c3b1b87ba295fbacf51 SHA512 9f6eb547a55e72d2b75d3145282127abfdc737c68526995e628b98f2dd7930732eff9dbc492ddd4425e4090e8449a89c585b563618415d05dee6777273c5d4f6
diff --git a/app-forensics/aide/aide-0.16-r1.ebuild b/app-forensics/aide/aide-0.16-r1.ebuild
new file mode 100644
index 000000000000..6f56d6e6be9c
--- /dev/null
+++ b/app-forensics/aide/aide-0.16-r1.ebuild
@@ -0,0 +1,142 @@
+# Copyright 1999-2018 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=6
+
+inherit autotools readme.gentoo-r1
+
+DESCRIPTION="AIDE (Advanced Intrusion Detection Environment) is a file integrity checker"
+HOMEPAGE="http://aide.sourceforge.net/"
+SRC_URI="mirror://sourceforge/aide/${P}.tar.gz"
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="amd64 x86"
+IUSE="acl audit curl e2fs mhash postgres prelink selinux static xattr zlib"
+
+COMMON_DEPEND="
+ !mhash? (
+ dev-libs/libgcrypt:0=
+ dev-libs/libgpg-error
+ )
+ mhash? ( app-crypt/mhash )
+ dev-libs/libpcre
+ acl? ( virtual/acl )
+ audit? ( sys-process/audit )
+ curl? ( net-misc/curl )
+ e2fs? ( sys-fs/e2fsprogs )
+ postgres? ( dev-db/postgresql:= )
+ prelink? ( dev-libs/elfutils )
+ selinux? ( sys-libs/libselinux )
+ xattr? ( sys-apps/attr )
+ zlib? ( sys-libs/zlib )
+"
+RDEPEND="
+ !static? ( ${COMMON_DEPEND} )
+ prelink? ( sys-devel/prelink )
+ selinux? ( sec-policy/selinux-aide )
+"
+DEPEND="${COMMON_DEPEND}
+ sys-devel/bison
+ sys-devel/flex
+ virtual/pkgconfig
+ static? (
+ !mhash? (
+ dev-libs/libgcrypt:0[static-libs]
+ dev-libs/libgpg-error[static-libs]
+ )
+ mhash? ( app-crypt/mhash[static-libs] )
+ dev-libs/libpcre[static-libs]
+ acl? ( virtual/acl[static-libs] )
+ e2fs? ( sys-fs/e2fsprogs[static-libs] )
+ prelink? ( dev-libs/elfutils[static-libs] )
+ selinux? ( sys-libs/libselinux[static-libs] )
+ xattr? ( sys-apps/attr[static-libs] )
+ zlib? ( sys-libs/zlib[static-libs] )
+ )
+"
+
+REQUIRED_USE="
+ postgres? ( !mhash )
+ static? ( !audit !curl !postgres )
+"
+
+HTML_DOCS=( doc/manual.html )
+
+DISABLE_AUTOFORMATTING=1
+DOC_CONTENTS="
+Example configuration file was installed at '${EPREFIX}/etc/aide/aide.conf'.
+Please edit it to meet your needs. Refer to aide.conf(5) manual page
+for more information.
+
+A helper script, aideinit, was installed and can be used to make AIDE
+management easier. Please run 'aideinit --help' for more information.
+"
+
+PATCHES=(
+ "${FILESDIR}/${P}-add-missing-include.patch"
+ "${FILESDIR}/${P}-fix-LIBS-LDFLAGS-mixing.patch"
+ "${FILESDIR}/${P}-fix-acl-configure-option.patch"
+ "${FILESDIR}/${P}-support-attr-2.4.48.patch"
+)
+
+src_prepare() {
+ default_src_prepare
+ sed -i -e 's| -Werror||g' configure.ac || die
+ eautoreconf
+}
+
+src_configure() {
+ local myeconfargs=(
+ --sysconfdir="${EPREFIX}/etc/${PN}"
+ --with-confighmactype="sha512" # Override default weak MD5 hash.
+ --with-dbhmackey="sha512" # Override default weak MD5 hash.
+ # Disable broken l10n support: https://sourceforge.net/p/aide/bugs/98/
+ # This doesn't affect anything because there are no localizations yet.
+ --without-locale
+ $(use_enable static)
+ $(use_with zlib)
+ $(use_with curl)
+ $(use_with acl posix-acl)
+ $(use_with selinux)
+ $(use_with prelink prelink "${EPREFIX}/usr/sbin/prelink")
+ $(use_with xattr)
+ $(use_with e2fs e2fsattrs)
+ $(use_with mhash mhash)
+ $(use_with !mhash gcrypt)
+ $(use_with postgres psql)
+ $(use_with audit)
+ )
+ econf "${myeconfargs[@]}"
+}
+
+src_install() {
+ default_src_install
+ readme.gentoo_create_doc
+
+ insinto /etc/${PN}
+ doins "${FILESDIR}"/aide.conf
+
+ dosbin "${FILESDIR}"/aideinit
+ dodoc "${FILESDIR}"/aide.cron
+
+ keepdir /var/{lib,log}/${PN}
+}
+
+pkg_postinst() {
+ readme.gentoo_print_elog
+
+ if use postgres; then
+ elog
+ elog "Due to a bad assumption by aide, you must issue the following"
+ elog "command after the database initialization (aide --init ...):"
+ elog
+ elog 'psql -c "update pg_index set indisunique=false from pg_class \\ '
+ elog " where pg_class.relname='TABLE_pkey' and \ "
+ elog ' pg_class.oid=pg_index.indexrelid" -h HOSTNAME -p PORT DBASE USER'
+ elog
+ elog "where TABLE, HOSTNAME, PORT, DBASE, and USER are the same as"
+ elog "in your aide.conf."
+ elog
+ fi
+}
diff --git a/app-forensics/aide/files/aide-0.16-add-missing-include.patch b/app-forensics/aide/files/aide-0.16-add-missing-include.patch
new file mode 100644
index 000000000000..75f0403c968e
--- /dev/null
+++ b/app-forensics/aide/files/aide-0.16-add-missing-include.patch
@@ -0,0 +1,24 @@
+commit 1cbb888d55388d6bb88141c946bd6993b3e9872f
+Author: Ilya Tumaykin <itumaykin@gmail.com>
+Date: Tue May 23 17:24:29 2017 +0300
+
+db: add missing include
+
+url_fclose() function used in this file is defined in fopen.h.
+See https://sourceforge.net/p/aide/bugs/99/
+
+diff --git a/src/db.c b/src/db.c
+index dd133d4..858240d 100644
+--- a/src/db.c
++++ b/src/db.c
+@@ -28,6 +28,10 @@
+ #include "db_disk.h"
+ #include "md.h"
+
++#ifdef WITH_CURL
++#include "fopen.h"
++#endif
++
+ #ifdef WITH_PSQL
+ #include "db_sql.h"
+ #endif
diff --git a/app-forensics/aide/files/aide-0.16-fix-LIBS-LDFLAGS-mixing.patch b/app-forensics/aide/files/aide-0.16-fix-LIBS-LDFLAGS-mixing.patch
new file mode 100644
index 000000000000..453abe5f1eae
--- /dev/null
+++ b/app-forensics/aide/files/aide-0.16-fix-LIBS-LDFLAGS-mixing.patch
@@ -0,0 +1,23 @@
+commit 6da37687ba7cf259ac19cae2e1c16115b6848143
+Author: Ilya Tumaykin <itumaykin@gmail.com>
+Date: Thu May 25 13:34:55 2017 +0300
+
+build: fix incorrect LIBS/LDFLAGS mixing
+
+Otherwise build with LDFLAGS='-Wl,--as-needed' and curl support fails.
+See https://bugs.gentoo.org/show_bug.cgi?id=271326
+and https://sourceforge.net/p/aide/bugs/96/
+
+diff --git a/configure.ac b/configure.ac
+index 3598ebe..0c5cb0c 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -713,7 +713,7 @@ if test x$with_curl = xyes; then
+ AC_CHECK_HEADERS(curl/curl.h,,
+ [AC_MSG_ERROR([You don't have curl properly installed. Install it or try --without-curl.])])
+ CFLAGS="$CFLAGS $CURL_CFLAGS"
+- LDFLAGS="$LDFLAGS $CURL_LIBS"
++ LIBS="$LIBS $CURL_LIBS"
+ AC_CHECK_LIB(curl,curl_easy_init,havecurl=yes,
+ [AC_MSG_ERROR([You don't have curl properly installed. Install it or try --without-curl.])]
+ )
diff --git a/app-forensics/aide/files/aide-0.16-fix-acl-configure-option.patch b/app-forensics/aide/files/aide-0.16-fix-acl-configure-option.patch
new file mode 100644
index 000000000000..a989e379039c
--- /dev/null
+++ b/app-forensics/aide/files/aide-0.16-fix-acl-configure-option.patch
@@ -0,0 +1,23 @@
+commit 3d9746bccbb50809e4c3de90ab5145a17af39aeb
+Author: Ilya Tumaykin <itumaykin@gmail.com>
+Date: Thu May 25 14:38:02 2017 +0300
+
+build: respect user choice for posix-acl configure option
+
+Otherwise acl support is enabled automagically, which is bad.
+See https://wiki.gentoo.org/wiki/Project:Quality_Assurance/Automagic_dependencies
+and https://sourceforge.net/p/aide/bugs/97/
+
+diff --git a/configure.ac b/configure.ac
+index 3598ebe..c45bbee 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -450,7 +450,7 @@ AC_MSG_CHECKING(for posix-acl-support)
+ AC_ARG_WITH([posix-acl],
+ [AC_HELP_STRING([--with-posix-acl],
+ [use POSIX ACLs (no checking)])],
+- [],
++ [with_posix_acl_support="$withval"],
+ [with_posix_acl_support=no]
+ )
+
diff --git a/app-forensics/aide/files/aide-0.16-support-attr-2.4.48.patch b/app-forensics/aide/files/aide-0.16-support-attr-2.4.48.patch
new file mode 100644
index 000000000000..8acb6e5b56b0
--- /dev/null
+++ b/app-forensics/aide/files/aide-0.16-support-attr-2.4.48.patch
@@ -0,0 +1,28 @@
+Fix build against attr >= 2.4.48
+
+Drop obsolete attr/xattr.h include as did attr upstream in attr-2.4.48.
+See http://git.savannah.nongnu.org/cgit/attr.git/commit/?id=7921157890d07858d092f4003ca4c6bae9fd2c38
+
+ENOATTR definition was moved to attr/attributes.h, thus include it.
+attr < 2.4.48 keeps ENOATTR definition in attr/xattr.h, so define it
+manually if necessary in order to preserve backwards compatibility.
+
+Bug: https://bugs.gentoo.org/648966
+Upstream-bug: https://sourceforge.net/p/aide/patches/23/
+
+diff --git a/include/db_config.h b/include/db_config.h
+index e92fe1c..7e5ff0d 100644
+--- a/include/db_config.h
++++ b/include/db_config.h
+@@ -62,7 +62,10 @@ typedef struct acl_type {
+
+ #ifdef WITH_XATTR /* Do generic user Xattrs. */
+ #include <sys/xattr.h>
+-#include <attr/xattr.h>
++#include <attr/attributes.h>
++#ifndef ENOATTR
++# define ENOATTR ENODATA
++#endif
+ #endif
+
+ typedef struct xattr_node
diff --git a/app-forensics/aide/files/aide.conf b/app-forensics/aide/files/aide.conf
new file mode 100644
index 000000000000..cef1813db9f8
--- /dev/null
+++ b/app-forensics/aide/files/aide.conf
@@ -0,0 +1,115 @@
+# AIDE conf
+
+database=file:/var/lib/aide/aide.db
+database_out=file:/var/lib/aide/aide.db.new
+
+# Change this to "no" or remove it to not gzip output
+# (only useful on systems with few CPU cycles to spare)
+gzip_dbout=yes
+
+# Here are all the things we can check - these are the default rules
+#
+#p: permissions
+#i: inode
+#n: number of links
+#u: user
+#g: group
+#s: size
+#b: block count
+#m: mtime
+#a: atime
+#c: ctime
+#S: check for growing size
+#md5: md5 checksum
+#sha1: sha1 checksum
+#rmd160: rmd160 checksum
+#tiger: tiger checksum
+#R: p+i+n+u+g+s+m+c+md5
+#L: p+i+n+u+g
+#E: Empty group
+#>: Growing logfile p+u+g+i+n+S
+#haval: haval checksum
+#gost: gost checksum
+#crc32: crc32 checksum
+
+# Defines formerly set here have been moved to /etc/default/aide.
+
+# Custom rules
+Binlib = p+i+n+u+g+s+b+m+c+md5+sha1
+ConfFiles = p+i+n+u+g+s+b+m+c+md5+sha1
+Logs = p+i+n+u+g+S
+Devices = p+i+n+u+g+s+b+c+md5+sha1
+Databases = p+n+u+g
+StaticDir = p+i+n+u+g
+ManPages = p+i+n+u+g+s+b+m+c+md5+sha1
+
+# Next decide what directories/files you want in the database
+
+# Kernel, system map, etc.
+=/boot$ Binlib
+# Binaries
+/bin Binlib
+/sbin Binlib
+/usr/bin Binlib
+/usr/sbin Binlib
+/usr/local/bin Binlib
+/usr/local/sbin Binlib
+#/usr/games Binlib
+# Libraries
+/lib Binlib
+/usr/lib Binlib
+/usr/local/lib Binlib
+# Log files
+=/var/log$ StaticDir
+#!/var/log/ksymoops
+/var/log/aide/aide.log(.[0-9])?(.gz)? Databases
+/var/log/aide/error.log(.[0-9])?(.gz)? Databases
+#/var/log/setuid.changes(.[0-9])?(.gz)? Databases
+!/var/log/aide
+/var/log Logs
+# Devices
+!/dev/pts
+# If you get spurious warnings about being unable to mmap() /dev/cpu/mtrr,
+# you may uncomment this to get rid of them. They're harmless but sometimes
+# annoying.
+#!/dev/cpu/mtrr
+#!/dev/xconsole
+/dev Devices
+# Other miscellaneous files
+/var/run$ StaticDir
+!/var/run
+# Test only the directory when dealing with /proc
+/proc$ StaticDir
+!/proc
+
+# You can look through these examples to get further ideas
+
+# MD5 sum files - especially useful with debsums -g
+#/var/lib/dpkg/info/([^\.]+).md5sums u+g+s+m+md5+sha1
+
+# Check crontabs
+#/var/spool/anacron/cron.daily Databases
+#/var/spool/anacron/cron.monthly Databases
+#/var/spool/anacron/cron.weekly Databases
+#/var/spool/cron Databases
+#/var/spool/cron/crontabs Databases
+
+# manpages can be trojaned, especially depending on *roff implementation
+#/usr/man ManPages
+#/usr/share/man ManPages
+#/usr/local/man ManPages
+
+# docs
+#/usr/doc ManPages
+#/usr/share/doc ManPages
+
+# check users' home directories
+#/home Binlib
+
+# check sources for modifications
+#/usr/src L
+#/usr/local/src L
+
+# Check headers for same
+#/usr/include L
+#/usr/local/include L
diff --git a/app-forensics/aide/files/aide.cron b/app-forensics/aide/files/aide.cron
new file mode 100644
index 000000000000..c28b78f8e9db
--- /dev/null
+++ b/app-forensics/aide/files/aide.cron
@@ -0,0 +1,192 @@
+#!/bin/bash
+# Modified: Benjamin Smee
+# Date: Fri Sep 10 11:35:41 BST 2004
+
+# This is the email address reports get mailed to
+MAILTO=root@localhost
+
+# Set this to suppress mailings when there's nothing to report
+QUIETREPORTS=1
+
+# This parameter defines which aide command to run from the cron script.
+# Sensible values are "update" and "check".
+# Default is "check", ensuring backwards compatibility.
+# Since "update" does not take any longer, it is recommended to use "update",
+# so that a new database is created every day. The new database needs to be
+# manually copied over the current one, though.
+COMMAND=update
+
+# This parameter defines how many lines to return per e-mail. Output longer
+# than this value will be truncated in the e-mail sent out.
+LINES=1000
+
+# This parameter gives a grep regular expression. If given, all output lines
+# that _don't_ match the regexp are listed first in the script's output. This
+# allows to easily remove noise from the aide report.
+NOISE="(/var/cache/|/var/lib/|/var/tmp)"
+PATH="/bin:/usr/bin:/sbin:/usr/sbin"
+LOGDIR="/var/log/aide"
+LOGFILE="aide.log"
+CONFFILE="/etc/aide/aide.conf"
+ERRORLOG="aide_error.log"
+MAILLOG="aide_mail.log"
+ERRORTMP=`tempfile --directory "/tmp" --prefix "$ERRORLOG"`
+
+[ -f /usr/bin/aide ] || exit 0
+
+DATABASE=`grep "^database=file:/" $CONFFILE | head -n 1 | cut --delimiter=: --fields=2`
+FQDN=`hostname -f`
+DATE=`date +"at %Y-%m-%d %H:%M"`
+
+# default values
+
+DATABASE="${DATABASE:-/var/lib/aide/aide.db}"
+
+AIDEARGS="-V4"
+
+if [ ! -f $DATABASE ]; then
+ /usr/sbin/sendmail $MAILTO <<EOF
+Subject: Daily AIDE report for $FQDN
+From: root@${FQDN}
+To: ${MAILTO}
+Fatal error: The AIDE database does not exist!
+This may mean you haven't created it, or it may mean that someone has removed it.
+EOF
+ exit 0
+fi
+
+# Removed so no deps on debianutils - strerror
+#[ -f "$LOGDIR/$LOGFILE" ] && savelog -j -t -g adm -m 640 -u root -c 7 "$LOGDIR/$LOGFILE" > /dev/null
+#[ -f "$LOGDIR/$ERRORLOG" ] && savelog -j -t -g adm -m 640 -u root -c 7 "$LOGDIR/$ERRORLOG" > /dev/null
+
+aide $AIDEARGS --$COMMAND >"$LOGDIR/$LOGFILE" 2>"$ERRORTMP"
+RETVAL=$?
+
+if [ -n "$QUIETREPORTS" ] && [ $QUIETREPORTS -a \! -s $LOGDIR/$LOGFILE -a \! -s $ERRORTMP ]; then
+ # Bail now because there was no output and QUIETREPORTS is set
+ exit 0
+fi
+
+MAILTMP=`tempfile --directory "/tmp" --prefix "$MAILLOG"`
+
+(cat << EOF
+This is an automated report generated by the Advanced Intrusion Detection
+Environment on $FQDN ${DATE}.
+
+EOF
+
+# include error log in daily report e-mail
+
+if [ "$RETVAL" != "0" ]; then
+ cat > "$LOGDIR/$ERRORLOG" << EOF
+
+*****************************************************************************
+* aide returned a non-zero exit value *
+*****************************************************************************
+
+EOF
+ echo "exit value is: $RETVAL" >> "$LOGDIR/$ERRORLOG"
+else
+ touch "$LOGDIR/$ERRORLOG"
+fi
+< "$ERRORTMP" cat >> "$LOGDIR/$ERRORLOG"
+rm -f "$ERRORTMP"
+
+if [ -s "$LOGDIR/$ERRORLOG" ]; then
+ errorlines=`wc -l "$LOGDIR/$ERRORLOG" | awk '{ print $1 }'`
+ if [ ${errorlines:=0} -gt $LINES ]; then
+ cat << EOF
+
+****************************************************************************
+* aide has returned many errors. *
+* the error log output has been truncated in this mail *
+****************************************************************************
+
+EOF
+ echo "Error output is $errorlines lines, truncated to $LINES."
+ head -$LINES "$LOGDIR/$ERRORLOG"
+ echo "The full output can be found in $LOGDIR/$ERRORLOG."
+ else
+ echo "Errors produced ($errorlines lines):"
+ cat "$LOGDIR/$ERRORLOG"
+ fi
+else
+ echo "AIDE produced no errors."
+fi
+
+# include de-noised log
+
+if [ -n "$NOISE" ]; then
+ NOISETMP=`tempfile --directory "/tmp" --prefix "aidenoise"`
+ NOISETMP2=`tempfile --directory "/tmp" --prefix "aidenoise"`
+ sed -n '1,/^Detailed information about changes:/p' "$LOGDIR/$LOGFILE" | \
+ grep '^\(changed\|removed\|added\):' | \
+ grep -v "^added: THERE WERE ALSO [0-9]\+ FILES ADDED UNDER THIS DIRECTORY" > $NOISETMP2
+
+ if [ -n "$NOISE" ]; then
+ < $NOISETMP2 grep -v "^\(changed\|removed\|added\):$NOISE" > $NOISETMP
+ rm -f $NOISETMP2
+ echo "De-Noised output removes everything matching $NOISE."
+ else
+ mv $NOISETMP2 $NOISETMP
+ echo "No noise expression was given."
+ fi
+
+ if [ -s "$NOISETMP" ]; then
+ loglines=`< $NOISETMP wc -l | awk '{ print $1 }'`
+ if [ ${loglines:=0} -gt $LINES ]; then
+ cat << EOF
+
+****************************************************************************
+* aide has returned long output which has been truncated in this mail *
+****************************************************************************
+
+EOF
+ echo "De-Noised output is $loglines lines, truncated to $LINES."
+ < $NOISETMP head -$LINES
+ echo "The full output can be found in $LOGDIR/$LOGFILE."
+ else
+ echo "De-Noised output of the daily AIDE run ($loglines lines):"
+ cat $NOISETMP
+ fi
+ else
+ echo "AIDE detected no changes after removing noise."
+ fi
+ rm -f $NOISETMP
+ echo "============================================================================"
+fi
+
+# include non-de-noised log
+
+if [ -s "$LOGDIR/$LOGFILE" ]; then
+ loglines=`wc -l "$LOGDIR/$LOGFILE" | awk '{ print $1 }'`
+ if [ ${loglines:=0} -gt $LINES ]; then
+ cat << EOF
+
+****************************************************************************
+* aide has returned long output which has been truncated in this mail *
+****************************************************************************
+
+EOF
+ echo "Output is $loglines lines, truncated to $LINES."
+ head -$LINES "$LOGDIR/$LOGFILE"
+ echo "The full output can be found in $LOGDIR/$LOGFILE."
+ else
+ echo "Output of the daily AIDE run ($loglines lines):"
+ cat "$LOGDIR/$LOGFILE"
+ fi
+else
+ echo "AIDE detected no changes."
+fi
+) > ${MAILTMP}
+
+(
+cat <<EOF
+Subject: Daily AIDE report for $FQDN
+From: root@${FQDN}
+To: ${MAILTO}
+EOF
+cat ${MAILTMP}
+) | /usr/sbin/sendmail $MAILTO
+
+rm -f "$MAILTMP"
diff --git a/app-forensics/aide/files/aideinit b/app-forensics/aide/files/aideinit
new file mode 100644
index 000000000000..6a3c60c37837
--- /dev/null
+++ b/app-forensics/aide/files/aideinit
@@ -0,0 +1,145 @@
+#!/bin/sh
+# Copyright 2003 Mike Markley <mike@markley.org>
+# This script is free for any purpose whatseoever so long as the above
+# copyright notice remains in place.
+#
+# Modified for Gentoo: Benjamin Smee
+# Date: Fri Sep 10 11:36:04 BST 2004
+
+# This is the email address reports get mailed to
+MAILTO=root@localhost
+
+# Defaults
+#MAILTO="${MAILTO:-root}"
+
+# Options
+opt_f=0
+opt_y=0
+opt_c=0
+opt_b=0
+config="/etc/aide/aide.conf"
+
+aideinit_usage() {
+ echo "Usage: $0 [options] -- [aide options]"
+ echo " -y|--yes Overwrite output file"
+ echo " -f|--force Force overwrite of database"
+ echo " -c|--config Specify alternate config file"
+ echo " -o|--output Specify alternate output file"
+ echo " -d|--database Specify alternate database file"
+ echo " -b|--background Run in the background"
+}
+
+while [ -n "$1" ]; do
+ case "$1" in
+ -h|--help)
+ aideinit_usage
+ exit 0
+ ;;
+ -f|--force)
+ opt_f=1
+ shift
+ ;;
+ -y|--yes)
+ opt_y=1
+ shift
+ ;;
+ -b|--background)
+ opt_b=1
+ shift
+ ;;
+ -o|--output)
+ shift
+ [ -z "$1" ] && aideinit_usage && exit 1
+ outfile=$1
+ shift
+ ;;
+ -d|--database)
+ shift
+ [ -z "$1" ] && aideinit_usage && exit 1
+ dbfile=$1
+ shift
+ ;;
+ -c|--config)
+ opt_c=1
+ shift
+ [ -z "$1" ] && aideinit_usage && exit 1
+ config=$1
+ shift
+ ;;
+ --)
+ shift
+ break 2
+ ;;
+ *)
+ echo "Unknown option $1 (use -- to delimit aideinit and aide options)"
+ exit
+ ;;
+ esac
+done
+
+if [ ! -f "$config" ]; then
+ echo "$0: $config: file not found"
+ exit 1
+fi
+
+if [ -z "$outfile" ]; then
+ outfile=`egrep "database_out=file:" $config | cut -d: -f2`
+ [ -z "$outfile" ] && outfile="/var/lib/aide/aide.db.new"
+fi
+if [ -z "$dbfile" ]; then
+ dbfile=`egrep "database=file:" $config | cut -d: -f2`
+ [ -z "$dbfile" ] && dbfile="/var/lib/aide/aide.db"
+fi
+
+if [ -f $outfile ]; then
+ if [ $opt_y -eq 0 ]; then
+ echo -n "Overwrite existing $outfile [Yn]? "
+ read yn
+ case "$yn" in
+ [Nn]*)
+ exit 0
+ ;;
+ esac
+ fi
+fi
+
+extraflags=""
+
+if [ $opt_c -eq 1 ]; then
+ extraflags="$extraflags --config $config"
+fi
+
+if [ $opt_b -eq 1 ]; then
+ (aide --init $extraflags $@ >/var/log/aide/aideinit.log 2>/var/log/aide/aideinit.errors
+ if [ -f "$dbfile" -a $opt_f -eq 0 ]; then
+ echo "$dbfile exists and -f was not specified" >> /var/log/aide/aideinit.errors
+ fi
+ lines=`wc -l /var/log/aide/aideinit.errors | awk '{ print $1 }'`
+ if [ "$lines" -gt 0 ]; then
+ (echo "AIDE init errors:"; cat /var/log/aide/aideinit.errors) | /bin/mail -s "AIDE initialization problem" $MAILTO
+ else
+ cp -f $outfile $dbfile
+ fi) &
+ exit 0
+fi
+
+echo "Running aide --init..."
+aide --init $extraflags $@
+
+return=$?
+if [ $return -ne 0 ]; then
+ echo "Something didn't quite go right; see $outfile for details" >&2
+ exit $return
+fi
+
+if [ -f "$dbfile" -a $opt_f -eq 0 ]; then
+ echo -n "Overwrite $dbfile [yN]? "
+ read yn
+ case "$yn" in
+ [yY]*)
+ cp -f $outfile $dbfile
+ ;;
+ esac
+else
+ cp -f $outfile $dbfile
+fi
diff --git a/app-forensics/aide/metadata.xml b/app-forensics/aide/metadata.xml
new file mode 100644
index 000000000000..a03a8cb8d7a2
--- /dev/null
+++ b/app-forensics/aide/metadata.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+ <maintainer type="person">
+ <email>itumaykin+gentoo@gmail.com</email>
+ <name>Coacher</name>
+ </maintainer>
+ <maintainer type="project">
+ <email>proxy-maint@gentoo.org</email>
+ <name>Proxy Maintainers</name>
+ </maintainer>
+ <use>
+ <flag name="e2fs">Enable support for checking file attributes on ext2/ext3/ext4 filesystems</flag>
+ <flag name="prelink">Bypass prelinking when calculating checksums</flag>
+ </use>
+ <upstream>
+ <remote-id type="sourceforge">aide</remote-id>
+ </upstream>
+</pkgmetadata>