Skip to content

Commit

Permalink
use FindInitBinary() for init binary
Browse files Browse the repository at this point in the history
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] containers/common#1110

Signed-off-by: Paul Holzinger <[email protected]>
  • Loading branch information
Luap99 committed Oct 18, 2023
1 parent 1d3ec78 commit efe5e98
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 13 deletions.
2 changes: 1 addition & 1 deletion pkg/specgen/generate/container_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ func MakeContainer(ctx context.Context, rt *libpod.Runtime, s *specgen.SpecGener
options = append(options, libpod.WithHostUsers(s.HostUsers))
}

command, err := makeCommand(s, imageData, rtc)
command, err := makeCommand(s, imageData)
if err != nil {
return nil, nil, nil, err
}
Expand Down
11 changes: 2 additions & 9 deletions pkg/specgen/generate/oci.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"strings"

"github.com/containers/common/libimage"
"github.com/containers/common/pkg/config"
"github.com/containers/podman/v4/libpod/define"
"github.com/containers/podman/v4/pkg/specgen"
"github.com/opencontainers/runtime-tools/generate"
Expand All @@ -24,7 +23,7 @@ func addRlimits(s *specgen.SpecGenerator, g *generate.Generator) {
}

// 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{}

entrypoint := s.Entrypoint
Expand All @@ -51,13 +50,7 @@ func makeCommand(s *specgen.SpecGenerator, imageData *libimage.ImageData, rtc *c
}

if s.Init {
initPath := s.InitPath
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")
}
// bind mount for this binary is added in addContainerInitBinary()
finalCommand = append([]string{define.ContainerInitPath, "--"}, finalCommand...)
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/specgen/generate/pause_image.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
// /usr/bin.
catatonitPath, err := rtConfig.FindHelperBinary("catatonit", true)
catatonitPath, err := rtConfig.FindInitBinary()
if err != nil {
return "", fmt.Errorf("finding pause binary: %w", err)
}
Expand Down
7 changes: 5 additions & 2 deletions pkg/specgen/generate/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,11 @@ func finalizeMounts(ctx context.Context, s *specgen.SpecGenerator, rt *libpod.Ru
// If requested, add container init binary
if s.Init {
initPath := s.InitPath
if initPath == "" && rtc != nil {
initPath = rtc.Engine.InitPath
if initPath == "" {
initPath, err = rtc.FindInitBinary()
if err != nil {
return nil, nil, nil, fmt.Errorf("lookup init binary: %w", err)
}
}
initMount, err := addContainerInitBinary(s, initPath)
if err != nil {
Expand Down

0 comments on commit efe5e98

Please sign in to comment.