Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tools: Align AGENT_POLICY_FILE check in rootfs-builder with upstream #244

Merged
merged 4 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion tools/osbuilder/node-builder/azure-linux/uvm_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@ IGVM_SVN=${IGVM_SVN:-0}
script_dir="$(dirname $(readlink -f $0))"
repo_dir="${script_dir}/../../../../"

agent_policy_file_abs="${repo_dir}/src/kata-opa/${AGENT_POLICY_FILE}"

common_file="common.sh"
source "${common_file}"

# This ensures that a pre-built agent binary is being injected into the rootfs
rootfs_make_flags="AGENT_SOURCE_BIN=${AGENT_INSTALL_DIR}/usr/bin/kata-agent"

if [ "${CONF_PODS}" == "yes" ]; then
rootfs_make_flags+=" AGENT_POLICY=yes CONF_GUEST=yes AGENT_POLICY_FILE=${AGENT_POLICY_FILE}"
rootfs_make_flags+=" AGENT_POLICY=yes CONF_GUEST=yes AGENT_POLICY_FILE=${agent_policy_file_abs}"
fi

if [ "${CONF_PODS}" == "yes" ]; then
Expand Down
11 changes: 7 additions & 4 deletions tools/osbuilder/rootfs-builder/rootfs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@ LIBC=${LIBC:-musl}
SECCOMP=${SECCOMP:-"yes"}
SELINUX=${SELINUX:-"no"}
AGENT_POLICY=${AGENT_POLICY:-no}
AGENT_POLICY_FILE=${AGENT_POLICY_FILE:-"allow-all.rego"}

lib_file="${script_dir}/../scripts/lib.sh"
source "$lib_file"

[ "${AGENT_POLICY}" == "yes" ] && agent_policy_file="$(readlink -f "${script_dir}/../../../src/kata-opa/${AGENT_POLICY_FILE}")"
if [[ "${AGENT_POLICY}" == "yes" ]]; then
agent_policy_file="$(readlink -f -v "${AGENT_POLICY_FILE:-"${script_dir}/../../../src/kata-opa/allow-all.rego"}")"
fi

#For cross build
CROSS_BUILD=${CROSS_BUILD:-false}
Expand Down Expand Up @@ -330,7 +331,9 @@ check_env_variables()

[ -n "${KERNEL_MODULES_DIR}" ] && [ ! -d "${KERNEL_MODULES_DIR}" ] && die "KERNEL_MODULES_DIR defined but is not an existing directory"

[ "${AGENT_POLICY}" == "yes" ] && [ ! -f "${agent_policy_file}" ] && die "agent policy file not found in '${agent_policy_file}'"
if [[ "${AGENT_POLICY}" == "yes" ]]; then
[ ! -f "${agent_policy_file}" ] && die "agent policy file not found in '${agent_policy_file}'"
fi

[ -n "${OSBUILDER_VERSION}" ] || die "need osbuilder version"
}
Expand Down Expand Up @@ -652,7 +655,7 @@ EOF
chmod g+rx,o+x "${ROOTFS_DIR}"
fi

if [ "${AGENT_POLICY}" == "yes" ]; then
if [[ "${AGENT_POLICY}" == "yes" ]]; then
# Install default settings for the kata-opa service.
local opa_settings_dir="/etc/kata-opa"
local policy_file_name="$(basename ${agent_policy_file})"
Expand Down
Loading