home · contact · privacy
Use hard links instead of symbolic links for /etc/.
authorChristian Heller <c.heller@plomlompom.de>
Mon, 19 Nov 2018 15:39:52 +0000 (16:39 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Mon, 19 Nov 2018 15:39:52 +0000 (16:39 +0100)
all_new_2018/hardlink_etc.sh [new file with mode: 0755]
all_new_2018/setup_server.sh
all_new_2018/symlink_etc.sh [deleted file]

diff --git a/all_new_2018/hardlink_etc.sh b/all_new_2018/hardlink_etc.sh
new file mode 100755 (executable)
index 0000000..a6f3b68
--- /dev/null
@@ -0,0 +1,23 @@
+#!/bin/sh
+# Hard link files to those in argument-selected subdirectories of
+# linkable_etc_files//, e.g. link /etc/foo/bar to
+# linkable_etc_files/$1/etc/foo/bar and so on. Create directories as
+# necessary. We do the hard linking so files that should be readable to
+# non-root in /etc/ remain so despite having a path below /root/, as
+# symbolic links point into /root/ without making the targets readable
+# to non-root.
+# CAUTION: This removes original files at the affected paths.
+set -e
+
+config_tree_prefix="${HOME}/config/all_new_2018/linkable_etc_files/"
+
+for target in "$@"; do
+    cd "${config_tree_prefix}${target}"
+    for path in $(find . -type f); do
+        linking=$(echo "${path}" | cut -c2-)
+        linked=$(realpath "${path}")
+        dir=$(dirname "${linking}")
+        mkdir -p "${dir}"
+        ln -f "${linked}" "${linking}"
+    done
+done
index 55650aadecbb2e7496ed85778081f22404d68995..a4f859966098316c9b863a9c3588722305859350 100755 (executable)
@@ -4,7 +4,7 @@
 set -e
 
 # Provide maximum input for set_hostname_and_fqdn.sh.
-if "$#" -ne 2 ]; then
+if "$#" -ne 2 ]; then
     echo "Need exactly two arguments (hostname, FQDN)."
     false
 fi
@@ -14,7 +14,7 @@ fqdn="$2"
 # Adapt /etc/ to our needs by symlinking into ./linkable_etc_files. This
 # will set basic configurations affecting following steps, such as setup
 # of APT and the locale selection, so needs to be right at the beginning.
-./symlink_etc.sh all server
+./hardlink_etc.sh all server
 
 # Set hostname and FQDN.
 ./set_hostname_and_fqdn.sh "${hostname}" "${fqdn}"
diff --git a/all_new_2018/symlink_etc.sh b/all_new_2018/symlink_etc.sh
deleted file mode 100755 (executable)
index 90cb20a..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/bin/sh
-# Symbolically link files to those in argument-selected subdirectories
-# of linkable_etc_files//, e.g. link /etc/foo/bar to
-# linkable_etc_files/$1/etc/foo/bar and so on. Create directories as
-# necessary.
-# CAUTION: This removes original files at the affected paths.
-set -e
-
-config_tree_prefix="${HOME}/config/all_new_2018/linkable_etc_files/"
-
-for target in "$@"; do
-    cd "${config_tree_prefix}${target}"
-    for path in $(find . -type f); do
-        linking=$(echo "${path}" | cut -c2-)
-        linked=$(realpath "${path}")
-        dir=$(dirname "${linking}")
-        mkdir -p "${dir}"
-        ln -fs "${linked}" "${linking}"
-    done
-done