mirror of
https://github.com/containers/podman.git
synced 2025-12-10 15:47:46 +08:00
If newuidmap or newgidmap fail, then check their permissions
Often distributions to not have newuidmap and netgidmap configured to be setuid. If Podman fails to setup the user namespace, check to see if these files doe not have the proper protection and tell the user. [NO NEW TESTS NEEDED] Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
6
vendor/github.com/containers/storage/drivers/aufs/aufs.go
generated
vendored
6
vendor/github.com/containers/storage/drivers/aufs/aufs.go
generated
vendored
@@ -1,3 +1,4 @@
|
||||
//go:build linux
|
||||
// +build linux
|
||||
|
||||
/*
|
||||
@@ -26,6 +27,7 @@ import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/fs"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
@@ -649,11 +651,11 @@ func (a *Driver) mounted(mountpoint string) (bool, error) {
|
||||
// Cleanup aufs and unmount all mountpoints
|
||||
func (a *Driver) Cleanup() error {
|
||||
var dirs []string
|
||||
if err := filepath.Walk(a.mntPath(), func(path string, info os.FileInfo, err error) error {
|
||||
if err := filepath.WalkDir(a.mntPath(), func(path string, d fs.DirEntry, err error) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !info.IsDir() {
|
||||
if !d.IsDir() {
|
||||
return nil
|
||||
}
|
||||
dirs = append(dirs, path)
|
||||
|
||||
10
vendor/github.com/containers/storage/drivers/btrfs/btrfs.go
generated
vendored
10
vendor/github.com/containers/storage/drivers/btrfs/btrfs.go
generated
vendored
@@ -1,3 +1,4 @@
|
||||
//go:build linux && cgo
|
||||
// +build linux,cgo
|
||||
|
||||
package btrfs
|
||||
@@ -16,6 +17,7 @@ import "C"
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"io/ioutil"
|
||||
"math"
|
||||
"os"
|
||||
@@ -256,7 +258,7 @@ func subvolDelete(dirpath, name string, quotaEnabled bool) error {
|
||||
var args C.struct_btrfs_ioctl_vol_args
|
||||
|
||||
// walk the btrfs subvolumes
|
||||
walkSubvolumes := func(p string, f os.FileInfo, err error) error {
|
||||
walkSubvolumes := func(p string, d fs.DirEntry, err error) error {
|
||||
if err != nil {
|
||||
if os.IsNotExist(err) && p != fullPath {
|
||||
// missing most likely because the path was a subvolume that got removed in the previous iteration
|
||||
@@ -267,20 +269,20 @@ func subvolDelete(dirpath, name string, quotaEnabled bool) error {
|
||||
}
|
||||
// we want to check children only so skip itself
|
||||
// it will be removed after the filepath walk anyways
|
||||
if f.IsDir() && p != fullPath {
|
||||
if d.IsDir() && p != fullPath {
|
||||
sv, err := isSubvolume(p)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Failed to test if %s is a btrfs subvolume: %v", p, err)
|
||||
}
|
||||
if sv {
|
||||
if err := subvolDelete(path.Dir(p), f.Name(), quotaEnabled); err != nil {
|
||||
if err := subvolDelete(path.Dir(p), d.Name(), quotaEnabled); err != nil {
|
||||
return fmt.Errorf("Failed to destroy btrfs child subvolume (%s) of parent (%s): %v", p, dirpath, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
if err := filepath.Walk(path.Join(dirpath, name), walkSubvolumes); err != nil {
|
||||
if err := filepath.WalkDir(path.Join(dirpath, name), walkSubvolumes); err != nil {
|
||||
return fmt.Errorf("Recursively walking subvolumes for %s failed: %v", dirpath, err)
|
||||
}
|
||||
|
||||
|
||||
2
vendor/github.com/containers/storage/drivers/chown_unix.go
generated
vendored
2
vendor/github.com/containers/storage/drivers/chown_unix.go
generated
vendored
@@ -84,7 +84,7 @@ func (c *platformChowner) LChown(path string, info os.FileInfo, toHost, toContai
|
||||
}
|
||||
if uid != int(st.Uid) || gid != int(st.Gid) {
|
||||
cap, err := system.Lgetxattr(path, "security.capability")
|
||||
if err != nil && !errors.Is(err, system.EOPNOTSUPP) && err != system.ErrNotSupportedPlatform {
|
||||
if err != nil && !errors.Is(err, system.EOPNOTSUPP) && !errors.Is(err, system.EOVERFLOW) && err != system.ErrNotSupportedPlatform {
|
||||
return fmt.Errorf("%s: %v", os.Args[0], err)
|
||||
}
|
||||
|
||||
|
||||
29
vendor/github.com/containers/storage/drivers/devmapper/deviceset.go
generated
vendored
29
vendor/github.com/containers/storage/drivers/devmapper/deviceset.go
generated
vendored
@@ -1,3 +1,4 @@
|
||||
//go:build linux && cgo
|
||||
// +build linux,cgo
|
||||
|
||||
package devmapper
|
||||
@@ -6,6 +7,7 @@ import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/fs"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
@@ -419,40 +421,35 @@ func (devices *DeviceSet) constructDeviceIDMap() {
|
||||
}
|
||||
}
|
||||
|
||||
func (devices *DeviceSet) deviceFileWalkFunction(path string, finfo os.FileInfo) error {
|
||||
func (devices *DeviceSet) deviceFileWalkFunction(path string, name string) error {
|
||||
|
||||
// Skip some of the meta files which are not device files.
|
||||
if strings.HasSuffix(finfo.Name(), ".migrated") {
|
||||
if strings.HasSuffix(name, ".migrated") {
|
||||
logrus.Debugf("devmapper: Skipping file %s", path)
|
||||
return nil
|
||||
}
|
||||
|
||||
if strings.HasPrefix(finfo.Name(), ".") {
|
||||
if strings.HasPrefix(name, ".") {
|
||||
logrus.Debugf("devmapper: Skipping file %s", path)
|
||||
return nil
|
||||
}
|
||||
|
||||
if finfo.Name() == deviceSetMetaFile {
|
||||
if name == deviceSetMetaFile {
|
||||
logrus.Debugf("devmapper: Skipping file %s", path)
|
||||
return nil
|
||||
}
|
||||
|
||||
if finfo.Name() == transactionMetaFile {
|
||||
if name == transactionMetaFile {
|
||||
logrus.Debugf("devmapper: Skipping file %s", path)
|
||||
return nil
|
||||
}
|
||||
|
||||
logrus.Debugf("devmapper: Loading data for file %s", path)
|
||||
|
||||
hash := finfo.Name()
|
||||
if hash == base {
|
||||
hash = ""
|
||||
}
|
||||
|
||||
// Include deleted devices also as cleanup delete device logic
|
||||
// will go through it and see if there are any deleted devices.
|
||||
if _, err := devices.lookupDevice(hash); err != nil {
|
||||
return fmt.Errorf("devmapper: Error looking up device %s:%v", hash, err)
|
||||
if _, err := devices.lookupDevice(name); err != nil {
|
||||
return fmt.Errorf("devmapper: Error looking up device %s:%v", name, err)
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -462,21 +459,21 @@ func (devices *DeviceSet) loadDeviceFilesOnStart() error {
|
||||
logrus.Debug("devmapper: loadDeviceFilesOnStart()")
|
||||
defer logrus.Debug("devmapper: loadDeviceFilesOnStart() END")
|
||||
|
||||
var scan = func(path string, info os.FileInfo, err error) error {
|
||||
var scan = func(path string, d fs.DirEntry, err error) error {
|
||||
if err != nil {
|
||||
logrus.Debugf("devmapper: Can't walk the file %s", path)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Skip any directories
|
||||
if info.IsDir() {
|
||||
if d.IsDir() {
|
||||
return nil
|
||||
}
|
||||
|
||||
return devices.deviceFileWalkFunction(path, info)
|
||||
return devices.deviceFileWalkFunction(path, d.Name())
|
||||
}
|
||||
|
||||
return filepath.Walk(devices.metadataDir(), scan)
|
||||
return filepath.WalkDir(devices.metadataDir(), scan)
|
||||
}
|
||||
|
||||
// Should be called with devices.Lock() held.
|
||||
|
||||
42
vendor/github.com/containers/storage/drivers/overlay/check_115.go
generated
vendored
42
vendor/github.com/containers/storage/drivers/overlay/check_115.go
generated
vendored
@@ -1,42 +0,0 @@
|
||||
// +build !go1.16
|
||||
|
||||
package overlay
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/containers/storage/pkg/archive"
|
||||
"github.com/containers/storage/pkg/system"
|
||||
)
|
||||
|
||||
func scanForMountProgramIndicators(home string) (detected bool, err error) {
|
||||
err = filepath.Walk(home, func(path string, info os.FileInfo, err error) error {
|
||||
if detected {
|
||||
return filepath.SkipDir
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
basename := filepath.Base(path)
|
||||
if strings.HasPrefix(basename, archive.WhiteoutPrefix) {
|
||||
detected = true
|
||||
return filepath.SkipDir
|
||||
}
|
||||
if info.IsDir() {
|
||||
xattrs, err := system.Llistxattr(path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, xattr := range xattrs {
|
||||
if strings.HasPrefix(xattr, "user.fuseoverlayfs.") || strings.HasPrefix(xattr, "user.containers.") {
|
||||
detected = true
|
||||
return filepath.SkipDir
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
})
|
||||
return detected, err
|
||||
}
|
||||
Reference in New Issue
Block a user