Skip to content

Commit

Permalink
qemu-secex: drop hardcoded 'secex-hostkey' name and inject user-provi…
Browse files Browse the repository at this point in the history
…ded file instead
  • Loading branch information
nikita-dubrovskii committed Nov 15, 2024
1 parent 979c3f4 commit 4cdb9b6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
12 changes: 9 additions & 3 deletions src/cmd-osbuild
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,20 @@ postprocess_qemu_secex() {
if [ ! -f "${hostkey}" ]; then
fatal "No hostkey and no genprotimgvm provided"
fi
ignition=$(mktemp -p "${tmp_builddir}")
butane -p -d "$(dirname "${hostkey}")" /usr/lib/coreos-assembler/secex-genprotimgvm-scripts/genprotimg.bu -o "${ignition}"
echo "Injecting user-provided hostkey into config"
ignition_cfg=$(mktemp -p "${tmp_builddir}")
butane_cfg=$(mktemp -p "${tmp_builddir}")
hostkey_name=$(basename "${hostkey}")
hostkey_path=$(dirname "${hostkey}")
cp /usr/lib/coreos-assembler/secex-genprotimgvm-scripts/genprotimg.bu "${butane_cfg}"
sed -i 's/HOSTKEY-FILE/'"${hostkey_name}"'/g' "${butane_cfg}"
butane -p -d "${hostkey_path}" "${butane_cfg}" -o "${ignition_cfg}"

cp "/srv/builds/latest/${basearch}/${name}-${build}-qemu.${basearch}.${suffix}" "${genprotimgvm}"
chmod +w "${genprotimgvm}"
genvm_args=("-drive" "if=none,id=hda,format=qcow2,file=${genprotimgvm},auto-read-only=off,cache=unsafe" \
"-device" "virtio-blk,drive=hda,bootindex=1")
kola qemuexec -i "${ignition}" -- "${genvm_args[@]}"
kola qemuexec -i "${ignition_cfg}" -- "${genvm_args[@]}"
fi
fi

Expand Down
2 changes: 1 addition & 1 deletion src/secex-genprotimgvm-scripts/genprotimg.bu
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ storage:
- path: /etc/se-hostkeys/ibm-z-hostkey-1
overwrite: true
contents:
local: secex-hostkey
local: HOSTKEY-FILE
- path: /usr/local/bin/do_genprotimg
overwrite: true
mode: 0755
Expand Down

0 comments on commit 4cdb9b6

Please sign in to comment.