bootstrap.go 1.1 KB
Newer Older
1 2 3 4 5 6 7
package libenclave // import "github.com/opencontainers/runc/libenclave"

import (
	"github.com/sirupsen/logrus"
	"os"
)

8 9 10 11 12 13
type enclaveRuntimeEnv struct {
	initPipe *os.File
	logPipe *os.File
	logLevel string
	fifoFd int
	agentPipe *os.File
14
	detached bool
15 16 17 18 19 20 21 22
}

var enclaveEnv enclaveRuntimeEnv

func GetEnclaveRunetimeEnv() *enclaveRuntimeEnv {
	return &enclaveEnv
}

23 24 25 26 27
// `rune init` needs to execute self (/proc/self/exe) in container environment
// as `runc init` executes entrypoint. Thus, some internal states in form of
// environment variable must be staged and then recovered after re-exec. This
// process is so called as libenclave bootstrapping, and the resulting process
// is so called as runelet.
28
func StartBootstrap(initPipe *os.File, logPipe *os.File, logLevel string, fifoFd int, agentPipe *os.File, detached bool) (err error) {
29 30
	logrus.Debug("bootstrapping libenclave ...")

31 32 33 34 35 36
	enclaveEnv.initPipe = initPipe
	enclaveEnv.logPipe = logPipe
	enclaveEnv.logLevel = logLevel
	enclaveEnv.fifoFd = fifoFd
	enclaveEnv.agentPipe = agentPipe
	enclaveEnv.detached = detached
37 38 39

	return nil
}