From 35d3038beac421e1c9d64999f5ad8614282f0428 Mon Sep 17 00:00:00 2001 From: yaazkal Date: Sun, 12 Dec 2021 12:10:39 -0500 Subject: [PATCH 1/2] [REF] Use host's time zone for jails by default --- usr/local/etc/bastille/bastille.conf.sample | 2 +- usr/local/share/bastille/create.sh | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/usr/local/etc/bastille/bastille.conf.sample b/usr/local/etc/bastille/bastille.conf.sample index 22653b3..de98f40 100644 --- a/usr/local/etc/bastille/bastille.conf.sample +++ b/usr/local/etc/bastille/bastille.conf.sample @@ -25,7 +25,7 @@ bastille_sharedir="/usr/local/share/bastille" ## default bastille_bootstrap_archives="base" ## default: "base" ## default timezone -bastille_tzdata="Etc/UTC" ## default: "Etc/UTC" +bastille_tzdata="" ## default: empty to use host's time zone ## default jail resolv.conf bastille_resolv_conf="/etc/resolv.conf" ## default: "/etc/resolv.conf" diff --git a/usr/local/share/bastille/create.sh b/usr/local/share/bastille/create.sh index d10eedd..d1dc233 100644 --- a/usr/local/share/bastille/create.sh +++ b/usr/local/share/bastille/create.sh @@ -440,8 +440,13 @@ create_jail() { ln -s usr/home home fi - ## TZ: configurable (default: Etc/UTC) - ln -s "/usr/share/zoneinfo/${bastille_tzdata}" etc/localtime + ## TZ: configurable (default: empty to use host's time zone) + if [ -z "${bastille_tzdata}" ]; then + # uses cp as a way to prevent issues with symlinks if the host happens to use that for tz configuration + cp /etc/localtime etc/localtime + else + ln -s "/usr/share/zoneinfo/${bastille_tzdata}" etc/localtime + fi # Post-creation jail misc configuration # Create a dummy fstab file From 68951de6873887b6b8b99752aba083f5c36ae8ab Mon Sep 17 00:00:00 2001 From: yaazkal Date: Sun, 12 Dec 2021 12:38:05 -0500 Subject: [PATCH 2/2] [FIX] Only use host's time zone for jails when already set in host --- usr/local/share/bastille/create.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/usr/local/share/bastille/create.sh b/usr/local/share/bastille/create.sh index d1dc233..d81ceda 100644 --- a/usr/local/share/bastille/create.sh +++ b/usr/local/share/bastille/create.sh @@ -442,8 +442,11 @@ create_jail() { ## TZ: configurable (default: empty to use host's time zone) if [ -z "${bastille_tzdata}" ]; then - # uses cp as a way to prevent issues with symlinks if the host happens to use that for tz configuration - cp /etc/localtime etc/localtime + # Note that if host has no time zone, FreeBSD assumes UTC anyway + if [ -e /etc/localtime ]; then + # uses cp as a way to prevent issues with symlinks if the host happens to use that for tz configuration + cp /etc/localtime etc/localtime + fi else ln -s "/usr/share/zoneinfo/${bastille_tzdata}" etc/localtime fi