Skip to content

Commit 97ae345

Browse files
committed
fix kata artifact file permission and ownership
1 parent bccee99 commit 97ae345

4 files changed

Lines changed: 41 additions & 30 deletions

File tree

REUSE.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ path = [
3636
"**.zip",
3737
".gitattributes",
3838
"**.tar.gz",
39-
"kata_keeplist.txt"
39+
"**/kata_keeplist.txt"
4040
]
4141
precedence = "aggregate"
4242
SPDX-FileCopyrightText = "2025 Intel Corporation"

trusted-workload/kata-deploy/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ all: build lint test
1515
build:
1616
@# Help: Runs build stage in all subprojects
1717
@echo "---MAKEFILE BUILD---"
18-
bash build-kata-deploy-image.sh
18+
sudo -E bash build-kata-deploy-image.sh
1919
@echo "---END MAKEFILE Build---"
2020

2121
clean:

trusted-workload/kata-deploy/build-kata-deploy-image.sh

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ KATA_ARTIFACT_NEW_NAME="kata-static.tar.xz"
3333
KATA_PATCH_DIR="patch/${KATA_CONTAINERS_TAG}"
3434
KATA_BOOT_COMPONENT_DIR="${KATA_ARTIFACT_DIR}/opt/kata/share/kata-containers"
3535
KATA_ARTIFACT_KERNEL_NAME="vmlinux.container"
36-
KATA_ARTIFACT_TOOTFS_NAME="kata-containers.img"
36+
KATA_ARTIFACT_ROOTFS_NAME="kata-containers.img"
3737

3838
check_file_exists() {
3939
local file="${1}"
@@ -75,6 +75,9 @@ tar -xf "${KATA_ARTIFACT_FILE_NAME}" -C "${KATA_ARTIFACT_DIR}"
7575
#check if the boot component directory exists
7676
check_dir_exists "${KATA_BOOT_COMPONENT_DIR}"
7777

78+
#create bm-agents group if it does not exist
79+
getent group bm-agents > /dev/null || groupadd -g 500 bm-agents
80+
7881
#copy edge microvisor kernel to the kata artifacts
7982
echo "INFO: Copying edge microvisor kernel to the Kata artifacts"
8083
cp "${EDGE_MICROVISOR_SRC}/${EDGE_MICROVISOR_KERNEL}" "${KATA_BOOT_COMPONENT_DIR}"
@@ -90,19 +93,27 @@ cp "${EDGE_MICROVISOR_SRC}/${EDGE_MICROVISOR_ROOTFS}" "${KATA_BOOT_COMPONENT_DIR
9093
#change symlink to point to the new kernel and rootfs
9194
echo "INFO: Change symlink to point to the new kernel and rootfs"
9295
ln -sf "${EDGE_MICROVISOR_KERNEL}" "${KATA_BOOT_COMPONENT_DIR}/${KATA_ARTIFACT_KERNEL_NAME}"
93-
ln -sf "${EDGE_MICROVISOR_ROOTFS}" "${KATA_BOOT_COMPONENT_DIR}/${KATA_ARTIFACT_TOOTFS_NAME}"
96+
ln -sf "${EDGE_MICROVISOR_ROOTFS}" "${KATA_BOOT_COMPONENT_DIR}/${KATA_ARTIFACT_ROOTFS_NAME}"
9497

9598
# Iterate over all files, directories, clean up unwanted files and directories and set permission and onwership
99+
chmod 750 "${KATA_ARTIFACT_DIR}/opt/kata"
100+
chown root:bm-agents "${KATA_ARTIFACT_DIR}/opt/kata"
101+
96102
pushd "${KATA_ARTIFACT_DIR}/opt/kata"
97103
for file in $(find . -type f -o -type d -o -type l | sed 's|^\./||'); do
98104
match=$(awk -v search="$file" '$0 ~ search { print $0; found=1; exit } END { if (!found) print ""; exit }' ../../../kata_keeplist.txt)
99105
if [[ -n "$match" ]]; then
100-
echo "INFO: Processing $file"
101-
chown $(echo "$match" | awk '{print $2}') "$file"
106+
chown $(echo "$match" | awk '{print $2}') "$file"
102107
chmod $(echo "$match" | awk '{print $3}') "$file"
103108
else
104-
[[ "$file" == *"$EDGE_MICROVISOR_KERNEL"* ]] && chown root:root "$file" && chmod 600 "$file" || rm -rf "$file"
105-
fi
109+
if [[ "$file" == *"$EDGE_MICROVISOR_KERNEL"* ]]; then
110+
chown root:bm-agents "$file" && chmod 640 "$file"
111+
elif [[ "$file" == *"$EDGE_MICROVISOR_KERNEL_CONFIG"* ]]; then
112+
chown root:root "$file" && chmod 600 "$file"
113+
else
114+
rm -rf "$file"
115+
fi
116+
fi
106117
done
107118
popd
108119

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
bin root:root 700
2-
bin/containerd-shim-kata-v2 root:root 700
1+
bin root:bm-agents 750
2+
bin/containerd-shim-kata-v2 root:bm-agents 740
33
bin/kata-agent-ctl root:root 700
44
bin/kata-collect-data.sh root:root 700
55
bin/kata-ctl root:root 700
@@ -9,7 +9,7 @@ bin/kata-monitor root:root 700
99
bin/kata-runtime root:root 700
1010
bin/kata-trace-forwarder root:root 700
1111
bin/stratovirt root:root 700
12-
bin/qemu-system-x86_64 root:root 700
12+
bin/qemu-system-x86_64 root:bm-agents 740
1313
include root:root 600
1414
include/libfdt_env.h root:root 600
1515
include/libfdt.h root:root 600
@@ -19,31 +19,31 @@ lib/kata-qemu root:root 600
1919
lib/kata-qemu/libfdt.a root:root 600
2020
lib/kata-qemu/pkgconfig root:root 600
2121
lib/kata-qemu/pkgconfig/libfdt.pc root:root 600
22-
libexec root:root 700
23-
libexec/virtiofsd root:root 700
24-
share root:root 700
22+
libexec root:bm-agents 750
23+
libexec/virtiofsd root:bm-agents 740
24+
share root:bm-agents 750
2525
share/bash-completion root:root 700
2626
share/bash-completion/completions root:root 700
2727
share/bash-completion/completions/kata-runtime root:root 700
28-
share/defaults root:root 600
29-
share/defaults/kata-containers root:root 600
28+
share/defaults root:bm-agents 750
29+
share/defaults/kata-containers root:bm-agents 750
3030
share/defaults/kata-containers/rules.rego root:root 600
3131
share/defaults/kata-containers/genpolicy-settings.json root:root 600
32-
share/defaults/kata-containers/configuration-qemu.toml root:root 600
32+
share/defaults/kata-containers/configuration-qemu.toml root:bm-agents 640
3333
share/defaults/kata-containers/agent-ctl root:root 600
3434
share/defaults/kata-containers/agent-ctl/oci_config.json root:root 600
35-
share/defaults/kata-containers/configuration.toml root:root 600
36-
share/kata-containers root:root 600
37-
share/kata-containers/trusted-vm.img root:root 600
35+
share/defaults/kata-containers/configuration.toml root:bm-agents 640
36+
share/kata-containers root:bm-agents 750
37+
share/kata-containers/trusted-vm.img root:bm-agents 640
3838
share/kata-containers/root_hash.txt root:root 600
39-
share/kata-containers/vmlinux.container root:root 600
40-
share/kata-containers/kata-containers.img root:root 600
41-
share/kata-qemu root:root 600
42-
share/kata-qemu/qemu root:root 600
43-
share/kata-qemu/qemu/pvh.bin root:root 600
44-
share/kata-qemu/qemu/kvmvapic.bin root:root 600
45-
share/kata-qemu/qemu/linuxboot_dma.bin root:root 600
46-
share/kata-qemu/qemu/bios-256k.bin root:root 600
47-
share/kata-qemu/qemu/efi-virtio.rom root:root 600
39+
share/kata-containers/vmlinux.container root:bm-agents 640
40+
share/kata-containers/kata-containers.img root:bm-agents 640
41+
share/kata-qemu root:bm-agents 750
42+
share/kata-qemu/qemu root:bm-agents 750
43+
share/kata-qemu/qemu/pvh.bin root:bm-agents 640
44+
share/kata-qemu/qemu/kvmvapic.bin root:bm-agents 640
45+
share/kata-qemu/qemu/linuxboot_dma.bin root:bm-agents 640
46+
share/kata-qemu/qemu/bios-256k.bin root:bm-agents 640
47+
share/kata-qemu/qemu/efi-virtio.rom root:bm-agents 640
4848
VERSION root:root 600
49-
versions.yaml root:root 600
49+
versions.yaml root:root 600

0 commit comments

Comments
 (0)