From eba34c4d5ebd0fec4af12d9aceaffdb1bc8ca823 Mon Sep 17 00:00:00 2001
From: Don Armstrong <don@donarmstrong.com>
Date: Thu, 10 May 2018 14:02:00 -0700
Subject: [PATCH] create a home directory for spamass-milter (Closes: #696861)

---
 debian/changelog               |  2 ++
 debian/spamass-milter.postinst | 10 +++++++++-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/debian/changelog b/debian/changelog
index 841160a..8dea5dd 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -4,6 +4,8 @@ spamass-milter (0.4.0-2) unstable; urgency=medium
   * Do not remove the socket if spamass-milter is already running (closes:
     #782252)
   * Enable the hardening flags (closes: #879671)
+  * Create a home directory for the spamass-milter user, because we use it
+    as the default for spamassassin (Closes: #696861)
 
  -- Don Armstrong <don@debian.org>  Thu, 10 May 2018 12:13:11 -0700
 
diff --git a/debian/spamass-milter.postinst b/debian/spamass-milter.postinst
index 8d44b05..5fb5ec8 100644
--- a/debian/spamass-milter.postinst
+++ b/debian/spamass-milter.postinst
@@ -10,7 +10,7 @@ case "$1" in
 		addgroup --system spamass-milter;
 	    fi;
 	    if ! id -u spamass-milter >/dev/null 2>&1; then
-		adduser --system --ingroup spamass-milter --no-create-home --home /var/lib/spamass-milter spamass-milter;
+		adduser --system --ingroup spamass-milter --home /var/lib/spamass-milter spamass-milter;
 		if [ -d /var/lib/spamass-milter ]; then 
 		    chown spamass-milter:spamass-milter /var/lib/spamass-milter
 		fi;
@@ -20,6 +20,14 @@ case "$1" in
 		fi;
 	    fi;
 	fi;
+    # create a home directory for spamass-milter if it does not exist,
+    # but only this once
+    if dpkg --compare-versions "$2" 'lt' '0.4.0-2'; then
+        if ! [ -d /var/lib/spamass-milter ]; then
+            mkdir /var/lib/spamass-milter &&
+                chown spamass-milter:spamass-milter /var/lib/spamass-milter;
+        fi;
+    fi;
 	# Attempt to remove /var/run/spamass if it exists
 
 	# If we're upgrading from -4 or earlier, we want to remove the
-- 
2.39.5