From 172d405cd45012c28533a53e79dfdae784c4e063 Mon Sep 17 00:00:00 2001 From: Kroese Date: Tue, 21 Oct 2025 20:58:11 +0200 Subject: [PATCH 1/5] Update mido.sh --- src/mido.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/mido.sh b/src/mido.sh index cc5b251..369fc17 100644 --- a/src/mido.sh +++ b/src/mido.sh @@ -487,8 +487,11 @@ getESD() { info "$msg" && html "$msg" rm -rf "$dir" - mkdir -p "$dir" + if ! makeDir "$dir"; then + error "Failed to create directory \"$dir\" !" && return 1 + fi + local xFile="products.xml" local eFile="esd_edition.xml" local fFile="products_filter.xml" From f42b65f52ffefa25a65f55e5cdd7105d5929a2c1 Mon Sep 17 00:00:00 2001 From: Kroese Date: Tue, 21 Oct 2025 21:46:17 +0200 Subject: [PATCH 2/5] fix: Inherit owner from parent folder Refactor directory creation to use makeDir function and handle errors appropriately. --- src/install.sh | 78 +++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 61 insertions(+), 17 deletions(-) diff --git a/src/install.sh b/src/install.sh index f9bd402..90dd92f 100644 --- a/src/install.sh +++ b/src/install.sh @@ -22,7 +22,11 @@ backup () { fi - mkdir -p "$root" + if ! makeDir "$root"; then + error "Failed to create directory \"$root\" !" + return 1 + fi + local folder="$name" local dir="$root/$folder" @@ -34,7 +38,11 @@ backup () { done rm -rf "$dir" - mkdir -p "$dir" + + if ! makeDir "$dir"; then + error "Failed to create directory \"$dir\" !" + return 1 + fi [ -f "$iso" ] && mv -f "$iso" "$dir/" find "$STORAGE" -maxdepth 1 -type f -iname 'data.*' -not -iname '*.iso' -exec mv -n {} "$dir/" \; @@ -156,7 +164,9 @@ startInstall() { ! backup "" && error "Backup failed!" fi - mkdir -p "$TMP" + if ! makeDir "$TMP"; then + error "Failed to create directory \"$TMP\" !" + fi if [ -z "$CUSTOM" ]; then @@ -188,6 +198,10 @@ finishInstall() { error "Failed to find ISO file: $iso" && return 1 fi + if [[ "$iso" == "$STORAGE/"* ]]; then + ! setOwner "$iso" && error "Failed to set the owner for \"$iso\" !" + fi + if [[ "$aborted" != [Yy1]* ]]; then # Mark ISO as prepared via magic byte byte="16" && [[ "$MANUAL" == [Yy1]* ]] && byte="17" @@ -196,56 +210,78 @@ finishInstall() { fi fi - cp -f /run/version "$STORAGE/windows.ver" + local file="$STORAGE/windows.ver" + cp -f /run/version "$file" + ! setOwner "$file" && error "Failed to set the owner for \"$file\" !" if [[ "$iso" == "$STORAGE/"* ]]; then if [[ "$aborted" != [Yy1]* ]] || [ -z "$CUSTOM" ]; then base=$(basename "$iso") - echo "$base" > "$STORAGE/windows.base" + file="$STORAGE/windows.base" + echo "$base" > "$file" + ! setOwner "$file" && error "Failed to set the owner for \"$file\" !" fi fi if [[ "${PLATFORM,,}" == "x64" ]]; then if [[ "${BOOT_MODE,,}" == "windows_legacy" ]]; then - echo "$BOOT_MODE" > "$STORAGE/windows.mode" + file="$STORAGE/windows.mode" + echo "$BOOT_MODE" > "$file" + ! setOwner "$file" && error "Failed to set the owner for \"$file\" !" if [[ "${MACHINE,,}" != "q35" ]]; then - echo "$MACHINE" > "$STORAGE/windows.old" + file="$STORAGE/windows.old" + echo "$MACHINE" > "$file" + ! setOwner "$file" && error "Failed to set the owner for \"$file\" !" fi else # Enable secure boot + TPM on manual installs as Win11 requires if [[ "$MANUAL" == [Yy1]* || "$aborted" == [Yy1]* ]]; then if [[ "${DETECTED,,}" == "win11"* ]]; then BOOT_MODE="windows_secure" - echo "$BOOT_MODE" > "$STORAGE/windows.mode" + file="$STORAGE/windows.mode" + echo "$BOOT_MODE" > "$file" + ! setOwner "$file" && error "Failed to set the owner for \"$file\" !" fi fi # Enable secure boot on multi-socket systems to workaround freeze if [ -n "$SOCKETS" ] && [[ "$SOCKETS" != "1" ]]; then BOOT_MODE="windows_secure" - echo "$BOOT_MODE" > "$STORAGE/windows.mode" + file="$STORAGE/windows.mode" + echo "$BOOT_MODE" > "$file" + ! setOwner "$file" && error "Failed to set the owner for \"$file\" !" fi fi fi if [ -n "${ARGS:-}" ]; then ARGUMENTS="$ARGS ${ARGUMENTS:-}" - echo "$ARGS" > "$STORAGE/windows.args" + file="$STORAGE/windows.args" + echo "$ARGS" > "$file" + ! setOwner "$file" && error "Failed to set the owner for \"$file\" !" fi if [ -n "${VGA:-}" ] && [[ "${VGA:-}" != "virtio"* ]]; then - echo "$VGA" > "$STORAGE/windows.vga" + file="$STORAGE/windows.vga" + echo "$VGA" > "$file" + ! setOwner "$file" && error "Failed to set the owner for \"$file\" !" fi if [ -n "${USB:-}" ] && [[ "${USB:-}" != "qemu-xhci"* ]]; then - echo "$USB" > "$STORAGE/windows.usb" + file="$STORAGE/windows.usb" + echo "$USB" > "$file" + ! setOwner "$file" && error "Failed to set the owner for \"$file\" !" fi if [ -n "${DISK_TYPE:-}" ] && [[ "${DISK_TYPE:-}" != "scsi" ]]; then - echo "$DISK_TYPE" > "$STORAGE/windows.type" + file="$STORAGE/windows.type" + echo "$DISK_TYPE" > "$file" + ! setOwner "$file" && error "Failed to set the owner for \"$file\" !" fi if [ -n "${ADAPTER:-}" ] && [[ "${ADAPTER:-}" != "virtio-net-pci" ]]; then - echo "$ADAPTER" > "$STORAGE/windows.net" + file="$STORAGE/windows.net" + echo "$ADAPTER" > "$file" + ! setOwner "$file" && error "Failed to set the owner for \"$file\" !" fi rm -rf "$TMP" @@ -351,7 +387,10 @@ extractESD() { fi rm -rf "$dir" - mkdir -p "$dir" + + if ! makeDir "$dir"; then + error "Failed to create directory \"$dir\" !" && return 1 + fi size=9606127360 size_gb=$(formatBytes "$size") @@ -486,14 +525,17 @@ extractImage() { info "$msg..." && html "$msg..." rm -rf "$dir" - mkdir -p "$dir" + + if ! makeDir "$dir"; then + error "Failed to create directory \"$dir\" !" && return 1 + fi size=$(stat -c%s "$iso") size_gb=$(formatBytes "$size") space=$(df --output=avail -B 1 "$dir" | tail -n 1) space_gb=$(formatBytes "$space") - if ((size<100000000)); then + if (( size < 100000000 )); then error "Invalid ISO file: Size is smaller than 100 MB" && return 1 fi @@ -1177,6 +1219,8 @@ buildImage() { [[ "$error" != "$hide" ]] && echo "$error" mv -f "$out" "$BOOT" || return 1 + ! setOwner "$BOOT" && error "Failed to set the owner for \"$BOOT\" !" + return 0 } From 600ae228a6f64e2f5e35a2cd23b0534c17369ab4 Mon Sep 17 00:00:00 2001 From: Kroese Date: Tue, 21 Oct 2025 21:49:05 +0200 Subject: [PATCH 3/5] Update power.sh --- src/power.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/power.sh b/src/power.sh index 8acb57b..98a6f73 100644 --- a/src/power.sh +++ b/src/power.sh @@ -105,7 +105,9 @@ finish() { if [ ! -f "$STORAGE/windows.boot" ] && [ -f "$BOOT" ]; then # Remove CD-ROM ISO after install if ready; then - touch "$STORAGE/windows.boot" + local file="$STORAGE/windows.boot" + touch "$file" + ! setOwner "$file" && error "Failed to set the owner for \"$file\" !" if [[ "$REMOVE" != [Nn]* ]]; then rm -f "$BOOT" 2>/dev/null || true fi From ea01e64441b24d5be1b0d3c8d938a5e7d4e5fa9e Mon Sep 17 00:00:00 2001 From: Kroese Date: Tue, 21 Oct 2025 22:02:57 +0200 Subject: [PATCH 4/5] Update install.sh --- src/install.sh | 44 ++++++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/src/install.sh b/src/install.sh index 90dd92f..d269f7e 100644 --- a/src/install.sh +++ b/src/install.sh @@ -188,6 +188,20 @@ startInstall() { return 0 } +writeFile() { + + local txt="$1" + local path="$2" + + echo "$txt" > "$path" + + if ! setOwner "$path"; then + error "Failed to set the owner for \"$path\" !" + fi + + return 0 +} + finishInstall() { local iso="$1" @@ -218,20 +232,17 @@ finishInstall() { if [[ "$aborted" != [Yy1]* ]] || [ -z "$CUSTOM" ]; then base=$(basename "$iso") file="$STORAGE/windows.base" - echo "$base" > "$file" - ! setOwner "$file" && error "Failed to set the owner for \"$file\" !" + writeFile "$base" "$file" fi fi if [[ "${PLATFORM,,}" == "x64" ]]; then if [[ "${BOOT_MODE,,}" == "windows_legacy" ]]; then file="$STORAGE/windows.mode" - echo "$BOOT_MODE" > "$file" - ! setOwner "$file" && error "Failed to set the owner for \"$file\" !" + writeFile "$BOOT_MODE" "$file" if [[ "${MACHINE,,}" != "q35" ]]; then file="$STORAGE/windows.old" - echo "$MACHINE" > "$file" - ! setOwner "$file" && error "Failed to set the owner for \"$file\" !" + writeFile "$MACHINE" "$file" fi else # Enable secure boot + TPM on manual installs as Win11 requires @@ -239,16 +250,14 @@ finishInstall() { if [[ "${DETECTED,,}" == "win11"* ]]; then BOOT_MODE="windows_secure" file="$STORAGE/windows.mode" - echo "$BOOT_MODE" > "$file" - ! setOwner "$file" && error "Failed to set the owner for \"$file\" !" + writeFile "$BOOT_MODE" "$file" fi fi # Enable secure boot on multi-socket systems to workaround freeze if [ -n "$SOCKETS" ] && [[ "$SOCKETS" != "1" ]]; then BOOT_MODE="windows_secure" file="$STORAGE/windows.mode" - echo "$BOOT_MODE" > "$file" - ! setOwner "$file" && error "Failed to set the owner for \"$file\" !" + writeFile "$BOOT_MODE" "$file" fi fi fi @@ -256,32 +265,27 @@ finishInstall() { if [ -n "${ARGS:-}" ]; then ARGUMENTS="$ARGS ${ARGUMENTS:-}" file="$STORAGE/windows.args" - echo "$ARGS" > "$file" - ! setOwner "$file" && error "Failed to set the owner for \"$file\" !" + writeFile "$ARGS" "$file" fi if [ -n "${VGA:-}" ] && [[ "${VGA:-}" != "virtio"* ]]; then file="$STORAGE/windows.vga" - echo "$VGA" > "$file" - ! setOwner "$file" && error "Failed to set the owner for \"$file\" !" + writeFile "$VGA" "$file" fi if [ -n "${USB:-}" ] && [[ "${USB:-}" != "qemu-xhci"* ]]; then file="$STORAGE/windows.usb" - echo "$USB" > "$file" - ! setOwner "$file" && error "Failed to set the owner for \"$file\" !" + writeFile "$USB" "$file" fi if [ -n "${DISK_TYPE:-}" ] && [[ "${DISK_TYPE:-}" != "scsi" ]]; then file="$STORAGE/windows.type" - echo "$DISK_TYPE" > "$file" - ! setOwner "$file" && error "Failed to set the owner for \"$file\" !" + writeFile "$DISK_TYPE" "$file" fi if [ -n "${ADAPTER:-}" ] && [[ "${ADAPTER:-}" != "virtio-net-pci" ]]; then file="$STORAGE/windows.net" - echo "$ADAPTER" > "$file" - ! setOwner "$file" && error "Failed to set the owner for \"$file\" !" + writeFile "$ADAPTER" "$file" fi rm -rf "$TMP" From 036a8ee6619acf95fd4a5c264a6672b893191399 Mon Sep 17 00:00:00 2001 From: Kroese Date: Wed, 22 Oct 2025 09:44:11 +0200 Subject: [PATCH 5/5] Update install.sh --- src/install.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/install.sh b/src/install.sh index d269f7e..6b26a5f 100644 --- a/src/install.sh +++ b/src/install.sh @@ -450,6 +450,8 @@ extractESD() { error "Adding WinPE failed ($retVal)" && return 1 } + fKill "progress.sh" + local msg="Extracting $desc setup" info "$msg..."