Package: logcheck
Version: 1.3.14
Severity: normal
Tags: patch

        Hi

 I don't want the logcheck email alias because I configure logcheck to
 send email to a different address, but it keeps getting re-added on
 upgrades.

 I've prepared a patch to only add the alias on install, not on
 upgrades, but I've noticed some small issues with the rest of the
 postinst (tests which could be simplified and tabs with different size
 expectations depending on the code block you're looking at), so I'm
 attaching a series of patches on top of current git to fix these.

   Thanks,
-- 
Loïc Minier
>From 0bb0adbaa4e2a84ad16b1871efa729cfd90eff2a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lo=C3=AFc=20Minier?= <l...@debian.org>
Date: Mon, 17 Oct 2011 09:22:36 +0200
Subject: [PATCH 1/4] Add logcheck alias on install not on upgrade

---
 debian/logcheck.postinst |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/debian/logcheck.postinst b/debian/logcheck.postinst
index 849ad98..7032323 100644
--- a/debian/logcheck.postinst
+++ b/debian/logcheck.postinst
@@ -47,13 +47,15 @@ case "$1" in
 	  adduser --quiet logcheck adm || true
 	fi
 
-	# add logcheck to /etc/aliases
-	if [ -f /etc/aliases ] || [ -L /etc/aliases ]; then
-    if ! grep -qi "^logcheck[[:space:]]*:" /etc/aliases; then
-      echo "logcheck: root" >> /etc/aliases
-      test -x "$(command -v newaliases)" && newaliases || :
+  # add logcheck to /etc/aliases on install; not on upgrade
+  if [ -z "$2" ]; then
+    if [ -f /etc/aliases ] || [ -L /etc/aliases ]; then
+      if ! grep -qi "^logcheck[[:space:]]*:" /etc/aliases; then
+        echo "logcheck: root" >> /etc/aliases
+        test -x "$(command -v newaliases)" && newaliases || :
+      fi
     fi
-	fi
+  fi
 
   # give logcheck system user a real name unless it has one.
   if [ -z "$(getent passwd logcheck | cut -d: -f5)" ]; then
-- 
1.7.5.4

>From d2e57486d3197297388494ed210e90b68d8fe23b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lo=C3=AFc=20Minier?= <l...@debian.org>
Date: Mon, 17 Oct 2011 09:23:15 +0200
Subject: [PATCH 2/4] Use [ -z ... ] rather than [ ! -n ... ]

---
 debian/logcheck.postinst |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/debian/logcheck.postinst b/debian/logcheck.postinst
index 7032323..d3dfbfc 100644
--- a/debian/logcheck.postinst
+++ b/debian/logcheck.postinst
@@ -63,7 +63,7 @@ case "$1" in
   fi
 
 	# Add logcheck mail header on install
-        if [ ! -n "$2" ] && [ ! -f /etc/logcheck/header.txt ]; then
+        if [ -z "$2" ] && [ ! -f /etc/logcheck/header.txt ]; then
           cp -p /usr/share/logcheck/header.txt /etc/logcheck
         fi
 
@@ -72,7 +72,7 @@ case "$1" in
 	chgrp -R logcheck /etc/logcheck || true
 
 	# Set Permissions on install, not upgrade
-	if [ ! -n "$2" ]; then
+	if [ -z "$2" ]; then
           chmod 2750 /etc/logcheck/ignore.d.paranoid || true
           chmod 2750 /etc/logcheck/ignore.d.workstation || true
           chmod 2750 /etc/logcheck/ignore.d.server || true
-- 
1.7.5.4

>From 11a96a81ec8bade1d4855495611452552cdfbe67 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lo=C3=AFc=20Minier?= <l...@debian.org>
Date: Mon, 17 Oct 2011 09:28:49 +0200
Subject: [PATCH 3/4] Fix indentation and whitespaces in postinsts

Also, call ":" in empty case statements.
---
 debian/logcheck-database.postinst |   60 ++++++++--------
 debian/logcheck.postinst          |  138 ++++++++++++++++++------------------
 2 files changed, 99 insertions(+), 99 deletions(-)

diff --git a/debian/logcheck-database.postinst b/debian/logcheck-database.postinst
index 4ff4888..c8f5337 100644
--- a/debian/logcheck-database.postinst
+++ b/debian/logcheck-database.postinst
@@ -29,39 +29,39 @@ set -e
 confdir="/etc/logcheck"
 
 case "$1" in
-    configure)
-	# Remove old sarge mv logcheck-data configfiles if unchanged
-	if [ -n "$2" ] && dpkg --compare-versions "$2" lt "1.2.48"; then
-		proftpd_sum=$(sha1sum '/etc/logcheck/ignore.d.paranoid/proftpd' 2>/dev/null \
-			| awk '{print $1}')
-		imap_sum=$(sha1sum '/etc/logcheck/ignore.d.paranoid/imap' 2>/dev/null \
-			| awk '{print $1}')
-		anacron_sum=$(sha1sum '/etc/logcheck/ignore.d.workstation/anacron' 2>/dev/null \
-			| awk '{print $1}')
-		if [ "${proftpd_sum}" = "da39a3ee5e6b4b0d3255bfef95601890afd80709" ]; then
-			rm -rf /etc/logcheck/ignore.d.paranoid/proftpd
-		fi
-		if [ "${imap_sum}" = "9d4e9db1bd0c5cdd5ea3ba8875e628bf50cf1f5f" ]; then
-			rm -rf /etc/logcheck/ignore.d.paranoid/imap
-		fi
-		if [ "${anacron_sum}" = "78e753ffeff32474a805a7654aa99a07076b6975" ]; then
-			rm -rf /etc/logcheck/ignore.d.workstation/anacron
-		fi
-	fi
+  configure)
+    # Remove old sarge mv logcheck-data configfiles if unchanged
+    if [ -n "$2" ] && dpkg --compare-versions "$2" lt "1.2.48"; then
+        proftpd_sum=$(sha1sum '/etc/logcheck/ignore.d.paranoid/proftpd' 2>/dev/null \
+            | awk '{print $1}')
+        imap_sum=$(sha1sum '/etc/logcheck/ignore.d.paranoid/imap' 2>/dev/null \
+            | awk '{print $1}')
+        anacron_sum=$(sha1sum '/etc/logcheck/ignore.d.workstation/anacron' 2>/dev/null \
+            | awk '{print $1}')
+        if [ "${proftpd_sum}" = "da39a3ee5e6b4b0d3255bfef95601890afd80709" ]; then
+            rm -rf /etc/logcheck/ignore.d.paranoid/proftpd
+        fi
+        if [ "${imap_sum}" = "9d4e9db1bd0c5cdd5ea3ba8875e628bf50cf1f5f" ]; then
+            rm -rf /etc/logcheck/ignore.d.paranoid/imap
+        fi
+        if [ "${anacron_sum}" = "78e753ffeff32474a805a7654aa99a07076b6975" ]; then
+            rm -rf /etc/logcheck/ignore.d.workstation/anacron
+        fi
+    fi
 
-  if getent group logcheck >/dev/null; then
-    chgrp -R logcheck /etc/logcheck
-  fi
-	;;
+    if getent group logcheck >/dev/null; then
+        chgrp -R logcheck /etc/logcheck
+    fi
+  ;;
 
-    abort-upgrade|abort-remove|abort-deconfigure)
+  abort-upgrade|abort-remove|abort-deconfigure)
+      :
+  ;;
 
-	;;
-
-    *)
-        echo "postinst called with unknown argument \`$1'" >&2
-        exit 1
-	;;
+  *)
+      echo "postinst called with unknown argument \`$1'" >&2
+      exit 1
+  ;;
 esac
 
 # dh_installdeb will replace this with shell code automatically
diff --git a/debian/logcheck.postinst b/debian/logcheck.postinst
index d3dfbfc..650a90f 100644
--- a/debian/logcheck.postinst
+++ b/debian/logcheck.postinst
@@ -21,80 +21,80 @@ set -e
 #     `abort-remove' or `abort-deconfigure'.
 
 case "$1" in
-    configure)
-	# Add logcheck user
-	# check for logcheck user or bad version without home
-	# touch cron job on updating accounts to fix #284788
-	if ! getent passwd logcheck > /dev/null; then
-	  adduser --quiet --system --home /var/lib/logcheck --no-create-home \
-      --group logcheck ||true
-	  touch /etc/cron.d/logcheck || true
-	fi
-
-	# check for logcheck group in case account exists without group
-	if ! getent group logcheck >/dev/null; then
-	  addgroup --system logcheck
-    usermod -g logcheck logcheck
-	fi
-
-  # make sure the home directory exists
-  if [ ! -d "$(getent passwd logcheck | cut -d: -f6)" ]; then
-    usermod -d /var/lib/logcheck logcheck > /dev/null || true
-  fi
-
-	# check for logcheck in adm group
-	if ! getent group adm | grep logcheck > /dev/null; then
-	  adduser --quiet logcheck adm || true
-	fi
-
-  # add logcheck to /etc/aliases on install; not on upgrade
-  if [ -z "$2" ]; then
-    if [ -f /etc/aliases ] || [ -L /etc/aliases ]; then
-      if ! grep -qi "^logcheck[[:space:]]*:" /etc/aliases; then
-        echo "logcheck: root" >> /etc/aliases
-        test -x "$(command -v newaliases)" && newaliases || :
-      fi
+  configure)
+    # Add logcheck user
+    # check for logcheck user or bad version without home
+    # touch cron job on updating accounts to fix #284788
+    if ! getent passwd logcheck > /dev/null; then
+        adduser --quiet --system --home /var/lib/logcheck --no-create-home \
+            --group logcheck || true
+        touch /etc/cron.d/logcheck || true
     fi
-  fi
 
-  # give logcheck system user a real name unless it has one.
-  if [ -z "$(getent passwd logcheck | cut -d: -f5)" ]; then
-    chfn -f 'logcheck system account' logcheck
-  fi
+    # check for logcheck group in case account exists without group
+    if ! getent group logcheck >/dev/null; then
+        addgroup --system logcheck
+        usermod -g logcheck logcheck
+    fi
+
+    # make sure the home directory exists
+    if [ ! -d "$(getent passwd logcheck | cut -d: -f6)" ]; then
+      usermod -d /var/lib/logcheck logcheck > /dev/null || true
+    fi
 
-	# Add logcheck mail header on install
-        if [ -z "$2" ] && [ ! -f /etc/logcheck/header.txt ]; then
-          cp -p /usr/share/logcheck/header.txt /etc/logcheck
+    # check for logcheck in adm group
+    if ! getent group adm | grep logcheck > /dev/null; then
+        adduser --quiet logcheck adm || true
+    fi
+
+    # add logcheck to /etc/aliases on install; not on upgrade
+    if [ -z "$2" ]; then
+        if [ -f /etc/aliases ] || [ -L /etc/aliases ]; then
+            if ! grep -qi "^logcheck[[:space:]]*:" /etc/aliases; then
+                echo "logcheck: root" >> /etc/aliases
+                test -x "$(command -v newaliases)" && newaliases || :
+            fi
         fi
+    fi
+
+    # give logcheck system user a real name unless it has one.
+    if [ -z "$(getent passwd logcheck | cut -d: -f5)" ]; then
+        chfn -f 'logcheck system account' logcheck
+    fi
+
+    # Add logcheck mail header on install
+    if [ -z "$2" ] && [ ! -f /etc/logcheck/header.txt ]; then
+        cp -p /usr/share/logcheck/header.txt /etc/logcheck
+    fi
+
+    # Unconditionalizing this for now as we have files that are
+    # unreadable upon upgrade.  <ttrox...@debian.org>
+    chgrp -R logcheck /etc/logcheck || true
+
+    # Set Permissions on install, not upgrade
+    if [ -z "$2" ]; then
+        chmod 2750 /etc/logcheck/ignore.d.paranoid || true
+        chmod 2750 /etc/logcheck/ignore.d.workstation || true
+        chmod 2750 /etc/logcheck/ignore.d.server || true
+        chmod 2750 /etc/logcheck/cracking.d || true
+        chmod 2750 /etc/logcheck/cracking.ignore.d || true
+        chmod 2750 /etc/logcheck/violations.d || true
+        chmod 2750 /etc/logcheck/violations.ignore.d || true
+        chmod -R g+rX /etc/logcheck || true
+    fi
+    chown -R logcheck:logcheck /var/lib/logcheck || true
+    chmod 0770 /var/lib/logcheck || true
+
+  ;;
+
+  abort-upgrade|abort-remove|abort-deconfigure)
+    :
+  ;;
 
-	# Unconditionalizing this for now as we have files that are
-	# unreadable upon upgrade.  <ttrox...@debian.org>
-	chgrp -R logcheck /etc/logcheck || true
-
-	# Set Permissions on install, not upgrade
-	if [ -z "$2" ]; then
-          chmod 2750 /etc/logcheck/ignore.d.paranoid || true
-          chmod 2750 /etc/logcheck/ignore.d.workstation || true
-          chmod 2750 /etc/logcheck/ignore.d.server || true
-          chmod 2750 /etc/logcheck/cracking.d || true
-          chmod 2750 /etc/logcheck/cracking.ignore.d || true
-          chmod 2750 /etc/logcheck/violations.d || true
-          chmod 2750 /etc/logcheck/violations.ignore.d || true
-	  chmod -R g+rX /etc/logcheck || true
-	fi
-	chown -R logcheck:logcheck /var/lib/logcheck || true
-	chmod 0770 /var/lib/logcheck || true
-
-	;;
-
-    abort-upgrade|abort-remove|abort-deconfigure)
-
-	;;
-
-    *)
-        echo "postinst called with unknown argument \`$1'" >&2
-        exit 1
-	;;
+  *)
+    echo "postinst called with unknown argument \`$1'" >&2
+    exit 1
+  ;;
 esac
 
 # dh_installdeb will replace this with shell code automatically
-- 
1.7.5.4

>From 81be7bd91f122c0e4f0e17d00b141dbcded9496d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lo=C3=AFc=20Minier?= <l...@debian.org>
Date: Mon, 17 Oct 2011 09:33:35 +0200
Subject: [PATCH 4/4] Merge two tests into a single lt-nl comparison

---
 debian/logcheck-database.postinst |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/debian/logcheck-database.postinst b/debian/logcheck-database.postinst
index c8f5337..a9d1a6c 100644
--- a/debian/logcheck-database.postinst
+++ b/debian/logcheck-database.postinst
@@ -31,7 +31,7 @@ confdir="/etc/logcheck"
 case "$1" in
   configure)
     # Remove old sarge mv logcheck-data configfiles if unchanged
-    if [ -n "$2" ] && dpkg --compare-versions "$2" lt "1.2.48"; then
+    if dpkg --compare-versions "$2" lt-nl "1.2.48"; then
         proftpd_sum=$(sha1sum '/etc/logcheck/ignore.d.paranoid/proftpd' 2>/dev/null \
             | awk '{print $1}')
         imap_sum=$(sha1sum '/etc/logcheck/ignore.d.paranoid/imap' 2>/dev/null \
-- 
1.7.5.4

_______________________________________________
Logcheck-devel mailing list
Logcheck-devel@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/logcheck-devel

Reply via email to