mirror of
https://github.com/opencontainers/runc.git
synced 2025-10-26 17:11:44 +08:00
Refactor init actions into separate types
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
35
linux_setns_init.go
Normal file
35
linux_setns_init.go
Normal file
@@ -0,0 +1,35 @@
|
||||
// +build linux
|
||||
|
||||
package libcontainer
|
||||
|
||||
import (
|
||||
"github.com/docker/libcontainer/apparmor"
|
||||
"github.com/docker/libcontainer/configs"
|
||||
"github.com/docker/libcontainer/label"
|
||||
"github.com/docker/libcontainer/system"
|
||||
)
|
||||
|
||||
// linuxSetnsInit performs the container's initialization for running a new process
|
||||
// inside an existing container.
|
||||
type linuxSetnsInit struct {
|
||||
args []string
|
||||
config *configs.Config
|
||||
}
|
||||
|
||||
func (l *linuxSetnsInit) Init() error {
|
||||
if err := setupRlimits(l.config); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := finalizeNamespace(l.config); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := apparmor.ApplyProfile(l.config.AppArmorProfile); err != nil {
|
||||
return err
|
||||
}
|
||||
if l.config.ProcessLabel != "" {
|
||||
if err := label.SetProcessLabel(l.config.ProcessLabel); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return system.Execv(l.args[0], l.args[0:], l.config.Env)
|
||||
}
|
||||
Reference in New Issue
Block a user