[pkg-ntp-maintainers] Bug#894475: ntpsec-ntpviz: shares /var/log/ntpstats with ntp, which gets zapped when ntp is purged

Richard Laager rlaager at wiktel.com
Fri Mar 30 22:31:49 UTC 2018


I did some testing just now.

I've updated ntpsec.postrm in git. I dropped the unnecessary LANG=C on
the first check, updated the style of the "then" statement, and most
importantly, moved the deluser inside the "! dpkg -s ntp" block:

        if ! dpkg -s ntp > /dev/null 2>&1; then
                rm -rf /var/lib/ntp/
                rm -rf /var/log/ntpstats/
                if ! LANG=C dpkg -s ntpsec-ntpviz 2> /dev/null | \
                     grep -qE "^Status: (hold|install)"; then
                        deluser --system --quiet ntp || true
                fi
        fi

Here is the equivalent diff for ntp, which I have tested and confirmed:

diff --git a/debian/ntp.postrm b/debian/ntp.postrm
index d959aa5..7ec4b6b 100644
--- a/debian/ntp.postrm
+++ b/debian/ntp.postrm
@@ -25,7 +25,12 @@ installinit_error() {
 #DEBHELPER#

 if [ "$1" = "purge" ]; then
-	deluser --system --quiet ntp || true
-	rm -rf /var/lib/ntp/
-	rm -rf /var/log/ntpstats/
+	if ! dpkg -s ntpsec > /dev/null 2>&1; then
+		rm -rf /var/lib/ntp/
+		rm -rf /var/log/ntpstats/
+		if ! LANG=C dpkg -s ntpsec-ntpviz 2> /dev/null | \
+		     grep -qE "^Status: (hold|install)"; then
+			deluser --system --quiet ntp || true
+		fi
+	fi
 fi

If this coordination is acceptable, I believe it solves the various
interactions. I'm happy to test more scenarios if anyone thinks I missed
something.

If this coordination is not acceptable, I'm open to alternative suggestions.

-- 
Richard



More information about the pkg-ntp-maintainers mailing list