Blame SOURCES/rear-pr2675.patch

9fdd73
diff --git a/usr/share/rear/lib/framework-functions.sh b/usr/share/rear/lib/framework-functions.sh
9fdd73
index 4878216b..e919bdbf 100644
9fdd73
--- a/usr/share/rear/lib/framework-functions.sh
9fdd73
+++ b/usr/share/rear/lib/framework-functions.sh
9fdd73
@@ -121,7 +121,7 @@ function cleanup_build_area_and_end_program () {
9fdd73
             sleep 2
9fdd73
             umount_mountpoint_lazy $BUILD_DIR/outputfs
9fdd73
         fi
9fdd73
-        remove_temporary_mountpoint '$BUILD_DIR/outputfs' || BugError "Directory $BUILD_DIR/outputfs not empty, can not remove"
9fdd73
+        remove_temporary_mountpoint "$BUILD_DIR/outputfs" || BugError "Directory $BUILD_DIR/outputfs not empty, can not remove"
9fdd73
         rmdir $v $BUILD_DIR >&2
9fdd73
     fi
9fdd73
     Log "End of program reached"
9fdd73
diff --git a/usr/share/rear/lib/global-functions.sh b/usr/share/rear/lib/global-functions.sh
9fdd73
index c1a11615..0f8f362d 100644
9fdd73
--- a/usr/share/rear/lib/global-functions.sh
9fdd73
+++ b/usr/share/rear/lib/global-functions.sh
9fdd73
@@ -317,7 +317,20 @@ function url_path() {
9fdd73
 
9fdd73
 ### Returns true if one can upload files to the URL
9fdd73
 function scheme_accepts_files() {
9fdd73
-    local scheme=$1
9fdd73
+    # Be safe against 'set -eu' which would exit 'rear' with "bash: $1: unbound variable"
9fdd73
+    # when scheme_accepts_files is called without an argument
9fdd73
+    # by bash parameter expansion with using an empty default value if $1 is unset or null.
9fdd73
+    # Bash parameter expansion with assigning a default value ${1:=} does not work
9fdd73
+    # (then it would still exit with "bash: $1: cannot assign in this way")
9fdd73
+    # but using a default value is practicable here because $1 is used only once
9fdd73
+    # cf. https://github.com/rear/rear/pull/2675#discussion_r705018956
9fdd73
+    local scheme=${1:-}
9fdd73
+    # Return false if scheme is empty or blank (e.g. when OUTPUT_URL is unset or empty or blank)
9fdd73
+    # cf. https://github.com/rear/rear/issues/2676
9fdd73
+    # and https://github.com/rear/rear/issues/2667#issuecomment-914447326
9fdd73
+    # also return false if scheme is more than one word (so no quoted "$scheme" here)
9fdd73
+    # cf. https://github.com/rear/rear/pull/2675#discussion_r704401462
9fdd73
+    test $scheme || return 1
9fdd73
     case $scheme in
9fdd73
         (null|tape|obdr)
9fdd73
             # tapes do not support uploading arbitrary files, one has to handle them
9fdd73
@@ -341,7 +354,10 @@ function scheme_accepts_files() {
9fdd73
 ### Returning true does not imply that the URL is currently mounted at a filesystem and usable,
9fdd73
 ### only that it can be mounted (use mount_url() first)
9fdd73
 function scheme_supports_filesystem() {
9fdd73
-    local scheme=$1
9fdd73
+    # Be safe against 'set -eu' exit if scheme_supports_filesystem is called without argument
9fdd73
+    local scheme=${1:-}
9fdd73
+    # Return false if scheme is empty or blank or more than one word, cf. scheme_accepts_files() above
9fdd73
+    test $scheme || return 1
9fdd73
     case $scheme in
9fdd73
         (null|tape|obdr|rsync|fish|ftp|ftps|hftp|http|https|sftp)
9fdd73
             return 1
9fdd73
@@ -560,7 +576,7 @@ function umount_url() {
9fdd73
 
9fdd73
     RemoveExitTask "perform_umount_url '$url' '$mountpoint' lazy"
9fdd73
 
9fdd73
-    remove_temporary_mountpoint '$mountpoint' && RemoveExitTask "remove_temporary_mountpoint '$mountpoint'"
9fdd73
+    remove_temporary_mountpoint "$mountpoint" && RemoveExitTask "remove_temporary_mountpoint '$mountpoint'"
9fdd73
     return 0
9fdd73
 }
9fdd73