fix(deps): update module github.com/opencontainers/selinux to v1.15.0

Signed-off-by: Mend Renovate <bot@renovateapp.com>
This commit is contained in:
Mend Renovate
2026-05-21 22:39:36 +00:00
parent 721883f732
commit 2e61f4b067
7 changed files with 78 additions and 7 deletions

2
go.mod
View File

@@ -82,7 +82,7 @@ require (
github.com/opencontainers/go-digest v1.0.0
github.com/opencontainers/image-spec v1.1.1
github.com/opencontainers/runtime-spec v1.3.0
github.com/opencontainers/selinux v1.14.1
github.com/opencontainers/selinux v1.15.0
github.com/pelletier/go-toml/v2 v2.3.1
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.23.2

4
go.sum
View File

@@ -632,8 +632,8 @@ github.com/opencontainers/runtime-spec v1.3.0 h1:YZupQUdctfhpZy3TM39nN9Ika5CBWT5
github.com/opencontainers/runtime-spec v1.3.0/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0=
github.com/opencontainers/runtime-tools v0.9.1-0.20251114084447-edf4cb3d2116 h1:tAKu3NkKWZYpqBSOJKwTxT1wIGueiF7gcmcNgr5pNTY=
github.com/opencontainers/runtime-tools v0.9.1-0.20251114084447-edf4cb3d2116/go.mod h1:DKDEfzxvRkoQ6n9TGhxQgg2IM1lY4aM0eaQP4e3oElw=
github.com/opencontainers/selinux v1.14.1 h1:a7XlXV/nN/l5zFP1FWZYoExpClu1QOPMfWUV2CZ8kEQ=
github.com/opencontainers/selinux v1.14.1/go.mod h1:LenyElirjUHszfxrjuFqC85HIeXZKumHcKMQtnaDlQQ=
github.com/opencontainers/selinux v1.15.0 h1:4Gs40e/R2FvM8PC1HPaPncLLaDor8Y2WDfk5gjU9o5M=
github.com/opencontainers/selinux v1.15.0/go.mod h1:LenyElirjUHszfxrjuFqC85HIeXZKumHcKMQtnaDlQQ=
github.com/package-url/packageurl-go v0.1.1 h1:KTRE0bK3sKbFKAk3yy63DpeskU7Cvs/x/Da5l+RtzyU=
github.com/package-url/packageurl-go v0.1.1/go.mod h1:uQd4a7Rh3ZsVg5j0lNyAfyxIeGde9yrlhjF78GzeW0c=
github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY=

View File

@@ -10,7 +10,6 @@ import (
// Valid Label Options
var validOptions = map[string]bool{
"disable": true,
"type": true,
"filetype": true,
"user": true,
@@ -35,9 +34,13 @@ func InitLabels(options []string) (plabel string, mlabel string, retErr error) {
if !selinux.GetEnabled() {
return "", "", nil
}
if len(options) > 0 && options[0] == "disable" {
return "", selinux.PrivContainerMountLabel(), nil
}
processLabel, mountLabel := selinux.ContainerLabels() //nolint:staticcheck // ContainerLabels will be moved to an internal package.
if processLabel == "" {
// processLabel is required; if empty, do nothing.
if processLabel == "" || len(options) == 0 {
// 1. processLabel is required; if empty, do nothing.
// 2. If there are no options to process, we're done.
return processLabel, mountLabel, nil
}
defer func() {
@@ -55,6 +58,8 @@ func InitLabels(options []string) (plabel string, mlabel string, retErr error) {
return "", "", err
}
for _, opt := range options {
// For backward compatibility, process "disable"
// even if it's not the only option.
if opt == "disable" {
selinux.ReleaseLabel(mountLabel)
return "", selinux.PrivContainerMountLabel(), nil

View File

@@ -48,6 +48,21 @@ var (
privContainerMountLabel string
)
// ProcessKind selects which process domain [SetProcessKind] applies to a label.
type ProcessKind int
const (
ProcessKindRegular ProcessKind = 1
ProcessKindInit ProcessKind = 2
ProcessKindKVM ProcessKind = 3
)
// SetProcessKind returns label with its type component replaced by the one
// corresponding to kind. Other label components are kept intact.
func SetProcessKind(label string, kind ProcessKind) (string, error) {
return setProcessKind(label, kind)
}
// Context is a representation of the SELinux label broken into 4 parts
type Context map[string]string
@@ -292,6 +307,8 @@ func KVMContainerLabels() (string, string) {
// KVMContainerLabel returns the default process label to be used
// for KVM containers by the calling process.
//
// If you only need to change a type of existing label, use [SetProcessKind] instead.
func KVMContainerLabel() (string, error) {
return kvmContainerLabel()
}
@@ -306,6 +323,8 @@ func InitContainerLabels() (string, string) {
// InitContainerLabel returns the default process label to be used
// for containers running an init system like systemd by the calling process.
//
// If you only need to change a type of existing label, use [SetProcessKind] instead.
func InitContainerLabel() (string, error) {
return initContainerLabel()
}

View File

@@ -1513,3 +1513,46 @@ func getDefaultContextWithLevel(user, level, scon string) (string, error) {
return getDefaultContextFromReaders(&c)
}
func (k ProcessKind) keys() (primary, fallback string, ok bool) {
switch k {
case ProcessKindRegular:
return "process", "", true
case ProcessKindInit:
return "init_process", "process", true
case ProcessKindKVM:
return "kvm_process", "process", true
}
return "", "", false
}
func setProcessKind(cLabel string, k ProcessKind) (string, error) {
if cLabel == "" {
return "", nil
}
primary, fallback, ok := k.keys()
if !ok {
return "", fmt.Errorf("selinux.SetProcessKind: invalid ProcessKind %d", k)
}
src := label(primary)
if src == "" && fallback != "" {
src = label(fallback)
}
if src == "" {
return cLabel, nil
}
// Replace cLabel type with one from src.
srcCtx, err := newContext(src)
if err != nil {
return "", fmt.Errorf("selinux.SetProcessKind: invalid %s label %s: %w", primary, src, err)
}
dstCtx, err := newContext(cLabel)
if err != nil {
return "", fmt.Errorf("selinux.SetProcessKind: invalid label %s: %w", cLabel, err)
}
dstCtx["type"] = srcCtx["type"]
return dstCtx.get(), nil
}

View File

@@ -157,3 +157,7 @@ func getDefaultContextWithLevel(string, string, string) (string, error) {
func label(_ string) string {
return ""
}
func setProcessKind(string, ProcessKind) (string, error) {
return "", nil
}

2
vendor/modules.txt vendored
View File

@@ -1368,7 +1368,7 @@ github.com/opencontainers/runtime-spec/specs-go/features
github.com/opencontainers/runtime-tools/generate
github.com/opencontainers/runtime-tools/generate/seccomp
github.com/opencontainers/runtime-tools/validate/capabilities
# github.com/opencontainers/selinux v1.14.1
# github.com/opencontainers/selinux v1.15.0
## explicit; go 1.22
github.com/opencontainers/selinux/go-selinux
github.com/opencontainers/selinux/go-selinux/label