changeset 250:c4d835ccb4ae

Implement configure for symlinked skeletons. Automatically decide if "etc" is a symlink to "skeleton/etc".
author Franz Glasner <fzglas.hg@dom66.de>
date Sun, 11 Sep 2022 13:58:08 +0200
parents a91e1c5173cc
children 7a6c03445ba1
files sbin/fjail sbin/ftjail
diffstat 2 files changed, 16 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/sbin/fjail	Sun Sep 11 13:02:39 2022 +0200
+++ b/sbin/fjail	Sun Sep 11 13:58:08 2022 +0200
@@ -69,6 +69,9 @@
     Configure some basic parts of the system at MOUNTPOINT:
     disable root password, syslog and other basic configuration settings
 
+    Also handle thin jails by checking whether "etc" is a symlink to
+    "skeleton/etc".
+
    hostid
 
      Print proposals for a hostuuid and hostid
@@ -395,7 +398,12 @@
         # 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"
+            # Handle thin jails automatically (but check expectations very strictly)
+            if [ \( -L "${_mp}/etc" \) -a \( "$(readlink "${_mp}/etc")" = "skeleton/etc" \) ]; then
+                ln -s ../../usr/share/zoneinfo/Europe/Berlin "${_mp}/etc/localtime"
+            else
+                ln -s ../usr/share/zoneinfo/Europe/Berlin "${_mp}/etc/localtime"
+            fi
             echo "Europe/Berlin" > "${_mp}/var/db/zoneinfo"
         else
             echo "WARNING: \"${_mp}/etc/localtime\" exists already -- not changed"
--- a/sbin/ftjail	Sun Sep 11 13:02:39 2022 +0200
+++ b/sbin/ftjail	Sun Sep 11 13:58:08 2022 +0200
@@ -624,7 +624,7 @@
             exit 2;
             ;;
         *)
-            echo "ERROR: option handling failed" >&2
+            echo "ERROR: option handling failed" 1>&2
             exit 2
             ;;
     esac
@@ -637,7 +637,7 @@
 shift $((OPTIND-1))
 OPTIND=1
 
-test $# -gt 0 || { echo "ERROR: no command given" >&2; exit 2; }
+test $# -gt 0 || { echo "ERROR: no command given" 1>&2; exit 2; }
 
 command="$1"
 shift
@@ -658,8 +658,12 @@
     populate-tmpl)
         command_populate_tmpl "$@"
         ;;
+    configure)
+        echo "ERROR: use \`fjail configure' instead" 1>&2;
+        exit 2
+        ;;
     *)
-        echo "ERROR: unknown command \`${command}'" >&2
+        echo "ERROR: unknown command \`${command}'" 1>&2
         exit 2
         ;;
 esac