changeset 210:4d7e00b500a1

Implement a sanity and consistency check when doing "natural" mounts
author Franz Glasner <fzglas.hg@dom66.de>
date Sun, 21 Aug 2022 15:55:01 +0200
parents 1b176ccd41b9
children ee9b32ab0e9a
files sbin/fjail
diffstat 1 files changed, 13 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/sbin/fjail	Sun Aug 21 15:18:20 2022 +0200
+++ b/sbin/fjail	Sun Aug 21 15:55:01 2022 +0200
@@ -446,6 +446,19 @@
                     _relative_mp="${_relative_mp%/}"
                     # The real effective full mountpoint
                     _real_mp="${_mountpoint}${_relative_mp}"
+
+                    #
+                    # Consistency and sanity check: computed real mountpoint must
+                    # be equal to the configured mountpoint when no custom mountpoint
+                    # is given.
+                    #
+                    if [ "${_mount_natural}" = "yes" ]; then
+                        if [ "${_real_mp}" != "${_mp}" ]; then
+                            echo "ERROR: mountpoint mismatch" >&2
+                            return 1
+                        fi
+                    fi
+
                     if [ "${_dry_run}" = "yes" ]; then
                         echo "Would mount ${_name} on ${_real_mp}"
                     else