Skip to content

Commit a8d87b9

Browse files
kata artifacts file permission fix (#8)
* fix kata artifact file permission and ownership Signed-off-by: Kumar, Anand <anand.kumar@intel.com>
1 parent b7c364b commit a8d87b9

6 files changed

Lines changed: 81 additions & 33 deletions

File tree

.github/workflows/post-merge-kata-deploy.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
uses: open-edge-platform/orch-ci/.github/workflows/post-merge.yml@main
1919
with:
2020
run_security_scans: true
21-
run_version_check: true
21+
run_version_check: false
2222
run_build: true
2323
run_docker_build: true
2424
run_docker_push: true

REUSE.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ path = [
3535
"venv/**",
3636
"**.zip",
3737
".gitattributes",
38-
"**.tar.gz"
38+
"**.tar.gz",
39+
"**/kata_keeplist.txt"
3940
]
4041
precedence = "aggregate"
4142
SPDX-FileCopyrightText = "2025 Intel Corporation"

helm/trustagent/values.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ config:
7575
# /opt/kata/bin/qemu-system-x86_64
7676
# /opt/kata/libexec/virtiofsd
7777
# /opt/kata/share/defaults/kata-containers/configuration-qemu.toml
78-
# /opt/kata/share/kata-containers/vmlinuz-6.12.19-1.emt3
78+
# /opt/kata/share/kata-containers/vmlinuz-6.12.20-1.emt3
7979
# /opt/kata/share/kata-containers/trusted-vm.img
8080
# /opt/kata/share/kata-qemu/qemu/bios-256k.bin
8181
# /opt/kata/share/kata-qemu/qemu/efi-virtio.rom

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: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +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"
37-
38-
39-
KATA_KEEPLIST_FILE_LIST=( "VERSION" "containerd-shim-kata-v2" "kata-agent-ctl" "kata-collect-data.sh" "kata-ctl" "kata-manager"
40-
"kata-manager.sh" "kata-monitor" "kata-runtime" "kata-trace-forwarder" "qemu-system-x86_64" "stratovirt" "fdt.h" "libfdt.h"
41-
"libfdt_env.h" "libfdt.a" "libfdt.pc" "virtiofsd" "oci_config.json" "configuration.toml" "configuration-qemu.toml"
42-
"genpolicy-settings.json" "rules.rego" "root_hash.txt" "bios-256k.bin" "efi-virtio.rom" "kvmvapic.bin" "linuxboot_dma.bin"
43-
"pvh.bin" "versions.yaml" )
44-
45-
KATA_DELETE_FILE_LIST=("runtime-rs" "share/defaults/kata-containers/runtime-rs" "share/kata-qemu/qemu/firmware" "share/kata-qemu-snp-experimental"
46-
"lib/kata-qemu-snp-experimental" "share/ovmf" )
36+
KATA_ARTIFACT_ROOTFS_NAME="kata-containers.img"
4737

4838
check_file_exists() {
4939
local file="${1}"
@@ -82,26 +72,12 @@ echo "INFO: Extracting Kata artifacts"
8272
mkdir -p "${KATA_ARTIFACT_DIR}"
8373
tar -xf "${KATA_ARTIFACT_FILE_NAME}" -C "${KATA_ARTIFACT_DIR}"
8474

85-
# Iterate over files and symlinks in the directory and remove the files not in the keeplist
86-
find "${KATA_ARTIFACT_DIR}" -type f -o -type l | while read -r item; do
87-
base_item=$(basename "$item")
88-
if [[ ! " ${KATA_KEEPLIST_FILE_LIST[@]} " =~ " ${base_item} " ]]; then
89-
#echo "INFO: Deleting: $item (not in keeplist)"
90-
rm -rf "$item"
91-
fi
92-
done
93-
94-
#iterate over the delete file list and remove the files
95-
pushd "${KATA_ARTIFACT_DIR}/opt/kata"
96-
for file in "${KATA_DELETE_FILE_LIST[@]}"; do
97-
echo "INFO: Removing ${file}"
98-
rm -rf "${file}"
99-
done
100-
popd
101-
10275
#check if the boot component directory exists
10376
check_dir_exists "${KATA_BOOT_COMPONENT_DIR}"
10477

78+
#create bm-agents group if it does not exist
79+
getent group bm-agents > /dev/null || groupadd -g 500 bm-agents
80+
10581
#copy edge microvisor kernel to the kata artifacts
10682
echo "INFO: Copying edge microvisor kernel to the Kata artifacts"
10783
cp "${EDGE_MICROVISOR_SRC}/${EDGE_MICROVISOR_KERNEL}" "${KATA_BOOT_COMPONENT_DIR}"
@@ -117,7 +93,29 @@ cp "${EDGE_MICROVISOR_SRC}/${EDGE_MICROVISOR_ROOTFS}" "${KATA_BOOT_COMPONENT_DIR
11793
#change symlink to point to the new kernel and rootfs
11894
echo "INFO: Change symlink to point to the new kernel and rootfs"
11995
ln -sf "${EDGE_MICROVISOR_KERNEL}" "${KATA_BOOT_COMPONENT_DIR}/${KATA_ARTIFACT_KERNEL_NAME}"
120-
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}"
97+
98+
# 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+
102+
pushd "${KATA_ARTIFACT_DIR}/opt/kata"
103+
for file in $(find . -type f -o -type d -o -type l | sed 's|^\./||'); do
104+
match=$(awk -v search="$file" '$0 ~ search { print $0; found=1; exit } END { if (!found) print ""; exit }' ../../../kata_keeplist.txt)
105+
if [[ -n "$match" ]]; then
106+
chown $(echo "$match" | awk '{print $2}') "$file"
107+
chmod $(echo "$match" | awk '{print $3}') "$file"
108+
else
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
117+
done
118+
popd
121119

122120
#retar the artifacts
123121
echo "INFO: Retar the artifacts"
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
bin root:bm-agents 750
2+
bin/containerd-shim-kata-v2 root:bm-agents 740
3+
bin/kata-agent-ctl root:root 700
4+
bin/kata-collect-data.sh root:root 700
5+
bin/kata-ctl root:root 700
6+
bin/kata-manager root:root 700
7+
bin/kata-manager.sh root:root 700
8+
bin/kata-monitor root:root 700
9+
bin/kata-runtime root:root 700
10+
bin/kata-trace-forwarder root:root 700
11+
bin/stratovirt root:root 700
12+
bin/qemu-system-x86_64 root:bm-agents 740
13+
include root:root 600
14+
include/libfdt_env.h root:root 600
15+
include/libfdt.h root:root 600
16+
include/fdt.h root:root 600
17+
lib root:root 600
18+
lib/kata-qemu root:root 600
19+
lib/kata-qemu/libfdt.a root:root 600
20+
lib/kata-qemu/pkgconfig root:root 600
21+
lib/kata-qemu/pkgconfig/libfdt.pc root:root 600
22+
libexec root:bm-agents 750
23+
libexec/virtiofsd root:bm-agents 740
24+
share root:bm-agents 750
25+
share/bash-completion root:root 700
26+
share/bash-completion/completions root:root 700
27+
share/bash-completion/completions/kata-runtime root:root 700
28+
share/defaults root:bm-agents 750
29+
share/defaults/kata-containers root:bm-agents 750
30+
share/defaults/kata-containers/rules.rego root:root 600
31+
share/defaults/kata-containers/genpolicy-settings.json root:root 600
32+
share/defaults/kata-containers/configuration-qemu.toml root:bm-agents 640
33+
share/defaults/kata-containers/agent-ctl root:root 600
34+
share/defaults/kata-containers/agent-ctl/oci_config.json 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
38+
share/kata-containers/root_hash.txt 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
48+
VERSION root:root 600
49+
versions.yaml root:root 600

0 commit comments

Comments
 (0)