From be58f2e412380d11bfec9459fab053f02199cdc8 Mon Sep 17 00:00:00 2001
From: Pierre Habouzit <madcoder@debian.org>
Date: Mon, 13 Apr 2009 17:47:20 +0200
Subject: [PATCH 4/5] be sure nsdc drops privilegies properly for anything else than start/stop.

Signed-off-by: Pierre Habouzit <madcoder@debian.org>
---
 nsdc.sh.in |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

--- a/nsdc.sh.in
+++ b/nsdc.sh.in
@@ -95,8 +95,18 @@ pidfile=`${nsd_checkconf} -o pidfile ${c
 difffile=`${nsd_checkconf} -o difffile ${configfile}`
 zonesdir=`${nsd_checkconf} -o zonesdir ${configfile}`
 lockfile="${dbfile}.lock"  # still needed
+username=`${nsd_checkconf} -o username ${configfile}`
 sbindir=`dirname ${nsd_checkconf}`
 
+case "$1" in
+    start|restart);;
+    *)
+        if [ "$(id -ru)" = 0 -a "$username" != "root" ]; then
+            exec su "$username" -s"$SHELL" -c "$0 -c \"$configfile\" $@"
+        fi
+    ;;
+esac
+
 # move to zonesdir (if specified), and make absolute pathnames.
 if test -n "${zonesdir}"; then
        zonesdir=`dirname ${zonesdir}/.`
