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:
Paul Holzinger
2023-10-17 15:00:46 +02:00
parent 1d3ec78e00
commit efe5e98d06
4 changed files with 9 additions and 13 deletions

View File

@ -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
} }

View File

@ -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...)
} }

View File

@ -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)
} }

View File

@ -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 {