From a4428eaaf1828305359fdf42759b65f972a1add4 Mon Sep 17 00:00:00 2001 From: HirazawaUi <695097494plus@gmail.com> Date: Thu, 18 May 2023 23:25:04 +0800 Subject: [PATCH] podman: Add binary file from helper_binaries_dir to find slirp4netns [NO NEW TESTS NEEDED] Fixes: #18568 Signed-off-by: binghongtao <695097494plus@gmail.com> --- libpod/info_linux.go | 3 +-- libpod/networking_linux.go | 2 +- libpod/networking_slirp4netns.go | 9 ++++++--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/libpod/info_linux.go b/libpod/info_linux.go index 44beafa8c9..a3073cb2d3 100644 --- a/libpod/info_linux.go +++ b/libpod/info_linux.go @@ -5,7 +5,6 @@ import ( "fmt" "math" "os" - "os/exec" "strconv" "strings" @@ -57,7 +56,7 @@ func (r *Runtime) setPlatformHostInfo(info *define.HostInfo) error { slirp4netnsPath := r.config.Engine.NetworkCmdPath if slirp4netnsPath == "" { - slirp4netnsPath, _ = exec.LookPath("slirp4netns") + slirp4netnsPath, _ = r.config.FindHelperBinary(slirp4netnsBinaryName, true) } if slirp4netnsPath != "" { version, err := programVersion(slirp4netnsPath) diff --git a/libpod/networking_linux.go b/libpod/networking_linux.go index 13befa0b37..7e97b1041b 100644 --- a/libpod/networking_linux.go +++ b/libpod/networking_linux.go @@ -392,7 +392,7 @@ func (r *Runtime) GetRootlessNetNs(new bool) (*RootlessNetNS, error) { path := r.config.Engine.NetworkCmdPath if path == "" { var err error - path, err = exec.LookPath("slirp4netns") + path, err = r.config.FindHelperBinary(slirp4netnsBinaryName, true) if err != nil { return nil, err } diff --git a/libpod/networking_slirp4netns.go b/libpod/networking_slirp4netns.go index 8e6dc8b901..0d185885d7 100644 --- a/libpod/networking_slirp4netns.go +++ b/libpod/networking_slirp4netns.go @@ -61,7 +61,10 @@ type slirp4netnsNetworkOptions struct { outboundAddr6 string } -const ipv6ConfDefaultAcceptDadSysctl = "/proc/sys/net/ipv6/conf/default/accept_dad" +const ( + ipv6ConfDefaultAcceptDadSysctl = "/proc/sys/net/ipv6/conf/default/accept_dad" + slirp4netnsBinaryName = "slirp4netns" +) func checkSlirpFlags(path string) (*slirpFeatures, error) { cmd := exec.Command(path, "--help") @@ -216,7 +219,7 @@ func (r *Runtime) setupSlirp4netns(ctr *Container, netns string) error { path := r.config.Engine.NetworkCmdPath if path == "" { var err error - path, err = exec.LookPath("slirp4netns") + path, err = r.config.FindHelperBinary(slirp4netnsBinaryName, true) if err != nil { return fmt.Errorf("could not find slirp4netns, the network namespace can't be configured: %w", err) } @@ -234,7 +237,7 @@ func (r *Runtime) setupSlirp4netns(ctr *Container, netns string) error { ctrNetworkSlipOpts := []string{} if ctr.config.NetworkOptions != nil { - ctrNetworkSlipOpts = append(ctrNetworkSlipOpts, ctr.config.NetworkOptions["slirp4netns"]...) + ctrNetworkSlipOpts = append(ctrNetworkSlipOpts, ctr.config.NetworkOptions[slirp4netnsBinaryName]...) } netOptions, err := parseSlirp4netnsNetworkOptions(r, ctrNetworkSlipOpts) if err != nil {