diff options
| author | Adam Tkac <atkac@fedoraproject.org> | 2009-06-18 10:04:51 +0000 |
|---|---|---|
| committer | Adam Tkac <atkac@fedoraproject.org> | 2009-06-18 10:04:51 +0000 |
| commit | 616a532b991eab88a7d4e2d028e86b57a6911305 (patch) | |
| tree | 8974189f58b3861c50fc9b6c0b29254aeb068c1d /named.init | |
| parent | 09a3df65ccf71933a46581d7ef41e0c26c008e2a (diff) | |
- 9.6.1 releasebind-9_6_1-1_fc11
- simplify chroot maintenance. Important files and directories are mounted
into chroot (see /etc/sysconfig/named for more info, #504596)
- fix doc/named.conf.default perms
Diffstat (limited to 'named.init')
| -rwxr-xr-x | named.init | 47 |
1 files changed, 47 insertions, 0 deletions
@@ -47,6 +47,47 @@ fi [ /etc/sysconfig/dnssec -nt /etc/named.conf ] && \ /usr/sbin/dnssec-configure -b --norestart --dnssec="$DNSSEC" --dlv="$DLV" +ROOTDIR_MOUNT='/etc/named /etc/pki/dnssec-keys /var/named /etc/named.conf +/etc/named.dnssec.keys /etc/named.rfc1912.zones /etc/rndc.conf /etc/rndc.key' + +mount_chroot_conf() +{ + if [ -n "$ROOTDIR" ]; then + for all in $ROOTDIR_MOUNT; do + # Skip nonexistant files + [ -e "$all" ] || continue + + # If mount source is a file + if ! [ -d "$all" ]; then + # mount it only if it is not present in chroot or it is empty + if ! [ -e "$ROOTDIR$all" ] || + [ `ls -s "$ROOTDIR$all" | awk '{ print $1 };'` -eq 0 ]; then + touch "$ROOTDIR$all" + mount --bind "$all" "$ROOTDIR$all" + fi + else + # Mount source is a directory. Mount it only if directory in chroot is + # empty. + [ `ls -1A $ROOTDIR$all | wc -l` -eq 0 ] && \ + mount --bind "$all" "$ROOTDIR$all" + fi + done + fi +} + +umount_chroot_conf() +{ + for all in $ROOTDIR_MOUNT; do + # Check if file is mount target. Do not use /proc/mounts because detecting + # of modified mounted files can fail. + if mount | grep -q '.* on '"$ROOTDIR$all"' .*'; then + umount "$ROOTDIR$all" + # Remove temporary created files + [ -f "$all" ] && rm -f "$ROOTDIR$all" + fi + done +} + # Check if all what named needs running start() { @@ -70,6 +111,8 @@ start() named_conf=${named_conf:-/etc/named.conf}; + mount_chroot_conf + if [ ! -r $ROOTDIR$named_conf ]; then echo 'Cannot find configuration file. You could create it by system-config-bind' exit 6; @@ -117,12 +160,14 @@ start() failure echo [ -x /usr/bin/logger ] && echo "$named_err" | /usr/bin/logger -pdaemon.error -tnamed; + umount_chroot_conf exit 2; fi; echo if [ $RETVAL -eq 0 ]; then touch /var/lock/subsys/named; else + umount_chroot_conf exit 7; fi return 0; @@ -148,6 +193,8 @@ stop() { fi; done + umount_chroot_conf + # remove pid files if [ $RETVAL -eq 0 ]; then rm -f /var/lock/subsys/named |
