50 lines
1.5 KiB
Diff
50 lines
1.5 KiB
Diff
From 19d48667d6220aaa150f052e66a1847e3ba8f8d4 Mon Sep 17 00:00:00 2001
|
|
From: Li Feng <lifeng68@huawei.com>
|
|
Date: Tue, 13 Apr 2021 06:40:43 +0000
|
|
Subject: [PATCH 04/14] example: use absolute path to find enclave.sign.so
|
|
|
|
Signed-off-by: Li Feng <lifeng68@huawei.com>
|
|
---
|
|
examples/helloworld/host/main.c | 18 +++++++++++++++++-
|
|
1 file changed, 17 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/examples/helloworld/host/main.c b/examples/helloworld/host/main.c
|
|
index e4c4ec4..51993ce 100644
|
|
--- a/examples/helloworld/host/main.c
|
|
+++ b/examples/helloworld/host/main.c
|
|
@@ -11,6 +11,8 @@
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
+#include <unistd.h>
|
|
+#include <linux/limits.h>
|
|
#include "enclave.h"
|
|
#include "helloworld_u.h"
|
|
|
|
@@ -26,7 +28,21 @@ int main()
|
|
|
|
printf("Create secgear enclave\n");
|
|
|
|
- res = cc_enclave_create(path, AUTO_ENCLAVE_TYPE, 0, SECGEAR_DEBUG_FLAG, NULL, 0, &context);
|
|
+ char real_p[PATH_MAX];
|
|
+ /* check file exists, if not exist then use absolute path */
|
|
+ if (realpath(path, real_p) == NULL) {
|
|
+ if (getcwd(real_p, sizeof(real_p)) == NULL) {
|
|
+ printf("Cannot find enclave.sign.so");
|
|
+ return -1;
|
|
+ }
|
|
+ if (PATH_MAX - strlen(real_p) <= strlen("/enclave.signed.so")) {
|
|
+ printf("Failed to strcat enclave.sign.so path");
|
|
+ return -1;
|
|
+ }
|
|
+ (void)strcat(real_p, "/enclave.signed.so");
|
|
+ }
|
|
+
|
|
+ res = cc_enclave_create(real_p, AUTO_ENCLAVE_TYPE, 0, SECGEAR_DEBUG_FLAG, NULL, 0, &context);
|
|
if (res != CC_SUCCESS) {
|
|
printf("Create enclave error\n");
|
|
return res;
|
|
--
|
|
2.27.0
|
|
|