summaryrefslogtreecommitdiffstats
path: root/etc
diff options
context:
space:
mode:
authorbz <bz@FreeBSD.org>2009-02-07 16:37:02 +0000
committerbz <bz@FreeBSD.org>2009-02-07 16:37:02 +0000
commitfabbde3ecefd44749fcd5f1c5d4349bda2c61c54 (patch)
tree82846e09b7f09a734b29e28db0990d068042a7eb /etc
parent093a3609e469adfcc22b631ffb58902ba133678d (diff)
downloadFreeBSD-src-fabbde3ecefd44749fcd5f1c5d4349bda2c61c54.zip
FreeBSD-src-fabbde3ecefd44749fcd5f1c5d4349bda2c61c54.tar.gz
Named normally cannot be started chrooted inside a jail. Thus treat
the jail case specifically. In case we find a proper pre-seeded devfs in the chroot path (mounted from the base system) permit starting chrooted else give proper warn/error messages. PR: conf/103489 Reviewed by: dougb MFC after: 5 days
Diffstat (limited to 'etc')
-rwxr-xr-xetc/rc.d/named28
1 files changed, 23 insertions, 5 deletions
diff --git a/etc/rc.d/named b/etc/rc.d/named
index 4aedb04..e40a464 100755
--- a/etc/rc.d/named
+++ b/etc/rc.d/named
@@ -61,10 +61,23 @@ chroot_autoupdate()
# Mount a devfs in the chroot directory if needed
#
- umount ${named_chrootdir}/dev 2>/dev/null
- devfs_domount ${named_chrootdir}/dev devfsrules_hide_all
- devfs -m ${named_chrootdir}/dev rule apply path null unhide
- devfs -m ${named_chrootdir}/dev rule apply path random unhide
+ if [ `${SYSCTL_N} security.jail.jailed` -eq 0 ]; then
+ umount ${named_chrootdir}/dev 2>/dev/null
+ devfs_domount ${named_chrootdir}/dev devfsrules_hide_all
+ devfs -m ${named_chrootdir}/dev rule apply path null unhide
+ devfs -m ${named_chrootdir}/dev rule apply path random unhide
+ else
+ if [ -c ${named_chrootdir}/dev/null -a \
+ -c ${named_chrootdir}/dev/random ]; then
+ info "named chroot: using pre-mounted devfs."
+ else
+ err 1 "named chroot: devfs cannot be mounted from" \
+ "within a jail. Thus a chrooted named cannot" \
+ "be run from within a jail." \
+ "To run named without chrooting it, set" \
+ "named_chrootdir=\"\" in /etc/rc.conf."
+ fi
+ fi
# Copy and/or update key files to the chroot /etc
#
@@ -113,7 +126,12 @@ named_stop()
named_poststop()
{
if [ -n "${named_chrootdir}" -a -c ${named_chrootdir}/dev/null ]; then
- umount ${named_chrootdir}/dev 2>/dev/null || true
+ if [ `${SYSCTL_N} security.jail.jailed` -eq 0 ]; then
+ umount ${named_chrootdir}/dev 2>/dev/null || true
+ else
+ warn "named chroot:" \
+ "cannot unmount devfs from inside jail!"
+ fi
fi
}
OpenPOWER on IntegriCloud