[Logcheck-commits] r1726 - logcheck/trunk/src

madduck at users.alioth.debian.org madduck at users.alioth.debian.org
Thu Aug 23 10:40:01 UTC 2007


Author: madduck
Date: 2007-08-23 10:40:01 +0000 (Thu, 23 Aug 2007)
New Revision: 1726

Added:
   logcheck/trunk/src/macros.Makefile
   logcheck/trunk/src/macros.violations.ignore.d_local-postfix.in
Log:
added ref implementation of interpolation



Added: logcheck/trunk/src/macros.Makefile
===================================================================
--- logcheck/trunk/src/macros.Makefile	                        (rev 0)
+++ logcheck/trunk/src/macros.Makefile	2007-08-23 10:40:01 UTC (rev 1726)
@@ -0,0 +1,53 @@
+#/usr/bin/make -f
+#
+# logcheck interpolation Makefile
+#
+# The Makefile allows for the automatic generation of logcheck/egrep -f files,
+# using interpolation. Any lines starting with '#: ' and specifying a variable
+# assignment are parsed into variable/value pairs, which are then subsequently
+# interpolated recursively into the rest of the file, replacing occurrences of
+# the variable name enclosed with 'at' signes (@).
+#
+# Example:
+#
+#   #: MYVAR = myval @ANOTHER@
+#   #: ANOTHER = foo
+#
+#   @MYVAR@
+#
+# This will yield
+#
+#   myval foo
+#
+# Limitations:
+# - no way to work around the situation when a string /@[_[:alnum:]]+@/ should
+#   actually be part of the result.
+#
+# Copyright © 2006 martin f. krafft <madduck at debian.org>
+# Released under the terms of the Artistic Licence
+#
+# Revision: 2006.06.30.1253
+#
+
+all: $(patsubst %.in,%,$(wildcard *.in))
+
+LEAD = ^\#:
+VAR = [_[:alnum:]]+
+VAR_ASSIGN = ($(VAR))[[:space:]]*=[[:space:]]*(.*)
+ESCAPES = s,\\,\\\\\\,g;s,/,\\/,g
+
+%: SEDSCRIPT = $(shell sed -rne '$(ESCAPES)' -e 's,$(LEAD) $(VAR_ASSIGN),s/@\1@/\2/g;,p' $<)
+%: %.in
+	sed -re '/$(LEAD) /d' \
+			-e '/^(#|[[:space:]]*$$)/d' \
+		$< > $@
+	while egrep -q '@$(VAR)@' $@; do \
+		md5sum=$$(md5sum $@); \
+		sed -i -e "$(SEDSCRIPT)" $@; \
+		if [ "$$(md5sum $@)" = "$$md5sum" ]; then \
+			VAR="$$(sed -rne 's,.*@([^@]+)@.*,\1,p' $@)"; \
+			echo "E: found the variable $$VAR but did not know what to substitute." >&2; \
+			exit 1; \
+		fi; \
+		cat $@; \
+	done

Added: logcheck/trunk/src/macros.violations.ignore.d_local-postfix.in
===================================================================
--- logcheck/trunk/src/macros.violations.ignore.d_local-postfix.in	                        (rev 0)
+++ logcheck/trunk/src/macros.violations.ignore.d_local-postfix.in	2007-08-23 10:40:01 UTC (rev 1726)
@@ -0,0 +1,18 @@
+#: LEAD       = ^\w{3} [ :[:digit:]]{11} @HOSTNAME@
+#: HOSTNAME   = [-_[:alnum:]]+
+#: PID        = [[:digit:]]{1,5}
+#: PROC_SMTPD = postfix/smtpd\[@PID@\]
+#: QUEUE_ID   = (NOQUEUE|[[:upper:][:digit:]]+)
+#: DN         = [-_.[:alnum:]]+
+#: FQDN       = @DN@\.[[:alpha:]]{2,4}
+#: IPADDR     = ([[:digit:]]{1,3}\.){3}[[:digit:]]{1,3}
+#: STATUS     = [45][[:digit:]]{2}
+#: EXT_STATUS = @STATUS@ ([[:digit:]]+\.){2}[[:digit:]]+
+#: EMAIL      = <[-_.+[:alnum:]]+@@DN@>
+#: PROTO      = proto=E?SMTP
+#: FROM       = from=@EMAIL@
+#: TO         = to=@EMAIL@
+#: HELO       = helo=<@DN@>
+#: EOL        = $
+
+ at LEAD@ @PROC_SMTPD@: @QUEUE_ID@: reject: RCPT from @FQDN@\[@IPADDR@\]: @EXT_STATUS@ @EMAIL@: Relay access denied; @FROM@ @TO@ @PROTO@ @HELO@@EOL@




More information about the Logcheck-commits mailing list