Commit 753f883c authored by Atemu's avatar Atemu
Browse files

stage-1: escape mount points and options



mountFS adds these strings to fstab and then relies on `mount` parsing fstab. If
they have spaces or tabs in them, that would break fstab and therefore not mount
with the unhelpful error: No such file or directory.

Co-authored-by: default avatarLily Foster <lily@lily.flowers>

Co-authored-by: default avatarLuflosi <Luflosi@users.noreply.github.com>
parent 7e2aec07
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -342,6 +342,14 @@ checkFS() {
    return 0
}

escapeFstab() {
    local original="$1"

    # Replace space
    local escaped="${original// /\\040}"
    # Replace tab
    echo "${escaped//$'\t'/\\011}"
}

# Function for mounting a file system.
mountFS() {
@@ -569,7 +577,7 @@ while read -u 3 mountPoint; do
        continue
    fi

    mountFS "$device" "$mountPoint" "$options" "$fsType"
    mountFS "$device" "$(escapeFstab "$mountPoint")" "$(escapeFstab "$options")" "$fsType"
done

exec 3>&-