2015-02-07 04:48:57 +08:00
|
|
|
// +build linux
|
|
|
|
|
|
|
|
package libcontainer
|
|
|
|
|
|
|
|
import (
|
2015-03-06 06:33:13 +08:00
|
|
|
"os"
|
|
|
|
|
2015-02-07 04:48:57 +08:00
|
|
|
"github.com/docker/libcontainer/apparmor"
|
|
|
|
"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 {
|
2015-02-10 05:11:57 +08:00
|
|
|
config *initConfig
|
2015-02-07 04:48:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (l *linuxSetnsInit) Init() error {
|
2015-02-10 05:11:57 +08:00
|
|
|
if err := setupRlimits(l.config.Config); err != nil {
|
2015-02-07 04:48:57 +08:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
if err := finalizeNamespace(l.config); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2015-02-10 05:11:57 +08:00
|
|
|
if err := apparmor.ApplyProfile(l.config.Config.AppArmorProfile); err != nil {
|
2015-02-07 04:48:57 +08:00
|
|
|
return err
|
|
|
|
}
|
2015-02-10 05:11:57 +08:00
|
|
|
if l.config.Config.ProcessLabel != "" {
|
|
|
|
if err := label.SetProcessLabel(l.config.Config.ProcessLabel); err != nil {
|
2015-02-07 04:48:57 +08:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
2015-03-06 06:33:13 +08:00
|
|
|
return system.Execv(l.config.Args[0], l.config.Args[0:], os.Environ())
|
2015-02-07 04:48:57 +08:00
|
|
|
}
|