From 01c502e1a1682b4d3c279dcd079e38e2d83a010f Mon Sep 17 00:00:00 2001 From: b1ackd0t <28790446+rodneyosodo@users.noreply.github.com> Date: Mon, 26 Aug 2024 18:19:47 +0300 Subject: [PATCH] NOISSUE - Fix Algo Path (#216) * fix(algorithm): fix running binary algorithm This is the error ``` "algorithm": executable file not found in $PATH ``` * fix(algorithm): get absolute filepath for all algorithms Signed-off-by: Rodney Osodo * fix(lint): fix linting errors * refactor: simplify algorithm filename Signed-off-by: Rodney Osodo --------- Signed-off-by: Rodney Osodo --- agent/service.go | 8 +++++++- hal/linux/README.md | 4 +++- hal/linux/board/cocos/linux.config | 2 +- hal/linux/configs/cocos_defconfig | 17 ++++++++--------- hal/linux/external.mk | 2 +- hal/linux/package/agent/Config.in | 6 +++--- hal/linux/package/agent/agent.mk | 2 +- 7 files changed, 24 insertions(+), 17 deletions(-) diff --git a/agent/service.go b/agent/service.go index 4c1b86ab..9ec81a48 100644 --- a/agent/service.go +++ b/agent/service.go @@ -10,6 +10,7 @@ import ( "fmt" "log/slog" "os" + "path/filepath" "slices" "github.com/google/go-sev-guest/client" @@ -118,7 +119,12 @@ func (as *agentService) Algo(ctx context.Context, algo Algorithm) error { return ErrHashMismatch } - f, err := os.Create("algorithm") + currentDir, err := os.Getwd() + if err != nil { + return fmt.Errorf("error getting current directory: %v", err) + } + + f, err := os.Create(filepath.Join(currentDir, "algorithm")) if err != nil { return fmt.Errorf("error creating algorithm file: %v", err) } diff --git a/hal/linux/README.md b/hal/linux/README.md index e6626be4..0208f8e3 100644 --- a/hal/linux/README.md +++ b/hal/linux/README.md @@ -1,7 +1,9 @@ # Hardware Abstraction Layer (HAL) for Confidential Computing -Cocos HAL for Linux is framework for building custom in-enclave Linux distribution. + +Cocos HAL for Linux is framework for building custom in-enclave Linux distribution. ## Usage + HAL uses [Buildroot](https://buildroot.org/)'s [_External Tree_ mechanism](https://buildroot.org/downloads/manual/manual.html#outside-br-custom) for building custom distro: ```bash diff --git a/hal/linux/board/cocos/linux.config b/hal/linux/board/cocos/linux.config index a9fc8f20..5c8c3aca 100644 --- a/hal/linux/board/cocos/linux.config +++ b/hal/linux/board/cocos/linux.config @@ -64,4 +64,4 @@ CONFIG_PREEMPT=n CONFIG_PREEMPT_DYNAMIC=n CONFIG_DEBUG_PREEMPT=n CONFIG_CGROUP_MISC=y -CONFIG_X86_CPUID=y \ No newline at end of file +CONFIG_X86_CPUID=y diff --git a/hal/linux/configs/cocos_defconfig b/hal/linux/configs/cocos_defconfig index 40f9ec06..73a443ee 100644 --- a/hal/linux/configs/cocos_defconfig +++ b/hal/linux/configs/cocos_defconfig @@ -45,13 +45,13 @@ BR2_PACKAGE_HOST_QEMU=y BR2_PACKAGE_HOST_QEMU_SYSTEM_MODE=y # Docker -BR2_PACKAGE_LIBSECCOMP_ARCH_SUPPORTS=y -BR2_PACKAGE_LIBSECCOMP=y -BR2_PACKAGE_CA_CERTIFICATES=y -BR2_PACKAGE_DOCKER_CLI=y -BR2_PACKAGE_DOCKER_COMPOSE=y -BR2_PACKAGE_DOCKER_ENGINE=y -BR2_PACKAGE_CONTAINERD=y +BR2_PACKAGE_LIBSECCOMP_ARCH_SUPPORTS=y +BR2_PACKAGE_LIBSECCOMP=y +BR2_PACKAGE_CA_CERTIFICATES=y +BR2_PACKAGE_DOCKER_CLI=y +BR2_PACKAGE_DOCKER_COMPOSE=y +BR2_PACKAGE_DOCKER_ENGINE=y +BR2_PACKAGE_CONTAINERD=y BR2_PACKAGE_RUNC=y BR2_PACKAGE_IPTABLES=y @@ -61,7 +61,7 @@ BR2_PACKAGE_PYTHON_PIP=y BR2_PACKAGE_BZIP2=y BR2_PACKAGE_XZ=y BR2_PACKAGE_ZIP=y -BR2_PACKAGE_PYTHON3_ZLIB=y +BR2_PACKAGE_PYTHON3_ZLIB=y BR2_PACKAGE_PYTHON3_XZ=y BR2_PACKAGE_PYTHON3_BZIP2=y BR2_INSTALL_LIBSTDCPP=y @@ -71,4 +71,3 @@ BR2_TOOLCHAIN_BUILDROOT_LIBSTDCPP=y BR2_PACKAGE_GCC=y BR2_PACKAGE_GCC_TARGET=y BR2_PACKAGE_LIBSTDCPP=y - diff --git a/hal/linux/external.mk b/hal/linux/external.mk index 361bdd25..0bfc533a 100644 --- a/hal/linux/external.mk +++ b/hal/linux/external.mk @@ -1 +1 @@ -include $(sort $(wildcard $(BR2_EXTERNAL_COCOS_PATH)/package/*/*.mk)) \ No newline at end of file +include $(sort $(wildcard $(BR2_EXTERNAL_COCOS_PATH)/package/*/*.mk)) diff --git a/hal/linux/package/agent/Config.in b/hal/linux/package/agent/Config.in index ed45cba0..ac8e5514 100644 --- a/hal/linux/package/agent/Config.in +++ b/hal/linux/package/agent/Config.in @@ -3,6 +3,6 @@ config BR2_PACKAGE_AGENT default y help Confidential Computing Agent is a state machine capable of - receiving datasets and algorithm, running computations, and - fetching the attestation report from within the - Confidential VM. \ No newline at end of file + receiving datasets and algorithm, running computations, and + fetching the attestation report from within the + Confidential VM. diff --git a/hal/linux/package/agent/agent.mk b/hal/linux/package/agent/agent.mk index 4cbd301a..8fa7c575 100644 --- a/hal/linux/package/agent/agent.mk +++ b/hal/linux/package/agent/agent.mk @@ -7,7 +7,7 @@ AGENT_VERSION = main AGENT_SITE = $(call github,ultravioletrs,cocos,$(AGENT_VERSION)) -define AGENT_BUILD_CMDS +define AGENT_BUILD_CMDS $(MAKE) -C $(@D) agent EMBED_ENABLED=$(AGENT_EMBED_ENABLED) endef