Blame SOURCES/rear-pr2675.patch

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