已合并
init tee client code #1
liuhao365创建于 9月17日
init tee client code #1
已合并
共 5 个文件变更+331-0
| @@ -0,0 +1,46 @@ | |||
| 1 | +From b0dfc0b2a86512fd2e6dfd131edd52af6087a5a4 Mon Sep 17 00:00:00 2001 | ||
| 2 | +From: root <root@localhost.localdomain> | ||
| 3 | +Date: Sat, 18 Jul 2026 16:29:16 +0800 | ||
| 4 | +Subject: [PATCH 1/2] add vm uid in TC_NS_ClientContext | ||
| 5 | + | ||
| 6 | +Signed-off-by: liuhao365 <liuhao365@h-partners.com> | ||
| 7 | +--- | ||
| 8 | + Makefile | 2 ++ | ||
| 9 | + src/inc/tc_ns_client.h | 3 +++ | ||
| 10 | + 2 files changed, 5 insertions(+) | ||
| 11 | + | ||
| 12 | +diff --git a/Makefile b/Makefile | ||
| 13 | +index d0f39e0..18421b4 100644 | ||
| 14 | +--- a/Makefile | ||
| 15 | ++++ b/Makefile | ||
| 16 | +@@ -9,11 +9,13 @@ TARGET_AGENTD := agentd | ||
| 17 | + WITH_CONFIDENTIAL_CONTAINER ?= true | ||
| 18 | + CROSS_DOMAIN_PERF := y | ||
| 19 | + CONFIG_TA_GET_CA_CMDLINE := n | ||
| 20 | ++CONFIG_VM_DEPLOY ?= y | ||
| 21 | + | ||
| 22 | + COMMON_CFLAGS := | ||
| 23 | + ifeq ($(WITH_CONFIDENTIAL_CONTAINER), true) | ||
| 24 | + COMMON_CFLAGS += -DCONFIG_PATH_NAMED_SOCKET=\"/var/itrustee/teecd/teecd.sock\" | ||
| 25 | + endif | ||
| 26 | ++COMMON_CFLAGS += -DCONFIG_VM_DEPLOY | ||
| 27 | + | ||
| 28 | + ifeq ($(TOOL_CHAIN),1) | ||
| 29 | + CC := aarch64-linux-gnu-gcc | ||
| 30 | +diff --git a/src/inc/tc_ns_client.h b/src/inc/tc_ns_client.h | ||
| 31 | +index 9608482..761a618 100644 | ||
| 32 | +--- a/src/inc/tc_ns_client.h | ||
| 33 | ++++ b/src/inc/tc_ns_client.h | ||
| 34 | +@@ -83,6 +83,9 @@ typedef struct { | ||
| 35 | + uint32_t file_h_addr; | ||
| 36 | + } memref; | ||
| 37 | + }; | ||
| 38 | ++#ifdef CONFIG_VM_DEPLOY | ||
| 39 | ++ unsigned int vm_uid; | ||
| 40 | ++#endif | ||
| 41 | + } TC_NS_ClientContext; | ||
| 42 | + | ||
| 43 | + typedef struct { | ||
| 44 | +-- | ||
| 45 | +2.33.0 | ||
| 46 | + | ||
| @@ -0,0 +1,194 @@ | |||
| 1 | +From 9d313e3b35110e3fa722d9ccd0836fd1cbd08d42 Mon Sep 17 00:00:00 2001 | ||
| 2 | +From: liuhao365 <liuhao365@h-partners.com> | ||
| 3 | +Date: Thu, 17 Sep 2026 16:44:33 +0800 | ||
| 4 | +Subject: [PATCH 2/2] support rpmbuild for src openeuler | ||
| 5 | + | ||
| 6 | +--- | ||
| 7 | + Makefile | 27 +++++---------------------- | ||
| 8 | + rpm-extra/teec.conf | 7 +++++++ | ||
| 9 | + rpm-extra/teecd.service | 12 ++++++++++++ | ||
| 10 | + rpm-extra/teecd.sh | 31 +++++++++++++++++++++++++++++++ | ||
| 11 | + 4 files changed, 55 insertions(+), 22 deletions(-) | ||
| 12 | + create mode 100644 rpm-extra/teec.conf | ||
| 13 | + create mode 100644 rpm-extra/teecd.service | ||
| 14 | + create mode 100644 rpm-extra/teecd.sh | ||
| 15 | + | ||
| 16 | +diff --git a/Makefile b/Makefile | ||
| 17 | +index 18421b4..67b8775 100644 | ||
| 18 | +--- a/Makefile | ||
| 19 | ++++ b/Makefile | ||
| 20 | +@@ -1,7 +1,6 @@ | ||
| 21 | + TARGET_LIB := libteec.so | ||
| 22 | + TARGET_APP := teecd | ||
| 23 | + TARGET_DIR := dist | ||
| 24 | +-LIBC_SEC := libboundscheck | ||
| 25 | + TARGET_LOG := tlogcat | ||
| 26 | + TARGET_LIBSEC := libboundscheck.so | ||
| 27 | + TARGET_TEE_TELEPORT := tee_teleport | ||
| 28 | +@@ -26,8 +25,7 @@ endif | ||
| 29 | + export CC | ||
| 30 | + export LD | ||
| 31 | + | ||
| 32 | +-all: $(TARGET_LIBSEC) $(TARGET_LIB) $(TARGET_APP) $(TARGET_LOG) $(TARGET_TEE_TELEPORT) $(TARGET_AGENTD) | ||
| 33 | +- @cd $(LIBC_SEC) && $(MAKE) clean | ||
| 34 | ++all: $(TARGET_LIB) $(TARGET_APP) $(TARGET_LOG) $(TARGET_TEE_TELEPORT) $(TARGET_AGENTD) | ||
| 35 | + | ||
| 36 | + install: | ||
| 37 | + [ -d "/usr/bin" ] && cp -f $(TARGET_DIR)/$(TARGET_APP) /usr/bin | ||
| 38 | +@@ -36,7 +34,6 @@ install: | ||
| 39 | + [ ! -d "/usr/lib64" ] && mkdir -p /usr/lib64 || true | ||
| 40 | + cp -f $(TARGET_DIR)/$(TARGET_LIB) /usr/lib64 # only for secgear | ||
| 41 | + [ -d "/lib64" ] && cp -f $(TARGET_DIR)/$(TARGET_LIB) /lib64 | ||
| 42 | +- [ -d "/lib64" ] && cp -f $(TARGET_DIR)/$(TARGET_LIBSEC) /lib64 | ||
| 43 | + | ||
| 44 | + install-container: | ||
| 45 | + [ -d "/usr/bin" ] && cp -f $(TARGET_DIR)/$(TARGET_LOG) /usr/bin | ||
| 46 | +@@ -46,10 +43,8 @@ install-container: | ||
| 47 | + cp -f $(TARGET_DIR)/$(TARGET_LIB) /usr/lib64 # only for secgear | ||
| 48 | + if [ -d "/lib/aarch64-linux-gnu" ]; then \ | ||
| 49 | + cp -f $(TARGET_DIR)/$(TARGET_LIB) /lib/aarch64-linux-gnu; \ | ||
| 50 | +- cp -f $(TARGET_DIR)/$(TARGET_LIBSEC) /lib/aarch64-linux-gnu; \ | ||
| 51 | + elif [ -d "/usr/local/lib" ]; then \ | ||
| 52 | + cp -f $(TARGET_DIR)/$(TARGET_LIB) /usr/local/lib; \ | ||
| 53 | +- cp -f $(TARGET_DIR)/$(TARGET_LIBSEC) /usr/local/lib; \ | ||
| 54 | + else \ | ||
| 55 | + echo "Not found ld library path"; \ | ||
| 56 | + fi | ||
| 57 | +@@ -72,18 +67,11 @@ endif | ||
| 58 | + | ||
| 59 | + LIB_OBJECTS := $(LIB_SOURCES:.c=.o) | ||
| 60 | + | ||
| 61 | +-$(TARGET_LIBSEC): | ||
| 62 | +- @echo "compile libboundscheck" | ||
| 63 | +- @$(MAKE) -C $(LIBC_SEC) | ||
| 64 | +- @echo "after compile libboundscheck" | ||
| 65 | +- | ||
| 66 | +- | ||
| 67 | +-$(TARGET_LIB):$(TARGET_LIBSEC) $(LIB_SOURCES) | ||
| 68 | ++$(TARGET_LIB): $(LIB_SOURCES) | ||
| 69 | + @echo "compile libteec.so" | ||
| 70 | + @$(CC) $(LIB_CFLAGS) -o $@ $(LIB_SOURCES) $(LIB_LDFLAGS) | ||
| 71 | + @mkdir -p $(TARGET_DIR) | ||
| 72 | + @mv libteec.so $(TARGET_DIR) | ||
| 73 | +- @cp $(LIBC_SEC)/lib/libboundscheck.so $(TARGET_DIR) | ||
| 74 | + @echo "after compile libteec.so" | ||
| 75 | + | ||
| 76 | + APP_CFLAGS := $(COMMON_CFLAGS) -DSEC_STORAGE_DATA_KUNPENG_PATH -D_GNU_SOURCE | ||
| 77 | +@@ -120,7 +108,7 @@ APP_SOURCES := src/teecd/teecd.c \ | ||
| 78 | + | ||
| 79 | + APP_OBJECTS := $(APP_SOURCES:.c=.o) | ||
| 80 | + | ||
| 81 | +-$(TARGET_APP): $(TARGET_LIBSEC) $(APP_SOURCES) | ||
| 82 | ++$(TARGET_APP): $(APP_SOURCES) | ||
| 83 | + @echo "compile teed" | ||
| 84 | + @$(CC) $(APP_CFLAGS) -o $@ $(APP_SOURCES) $(APP_LDFLAGS) | ||
| 85 | + @mkdir -p $(TARGET_DIR) | ||
| 86 | +@@ -202,7 +190,7 @@ LOG_CFLAGS += -Werror -Wall -Wextra -fstack-protector-all -Wl,-z,relro,-z,now,-z | ||
| 87 | + LOG_CFLAGS += -Iinclude -Iinclude/cloud -Iext_include -Ilibboundscheck/include -Iinclude -Isrc/inc -Isrc/tlogcat/ -Isrc/common | ||
| 88 | + LOG_LDFLAGS += -lboundscheck -Llibboundscheck/lib -lz | ||
| 89 | + LOG_OBJECTS := $(LOG_SOURCES:.c=.o) | ||
| 90 | +-$(TARGET_LOG): $(TARGET_LIBSEC) $(LOG_SOURCES) | ||
| 91 | ++$(TARGET_LOG): $(LOG_SOURCES) | ||
| 92 | + @echo "compile tlogcat" | ||
| 93 | + @echo "TEE_LOG_PATH_BASE is $(TEE_LOG_PATH_BASE)" | ||
| 94 | + @$(CC) $(LOG_CFLAGS) -o $@ $(LOG_SOURCES) $(LOG_LDFLAGS) | ||
| 95 | +@@ -210,10 +198,6 @@ $(TARGET_LOG): $(TARGET_LIBSEC) $(LOG_SOURCES) | ||
| 96 | + @mv tlogcat $(TARGET_DIR) | ||
| 97 | + @echo "after compile tlogcat" | ||
| 98 | + | ||
| 99 | +-clean: | ||
| 100 | +- @cd $(LIBC_SEC) && $(MAKE) clean | ||
| 101 | +- @rm -rf $(TARGET_DIR) | ||
| 102 | +- | ||
| 103 | + ############################# | ||
| 104 | + ## tee_teleport | ||
| 105 | + ############################# | ||
| 106 | +@@ -229,7 +213,7 @@ TEE_TELEPORT_CFLAGS += -Iinclude -Iinclude/cloud -Isrc/libteec_vendor -Iext_incl | ||
| 107 | + TEE_TELEPORT_CFLAGS += -Ilibboundscheck/include -Iinclude -Isrc/inc -Isrc/tee_teleport -Isrc/common -Isrc/authentication | ||
| 108 | + TEE_TELEPORT_CFLAGS += -DCONFIG_KUNPENG_PLATFORM -DCONFIG_TEE_TELEPORT_SUPPORT | ||
| 109 | + TEE_TELEPORT_LDFLAGS += $(LD_CFLAGS) -Llibboundscheck/lib -L$(TARGET_DIR) -lboundscheck -lteec -lpthread | ||
| 110 | +-$(TARGET_TEE_TELEPORT): $(TARGET_LIBSEC) $(TARGET_LIB) | ||
| 111 | ++$(TARGET_TEE_TELEPORT): $(TARGET_LIB) | ||
| 112 | + @echo "compile tee_teleport" | ||
| 113 | + @$(CC) $(TEE_TELEPORT_CFLAGS) -o $@ $(TEE_TELEPORT_SOURCES) $(TEE_TELEPORT_LDFLAGS) | ||
| 114 | + @mkdir -p $(TARGET_DIR) | ||
| 115 | +@@ -237,5 +221,4 @@ $(TARGET_TEE_TELEPORT): $(TARGET_LIBSEC) $(TARGET_LIB) | ||
| 116 | + @echo "after compile tee_teleport" | ||
| 117 | + | ||
| 118 | + clean: | ||
| 119 | +- @cd $(LIBC_SEC) && $(MAKE) clean | ||
| 120 | + @rm -rf $(TARGET_DIR) | ||
| 121 | +diff --git a/rpm-extra/teec.conf b/rpm-extra/teec.conf | ||
| 122 | +new file mode 100644 | ||
| 123 | +index 0000000..b9ffb8e | ||
| 124 | +--- /dev/null | ||
| 125 | ++++ b/rpm-extra/teec.conf | ||
| 126 | +@@ -0,0 +1,7 @@ | ||
| 127 | ++# teec.conf - TEE Client Configuration | ||
| 128 | ++# | ||
| 129 | ++# load mod configuration for TEE client | ||
| 130 | ++# 1 = Container | ||
| 131 | ++# 2 = Virtual Machine (default) | ||
| 132 | ++ | ||
| 133 | ++load_mode = 2 | ||
| 134 | + | ||
| 135 | +diff --git a/rpm-extra/teecd.service b/rpm-extra/teecd.service | ||
| 136 | +new file mode 100644 | ||
| 137 | +index 0000000..c11a687 | ||
| 138 | +--- /dev/null | ||
| 139 | ++++ b/rpm-extra/teecd.service | ||
| 140 | +@@ -0,0 +1,12 @@ | ||
| 141 | ++[Unit] | ||
| 142 | ++Description=itrustee client Service | ||
| 143 | ++ | ||
| 144 | ++[Service] | ||
| 145 | ++Type=simple | ||
| 146 | ++ExecStart=/usr/bin/teecd.sh | ||
| 147 | ++Restart=always | ||
| 148 | ++RestartSec=3 | ||
| 149 | ++User=root | ||
| 150 | ++ | ||
| 151 | ++[Install] | ||
| 152 | ++WantedBy=multi-user.target | ||
| 153 | + | ||
| 154 | +diff --git a/rpm-extra/teecd.sh b/rpm-extra/teecd.sh | ||
| 155 | +new file mode 100644 | ||
| 156 | +index 0000000..e4db840 | ||
| 157 | +--- /dev/null | ||
| 158 | ++++ b/rpm-extra/teecd.sh | ||
| 159 | +@@ -0,0 +1,31 @@ | ||
| 160 | ++#!/bin/bash | ||
| 161 | ++# Copyright (c) Huawei Technologies Co., Ltd. 2026-2026. All rights reserved. | ||
| 162 | ++# build rpms for itrustee client | ||
| 163 | ++set -eu | ||
| 164 | ++ | ||
| 165 | ++ | ||
| 166 | ++# Parse load_mode from teec.conf | ||
| 167 | ++CONFIG_FILE="/etc/teec.conf" | ||
| 168 | ++load_mode=2 # default value | ||
| 169 | ++ | ||
| 170 | ++if [ -f "$CONFIG_FILE" ]; then | ||
| 171 | ++ parsed_mode=$(grep -E '^\s*load_mode\s*=' "$CONFIG_FILE" | sed 's/.*=\s*//' | tr -d '[:space:]' ) | ||
| 172 | ++ if [ -n "$parsed_mode" ] && { [ "$parsed_mode" = "1" ] || [ "$parsed_mode" = "2" ]; }; then | ||
| 173 | ++ load_mode=$parsed_mode | ||
| 174 | ++ fi | ||
| 175 | ++fi | ||
| 176 | ++ | ||
| 177 | ++if [ $(systemd-detect-virt) = "none" ]; then | ||
| 178 | ++ driver_args=(tzdriver load_mode=$load_mode) | ||
| 179 | ++else | ||
| 180 | ++ driver_args=(vtzdriver) | ||
| 181 | ++fi | ||
| 182 | ++ | ||
| 183 | ++/sbin/modprobe vhost_vsock || true | ||
| 184 | ++ | ||
| 185 | ++if ! /sbin/modprobe "${driver_args[@]}" 2>/dev/null; then | ||
| 186 | ++ echo "failed to load ${driver_args[0]}" | ||
| 187 | ++ exit 1 | ||
| 188 | ++fi | ||
| 189 | ++ | ||
| 190 | ++exec /usr/bin/teecd | ||
| 191 | + | ||
| 192 | +-- | ||
| 193 | +2.33.0 | ||
| 194 | + | ||
Binary files do not support preview
| @@ -0,0 +1,88 @@ | |||
| 1 | +Name: tee_client | ||
| 2 | +Version: 1.0.0 | ||
| 3 | +Release: 1%{?dist} | ||
| 4 | +Group: System Environment/Daemons | ||
| 5 | +Summary: itrustee daemon and libraries | ||
| 6 | +License: GPLv3 | ||
| 7 | +URL: https://gitee.com/openeuler/itrustee_client | ||
| 8 | +Source0: itrustee_client.tar.gz | ||
| 9 | + | ||
| 10 | +ExclusiveArch: aarch64 | ||
| 11 | + | ||
| 12 | +Provides: libteec.so()(64bit) | ||
| 13 | + | ||
| 14 | +%{?systemd_requires} | ||
| 15 | +BuildRequires: systemd | ||
| 16 | +BuildRequires: gcc | ||
| 17 | +BuildRequires: patch | ||
| 18 | +BuildRequires: make | ||
| 19 | +BuildRequires: libboundscheck | ||
| 20 | +BuildRequires: zlib-devel | ||
| 21 | + | ||
| 22 | +Patch1: 0001-add-vm-uid-in-TC_NS_ClientContext.patch | ||
| 23 | +Patch2: 0002-support-rpmbuild-for-src-openeuler.patch | ||
| 24 | + | ||
| 25 | +%global debug_package %{nil} | ||
| 26 | + | ||
| 27 | +%description | ||
| 28 | +tee_client provides the iTrustee client daemon and libraries. | ||
| 29 | +It includes teecd daemon, tee_teleport, agentd, tlogcat tools | ||
| 30 | +and the libteec.so library used by TEE client applications. | ||
| 31 | + | ||
| 32 | +%prep | ||
| 33 | +%autosetup -n itrustee_client -p1 | ||
| 34 | + | ||
| 35 | +%build | ||
| 36 | +make %{?_smp_mflags} | ||
| 37 | + | ||
| 38 | +%install | ||
| 39 | +rm -rf %{buildroot} | ||
| 40 | +mkdir -p %{buildroot}%{_bindir} | ||
| 41 | +mkdir -p %{buildroot}%{_libdir} | ||
| 42 | +mkdir -p %{buildroot}%{_unitdir} | ||
| 43 | +mkdir -p %{buildroot}%{_sysconfdir} | ||
| 44 | + | ||
| 45 | +install -m 0500 dist/teecd %{buildroot}%{_bindir}/ | ||
| 46 | +install -m 0755 dist/tee_teleport %{buildroot}%{_bindir}/ | ||
| 47 | +install -m 0755 dist/agentd %{buildroot}%{_bindir}/ | ||
| 48 | +install -m 0755 dist/tlogcat %{buildroot}%{_bindir}/ | ||
| 49 | +install -m 0644 dist/libteec.so %{buildroot}%{_libdir}/ | ||
| 50 | + | ||
| 51 | +install -m 0755 rpm-extra/teecd.sh %{buildroot}%{_bindir}/ | ||
| 52 | +install -m 0644 rpm-extra/teecd.service %{buildroot}%{_unitdir}/teecd.service | ||
| 53 | +install -m 0644 rpm-extra/teec.conf %{buildroot}%{_sysconfdir}/teec.conf | ||
| 54 | + | ||
| 55 | +%post | ||
| 56 | +/sbin/ldconfig | ||
| 57 | +systemctl daemon-reload || : | ||
| 58 | +systemctl enable teecd.service || : | ||
| 59 | +systemctl start teecd.service || : | ||
| 60 | + | ||
| 61 | +%preun | ||
| 62 | +if [ $1 -eq 0 ]; then | ||
| 63 | + systemctl disable teecd.service || : | ||
| 64 | + systemctl stop teecd.service || : | ||
| 65 | +fi | ||
| 66 | + | ||
| 67 | +%postun | ||
| 68 | +if [ $1 -eq 0 ]; then | ||
| 69 | + systemctl daemon-reload || : | ||
| 70 | +fi | ||
| 71 | + | ||
| 72 | +%files | ||
| 73 | +%defattr(-,root,root,-) | ||
| 74 | +%{_bindir}/teecd | ||
| 75 | +%{_bindir}/tee_teleport | ||
| 76 | +%{_bindir}/agentd | ||
| 77 | +%{_bindir}/tlogcat | ||
| 78 | +%{_bindir}/teecd.sh | ||
| 79 | + | ||
| 80 | +%{_libdir}/libteec.so | ||
| 81 | + | ||
| 82 | +%{_unitdir}/teecd.service | ||
| 83 | + | ||
| 84 | +%config(noreplace) %{_sysconfdir}/teec.conf | ||
| 85 | + | ||
| 86 | +%changelog | ||
| 87 | +* Mon Jul 20 2026 liuhao <liuhao365@h-partners.com> - 1.0.0-1 | ||
| 88 | +- package init | ||