Unverified Commit 62c1e4a5 authored by Kroese's avatar Kroese Committed by GitHub
Browse files

fix: Inherit owner from parent folder (#951)

parent 686fe351
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -79,12 +79,14 @@ case "${BOOT_MODE,,}" in
        /run/utk.bin "$OVMF/$ROM" replace_ffs LogoDXE "/var/www/img/${PROCESS,,}.ffs" save "$DEST.tmp"
      fi
      mv "$DEST.tmp" "$DEST.rom"
      ! setOwner "$DEST.rom" && error "Failed to set the owner for \"$DEST.rom\" !"
    fi

    if [ ! -s "$DEST.vars" ] || [ ! -f "$DEST.vars" ]; then
      [ ! -s "$OVMF/$VARS" ] || [ ! -f "$OVMF/$VARS" ]&& error "UEFI vars file ($OVMF/$VARS) not found!" && exit 45
      cp "$OVMF/$VARS" "$DEST.tmp"
      mv "$DEST.tmp" "$DEST.vars"
      ! setOwner "$DEST.vars" && error "Failed to set the owner for \"$DEST.vars\" !"
    fi

    if [[ "${BOOT_MODE,,}" == "secure" || "${BOOT_MODE,,}" == "windows_secure" ]]; then
+11 −0
Original line number Diff line number Diff line
@@ -586,6 +586,17 @@ addDisk () {

  fi

  if [ -f "$DISK_FILE" ]; then

    uid=$(stat -c '%u' "$DIR")
    gid=$(stat -c '%g' "$DIR")

    if ! chown "$uid:$gid" "$DISK_FILE"; then
      error "Failed to set the owner for \"$DISK_FILE\" !"
    fi

  fi

  DISK_OPTS+=$(createDevice "$DISK_FILE" "$DISK_TYPE" "$DISK_INDEX" "$DISK_ADDRESS" "$DISK_FMT" "$DISK_IO" "$DISK_CACHE" "" "")

  return 0
+12 −2
Original line number Diff line number Diff line
@@ -366,7 +366,9 @@ if [[ "${BOOT,,}" != "http"* ]]; then
  error "Invalid BOOT value specified, \"$BOOT\" is not a valid URL!" && exit 64
fi

mkdir -p "$STORAGE"
if ! makeDir "$STORAGE"; then
  error "Failed to create directory \"$STORAGE\" !" && exit 33
fi

find "$STORAGE" -maxdepth 1 -type f \( -iname '*.rom' -or -iname '*.vars' \) -delete
find "$STORAGE" -maxdepth 1 -type f \( -iname 'data.*' -or -iname 'qemu.*' \) -delete
@@ -410,7 +412,11 @@ case "${base,,}" in

    tmp="$STORAGE/extract"
    rm -rf "$tmp"
    mkdir -p "$tmp"

    if ! makeDir "$tmp"; then
      error "Failed to create directory \"$tmp\" !" && exit 33
    fi

    7z x "$STORAGE/$base" -o"$tmp" > /dev/null

    rm -f "$STORAGE/$base"
@@ -429,6 +435,8 @@ esac

case "${base,,}" in
  *".iso" | *".img" | *".raw" | *".qcow2" )

    ! setOwner "$STORAGE/$base" && error "Failed to set the owner for \"$STORAGE/$base\" !"
    detectType "$STORAGE/$base" && return 0
    error "Cannot read file \"${base}\"" && exit 63 ;;
esac
@@ -451,6 +459,8 @@ dst="$STORAGE/${base%.*}.$target_ext"
! convertImage "$STORAGE/$base" "$source_fmt" "$dst" "$target_fmt" && exit 35

base=$(basename "$dst")

! setOwner "$STORAGE/$base" && error "Failed to set the owner for \"$STORAGE/$base\" !"
detectType "$STORAGE/$base" && return 0
error "Cannot convert file \"${base}\"" && exit 36

+7 −1
Original line number Diff line number Diff line
@@ -390,7 +390,12 @@ configurePasst() {

  PASST_OPTS+=" -H $VM_NET_HOST"
  PASST_OPTS+=" -M $GATEWAY_MAC"
  PASST_OPTS+=" --runas $UID:$GID"

  local uid gid
  uid=$(id -u)
  gid=$(id -g)
  PASST_OPTS+=" --runas $uid:$gid"

  PASST_OPTS+=" -P /var/run/passt.pid"
  PASST_OPTS+=" -l $log"
  PASST_OPTS+=" -q"
@@ -767,6 +772,7 @@ getInfo() {
      # Generate MAC address based on Docker container ID in hostname
      MAC=$(echo "$HOST" | md5sum | sed 's/^\(..\)\(..\)\(..\)\(..\)\(..\).*$/02:\1:\2:\3:\4:\5/')
      echo "${MAC^^}" > "$file"
      ! setOwner "$file" && error "Failed to set the owner for \"$file\" !"
    fi
  fi

+1 −2
Original line number Diff line number Diff line
@@ -79,8 +79,7 @@ fi

# Check folder

if [[ "${COMMIT:-}" == [Yy1]* ]]; then
  STORAGE="/local"
if [[ "${STORAGE,,}" != "/storage" ]]; then
  mkdir -p "$STORAGE"
fi

Loading