From 415457d63cf2740c7356cb09b4a1577a2e3cb515 Mon Sep 17 00:00:00 2001
From: "Steinar H. Gunderson" <sesse@debian.org>
Date: Mon, 7 Aug 2006 21:27:37 +0200
Subject: [PATCH] Imported Debian patch 1.0.9-6

---
 debian/changelog                  | 10 ++++++++++
 debian/nfs-common.init            | 14 ++++++++++++++
 debian/nfs-kernel-server.postinst |  1 +
 3 files changed, 25 insertions(+)

diff --git a/debian/changelog b/debian/changelog
index d09b237..84c9923 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,13 @@
+nfs-utils (1:1.0.9-6) unstable; urgency=low
+
+  * Enable idmapd by default if we find an /etc/exports file, as NFSv4 exports
+    need idmapd. (See the init script for the complete reasoning). Also start
+    nfs-common on initial installation of nfs-kernel-server, as we don't want
+    to reboot or restart nfs-common manually just to get idmapd working the
+    first time. (Closes: #381366)
+
+ -- Steinar H. Gunderson <sesse@debian.org>  Mon,  7 Aug 2006 21:27:37 +0200
+
 nfs-utils (1:1.0.9-5) unstable; urgency=low
 
   * Put rpc.svcgssd back into place; removing it was obviously not what
diff --git a/debian/nfs-common.init b/debian/nfs-common.init
index 5c34c9e..f397e64 100644
--- a/debian/nfs-common.init
+++ b/debian/nfs-common.init
@@ -76,6 +76,20 @@ done
 
 exec 0<&9 9<&-
 
+#
+# We also need idmapd if we run an NFSv4 server. It's fairly difficult
+# to autodetect whether there are NFSv4 exports or not, and idmapd is not a
+# particularily heavy daemon, so we auto-enable it if we find an /etc/exports
+# file. This does not mean that there are NFSv4 or other mounts active (or
+# even that nfs-kernel-server is installed), but it matches what the "start"
+# condition in nfs-kernel-server's init script does, which has a value in
+# itself.
+#
+if [ -f /etc/exports ]; then
+    AUTO_NEED_IDMAPD=yes
+fi
+
+
 case "$NEED_IDMAPD" in
     yes|no)	
         ;;
diff --git a/debian/nfs-kernel-server.postinst b/debian/nfs-kernel-server.postinst
index f7dbc25..5788144 100644
--- a/debian/nfs-kernel-server.postinst
+++ b/debian/nfs-kernel-server.postinst
@@ -19,4 +19,5 @@ esac
 
 act="restart"
 [ "$1:$2" = "configure:" ] && act="start"
+[ "$1:$2" = "configure:" ] && invoke-rc.d nfs-common start
 invoke-rc.d nfs-kernel-server $act
-- 
2.39.5