mirror of
https://github.com/containers/podman.git
synced 2025-07-04 09:58:58 +08:00
use FindInitBinary() for init binary
Use the new FindInitBinary() function to lookup the init binary, this allows the use of helper_binaries_dir in contianers.conf[1] [NO NEW TESTS NEEDED] [1] https://github.com/containers/common/issues/1110 Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
@ -227,7 +227,7 @@ func MakeContainer(ctx context.Context, rt *libpod.Runtime, s *specgen.SpecGener
|
|||||||
options = append(options, libpod.WithHostUsers(s.HostUsers))
|
options = append(options, libpod.WithHostUsers(s.HostUsers))
|
||||||
}
|
}
|
||||||
|
|
||||||
command, err := makeCommand(s, imageData, rtc)
|
command, err := makeCommand(s, imageData)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, nil, err
|
return nil, nil, nil, err
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,6 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/containers/common/libimage"
|
"github.com/containers/common/libimage"
|
||||||
"github.com/containers/common/pkg/config"
|
|
||||||
"github.com/containers/podman/v4/libpod/define"
|
"github.com/containers/podman/v4/libpod/define"
|
||||||
"github.com/containers/podman/v4/pkg/specgen"
|
"github.com/containers/podman/v4/pkg/specgen"
|
||||||
"github.com/opencontainers/runtime-tools/generate"
|
"github.com/opencontainers/runtime-tools/generate"
|
||||||
@ -24,7 +23,7 @@ func addRlimits(s *specgen.SpecGenerator, g *generate.Generator) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Produce the final command for the container.
|
// Produce the final command for the container.
|
||||||
func makeCommand(s *specgen.SpecGenerator, imageData *libimage.ImageData, rtc *config.Config) ([]string, error) {
|
func makeCommand(s *specgen.SpecGenerator, imageData *libimage.ImageData) ([]string, error) {
|
||||||
finalCommand := []string{}
|
finalCommand := []string{}
|
||||||
|
|
||||||
entrypoint := s.Entrypoint
|
entrypoint := s.Entrypoint
|
||||||
@ -51,13 +50,7 @@ func makeCommand(s *specgen.SpecGenerator, imageData *libimage.ImageData, rtc *c
|
|||||||
}
|
}
|
||||||
|
|
||||||
if s.Init {
|
if s.Init {
|
||||||
initPath := s.InitPath
|
// bind mount for this binary is added in addContainerInitBinary()
|
||||||
if initPath == "" && rtc != nil {
|
|
||||||
initPath = rtc.Engine.InitPath
|
|
||||||
}
|
|
||||||
if initPath == "" {
|
|
||||||
return nil, fmt.Errorf("no path to init binary found but container requested an init")
|
|
||||||
}
|
|
||||||
finalCommand = append([]string{define.ContainerInitPath, "--"}, finalCommand...)
|
finalCommand = append([]string{define.ContainerInitPath, "--"}, finalCommand...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ func buildPauseImage(rt *libpod.Runtime, rtConfig *config.Config) (string, error
|
|||||||
|
|
||||||
// Also look into the path as some distributions install catatonit in
|
// Also look into the path as some distributions install catatonit in
|
||||||
// /usr/bin.
|
// /usr/bin.
|
||||||
catatonitPath, err := rtConfig.FindHelperBinary("catatonit", true)
|
catatonitPath, err := rtConfig.FindInitBinary()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("finding pause binary: %w", err)
|
return "", fmt.Errorf("finding pause binary: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -131,8 +131,11 @@ func finalizeMounts(ctx context.Context, s *specgen.SpecGenerator, rt *libpod.Ru
|
|||||||
// If requested, add container init binary
|
// If requested, add container init binary
|
||||||
if s.Init {
|
if s.Init {
|
||||||
initPath := s.InitPath
|
initPath := s.InitPath
|
||||||
if initPath == "" && rtc != nil {
|
if initPath == "" {
|
||||||
initPath = rtc.Engine.InitPath
|
initPath, err = rtc.FindInitBinary()
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, nil, fmt.Errorf("lookup init binary: %w", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
initMount, err := addContainerInitBinary(s, initPath)
|
initMount, err := addContainerInitBinary(s, initPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Reference in New Issue
Block a user