Skip to content

Commit bca4212

Browse files
authored
Merge pull request #443 from snir911/cloud-init
podvm: disable cloud-init unsafe modules for CoCo
2 parents dfd0073 + 1b74591 commit bca4212

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

Diff for: config/peerpods/podvm/lib.sh

+34
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,11 @@ function prepare_source_code() {
229229
create_overlay_mount_unit
230230
fi
231231

232+
# disable ssh and unsafe cloud-init modules
233+
if [[ "$CONFIDENTIAL_COMPUTE_ENABLED" == "yes" ]] || [[ -n "$CUSTOM_CLOUD_INIT_MODULES" ]]; then
234+
[[ "$CUSTOM_CLOUD_INIT_MODULES" != "no" ]] && [[ "$CLOUD_PROVIDER" != "libvirt" ]] && set_custom_cloud_init_modules
235+
fi
236+
232237
# Validate and copy HKD for IBM Z Secure Enablement
233238
if [[ "$SE_BOOT" == "true" ]]; then
234239
if [[ -z "$HOST_KEY_CERTS" ]]; then
@@ -306,6 +311,35 @@ function extract_container_image() {
306311

307312
}
308313

314+
# These are cloud-init modules we allow for the CoCo case, it's mostly used to disable ssh
315+
# and other unsafe modules
316+
function set_custom_cloud_init_modules() {
317+
local cfg_file="${podvm_dir}/files/etc/cloud/cloud.cfg.d/99_coco_only_allow.cfg"
318+
mkdir -p $(dirname "${cfg_file}")
319+
cat <<EOF >"${cfg_file}"
320+
cloud_init_modules:
321+
- migrator
322+
- set_hostname
323+
- update_hostname
324+
325+
cloud_config_modules:
326+
- locale
327+
- rh_subscription
328+
- ntp
329+
- timezone
330+
- disable_ec2_metadata
331+
332+
cloud_final_modules:
333+
#- reset_rmc # needed for ibm power?
334+
#- install_hotplug ?
335+
- phone_home
336+
- final_message
337+
- power_state_change
338+
EOF
339+
echo "sudo cp -a /tmp/files/etc/cloud/cloud.cfg.d/* /etc/cloud/cloud.cfg.d/" >> "${podvm_dir}"/qcow2/copy-files.sh
340+
echo "Inject cloud-init configuration file:" && cat "${cfg_file}"
341+
}
342+
309343
# Function to create overlay mount unit in the podvm files
310344
# this ensures rw (overlay) layer for the container images are in memory (encrypted)
311345
function create_overlay_mount_unit() {

0 commit comments

Comments
 (0)