Source: aide-common
Severity: wishlist
Tags: patch

Hi,

please consider the following patch which will make aide-common's
postinst keep its hands off an ucf-conffile that was registered to a
different package. This way, it is seamlessly possible to have a
conffile of aide-common overriden by a different package. This might
aid migration of aide rules to the packages that actually need the
aide rule, or to have locally changed rules in a local package.

This patch has been tested a little bit and didn't cause bad explosions.

Greetings
Marc

>From 00f2085dd7378b9297d3b61dc92489832f32138c Mon Sep 17 00:00:00 2001
From: Marc Haber <mh+debian-packa...@zugschlus.de>
Date: Sat, 17 Aug 2013 15:36:08 +0000
Subject: [PATCH] skip conffiles belonging to a different package

---
 debian/aide-common.postinst | 33 +++++++++++++++++++--------------
 1 file changed, 19 insertions(+), 14 deletions(-)

diff --git a/debian/aide-common.postinst b/debian/aide-common.postinst
index e00af8a..4fbcc15 100644
--- a/debian/aide-common.postinst
+++ b/debian/aide-common.postinst
@@ -42,20 +42,25 @@ UCFR="ucfr"
   (cd "$TRGDIR"&& xargs -0 mkdir -p --)

 for file in $(find $SRCDIR -type f -printf '%P\n' ); do
-  OLDSUM=""
-  if [ -f "$TRGDIR/$file" ]; then
-    OLDSUM="$(md5sum "$TRGDIR/$file")"
-  fi
-  $UCF "$SRCDIR/$file" "$TRGDIR/$file"
-  $UCFR "$PKGNAME" "$TRGDIR/$file"
-  if cmp --quiet "$SRCDIR/$file" "$TRGDIR/$file" && \
-    [ "$OLDSUM" != "$(md5sum "$TRGDIR/$file")" ]; then
-    # "$TRGDIR/$file" has changed while ucf was running and it changed
-    # to the file that was shipped with the package. We (hopefully safely)
-    # assume that this means that the user decided to accept the new
-    # version, and we're now copying over the file mode as well.
-    # This is a workaround for ucf issue #406476.
-    chmod --reference="$SRCDIR/$file" "$TRGDIR/$file"
+  PKG="$(ucfq --with-colons $TRGDIR/$file | awk '{print $2}' FS=":")"
+  # skip conffile if it is associated with a different package.
+  # This allows other packages to hijack aide's conffiles.
+  if [ -z "$PKG" ] || [ "$PKG" = "$PKGNAME" ]; then
+    OLDSUM=""
+    if [ -f "$TRGDIR/$file" ]; then
+      OLDSUM="$(md5sum "$TRGDIR/$file")"
+    fi
+    $UCF "$SRCDIR/$file" "$TRGDIR/$file"
+    $UCFR "$PKGNAME" "$TRGDIR/$file"
+    if cmp --quiet "$SRCDIR/$file" "$TRGDIR/$file" && \
+      [ "$OLDSUM" != "$(md5sum "$TRGDIR/$file")" ]; then
+      # "$TRGDIR/$file" has changed while ucf was running and it changed
+      # to the file that was shipped with the package. We (hopefully safely)
+      # assume that this means that the user decided to accept the new
+      # version, and we're now copying over the file mode as well.
+      # This is a workaround for ucf issue #406476.
+      chmod --reference="$SRCDIR/$file" "$TRGDIR/$file"
+    fi
   fi
 done

--
1.8.4.rc2


-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to