--- named_orig 2016-12-03 11:50:12.719275875 +0100 +++ named_orig 2016-12-03 11:59:40.868146451 +0100 @@ -120,6 +120,11 @@ ebegin "Starting ${CHROOT:+chrooted }named" + # moved initialization of piddir to top, to prevent uninialized use of piddir below! + # create piddir (usually /run/named) if necessary, bug 334535 + _get_pidfile + piddir="${PIDFILE%/*}" + if [ -n "${CHROOT}" ]; then if [ ${CHROOT_NOCHECK:-0} -eq 0 ]; then check_chroot || { @@ -160,9 +165,6 @@ checkconfig || { eend 1; return 1; } - # create piddir (usually /run/named) if necessary, bug 334535 - _get_pidfile - piddir="${PIDFILE%/*}" checkpath -q -d -o root:named -m 0770 "${piddir}" || { eerror "Failed to create PID directory at $piddir" eend 1 @@ -202,7 +204,8 @@ # -R 10, bug 335398 _get_pidfile - start-stop-daemon --stop --retry 10 --pidfile $PIDFILE \ + # Hack to work around the strange fact that start-stop-daemon is using the argument of --pidfile to be inside of the chroot at start but not on stop + start-stop-daemon --stop --retry 10 --pidfile ${CHROOT}/$PIDFILE \ --exec /usr/sbin/named if [ -n "${CHROOT}" ] && [ "${CHROOT_NOMOUNT:-0}" -eq 0 ]; then