changeset 229:243dba574ad3

More sanity checks when configuring jails
author Franz Glasner <fzglas.hg@dom66.de>
date Fri, 02 Sep 2022 09:25:50 +0200
parents 4493e364cabf
children 16feee945857
files sbin/fjail
diffstat 1 files changed, 21 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/sbin/fjail	Thu Sep 01 09:45:41 2022 +0200
+++ b/sbin/fjail	Fri Sep 02 09:25:50 2022 +0200
@@ -380,19 +380,28 @@
     # Deactive the by default empty root password
     pw -R "${_mp}" usermod -w no -n root
 
-    sysrc -R "${_mp}" sendmail_enable=NONE
-    sysrc -R "${_mp}" clear_tmp_enable=YES
-    sysrc -R "${_mp}" clear_tmp_X=NO
-    sysrc -R "${_mp}" syslogd_flags=-ss
-    sysrc -R "${_mp}" bsdstats_enable=NO       # no automatic BSD stats when booting
+    if [ -f "${_mp}/etc/defaults/rc.conf" ]; then
+
+        sysrc -R "${_mp}" sendmail_enable=NONE
+        sysrc -R "${_mp}" clear_tmp_enable=YES
+        sysrc -R "${_mp}" clear_tmp_X=NO
+        sysrc -R "${_mp}" syslogd_flags=-ss
+        sysrc -R "${_mp}" bsdstats_enable=NO       # no automatic BSD stats when booting
+    else
+        echo "WARNING: No \"${_mp}/etc/defaults/rc.conf\": not configuring \"rc.conf\""
+    fi
 
-    # Timezone to CET
-    if [ ! -f "${_mp}/etc/localtime" ]; then
-        echo "Setting timezone to Europe/Berlin"
-        ln -s ../usr/share/zoneinfo/Europe/Berlin "${_mp}/etc/localtime"
-        echo "Europe/Berlin" > "${_mp}/var/db/zoneinfo"
+    if [ -f "${_mp}/usr/share/zoneinfo/Europe/Berlin" ]; then
+        # Timezone to CET
+        if [ ! -f "${_mp}/etc/localtime" ]; then
+            echo "Setting timezone to Europe/Berlin"
+            ln -s ../usr/share/zoneinfo/Europe/Berlin "${_mp}/etc/localtime"
+            echo "Europe/Berlin" > "${_mp}/var/db/zoneinfo"
+        else
+            echo "WARNING: \"${_mp}/etc/localtime\" exists already -- not changed"
+        fi
     else
-        echo "WARNING: \"${_mp}/etc/localtime\" exists already -- not changed"
+        echo "WARNING: No timezone data file found at \"${_mp}/usr/share/zoneinfo/Europe/Berlin\": skipping timezone setup"
     fi
 
     # resolv.conf
@@ -416,7 +425,7 @@
         echo "daily_status_uptime_enable=\"NO\"" >> "${_pcl}"
 
         echo "security_status_chkmounts_enable=\"NO\"" >> "${_pcl}"
-        
+
     else
         echo "WARNING: \"${_pcl}\" exists already -- not changed"
     fi