Files
podman/vendor/github.com/containers/common/pkg/config/config_local.go
Joshua Arrevillaga e14b8acba8 Update vendor dependencies
- Update github.com/containers/common to v0.64.1-0.20250806164630-57def9601f3b
- Update github.com/spf13/pflag to v1.0.7
- Update github.com/seccomp/libseccomp-golang to v0.11.1

Signed-off-by: Joshua Arrevillaga <2004jarrevillaga@gmail.com>
2025-08-07 14:54:08 -04:00

125 lines
2.9 KiB
Go

//go:build !remote
package config
import (
"fmt"
"os"
"path/filepath"
"strconv"
"strings"
"github.com/containers/storage/pkg/fileutils"
units "github.com/docker/go-units"
"tags.cncf.io/container-device-interface/pkg/parser"
)
func (c *EngineConfig) validatePaths() error {
// Relative paths can cause nasty bugs, because core paths we use could
// shift between runs or even parts of the program. - The OCI runtime
// uses a different working directory than we do, for example.
if c.StaticDir != "" && !filepath.IsAbs(c.StaticDir) {
return fmt.Errorf("static directory must be an absolute path - instead got %q", c.StaticDir)
}
if c.TmpDir != "" && !filepath.IsAbs(c.TmpDir) {
return fmt.Errorf("temporary directory must be an absolute path - instead got %q", c.TmpDir)
}
if c.VolumePath != "" && !filepath.IsAbs(c.VolumePath) {
return fmt.Errorf("volume path must be an absolute path - instead got %q", c.VolumePath)
}
return nil
}
func (c *ContainersConfig) validateDevices() error {
for _, d := range c.Devices.Get() {
if parser.IsQualifiedName(d) {
continue
}
_, _, _, err := Device(d)
if err != nil {
return err
}
}
return nil
}
func (c *ContainersConfig) validateInterfaceName() error {
if c.InterfaceName == "device" || c.InterfaceName == "" {
return nil
}
return fmt.Errorf("invalid interface_name option %s", c.InterfaceName)
}
func (c *ContainersConfig) validateUlimits() error {
for _, u := range c.DefaultUlimits.Get() {
ul, err := units.ParseUlimit(u)
if err != nil {
return fmt.Errorf("unrecognized ulimit %s: %w", u, err)
}
_, err = ul.GetRlimit()
if err != nil {
return err
}
}
return nil
}
func (c *ContainersConfig) validateTZ() error {
if c.TZ == "local" || c.TZ == "" {
return nil
}
lookupPaths := []string{
"/usr/share/zoneinfo",
"/etc/zoneinfo",
}
// Allow using TZDIR to override the lookupPaths. Ref:
// https://sourceware.org/git/?p=glibc.git;a=blob;f=time/tzfile.c;h=8a923d0cccc927a106dc3e3c641be310893bab4e;hb=HEAD#l149
tzdir := os.Getenv("TZDIR")
if tzdir != "" {
lookupPaths = []string{tzdir}
}
for _, paths := range lookupPaths {
zonePath := filepath.Join(paths, c.TZ)
if err := fileutils.Exists(zonePath); err == nil {
// found zone information
return nil
}
}
return fmt.Errorf(
"find timezone %s in paths: %s",
c.TZ, strings.Join(lookupPaths, ", "),
)
}
func (c *ContainersConfig) validateUmask() error {
// Valid values are 0 to 7777 octal.
_, err := strconv.ParseUint(c.Umask, 8, 12)
if err != nil {
return fmt.Errorf("not a valid umask %s", c.Umask)
}
return nil
}
func (c *ContainersConfig) validateLogPath() error {
if c.LogPath == "" {
return nil
}
if !filepath.IsAbs(c.LogPath) {
return fmt.Errorf("log_path must be an absolute path - instead got %q", c.LogPath)
}
if strings.ContainsAny(c.LogPath, "\x00") {
return fmt.Errorf("log_path contains null bytes - got %q", c.LogPath)
}
return nil
}
func isRemote() bool {
return false
}