From 303d38369a5fd2961b51bb8bbf1f0dfb739e7934 Mon Sep 17 00:00:00 2001 From: Pawel Jakub Dawidek Date: Fri, 5 Mar 2004 09:17:01 +0000 Subject: [PATCH] Teach 'hostname' script how to act inside a jail. No objections from: mtm, arch@ --- etc/rc.d/hostname | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/etc/rc.d/hostname b/etc/rc.d/hostname index 56bf3c2a214b..695d3761207a 100644 --- a/etc/rc.d/hostname +++ b/etc/rc.d/hostname @@ -39,12 +39,20 @@ stop_cmd=":" hostname_start() { - # Set the host name if it is not already set + # If we are not inside a jail, set the host name if it is not already set. + # If we are inside a jail, set the host name even if it is already set, + # but first check if it is permitted. # - if [ -z "`hostname -s`" ]; then - hostname ${hostname} - echo "Setting hostname: `hostname`." + if [ `$SYSCTL_N security.jail.jailed` -eq 1 ]; then + if [ `$SYSCTL_N security.jail.set_hostname_allowed` -eq 0 ]; then + return + fi + elif [ -n "`hostname -s`" ]; then + return fi + + hostname ${hostname} + echo "Setting hostname: `hostname`." } load_rc_config $name