Minor cleanup in bind-chroot-admin script

This commit is contained in:
Adam Tkac 2007-02-15 15:46:08 +00:00
parent 168cdeae16
commit 7d1ee6c49c
2 changed files with 14 additions and 21 deletions

View File

@ -21,16 +21,6 @@
# #
# #
BIND_CHROOT_PREFIX=${BIND_CHROOT_PREFIX:-@BIND_CHROOT_PREFIX@} BIND_CHROOT_PREFIX=${BIND_CHROOT_PREFIX:-@BIND_CHROOT_PREFIX@}
if [ -e /etc/sysconfig/named ]; then
BIND_CHROOT_PREFIX_TEMP=`grep "^\s*ROOTDIR" "/etc/sysconfig/named"`
BIND_CHROOT_PREFIX_TEMP=${BIND_CHROOT_PREFIX_TEMP#*\=}
BIND_CHROOT_PREFIX_TEMP=${BIND_CHROOT_PREFIX_TEMP%#*}
if [ ! ${#BIND_CHROOT_PREFIX_TEMP} -eq 0 ]; then
BIND_CHROOT_PREFIX=$BIND_CHROOT_PREFIX_TEMP
fi
fi
BIND_DIR=${BIND_DIR:-@BIND_DIR@} BIND_DIR=${BIND_DIR:-@BIND_DIR@}
function usage() function usage()
@ -55,11 +45,14 @@ function rootdir()
if [ -L "$BIND_CHROOT_PREFIX" ]; then if [ -L "$BIND_CHROOT_PREFIX" ]; then
BIND_CHROOT_PREFIX=`/usr/bin/readlink "$BIND_CHROOT_PREFIX"`; BIND_CHROOT_PREFIX=`/usr/bin/readlink "$BIND_CHROOT_PREFIX"`;
fi fi
return 0; ENABLED=0;
else
ENABLED=1;
fi; fi;
return 1;
} }
rootdir;
function selinux_enabled() function selinux_enabled()
{ {
while read d mp fs rest; do if [ "$fs" = "selinuxfs" ]; then return 0; fi; done < /proc/mounts while read d mp fs rest; do if [ "$fs" = "selinuxfs" ]; then return 0; fi; done < /proc/mounts
@ -68,13 +61,10 @@ function selinux_enabled()
function check_dirs() function check_dirs()
{ {
if [ -z "$BIND_CHROOT_PREFIX" ]; then
rootdir;
if [ -z "$BIND_CHROOT_PREFIX" ]; then if [ -z "$BIND_CHROOT_PREFIX" ]; then
usage; usage;
exit 1; exit 1;
fi; fi;
fi
BIND_DIR=`echo $BIND_DIR | sed 's#//*#/#g;s#/$##'`; BIND_DIR=`echo $BIND_DIR | sed 's#//*#/#g;s#/$##'`;
if [ -L "$BIND_DIR" ]; then if [ -L "$BIND_DIR" ]; then
BIND_DIR=`/usr/bin/readlink "$BIND_DIR"`; BIND_DIR=`/usr/bin/readlink "$BIND_DIR"`;
@ -223,7 +213,7 @@ function sync_files()
pfx='' pfx=''
changed=`/bin/mktemp /tmp/XXXXXX`; changed=`/bin/mktemp /tmp/XXXXXX`;
rm -f $changed rm -f $changed
if rootdir ; then # chroot is enabled if [ $ENABLED -eq 0 ] ; then # chroot is enabled
/usr/bin/find /{etc/{named.*,rndc.*},${BIND_DIR#/}{/*,/data/*,/slaves/*}} -maxdepth 0 -type f | /usr/bin/find /{etc/{named.*,rndc.*},${BIND_DIR#/}{/*,/data/*,/slaves/*}} -maxdepth 0 -type f |
while read f; while read f;
do do
@ -291,7 +281,7 @@ function sync_files()
function clean_root() function clean_root()
{ {
if ! rootdir ; then # chroot is disabled, clean it up if [ $ENABLED -eq 0 ] ; then # chroot is disabled, clean it up
if [ -n "${BIND_CHROOT_PREFIX}" -a "x${BIND_CHROOT_PREFIX}" != "x/" ]; then if [ -n "${BIND_CHROOT_PREFIX}" -a "x${BIND_CHROOT_PREFIX}" != "x/" ]; then
rm -r ${BIND_CHROOT_PREFIX}/dev >/dev/null 2>&1 || :; rm -r ${BIND_CHROOT_PREFIX}/dev >/dev/null 2>&1 || :;
rmdir ${BIND_CHROOT_PREFIX}/proc >/dev/null 2>&1 || :; rmdir ${BIND_CHROOT_PREFIX}/proc >/dev/null 2>&1 || :;

View File

@ -17,7 +17,7 @@ Summary: The Berkeley Internet Name Domain (BIND) DNS (Domain Name System) serv
Name: bind Name: bind
License: BSD-like License: BSD-like
Version: 9.3.4 Version: 9.3.4
Release: 6%{?dist} Release: 7%{?dist}
Epoch: 31 Epoch: 31
Url: http://www.isc.org/products/BIND/ Url: http://www.isc.org/products/BIND/
Buildroot: %{_tmppath}/%{name}-root Buildroot: %{_tmppath}/%{name}-root
@ -744,6 +744,9 @@ rm -rf ${RPM_BUILD_ROOT}
:; :;
%changelog %changelog
* Thu Feb 15 2007 Adam Tkac <atkac@redhat.com> 31:9.3.4-7.fc7
- minor cleanup in bind-chroot-admin script
* Fri Feb 09 2007 Adam Tkac <atkac@redhat.com> 31:9.3.4-6.fc7 * Fri Feb 09 2007 Adam Tkac <atkac@redhat.com> 31:9.3.4-6.fc7
- fixed broken bind-chroot-admin script (#227995) - fixed broken bind-chroot-admin script (#227995)