changeset 561:d173161a3a0f

FIX: SC2295: expansions inside ${..} need to be quoted separately, otherwise they will match as a pattern. All our prefixes should be without shell pattern matching (?, *, [ et al.).
author Franz Glasner <fzglas.hg@dom66.de>
date Wed, 11 Sep 2024 18:19:41 +0200
parents 56ae2b21da67
children 3fb59bd978c0
files sbin/ftjail sbin/fzfs
diffstat 2 files changed, 7 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/sbin/ftjail	Wed Sep 11 16:49:17 2024 +0200
+++ b/sbin/ftjail	Wed Sep 11 18:19:41 2024 +0200
@@ -425,7 +425,7 @@
                     #
 
                     # Determine the mountpoint relative to the parent mountpoint
-                    _relative_mp="${_mp#${_rootds_mountpoint}}"
+                    _relative_mp="${_mp#"${_rootds_mountpoint}"}"
                     # Eventually remove a trailing slash
                     _relative_mp="${_relative_mp%/}"
                     # The real effective full mountpoint
@@ -719,7 +719,7 @@
             if [ "${_name}" = "${_name%@*}@${_snapshot_name}" ]; then
                 echo "FOUND: $_name"
                 # Determine the relative name of the dataset
-                _relative_name="${_name#${_ds_source}}"
+                _relative_name="${_name#"${_ds_source}"}"
                 _relative_name="${_relative_name%@*}"
                 echo "  -> $_relative_name"
                 if [ -z "${_relative_name}" ]; then
--- a/sbin/fzfs	Wed Sep 11 16:49:17 2024 +0200
+++ b/sbin/fzfs	Wed Sep 11 18:19:41 2024 +0200
@@ -176,7 +176,7 @@
                         _relative_mp=""
                         _real_mp="${_mountpoint}"
                     else
-                        _relative_mp="${_mp#${_rootds_mountpoint_prefix}}"
+                        _relative_mp="${_mp#"${_rootds_mountpoint_prefix}"}"
                         # Eventually remove a trailing slash
                         _relative_mp="${_relative_mp%/}"
                         if [ -z "${_relative_mp}" ]; then
@@ -436,7 +436,7 @@
         IFS=$' \t\n'
 
         # Determine the relative name of the dataset
-        _ds_relname="${_ds#${_ds_source_base}}"
+        _ds_relname="${_ds#"${_ds_source_base}"}"
 
         _ds_canmount=$(zfs get -H -o value canmount "${_ds}")
 
@@ -567,7 +567,7 @@
     _idx=1
     while farray_tryget _ds _ds_tree ${_idx}; do
         # Determine the relative name of the dataset
-        _ds_relname="${_ds#${_ds_source_base}}"
+        _ds_relname="${_ds#"${_ds_source_base}"}"
 
         # Need to determine in *every* case (local, default, received, ...)
         _ds_canmount="$(zfs get -H -o value canmount "${_ds}")"
@@ -631,7 +631,7 @@
     _idx=1
     while farray_tryget _ds _ds_tree ${_idx}; do
         # Determine the relative name of the dataset
-        _ds_relname="${_ds#${_ds_source_base}}"
+        _ds_relname="${_ds#"${_ds_source_base}"}"
 
         # Need to determine in *every* case (default, local, received, ...)
         _ds_canmount="$(zfs get -H -o value canmount "${_ds}")"
@@ -735,7 +735,7 @@
     | {
         while IFS=$'\t' read -r _current_name _current_type ; do
             # Determine the relative name of the dataset
-            _relative_name="${_current_name#${_source_name}}"
+            _relative_name="${_current_name#"${_source_name}"}"
             _relative_name="${_relative_name%@*}"
             if [ "${_current_type}" != "filesystem" ]; then
                 echo "ERROR: Got a snapshot but expected a filesystem" 1>&2