[Logcheck-commits] [logcheck] 01/01: s/logcheck: fix check if rule files are unreadable

Hannes von Haugwitz hvhaugwitz at moszumanska.debian.org
Sat Jan 14 11:37:02 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 a588619e6852c3d37a89e65717bf0824a81b490b
Author: Hannes von Haugwitz <hannes at vonhaugwitz.com>
Date:   Sat Jan 14 12:30:39 2017 +0100

    s/logcheck: fix check if rule files are unreadable
    
    closes: #418147
---
 debian/changelog |  3 +++
 src/logcheck     | 29 ++++++++++++++++-------------
 2 files changed, 19 insertions(+), 13 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 1333382..0803292 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,5 +1,8 @@
 logcheck (1.3.18) UNRELEASED; urgency=medium
 
+  * src/logcheck:
+    - fix check if rule files are unreadable, thanks to Simon Ruderich
+      for the patch (closes: #418147)
   * src/logcheck-test:
     - make mktemp usage more portable
   * Makefile:
diff --git a/src/logcheck b/src/logcheck
index a8d2d02..9b8c77a 100755
--- a/src/logcheck
+++ b/src/logcheck
@@ -1,10 +1,10 @@
 #!/usr/bin/env bash
 #
-# Copyright (C) 2004-2012,2014 Debian Logcheck Team
-#                              <logcheck-devel at alioth.lists.debian.org>
-# Copyright (C) 2002,2003      Jonathan Middleton <jjm at ixtab.org.uk>
-# Copyright (C) 1999-2002      Rene Mayrhofer <rmayr at debian.org>
-# Copyright (C) 1996-1997      Craig Rowland <crowland at psionic.com>
+# Copyright (C) 2004-2012,2014,2017 Debian Logcheck Team
+#                                   <logcheck-devel at alioth.lists.debian.org>
+# Copyright (C) 2002,2003           Jonathan Middleton <jjm at ixtab.org.uk>
+# Copyright (C) 1999-2002           Rene Mayrhofer <rmayr at debian.org>
+# Copyright (C) 1996-1997           Craig Rowland <crowland at psionic.com>
 
 # This file is part of Logcheck
 
@@ -215,18 +215,21 @@ cleanrules() {
 	    mkdir "$cleaned" \
 	        || error "Could not make dir $cleaned for cleaned rulefiles."
 	fi
+	# run-parts doesn't include files which are not readable. Use this
+	# separate check to correctly report unreadable files.
+	for x in "$dir"/*; do
+		if [ -f "$x" ] && [ ! -r "$x" ]; then
+			error "Couldn't read $x"
+		fi
+	done
 	for rulefile in $(run-parts --list "$dir"); do
 	    rulefile="$(basename "$rulefile")"
 	    if [ -f "${dir}/${rulefile}" ]; then
 		debug "cleanrules: ${dir}/${rulefile}"
-		if [ -r "${dir}/${rulefile}" ]; then
-			# pipe to cat on greps to get usable exit status
-			egrep --text -v '^[[:space:]]*$|^#' "$dir/$rulefile" | cat \
-				>> "$cleaned/$rulefile" \
-			|| error "Couldn't append to $cleaned/$rulefile."
-		else
-			error "Couldn't read $dir/$rulefile"
-		fi
+		# pipe to cat on greps to get usable exit status
+		egrep --text -v '^[[:space:]]*$|^#' "$dir/$rulefile" | cat \
+			>> "$cleaned/$rulefile" \
+		|| error "Couldn't append to $cleaned/$rulefile."
 	    fi
 	done
     elif [ -f "$dir" ]; 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