Lines 27-34
Link Here
|
27 |
return 1 |
27 |
return 1 |
28 |
fi |
28 |
fi |
29 |
|
29 |
|
30 |
from=$1 |
30 |
from=$(echo $1 | sed 's#//*#/#g') |
31 |
to=$2 |
31 |
to=$(echo $2 | sed 's#//*#/#g') |
32 |
shift 2 |
32 |
shift 2 |
33 |
|
33 |
|
34 |
opts="${*}" |
34 |
opts="${*}" |
Lines 47-53
Link Here
|
47 |
} |
47 |
} |
48 |
|
48 |
|
49 |
_umount() { |
49 |
_umount() { |
50 |
local dir=$1 |
50 |
local dir=$(echo $1 | sed 's#//*#/#g') |
51 |
local ret=0 |
51 |
local ret=0 |
52 |
|
52 |
|
53 |
if [ -n "$(awk "\$2 == \"${dir}\" { print \$2 }" /proc/mounts)" ]; then |
53 |
if [ -n "$(awk "\$2 == \"${dir}\" { print \$2 }" /proc/mounts)" ]; then |
Lines 64-72
Link Here
|
64 |
|
64 |
|
65 |
_get_pidfile() { |
65 |
_get_pidfile() { |
66 |
# as suggested in bug #107724, bug 335398#c17 |
66 |
# as suggested in bug #107724, bug 335398#c17 |
67 |
[ -n "${PIDFILE}" ] || PIDFILE=${CHROOT}$(\ |
67 |
[ -n "${PIDFILE}" ] || PIDFILE=$(/usr/sbin/named-checkconf -p ${NAMED_CONF#${CHROOT}} | grep 'pid-file' | cut -d\" -f2) |
68 |
/usr/sbin/named-checkconf -p ${CHROOT:+-t} ${CHROOT} ${NAMED_CONF#${CHROOT}} | grep 'pid-file' | cut -d\" -f2) |
68 |
[ -z "${PIDFILE}" ] && PIDFILE=/run/named/named.pid |
69 |
[ -z "${PIDFILE}" ] && PIDFILE=${CHROOT}/run/named/named.pid |
|
|
70 |
} |
69 |
} |
71 |
|
70 |
|
72 |
check_chroot() { |
71 |
check_chroot() { |
Lines 119-124
Link Here
|
119 |
|
118 |
|
120 |
ebegin "Starting ${CHROOT:+chrooted }named" |
119 |
ebegin "Starting ${CHROOT:+chrooted }named" |
121 |
|
120 |
|
|
|
121 |
# create piddir (usually /run/named) if necessary, bug 334535 |
122 |
_get_pidfile |
123 |
piddir=${PIDFILE%/*} |
124 |
checkpath -q -d -o root:named -m 0770 "${piddir}" || { |
125 |
eerror "Failed to create PID directory at $piddir" |
126 |
eend 1 |
127 |
return 1 |
128 |
} |
129 |
|
122 |
if [ -n "${CHROOT}" ]; then |
130 |
if [ -n "${CHROOT}" ]; then |
123 |
if [ ${CHROOT_NOCHECK:-0} -eq 0 ]; then |
131 |
if [ ${CHROOT_NOCHECK:-0} -eq 0 ]; then |
124 |
check_chroot || { |
132 |
check_chroot || { |
Lines 147-173
Link Here
|
147 |
_mount /etc/bind ${CHROOT}/etc/bind -o bind |
155 |
_mount /etc/bind ${CHROOT}/etc/bind -o bind |
148 |
_mount /var/bind ${CHROOT}/var/bind -o bind |
156 |
_mount /var/bind ${CHROOT}/var/bind -o bind |
149 |
_mount /var/log/named ${CHROOT}/var/log/named -o bind |
157 |
_mount /var/log/named ${CHROOT}/var/log/named -o bind |
|
|
158 |
_mount ${piddir} ${CHROOT}/${piddir} -o bind |
150 |
if [ "${CHROOT_GEOIP:-0}" -eq 1 ]; then |
159 |
if [ "${CHROOT_GEOIP:-0}" -eq 1 ]; then |
151 |
_mount /usr/share/GeoIP ${CHROOT}/usr/share/GeoIP -o bind |
160 |
_mount /usr/share/GeoIP ${CHROOT}/usr/share/GeoIP -o bind |
152 |
fi |
161 |
fi |
153 |
fi |
162 |
fi |
154 |
|
|
|
155 |
# On initial startup, if piddir inside the chroot /var/run/named |
156 |
# Then the .../var/run part might not exist yet |
157 |
checkpath -q -d -o root:root -m 0755 "${piddir}/.." |
158 |
fi |
163 |
fi |
159 |
|
164 |
|
160 |
checkconfig || { eend 1; return 1; } |
165 |
checkconfig || { eend 1; return 1; } |
161 |
|
166 |
|
162 |
# create piddir (usually /run/named) if necessary, bug 334535 |
|
|
163 |
_get_pidfile |
164 |
piddir="${PIDFILE%/*}" |
165 |
checkpath -q -d -o root:named -m 0770 "${piddir}" || { |
166 |
eerror "Failed to create PID directory at $piddir" |
167 |
eend 1 |
168 |
return 1 |
169 |
} |
170 |
|
171 |
# In case someone have $CPU set in /etc/conf.d/named |
167 |
# In case someone have $CPU set in /etc/conf.d/named |
172 |
if [ -n "${CPU}" ] && [ "${CPU}" -gt 0 ]; then |
168 |
if [ -n "${CPU}" ] && [ "${CPU}" -gt 0 ]; then |
173 |
CPU="-n ${CPU}" |
169 |
CPU="-n ${CPU}" |
Lines 221-226
Link Here
|
221 |
done |
217 |
done |
222 |
|
218 |
|
223 |
[ "${CHROOT_GEOIP:-0}" -eq 1 ] && _umount ${CHROOT}/usr/share/GeoIP |
219 |
[ "${CHROOT_GEOIP:-0}" -eq 1 ] && _umount ${CHROOT}/usr/share/GeoIP |
|
|
220 |
_umount ${CHROOT}/${PIDFILE%/*} |
224 |
_umount ${CHROOT}/etc/bind |
221 |
_umount ${CHROOT}/etc/bind |
225 |
_umount ${CHROOT}/var/log/named |
222 |
_umount ${CHROOT}/var/log/named |
226 |
_umount ${CHROOT}/var/bind |
223 |
_umount ${CHROOT}/var/bind |