propagate argv0 when re-execing from /proc/self/exe
This allows runc to be used as a target for docker's reexec module that depends on a correct argv0 to select which process entrypoint to invoke. Without this patch, when runc re-execs argv0 is set to "/proc/self/exe" and the reexec module doesn't know what to do with it. Signed-off-by: Petros Angelatos <petrosagg@gmail.com>
This commit is contained in:
parent
6d30f7a01b
commit
8098828680
|
@ -40,6 +40,7 @@ type linuxContainer struct {
|
||||||
config *configs.Config
|
config *configs.Config
|
||||||
cgroupManager cgroups.Manager
|
cgroupManager cgroups.Manager
|
||||||
intelRdtManager intelrdt.Manager
|
intelRdtManager intelrdt.Manager
|
||||||
|
initPath string
|
||||||
initArgs []string
|
initArgs []string
|
||||||
initProcess parentProcess
|
initProcess parentProcess
|
||||||
initProcessStartTime uint64
|
initProcessStartTime uint64
|
||||||
|
@ -413,7 +414,8 @@ func (c *linuxContainer) newParentProcess(p *Process, doInit bool) (parentProces
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *linuxContainer) commandTemplate(p *Process, childPipe *os.File) (*exec.Cmd, error) {
|
func (c *linuxContainer) commandTemplate(p *Process, childPipe *os.File) (*exec.Cmd, error) {
|
||||||
cmd := exec.Command(c.initArgs[0], c.initArgs[1:]...)
|
cmd := exec.Command(c.initPath, c.initArgs[1:]...)
|
||||||
|
cmd.Args[0] = c.initArgs[0]
|
||||||
cmd.Stdin = p.Stdin
|
cmd.Stdin = p.Stdin
|
||||||
cmd.Stdout = p.Stdout
|
cmd.Stdout = p.Stdout
|
||||||
cmd.Stderr = p.Stderr
|
cmd.Stderr = p.Stderr
|
||||||
|
|
|
@ -134,7 +134,8 @@ func New(root string, options ...func(*LinuxFactory) error) (Factory, error) {
|
||||||
}
|
}
|
||||||
l := &LinuxFactory{
|
l := &LinuxFactory{
|
||||||
Root: root,
|
Root: root,
|
||||||
InitArgs: []string{"/proc/self/exe", "init"},
|
InitPath: "/proc/self/exe",
|
||||||
|
InitArgs: []string{os.Args[0], "init"},
|
||||||
Validator: validate.New(),
|
Validator: validate.New(),
|
||||||
CriuPath: "criu",
|
CriuPath: "criu",
|
||||||
}
|
}
|
||||||
|
@ -155,6 +156,10 @@ type LinuxFactory struct {
|
||||||
// Root directory for the factory to store state.
|
// Root directory for the factory to store state.
|
||||||
Root string
|
Root string
|
||||||
|
|
||||||
|
// InitPath is the path for calling the init responsibilities for spawning
|
||||||
|
// a container.
|
||||||
|
InitPath string
|
||||||
|
|
||||||
// InitArgs are arguments for calling the init responsibilities for spawning
|
// InitArgs are arguments for calling the init responsibilities for spawning
|
||||||
// a container.
|
// a container.
|
||||||
InitArgs []string
|
InitArgs []string
|
||||||
|
@ -207,6 +212,7 @@ func (l *LinuxFactory) Create(id string, config *configs.Config) (Container, err
|
||||||
id: id,
|
id: id,
|
||||||
root: containerRoot,
|
root: containerRoot,
|
||||||
config: config,
|
config: config,
|
||||||
|
initPath: l.InitPath,
|
||||||
initArgs: l.InitArgs,
|
initArgs: l.InitArgs,
|
||||||
criuPath: l.CriuPath,
|
criuPath: l.CriuPath,
|
||||||
newuidmapPath: l.NewuidmapPath,
|
newuidmapPath: l.NewuidmapPath,
|
||||||
|
@ -243,6 +249,7 @@ func (l *LinuxFactory) Load(id string) (Container, error) {
|
||||||
initProcessStartTime: state.InitProcessStartTime,
|
initProcessStartTime: state.InitProcessStartTime,
|
||||||
id: id,
|
id: id,
|
||||||
config: &state.Config,
|
config: &state.Config,
|
||||||
|
initPath: l.InitPath,
|
||||||
initArgs: l.InitArgs,
|
initArgs: l.InitArgs,
|
||||||
criuPath: l.CriuPath,
|
criuPath: l.CriuPath,
|
||||||
newuidmapPath: l.NewuidmapPath,
|
newuidmapPath: l.NewuidmapPath,
|
||||||
|
|
Loading…
Reference in New Issue