mirror of
https://github.com/containers/podman.git
synced 2025-06-23 02:18:13 +08:00
Merge pull request #18620 from HirazawaUi/find_slirp4netns_from_helper_binaries_dir
podman: Added find slirp4netns binary file from helper_binaries_dir
This commit is contained in:
@ -438,7 +438,8 @@ func rootFlags(cmd *cobra.Command, podmanConfig *entities.PodmanConfig) {
|
|||||||
pFlags.StringVar(&podmanConfig.ConmonPath, conmonFlagName, "", "Path of the conmon binary")
|
pFlags.StringVar(&podmanConfig.ConmonPath, conmonFlagName, "", "Path of the conmon binary")
|
||||||
_ = cmd.RegisterFlagCompletionFunc(conmonFlagName, completion.AutocompleteDefault)
|
_ = cmd.RegisterFlagCompletionFunc(conmonFlagName, completion.AutocompleteDefault)
|
||||||
|
|
||||||
// TODO (5.0): remove this option with the next major release after https://github.com/containers/podman/issues/18560 was implemented
|
// TODO (5.0): --network-cmd-path is deprecated, remove this option with the next major release
|
||||||
|
// We need to find all the places that use r.config.Engine.NetworkCmdPath and remove it
|
||||||
networkCmdPathFlagName := "network-cmd-path"
|
networkCmdPathFlagName := "network-cmd-path"
|
||||||
pFlags.StringVar(&podmanConfig.ContainersConf.Engine.NetworkCmdPath, networkCmdPathFlagName, podmanConfig.ContainersConfDefaultsRO.Engine.NetworkCmdPath, "Path to the command for configuring the network")
|
pFlags.StringVar(&podmanConfig.ContainersConf.Engine.NetworkCmdPath, networkCmdPathFlagName, podmanConfig.ContainersConfDefaultsRO.Engine.NetworkCmdPath, "Path to the command for configuring the network")
|
||||||
_ = cmd.RegisterFlagCompletionFunc(networkCmdPathFlagName, completion.AutocompleteDefault)
|
_ = cmd.RegisterFlagCompletionFunc(networkCmdPathFlagName, completion.AutocompleteDefault)
|
||||||
|
@ -83,7 +83,9 @@ Remote connections use local containers.conf for default.
|
|||||||
Log messages at and above specified level: debug, info, warn, error, fatal or panic (default: "warn")
|
Log messages at and above specified level: debug, info, warn, error, fatal or panic (default: "warn")
|
||||||
|
|
||||||
#### **--network-cmd-path**=*path*
|
#### **--network-cmd-path**=*path*
|
||||||
Path to the `slirp4netns(1)` command binary to use for setting up a slirp4netns network. If "" is used then the binary is looked up using the $PATH environment variable.
|
Path to the `slirp4netns(1)` command binary to use for setting up a slirp4netns network.
|
||||||
|
If "" is used, then the binary will first be searched using the `helper_binaries_dir` option in `containers.conf`, and second using the `$PATH` environment variable.
|
||||||
|
**Note:** This option is deprecated and will be removed with Podman 5.0. Use the `helper_binaries_dir` option in `containers.conf` instead.
|
||||||
|
|
||||||
#### **--network-config-dir**=*directory*
|
#### **--network-config-dir**=*directory*
|
||||||
|
|
||||||
|
@ -5,7 +5,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"math"
|
"math"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@ -57,7 +56,7 @@ func (r *Runtime) setPlatformHostInfo(info *define.HostInfo) error {
|
|||||||
|
|
||||||
slirp4netnsPath := r.config.Engine.NetworkCmdPath
|
slirp4netnsPath := r.config.Engine.NetworkCmdPath
|
||||||
if slirp4netnsPath == "" {
|
if slirp4netnsPath == "" {
|
||||||
slirp4netnsPath, _ = exec.LookPath("slirp4netns")
|
slirp4netnsPath, _ = r.config.FindHelperBinary(slirp4netnsBinaryName, true)
|
||||||
}
|
}
|
||||||
if slirp4netnsPath != "" {
|
if slirp4netnsPath != "" {
|
||||||
version, err := programVersion(slirp4netnsPath)
|
version, err := programVersion(slirp4netnsPath)
|
||||||
|
@ -392,7 +392,7 @@ func (r *Runtime) GetRootlessNetNs(new bool) (*RootlessNetNS, error) {
|
|||||||
path := r.config.Engine.NetworkCmdPath
|
path := r.config.Engine.NetworkCmdPath
|
||||||
if path == "" {
|
if path == "" {
|
||||||
var err error
|
var err error
|
||||||
path, err = exec.LookPath("slirp4netns")
|
path, err = r.config.FindHelperBinary(slirp4netnsBinaryName, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,10 @@ type slirp4netnsNetworkOptions struct {
|
|||||||
outboundAddr6 string
|
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) {
|
func checkSlirpFlags(path string) (*slirpFeatures, error) {
|
||||||
cmd := exec.Command(path, "--help")
|
cmd := exec.Command(path, "--help")
|
||||||
@ -216,7 +219,7 @@ func (r *Runtime) setupSlirp4netns(ctr *Container, netns string) error {
|
|||||||
path := r.config.Engine.NetworkCmdPath
|
path := r.config.Engine.NetworkCmdPath
|
||||||
if path == "" {
|
if path == "" {
|
||||||
var err error
|
var err error
|
||||||
path, err = exec.LookPath("slirp4netns")
|
path, err = r.config.FindHelperBinary(slirp4netnsBinaryName, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("could not find slirp4netns, the network namespace can't be configured: %w", err)
|
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{}
|
ctrNetworkSlipOpts := []string{}
|
||||||
if ctr.config.NetworkOptions != nil {
|
if ctr.config.NetworkOptions != nil {
|
||||||
ctrNetworkSlipOpts = append(ctrNetworkSlipOpts, ctr.config.NetworkOptions["slirp4netns"]...)
|
ctrNetworkSlipOpts = append(ctrNetworkSlipOpts, ctr.config.NetworkOptions[slirp4netnsBinaryName]...)
|
||||||
}
|
}
|
||||||
netOptions, err := parseSlirp4netnsNetworkOptions(r, ctrNetworkSlipOpts)
|
netOptions, err := parseSlirp4netnsNetworkOptions(r, ctrNetworkSlipOpts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Reference in New Issue
Block a user