Skip to content

Commit 6150a01

Browse files
qemu-secex: drop hardcoded 'secex-hostkey' name and inject user-provided file instead
1 parent d2d497a commit 6150a01

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/cmd-buildextend-metal

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,15 +236,22 @@ if [[ "${image_type}" == "qemu-secex" ]]; then
236236
fatal "No hostkey and no genprotimgvm provided"
237237
fi
238238
echo "Generating genprotimgvm locally"
239-
ignition=$(mktemp -p "${tmp_builddir}")
240-
butane -p -d "$(dirname "${hostkey}")" /usr/lib/coreos-assembler/secex-genprotimgvm-scripts/genprotimg.bu -o "${ignition}"
239+
ignition_cfg=$(mktemp -p "${tmp_builddir}")
240+
butane_cfg=$(mktemp -p "${tmp_builddir}")
241+
242+
echo "Inject user-provided hostkey into config"
243+
hostkey_name=$(basename "${hostkey}")
244+
hostkey_path=$(dirname "${hostkey}")
245+
cp /usr/lib/coreos-assembler/secex-genprotimgvm-scripts/genprotimg.bu "${butane_cfg}"
246+
sed -i 's/HOSTKEY-FILE/'"${hostkey_name}"'/g' "${butane_cfg}"
247+
butane -p -d "${hostkey_path}" "${butane_cfg}" -o "${ignition_cfg}"
241248

242249
genprotimgvm=/srv/fake-secure-vm.qcow2
243250
cp "/srv/builds/latest/${basearch}/${name}-${build}-qemu.${basearch}.${image_format}" "${genprotimgvm}"
244251
chmod +w "${genprotimgvm}"
245252
genvm_args=("-drive" "if=none,id=hda,file=${genprotimgvm},auto-read-only=off,cache=unsafe" \
246253
"-device" "virtio-blk,drive=hda,bootindex=1")
247-
kola qemuexec -i "${ignition}" -- "${genvm_args[@]}"
254+
kola qemuexec -i "${ignition_cfg}" -- "${genvm_args[@]}"
248255
fi
249256

250257
# Basic qemu args:

src/secex-genprotimgvm-scripts/genprotimg.bu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ storage:
1313
- path: /etc/se-hostkeys/ibm-z-hostkey-1
1414
overwrite: true
1515
contents:
16-
local: secex-hostkey
16+
local: HOSTKEY-FILE
1717
- path: /etc/do_genprotimg
1818
overwrite: true
1919
mode: 0755

0 commit comments

Comments
 (0)