Update vendor of containers/common

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
Daniel J Walsh
2023-07-26 06:14:09 -04:00
parent b2a857a023
commit 6dda21984a
9 changed files with 53 additions and 37 deletions

View File

@ -185,6 +185,9 @@ type ContainersConfig struct {
// Containers logs default to truncated container ID as a tag.
LogTag string `toml:"log_tag,omitempty"`
// Mount to add to all containers
Mounts []string `toml:"mounts,omitempty"`
// NetNS indicates how to create a network namespace for the container
NetNS string `toml:"netns,omitempty"`
@ -1021,17 +1024,7 @@ func (c *NetworkConfig) Validate() error {
}
}
if stringsEq(c.CNIPluginDirs, DefaultCNIPluginDirs) {
return nil
}
for _, pluginDir := range c.CNIPluginDirs {
if err := isDirectory(pluginDir); err == nil {
return nil
}
}
return fmt.Errorf("invalid cni_plugin_dirs: %s", strings.Join(c.CNIPluginDirs, ","))
return nil
}
// FindConmon iterates over (*Config).ConmonPath and returns the path

View File

@ -196,6 +196,13 @@ default_sysctls = [
#
#log_tag = ""
# List of mounts. Specified as
# "type=TYPE,source=<directory-on-host>,destination=<directory-in-container>,<options>", for example:
# "type=bind,source=/var/lib/foobar,destination=/var/lib/foobar,ro".
# If it is empty or commented out, no mounts will be added
#
#mounts = []
# Default way to to create a Network namespace for the container
# Options are:
# `private` Create private Network Namespace for the container.
@ -276,7 +283,7 @@ default_sysctls = [
# If it is empty or commented out, no volumes will be added
#
#volumes = []
#
#[engine.platform_to_oci_runtime]
#"wasi/wasm" = ["crun-wasm"]
#"wasi/wasm32" = ["crun-wasm"]

View File

@ -186,19 +186,18 @@ func DefaultConfig() (*Config, error) {
return &Config{
Containers: ContainersConfig{
Devices: []string{},
Volumes: []string{},
Annotations: []string{},
ApparmorProfile: DefaultApparmorProfile,
BaseHostsFile: "",
CgroupNS: cgroupNS,
Cgroups: getDefaultCgroupsMode(),
DNSOptions: []string{},
DNSSearches: []string{},
DNSServers: []string{},
DefaultCapabilities: DefaultCapabilities,
DefaultSysctls: []string{},
DefaultUlimits: getDefaultProcessLimits(),
DNSServers: []string{},
DNSOptions: []string{},
DNSSearches: []string{},
Devices: []string{},
EnableKeyring: true,
EnableLabeling: selinuxEnabled(),
Env: []string{
@ -207,20 +206,22 @@ func DefaultConfig() (*Config, error) {
},
EnvHost: false,
HTTPProxy: true,
IPCNS: "shareable",
Init: false,
InitPath: "",
IPCNS: "shareable",
LogDriver: defaultLogDriver(),
LogSizeMax: DefaultLogSizeMax,
Mounts: []string{},
NetNS: "private",
NoHosts: false,
PidsLimit: DefaultPidsLimit,
PidNS: "private",
PidsLimit: DefaultPidsLimit,
ShmSize: DefaultShmSize,
TZ: "",
Umask: "0022",
UTSNS: "private",
Umask: "0022",
UserNSSize: DefaultUserNSSize, // Deprecated
Volumes: []string{},
},
Network: NetworkConfig{
DefaultNetwork: "podman",
@ -500,6 +501,11 @@ func (c *Config) Volumes() []string {
return c.Containers.Volumes
}
// Mounts returns the default set of mounts that should be mounted in containers.
func (c *Config) Mounts() []string {
return c.Containers.Mounts
}
// Devices returns the default additional devices for containers.
func (c *Config) Devices() []string {
return c.Containers.Devices

View File

@ -15,6 +15,8 @@ import (
"golang.org/x/term"
)
const sshdPort = 22
func Validate(user *url.Userinfo, path string, port int, identity string) (*config.Destination, *url.URL, error) {
// url.Parse NEEDS ssh://, if this ever fails or returns some nonsense, that is why.
uri, err := url.Parse(path)
@ -28,11 +30,10 @@ func Validate(user *url.Userinfo, path string, port int, identity string) (*conf
}
if uri.Port() == "" {
if port != 0 {
uri.Host = net.JoinHostPort(uri.Host, strconv.Itoa(port))
} else {
uri.Host = net.JoinHostPort(uri.Host, "22")
if port == 0 {
port = sshdPort
}
uri.Host = net.JoinHostPort(uri.Host, strconv.Itoa(port))
}
if user != nil {
@ -165,11 +166,15 @@ func ParseScpArgs(options ConnectionScpOptions) (string, string, string, bool, e
}
func DialNet(sshClient *ssh.Client, mode string, url *url.URL) (net.Conn, error) {
port, err := strconv.Atoi(url.Port())
if err != nil {
return nil, err
port := sshdPort
if url.Port() != "" {
p, err := strconv.Atoi(url.Port())
if err != nil {
return nil, err
}
port = p
}
if _, _, err = Validate(url.User, url.Hostname(), port, ""); err != nil {
if _, _, err := Validate(url.User, url.Hostname(), port, ""); err != nil {
return nil, err
}
return sshClient.Dial(mode, url.Path)