未验证 提交 76156bb6 编写于 作者: H haosanzi 提交者: GitHub

rune/libenclave: Change to preload libsgx_launch.so.1 instead of libsgx_launch.so

The official psw installer from Intel doesn't create a symbol link libsgx_launch.so to libsgx_launch.so.1, leading to pal init failure.

Signed-off-by: Shirong Hao<shirong@linux.alibaba.com>
上级 196cf5ad
...@@ -3,6 +3,7 @@ package intelsgx // import "github.com/opencontainers/runc/libenclave/intelsgx" ...@@ -3,6 +3,7 @@ package intelsgx // import "github.com/opencontainers/runc/libenclave/intelsgx"
/* /*
#cgo linux LDFLAGS: -ldl #cgo linux LDFLAGS: -ldl
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h>
#include <dlfcn.h> #include <dlfcn.h>
*/ */
import "C" import "C"
...@@ -11,6 +12,15 @@ import ( ...@@ -11,6 +12,15 @@ import (
"unsafe" "unsafe"
) )
func loadLibrary(p string) {
path := C.CString(p)
dl := C.dlopen(path, C.RTLD_NOW)
if dl == nil {
C.perror(C.CString("failed to load library " + p))
}
C.free(unsafe.Pointer(path))
}
// Due to the design of runelet, the Enclave Runtime PAL is loaded // Due to the design of runelet, the Enclave Runtime PAL is loaded
// in host but launched in container. The fact that certain libraries // in host but launched in container. The fact that certain libraries
// from Intel SGX PSW would use dlopen() to further load // from Intel SGX PSW would use dlopen() to further load
...@@ -19,9 +29,7 @@ import ( ...@@ -19,9 +29,7 @@ import (
// are completely loaded in host, preload them prior to switch // are completely loaded in host, preload them prior to switch
// into container. // into container.
func preloadSgxPswLib() { func preloadSgxPswLib() {
path := C.CString("libsgx_launch.so") loadLibrary("libsgx_launch.so.1")
C.dlopen(path, C.RTLD_NOW)
C.free(unsafe.Pointer(path))
} }
func init() { func init() {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册