Blame SOURCES/rear-pr2675.patch

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