[Logcheck-commits] [logcheck] 01/01: Add support for logcheck.logfiles.d
Hannes von Haugwitz
hvhaugwitz at moszumanska.debian.org
Sun Jan 22 13:59:38 UTC 2017
This is an automated email from the git hooks/post-receive script.
hvhaugwitz pushed a commit to branch master
in repository logcheck.
commit 2abc39d9ff71bb0757db50b4f46ea506e2965348
Author: Hannes von Haugwitz <hannes at vonhaugwitz.com>
Date: Sun Jan 22 13:51:54 2017 +0100
Add support for logcheck.logfiles.d
closes: #481353
---
Makefile | 2 ++
debian/changelog | 2 ++
debian/logcheck.dirs | 1 +
debian/logcheck.postinst | 1 +
docs/logcheck.sgml | 8 ++++++++
src/logcheck | 21 +++++++++++++++++----
6 files changed, 31 insertions(+), 4 deletions(-)
diff --git a/Makefile b/Makefile
index 4d16316..6afc951 100644
--- a/Makefile
+++ b/Makefile
@@ -23,6 +23,7 @@ install:
install -m 2750 -d $(DESTDIR)/$(CONFDIR)/cracking.ignore.d
install -m 2750 -d $(DESTDIR)/$(CONFDIR)/violations.d
install -m 2750 -d $(DESTDIR)/$(CONFDIR)/violations.ignore.d
+ install -m 2750 -d $(DESTDIR)/$(CONFDIR)/logcheck.logfiles.d
# Install the scripts
install -m 755 src/logcheck $(DESTDIR)/$(SBINDIR)/
@@ -68,6 +69,7 @@ clean:
-rm -rf $(DESTDIR)/$(CONFDIR)/violations.d/
-rm -rf $(DESTDIR)/$(CONFDIR)/violations.ignore.d/
-rm -rf $(DESTDIR)/$(CONFDIR)/cracking.d/
+ -rm -rf $(DESTDIR)/$(CONFDIR)/logcheck.logfiles.d/
# Remove the statedir and it's contents
-rm -rf $(DESTDIR)/var/lib/logcheck
diff --git a/debian/changelog b/debian/changelog
index 854b8ba..dcc02f7 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -25,6 +25,8 @@ logcheck (1.3.18) UNRELEASED; urgency=medium
patch (closes: #786815)
- use secure Vcs-* fields
* debian/copyright: update copyright year to 2017
+ * Add support for logcheck.logfiles.d, thanks to Vincas Dargis for
+ the initial patch (closes: #481353)
* Replace all occurrences of 'deinstall' with 'uninstall', thanks to duelle
for the patch
diff --git a/debian/logcheck.dirs b/debian/logcheck.dirs
index 3652348..c76f20b 100644
--- a/debian/logcheck.dirs
+++ b/debian/logcheck.dirs
@@ -6,3 +6,4 @@
/etc/logcheck/cracking.ignore.d
/etc/logcheck/violations.d
/etc/logcheck/violations.ignore.d
+/etc/logcheck/logcheck.logfiles.d
diff --git a/debian/logcheck.postinst b/debian/logcheck.postinst
index 650a90f..b38db80 100644
--- a/debian/logcheck.postinst
+++ b/debian/logcheck.postinst
@@ -80,6 +80,7 @@ case "$1" in
chmod 2750 /etc/logcheck/cracking.ignore.d || true
chmod 2750 /etc/logcheck/violations.d || true
chmod 2750 /etc/logcheck/violations.ignore.d || true
+ chmod 2750 /etc/logcheck/logcheck.logfiles.d || true
chmod -R g+rX /etc/logcheck || true
fi
chown -R logcheck:logcheck /var/lib/logcheck || true
diff --git a/docs/logcheck.sgml b/docs/logcheck.sgml
index 27a3429..b15a31f 100644
--- a/docs/logcheck.sgml
+++ b/docs/logcheck.sgml
@@ -149,6 +149,13 @@ manpage.1: manpage.sgml
</listitem>
</varlistentry>
<varlistentry>
+ <term><option>-D DIR</option>
+ </term>
+ <listitem>
+ <para>Overrule default logfiles lists directory</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
<term><option>-m</option>
</term>
<listitem>
@@ -239,6 +246,7 @@ manpage.1: manpage.sgml
<para>/etc/logcheck/logcheck.conf is the main configuration file.</para>
<para>/etc/logcheck/logcheck.logfiles is the list of files to monitor.</para>
+ <para>/etc/logcheck/logcheck.logfiles.d is the directory of lists of files to monitor.</para>
<para>/usr/share/doc/logcheck-database/README.logcheck-database.gz for hints on how to write, test and maintain rules.</para>
</refsect1>
<refsect1>
diff --git a/src/logcheck b/src/logcheck
index 9b8c77a..a8c58ea 100755
--- a/src/logcheck
+++ b/src/logcheck
@@ -73,6 +73,7 @@ RULEDIR="/etc/logcheck"
CONFFILE="/etc/logcheck/logcheck.conf"
STATEDIR="/var/lib/logcheck"
LOGFILES_LIST="/etc/logcheck/logcheck.logfiles"
+LOGFILES_LIST_D="/etc/logcheck/logcheck.logfiles.d"
LOGFILE_FALLBACK="/var/log/syslog"
LOGTAIL="/usr/sbin/logtail2"
CAT="/bin/cat"
@@ -447,7 +448,7 @@ logoutput() {
usage() {
debug "usage: Printing usage and exiting"
cat<<EOF
-usage: logcheck [-c CFG] [-d] [-h] [-H HOST] [-l LOG] [-L CFG] [-m MAIL] [-o]
+usage: logcheck [-c CFG] [-d] [-h] [-H HOST] [-l LOG] [-L CFG] [-D DIR] [-m MAIL] [-o]
[-r DIR] [-s|-p|-w] [-R] [-S DIR] [-t] [-T] [-u]
-c CFG = override default configuration file
-d = debug mode
@@ -455,6 +456,7 @@ usage: logcheck [-c CFG] [-d] [-h] [-H HOST] [-l LOG] [-L CFG] [-m MAIL] [-o]
-H HOST = use this hostname in the subject of any generated mail
-l LOG = check the specified logfile
-L CFG = override default logfiles list
+ -D DIR = override default logfiles lists directory
-m MAIL = send the report to the specified recipient
-o = send the report to stdout, no mail will be sent
-p = use the "paranoid" runlevel
@@ -556,6 +558,10 @@ while getopts "$GETOPTS" opt; do
debug "Setting LOGFILES_LIST to $OPTARG"
LOGFILES_LIST="$OPTARG"
;;
+ D)
+ debug "Setting LOGFILES_LIST_D to $OPTARG"
+ LOGFILES_LIST_D="$OPTARG"
+ ;;
m)
debug "Setting SENDMAILTO to $OPTARG"
SENDMAILTO="$OPTARG"
@@ -664,10 +670,17 @@ fi
# Handle log rotation correctly, idea taken from Wiktor Niesiobedzki.
mkdir "$TMPDIR/logoutput" \
|| error "Could not mkdir for log files"
-if [ ! "$LOGFILE" ] && [ -r "$LOGFILES_LIST" ]; then
+LOGFILES=$(ls -1d "$LOGFILES_LIST" "$LOGFILES_LIST_D"/*.logfiles 2>/dev/null)
+if [ ! "$LOGFILE" ] && [ -n "$LOGFILES" ]; then
SAVEIFS=$IFS; IFS=$(echo -en "\n\b");
- for file in $(egrep --text -v "(^#|^[[:space:]]*$)" "$LOGFILES_LIST"); do
- logoutput "$file"
+ for file_list in ${LOGFILES} ; do
+ if [ -f "$file_list" ] ; then
+ for file in $(egrep --text -v -h "(^#|^[[:space:]]*$)" "$file_list"); do
+ logoutput "$file"
+ done
+ else
+ error "$file_list is not a regular file"
+ fi
done
IFS=$SAVEIFS
elif [ "$LOGFILE" ]; then
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/logcheck/logcheck.git
More information about the Logcheck-commits
mailing list