mirror of
https://github.com/opencontainers/runc.git
synced 2025-10-07 08:21:01 +08:00
vendor: opencontainers/selinux v1.5.1, update deprecated uses
full diff: https://github.com/opencontainers/selinux/v1.4.0...v1.5.1 Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
2
go.mod
2
go.mod
@@ -14,7 +14,7 @@ require (
|
|||||||
github.com/moby/sys/mountinfo v0.1.3
|
github.com/moby/sys/mountinfo v0.1.3
|
||||||
github.com/mrunalp/fileutils v0.0.0-20171103030105-7d4729fb3618
|
github.com/mrunalp/fileutils v0.0.0-20171103030105-7d4729fb3618
|
||||||
github.com/opencontainers/runtime-spec v1.0.2
|
github.com/opencontainers/runtime-spec v1.0.2
|
||||||
github.com/opencontainers/selinux v1.4.0
|
github.com/opencontainers/selinux v1.5.1
|
||||||
github.com/pkg/errors v0.9.1
|
github.com/pkg/errors v0.9.1
|
||||||
github.com/seccomp/libseccomp-golang v0.9.1
|
github.com/seccomp/libseccomp-golang v0.9.1
|
||||||
github.com/sirupsen/logrus v1.6.0
|
github.com/sirupsen/logrus v1.6.0
|
||||||
|
2
go.sum
2
go.sum
@@ -29,6 +29,8 @@ github.com/opencontainers/runtime-spec v1.0.2 h1:UfAcuLBJB9Coz72x1hgl8O5RVzTdNia
|
|||||||
github.com/opencontainers/runtime-spec v1.0.2/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0=
|
github.com/opencontainers/runtime-spec v1.0.2/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0=
|
||||||
github.com/opencontainers/selinux v1.4.0 h1:cpiX/2wWIju/6My60T6/z9CxNG7c8xTQyEmA9fChpUo=
|
github.com/opencontainers/selinux v1.4.0 h1:cpiX/2wWIju/6My60T6/z9CxNG7c8xTQyEmA9fChpUo=
|
||||||
github.com/opencontainers/selinux v1.4.0/go.mod h1:yTcKuYAh6R95iDpefGLQaPaRwJFwyzAJufJyiTt7s0g=
|
github.com/opencontainers/selinux v1.4.0/go.mod h1:yTcKuYAh6R95iDpefGLQaPaRwJFwyzAJufJyiTt7s0g=
|
||||||
|
github.com/opencontainers/selinux v1.5.1 h1:jskKwSMFYqyTrHEuJgQoUlTcId0av64S6EWObrIfn5Y=
|
||||||
|
github.com/opencontainers/selinux v1.5.1/go.mod h1:yTcKuYAh6R95iDpefGLQaPaRwJFwyzAJufJyiTt7s0g=
|
||||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||||
|
@@ -11,9 +11,8 @@ import (
|
|||||||
"github.com/opencontainers/runc/libcontainer/keys"
|
"github.com/opencontainers/runc/libcontainer/keys"
|
||||||
"github.com/opencontainers/runc/libcontainer/seccomp"
|
"github.com/opencontainers/runc/libcontainer/seccomp"
|
||||||
"github.com/opencontainers/runc/libcontainer/system"
|
"github.com/opencontainers/runc/libcontainer/system"
|
||||||
"github.com/opencontainers/selinux/go-selinux/label"
|
"github.com/opencontainers/selinux/go-selinux"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
"golang.org/x/sys/unix"
|
"golang.org/x/sys/unix"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -34,10 +33,10 @@ func (l *linuxSetnsInit) Init() error {
|
|||||||
defer runtime.UnlockOSThread()
|
defer runtime.UnlockOSThread()
|
||||||
|
|
||||||
if !l.config.Config.NoNewKeyring {
|
if !l.config.Config.NoNewKeyring {
|
||||||
if err := label.SetKeyLabel(l.config.ProcessLabel); err != nil {
|
if err := selinux.SetKeyLabel(l.config.ProcessLabel); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer label.SetKeyLabel("")
|
defer selinux.SetKeyLabel("")
|
||||||
// Do not inherit the parent's session keyring.
|
// Do not inherit the parent's session keyring.
|
||||||
if _, err := keys.JoinSessionKeyring(l.getSessionRingName()); err != nil {
|
if _, err := keys.JoinSessionKeyring(l.getSessionRingName()); err != nil {
|
||||||
// Same justification as in standart_init_linux.go as to why we
|
// Same justification as in standart_init_linux.go as to why we
|
||||||
@@ -62,10 +61,10 @@ func (l *linuxSetnsInit) Init() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if err := label.SetProcessLabel(l.config.ProcessLabel); err != nil {
|
if err := selinux.SetExecLabel(l.config.ProcessLabel); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer label.SetProcessLabel("")
|
defer selinux.SetExecLabel("")
|
||||||
// Without NoNewPrivileges seccomp is a privileged operation, so we need to
|
// Without NoNewPrivileges seccomp is a privileged operation, so we need to
|
||||||
// do this before dropping capabilities; otherwise do it as late as possible
|
// do this before dropping capabilities; otherwise do it as late as possible
|
||||||
// just before execve so as few syscalls take place after it as possible.
|
// just before execve so as few syscalls take place after it as possible.
|
||||||
|
@@ -13,7 +13,7 @@ import (
|
|||||||
"github.com/opencontainers/runc/libcontainer/keys"
|
"github.com/opencontainers/runc/libcontainer/keys"
|
||||||
"github.com/opencontainers/runc/libcontainer/seccomp"
|
"github.com/opencontainers/runc/libcontainer/seccomp"
|
||||||
"github.com/opencontainers/runc/libcontainer/system"
|
"github.com/opencontainers/runc/libcontainer/system"
|
||||||
"github.com/opencontainers/selinux/go-selinux/label"
|
"github.com/opencontainers/selinux/go-selinux"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
"golang.org/x/sys/unix"
|
"golang.org/x/sys/unix"
|
||||||
@@ -47,10 +47,10 @@ func (l *linuxStandardInit) Init() error {
|
|||||||
runtime.LockOSThread()
|
runtime.LockOSThread()
|
||||||
defer runtime.UnlockOSThread()
|
defer runtime.UnlockOSThread()
|
||||||
if !l.config.Config.NoNewKeyring {
|
if !l.config.Config.NoNewKeyring {
|
||||||
if err := label.SetKeyLabel(l.config.ProcessLabel); err != nil {
|
if err := selinux.SetKeyLabel(l.config.ProcessLabel); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer label.SetKeyLabel("")
|
defer selinux.SetKeyLabel("")
|
||||||
ringname, keepperms, newperms := l.getSessionRingParams()
|
ringname, keepperms, newperms := l.getSessionRingParams()
|
||||||
|
|
||||||
// Do not inherit the parent's session keyring.
|
// Do not inherit the parent's session keyring.
|
||||||
@@ -83,7 +83,8 @@ func (l *linuxStandardInit) Init() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
label.Init()
|
// initialises the labeling system
|
||||||
|
selinux.GetEnabled()
|
||||||
if err := prepareRootfs(l.pipe, l.config); err != nil {
|
if err := prepareRootfs(l.pipe, l.config); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -145,10 +146,10 @@ func (l *linuxStandardInit) Init() error {
|
|||||||
if err := syncParentReady(l.pipe); err != nil {
|
if err := syncParentReady(l.pipe); err != nil {
|
||||||
return errors.Wrap(err, "sync ready")
|
return errors.Wrap(err, "sync ready")
|
||||||
}
|
}
|
||||||
if err := label.SetProcessLabel(l.config.ProcessLabel); err != nil {
|
if err := selinux.SetExecLabel(l.config.ProcessLabel); err != nil {
|
||||||
return errors.Wrap(err, "set process label")
|
return errors.Wrap(err, "set process label")
|
||||||
}
|
}
|
||||||
defer label.SetProcessLabel("")
|
defer selinux.SetExecLabel("")
|
||||||
// Without NoNewPrivileges seccomp is a privileged operation, so we need to
|
// Without NoNewPrivileges seccomp is a privileged operation, so we need to
|
||||||
// do this before dropping capabilities; otherwise do it as late as possible
|
// do this before dropping capabilities; otherwise do it as late as possible
|
||||||
// just before execve so as few syscalls take place after it as possible.
|
// just before execve so as few syscalls take place after it as possible.
|
||||||
|
88
vendor/github.com/opencontainers/selinux/go-selinux/selinux_linux.go
generated
vendored
88
vendor/github.com/opencontainers/selinux/go-selinux/selinux_linux.go
generated
vendored
@@ -31,6 +31,7 @@ const (
|
|||||||
// Disabled constant to indicate SELinux is disabled
|
// Disabled constant to indicate SELinux is disabled
|
||||||
Disabled = -1
|
Disabled = -1
|
||||||
|
|
||||||
|
contextFile = "/usr/share/containers/selinux/contexts"
|
||||||
selinuxDir = "/etc/selinux/"
|
selinuxDir = "/etc/selinux/"
|
||||||
selinuxConfig = selinuxDir + "config"
|
selinuxConfig = selinuxDir + "config"
|
||||||
selinuxfsMount = "/sys/fs/selinux"
|
selinuxfsMount = "/sys/fs/selinux"
|
||||||
@@ -684,23 +685,26 @@ func ROFileLabel() string {
|
|||||||
return roFileLabel
|
return roFileLabel
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
func openContextFile() (*os.File, error) {
|
||||||
ContainerLabels returns an allocated processLabel and fileLabel to be used for
|
if f, err := os.Open(contextFile); err == nil {
|
||||||
container labeling by the calling process.
|
return f, nil
|
||||||
*/
|
}
|
||||||
func ContainerLabels() (processLabel string, fileLabel string) {
|
lxcPath := filepath.Join(getSELinuxPolicyRoot(), "/contexts/lxc_contexts")
|
||||||
|
return os.Open(lxcPath)
|
||||||
|
}
|
||||||
|
|
||||||
|
var labels = loadLabels()
|
||||||
|
|
||||||
|
func loadLabels() map[string]string {
|
||||||
var (
|
var (
|
||||||
val, key string
|
val, key string
|
||||||
bufin *bufio.Reader
|
bufin *bufio.Reader
|
||||||
)
|
)
|
||||||
|
|
||||||
if !GetEnabled() {
|
labels := make(map[string]string)
|
||||||
return "", ""
|
in, err := openContextFile()
|
||||||
}
|
|
||||||
lxcPath := fmt.Sprintf("%s/contexts/lxc_contexts", getSELinuxPolicyRoot())
|
|
||||||
in, err := os.Open(lxcPath)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", ""
|
return labels
|
||||||
}
|
}
|
||||||
defer in.Close()
|
defer in.Close()
|
||||||
|
|
||||||
@@ -712,7 +716,7 @@ func ContainerLabels() (processLabel string, fileLabel string) {
|
|||||||
if err == io.EOF {
|
if err == io.EOF {
|
||||||
done = true
|
done = true
|
||||||
} else {
|
} else {
|
||||||
goto exit
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
line = strings.TrimSpace(line)
|
line = strings.TrimSpace(line)
|
||||||
@@ -726,26 +730,64 @@ func ContainerLabels() (processLabel string, fileLabel string) {
|
|||||||
}
|
}
|
||||||
if groups := assignRegex.FindStringSubmatch(line); groups != nil {
|
if groups := assignRegex.FindStringSubmatch(line); groups != nil {
|
||||||
key, val = strings.TrimSpace(groups[1]), strings.TrimSpace(groups[2])
|
key, val = strings.TrimSpace(groups[1]), strings.TrimSpace(groups[2])
|
||||||
if key == "process" {
|
labels[key] = strings.Trim(val, "\"")
|
||||||
processLabel = strings.Trim(val, "\"")
|
|
||||||
}
|
|
||||||
if key == "file" {
|
|
||||||
fileLabel = strings.Trim(val, "\"")
|
|
||||||
}
|
|
||||||
if key == "ro_file" {
|
|
||||||
roFileLabel = strings.Trim(val, "\"")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if processLabel == "" || fileLabel == "" {
|
return labels
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
KVMContainerLabels returns the default processLabel and mountLabel to be used
|
||||||
|
for kvm containers by the calling process.
|
||||||
|
*/
|
||||||
|
func KVMContainerLabels() (string, string) {
|
||||||
|
processLabel := labels["kvm_process"]
|
||||||
|
if processLabel == "" {
|
||||||
|
processLabel = labels["process"]
|
||||||
|
}
|
||||||
|
|
||||||
|
return addMcs(processLabel, labels["file"])
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
InitContainerLabels returns the default processLabel and file labels to be
|
||||||
|
used for containers running an init system like systemd by the calling process.
|
||||||
|
*/
|
||||||
|
func InitContainerLabels() (string, string) {
|
||||||
|
processLabel := labels["init_process"]
|
||||||
|
if processLabel == "" {
|
||||||
|
processLabel = labels["process"]
|
||||||
|
}
|
||||||
|
|
||||||
|
return addMcs(processLabel, labels["file"])
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
ContainerLabels returns an allocated processLabel and fileLabel to be used for
|
||||||
|
container labeling by the calling process.
|
||||||
|
*/
|
||||||
|
func ContainerLabels() (processLabel string, fileLabel string) {
|
||||||
|
if !GetEnabled() {
|
||||||
return "", ""
|
return "", ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
processLabel = labels["process"]
|
||||||
|
fileLabel = labels["file"]
|
||||||
|
roFileLabel = labels["ro_file"]
|
||||||
|
|
||||||
|
if processLabel == "" || fileLabel == "" {
|
||||||
|
return "", fileLabel
|
||||||
|
}
|
||||||
|
|
||||||
if roFileLabel == "" {
|
if roFileLabel == "" {
|
||||||
roFileLabel = fileLabel
|
roFileLabel = fileLabel
|
||||||
}
|
}
|
||||||
exit:
|
|
||||||
|
return addMcs(processLabel, fileLabel)
|
||||||
|
}
|
||||||
|
|
||||||
|
func addMcs(processLabel, fileLabel string) (string, string) {
|
||||||
scon, _ := NewContext(processLabel)
|
scon, _ := NewContext(processLabel)
|
||||||
if scon["level"] != "" {
|
if scon["level"] != "" {
|
||||||
mcs := uniqMcs(1024)
|
mcs := uniqMcs(1024)
|
||||||
|
14
vendor/github.com/opencontainers/selinux/go-selinux/selinux_stub.go
generated
vendored
14
vendor/github.com/opencontainers/selinux/go-selinux/selinux_stub.go
generated
vendored
@@ -113,7 +113,7 @@ SetTaskLabel sets the SELinux label for the current thread, or an error.
|
|||||||
This requires the dyntransition permission.
|
This requires the dyntransition permission.
|
||||||
*/
|
*/
|
||||||
func SetTaskLabel(label string) error {
|
func SetTaskLabel(label string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -201,6 +201,18 @@ func ROFileLabel() string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// KVMContainerLabels returns the default processLabel and mountLabel to be used
|
||||||
|
// for kvm containers by the calling process.
|
||||||
|
func KVMContainerLabels() (string, string) {
|
||||||
|
return "", ""
|
||||||
|
}
|
||||||
|
|
||||||
|
// InitContainerLabels returns the default processLabel and file labels to be
|
||||||
|
// used for containers running an init system like systemd by the calling
|
||||||
|
func InitContainerLabels() (string, string) {
|
||||||
|
return "", ""
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
ContainerLabels returns an allocated processLabel and fileLabel to be used for
|
ContainerLabels returns an allocated processLabel and fileLabel to be used for
|
||||||
container labeling by the calling process.
|
container labeling by the calling process.
|
||||||
|
2
vendor/modules.txt
vendored
2
vendor/modules.txt
vendored
@@ -40,7 +40,7 @@ github.com/mrunalp/fileutils
|
|||||||
# github.com/opencontainers/runtime-spec v1.0.2
|
# github.com/opencontainers/runtime-spec v1.0.2
|
||||||
## explicit
|
## explicit
|
||||||
github.com/opencontainers/runtime-spec/specs-go
|
github.com/opencontainers/runtime-spec/specs-go
|
||||||
# github.com/opencontainers/selinux v1.4.0
|
# github.com/opencontainers/selinux v1.5.1
|
||||||
## explicit
|
## explicit
|
||||||
github.com/opencontainers/selinux/go-selinux
|
github.com/opencontainers/selinux/go-selinux
|
||||||
github.com/opencontainers/selinux/go-selinux/label
|
github.com/opencontainers/selinux/go-selinux/label
|
||||||
|
Reference in New Issue
Block a user