mirror of
https://github.com/containers/podman.git
synced 2025-05-22 01:27:07 +08:00
vendor: bump c/common to v0.49.2-0.20220929111928-2d1b45ae2423
[NO NEW TESTS NEEDED] [NO TESTS NEEDED] Signed-off-by: Aditya R <arajan@redhat.com>
This commit is contained in:
1
vendor/github.com/opencontainers/selinux/go-selinux/doc.go
generated
vendored
1
vendor/github.com/opencontainers/selinux/go-selinux/doc.go
generated
vendored
@ -9,6 +9,5 @@ Usage:
|
||||
if selinux.EnforceMode() != selinux.Enforcing {
|
||||
selinux.SetEnforceMode(selinux.Enforcing)
|
||||
}
|
||||
|
||||
*/
|
||||
package selinux
|
||||
|
46
vendor/github.com/opencontainers/selinux/go-selinux/label/label_linux.go
generated
vendored
46
vendor/github.com/opencontainers/selinux/go-selinux/label/label_linux.go
generated
vendored
@ -3,8 +3,6 @@ package label
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/user"
|
||||
"strings"
|
||||
|
||||
"github.com/opencontainers/selinux/go-selinux"
|
||||
@ -113,50 +111,6 @@ func Relabel(path string, fileLabel string, shared bool) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
exclude_paths := map[string]bool{
|
||||
"/": true,
|
||||
"/bin": true,
|
||||
"/boot": true,
|
||||
"/dev": true,
|
||||
"/etc": true,
|
||||
"/etc/passwd": true,
|
||||
"/etc/pki": true,
|
||||
"/etc/shadow": true,
|
||||
"/home": true,
|
||||
"/lib": true,
|
||||
"/lib64": true,
|
||||
"/media": true,
|
||||
"/opt": true,
|
||||
"/proc": true,
|
||||
"/root": true,
|
||||
"/run": true,
|
||||
"/sbin": true,
|
||||
"/srv": true,
|
||||
"/sys": true,
|
||||
"/tmp": true,
|
||||
"/usr": true,
|
||||
"/var": true,
|
||||
"/var/lib": true,
|
||||
"/var/log": true,
|
||||
}
|
||||
|
||||
if home := os.Getenv("HOME"); home != "" {
|
||||
exclude_paths[home] = true
|
||||
}
|
||||
|
||||
if sudoUser := os.Getenv("SUDO_USER"); sudoUser != "" {
|
||||
if usr, err := user.Lookup(sudoUser); err == nil {
|
||||
exclude_paths[usr.HomeDir] = true
|
||||
}
|
||||
}
|
||||
|
||||
if path != "/" {
|
||||
path = strings.TrimSuffix(path, "/")
|
||||
}
|
||||
if exclude_paths[path] {
|
||||
return fmt.Errorf("SELinux relabeling of %s is not allowed", path)
|
||||
}
|
||||
|
||||
if shared {
|
||||
c, err := selinux.NewContext(fileLabel)
|
||||
if err != nil {
|
||||
|
1
vendor/github.com/opencontainers/selinux/go-selinux/label/label_stub.go
generated
vendored
1
vendor/github.com/opencontainers/selinux/go-selinux/label/label_stub.go
generated
vendored
@ -1,3 +1,4 @@
|
||||
//go:build !linux
|
||||
// +build !linux
|
||||
|
||||
package label
|
||||
|
12
vendor/github.com/opencontainers/selinux/go-selinux/rchcon.go
generated
vendored
12
vendor/github.com/opencontainers/selinux/go-selinux/rchcon.go
generated
vendored
@ -1,3 +1,4 @@
|
||||
//go:build linux && go1.16
|
||||
// +build linux,go1.16
|
||||
|
||||
package selinux
|
||||
@ -11,7 +12,18 @@ import (
|
||||
)
|
||||
|
||||
func rchcon(fpath, label string) error {
|
||||
fastMode := false
|
||||
// If the current label matches the new label, assume
|
||||
// other labels are correct.
|
||||
if cLabel, err := lFileLabel(fpath); err == nil && cLabel == label {
|
||||
fastMode = true
|
||||
}
|
||||
return pwalkdir.Walk(fpath, func(p string, _ fs.DirEntry, _ error) error {
|
||||
if fastMode {
|
||||
if cLabel, err := lFileLabel(fpath); err == nil && cLabel == label {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
e := lSetFileLabel(p, label)
|
||||
// Walk a file tree can race with removal, so ignore ENOENT.
|
||||
if errors.Is(e, os.ErrNotExist) {
|
||||
|
1
vendor/github.com/opencontainers/selinux/go-selinux/rchcon_go115.go
generated
vendored
1
vendor/github.com/opencontainers/selinux/go-selinux/rchcon_go115.go
generated
vendored
@ -1,3 +1,4 @@
|
||||
//go:build linux && !go1.16
|
||||
// +build linux,!go1.16
|
||||
|
||||
package selinux
|
||||
|
80
vendor/github.com/opencontainers/selinux/go-selinux/selinux_linux.go
generated
vendored
80
vendor/github.com/opencontainers/selinux/go-selinux/selinux_linux.go
generated
vendored
@ -11,6 +11,7 @@ import (
|
||||
"io/ioutil"
|
||||
"math/big"
|
||||
"os"
|
||||
"os/user"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
@ -1072,21 +1073,6 @@ func copyLevel(src, dest string) (string, error) {
|
||||
return tcon.Get(), nil
|
||||
}
|
||||
|
||||
// Prevent users from relabeling system files
|
||||
func badPrefix(fpath string) error {
|
||||
if fpath == "" {
|
||||
return ErrEmptyPath
|
||||
}
|
||||
|
||||
badPrefixes := []string{"/usr"}
|
||||
for _, prefix := range badPrefixes {
|
||||
if strings.HasPrefix(fpath, prefix) {
|
||||
return fmt.Errorf("relabeling content in %s is not allowed", prefix)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// chcon changes the fpath file object to the SELinux label label.
|
||||
// If fpath is a directory and recurse is true, then chcon walks the
|
||||
// directory tree setting the label.
|
||||
@ -1097,12 +1083,70 @@ func chcon(fpath string, label string, recurse bool) error {
|
||||
if label == "" {
|
||||
return nil
|
||||
}
|
||||
if err := badPrefix(fpath); err != nil {
|
||||
return err
|
||||
|
||||
exclude_paths := map[string]bool{
|
||||
"/": true,
|
||||
"/bin": true,
|
||||
"/boot": true,
|
||||
"/dev": true,
|
||||
"/etc": true,
|
||||
"/etc/passwd": true,
|
||||
"/etc/pki": true,
|
||||
"/etc/shadow": true,
|
||||
"/home": true,
|
||||
"/lib": true,
|
||||
"/lib64": true,
|
||||
"/media": true,
|
||||
"/opt": true,
|
||||
"/proc": true,
|
||||
"/root": true,
|
||||
"/run": true,
|
||||
"/sbin": true,
|
||||
"/srv": true,
|
||||
"/sys": true,
|
||||
"/tmp": true,
|
||||
"/usr": true,
|
||||
"/var": true,
|
||||
"/var/lib": true,
|
||||
"/var/log": true,
|
||||
}
|
||||
|
||||
if home := os.Getenv("HOME"); home != "" {
|
||||
exclude_paths[home] = true
|
||||
}
|
||||
|
||||
if sudoUser := os.Getenv("SUDO_USER"); sudoUser != "" {
|
||||
if usr, err := user.Lookup(sudoUser); err == nil {
|
||||
exclude_paths[usr.HomeDir] = true
|
||||
}
|
||||
}
|
||||
|
||||
if fpath != "/" {
|
||||
fpath = strings.TrimSuffix(fpath, "/")
|
||||
}
|
||||
if exclude_paths[fpath] {
|
||||
return fmt.Errorf("SELinux relabeling of %s is not allowed", fpath)
|
||||
}
|
||||
|
||||
if !recurse {
|
||||
return setFileLabel(fpath, label)
|
||||
err := lSetFileLabel(fpath, label)
|
||||
if err != nil {
|
||||
// Check if file doesn't exist, must have been removed
|
||||
if errors.Is(err, os.ErrNotExist) {
|
||||
return nil
|
||||
}
|
||||
// Check if current label is correct on disk
|
||||
flabel, nerr := lFileLabel(fpath)
|
||||
if nerr == nil && flabel == label {
|
||||
return nil
|
||||
}
|
||||
// Check if file doesn't exist, must have been removed
|
||||
if errors.Is(nerr, os.ErrNotExist) {
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
return rchcon(fpath, label)
|
||||
|
1
vendor/github.com/opencontainers/selinux/go-selinux/selinux_stub.go
generated
vendored
1
vendor/github.com/opencontainers/selinux/go-selinux/selinux_stub.go
generated
vendored
@ -1,3 +1,4 @@
|
||||
//go:build !linux
|
||||
// +build !linux
|
||||
|
||||
package selinux
|
||||
|
Reference in New Issue
Block a user