pal_linux.go 1.1 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11
package enclave_runtime_pal // import "github.com/opencontainers/runc/libenclave/internal/runtime/pal"

import (
	"fmt"
	"os"
)

func (pal *enclaveRuntimePal) Load(palPath string) (err error) {
	if err = pal.getPalApiVersion(); err != nil {
		return err
	}
12
	return nil
13 14 15
}

func (pal *enclaveRuntimePal) getPalApiVersion() error {
16 17 18 19
	api := &enclaveRuntimePalApiV1{}
	ver := api.get_version()
	if ver > palApiVersion {
		return fmt.Errorf("unsupported pal api version %d", ver)
20
	}
21 22
	pal.version = ver
	return nil
23 24 25 26
}

func (pal *enclaveRuntimePal) Init(args string, logLevel string) error {
	api := &enclaveRuntimePalApiV1{}
27
	return api.init(args, logLevel)
28 29 30 31 32 33 34 35
}

func (pal *enclaveRuntimePal) Attest() (err error) {
	return nil
}

func (pal *enclaveRuntimePal) Exec(cmd []string, envp []string, stdio [3]*os.File) (int32, error) {
	api := &enclaveRuntimePalApiV1{}
36
	return api.exec(cmd, envp, stdio)
37 38 39 40 41
}

func (pal *enclaveRuntimePal) Kill(sig int, pid int) error {
	if pal.version >= 2 {
		api := &enclaveRuntimePalApiV1{}
42
		return api.kill(sig, pid)
43 44 45 46 47 48
	}
	return nil
}

func (pal *enclaveRuntimePal) Destroy() error {
	api := &enclaveRuntimePalApiV1{}
49
	return api.destroy()
50
}