summaryrefslogtreecommitdiffstats
path: root/etc/rc.d/hostname
diff options
context:
space:
mode:
authorpjd <pjd@FreeBSD.org>2004-03-05 09:17:01 +0000
committerpjd <pjd@FreeBSD.org>2004-03-05 09:17:01 +0000
commitef845cae5e4773c279a684b126d34e068ad684d2 (patch)
tree6bf2a422703ffad6d5ab773fd0c0a45cc74627a9 /etc/rc.d/hostname
parent9229a66472aaeec107fd55b0904229dd71ff1018 (diff)
downloadFreeBSD-src-ef845cae5e4773c279a684b126d34e068ad684d2.zip
FreeBSD-src-ef845cae5e4773c279a684b126d34e068ad684d2.tar.gz
Teach 'hostname' script how to act inside a jail.
No objections from: mtm, arch@
Diffstat (limited to 'etc/rc.d/hostname')
-rw-r--r--etc/rc.d/hostname16
1 files changed, 12 insertions, 4 deletions
diff --git a/etc/rc.d/hostname b/etc/rc.d/hostname
index 56bf3c2..695d376 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
OpenPOWER on IntegriCloud