mirror of
https://github.com/podman-container-tools/podman.git
synced 2026-10-13 01:17:39 +00:00
Merge pull request #18172 from TomSweeneyRedHat/dev/tsweeney/store1.45.5
[v4.4.1-rhel] Vendor c/storage v1.45.5
This commit is contained in:
commit
fd0ea3b971
17 changed files with 231 additions and 226 deletions
10
go.mod
10
go.mod
|
|
@ -17,7 +17,7 @@ require (
|
|||
github.com/containers/image/v5 v5.24.1
|
||||
github.com/containers/ocicrypt v1.1.7
|
||||
github.com/containers/psgo v1.8.0
|
||||
github.com/containers/storage v1.45.3
|
||||
github.com/containers/storage v1.45.5
|
||||
github.com/coreos/go-systemd/v22 v22.5.0
|
||||
github.com/coreos/stream-metadata-go v0.0.0-20210225230131-70edb9eb47b3
|
||||
github.com/cyphar/filepath-securejoin v0.2.3
|
||||
|
|
@ -45,9 +45,9 @@ require (
|
|||
github.com/opencontainers/go-digest v1.0.0
|
||||
github.com/opencontainers/image-spec v1.1.0-rc2
|
||||
github.com/opencontainers/runc v1.1.4
|
||||
github.com/opencontainers/runtime-spec v1.0.3-0.20220825212826-86290f6a00fb
|
||||
github.com/opencontainers/runtime-spec v1.1.0-rc.1
|
||||
github.com/opencontainers/runtime-tools v0.9.1-0.20221014010322-58c91d646d86
|
||||
github.com/opencontainers/selinux v1.10.2
|
||||
github.com/opencontainers/selinux v1.11.0
|
||||
github.com/openshift/imagebuilder v1.2.4-0.20220711175835-4151e43600df
|
||||
github.com/rootless-containers/rootlesskit v1.1.0
|
||||
github.com/sirupsen/logrus v1.9.0
|
||||
|
|
@ -73,14 +73,14 @@ require (
|
|||
require (
|
||||
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
|
||||
github.com/Microsoft/go-winio v0.6.0 // indirect
|
||||
github.com/Microsoft/hcsshim v0.9.6 // indirect
|
||||
github.com/Microsoft/hcsshim v0.9.7 // indirect
|
||||
github.com/VividCortex/ewma v1.2.0 // indirect
|
||||
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d // indirect
|
||||
github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d // indirect
|
||||
github.com/chzyer/readline v1.5.1 // indirect
|
||||
github.com/containerd/cgroups v1.0.4 // indirect
|
||||
github.com/containerd/containerd v1.6.15 // indirect
|
||||
github.com/containerd/stargz-snapshotter/estargz v0.13.0 // indirect
|
||||
github.com/containerd/stargz-snapshotter/estargz v0.14.1 // indirect
|
||||
github.com/containers/libtrust v0.0.0-20230121012942-c1716e8a8d01 // indirect
|
||||
github.com/coreos/go-oidc/v3 v3.5.0 // indirect
|
||||
github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f // indirect
|
||||
|
|
|
|||
20
go.sum
20
go.sum
|
|
@ -84,8 +84,8 @@ github.com/Microsoft/hcsshim v0.8.21/go.mod h1:+w2gRZ5ReXQhFOrvSQeNfhrYB/dg3oDwT
|
|||
github.com/Microsoft/hcsshim v0.8.22/go.mod h1:91uVCVzvX2QD16sMCenoxxXo6L1wJnLMX2PSufFMtF0=
|
||||
github.com/Microsoft/hcsshim v0.8.23/go.mod h1:4zegtUJth7lAvFyc6cH2gGQ5B3OFQim01nnU2M8jKDg=
|
||||
github.com/Microsoft/hcsshim v0.9.4/go.mod h1:7pLA8lDk46WKDWlVsENo92gC0XFa8rbKfyFRBqxEbCc=
|
||||
github.com/Microsoft/hcsshim v0.9.6 h1:VwnDOgLeoi2du6dAznfmspNqTiwczvjv4K7NxuY9jsY=
|
||||
github.com/Microsoft/hcsshim v0.9.6/go.mod h1:7pLA8lDk46WKDWlVsENo92gC0XFa8rbKfyFRBqxEbCc=
|
||||
github.com/Microsoft/hcsshim v0.9.7 h1:mKNHW/Xvv1aFH87Jb6ERDzXTJTLPlmzfZ28VBFD/bfg=
|
||||
github.com/Microsoft/hcsshim v0.9.7/go.mod h1:7pLA8lDk46WKDWlVsENo92gC0XFa8rbKfyFRBqxEbCc=
|
||||
github.com/Microsoft/hcsshim/test v0.0.0-20201218223536-d3e5debf77da/go.mod h1:5hlzMzRKMLyo42nCZ9oml8AdTlq/0cvIaBv6tK1RehU=
|
||||
github.com/Microsoft/hcsshim/test v0.0.0-20210227013316-43a75bb4edd3/go.mod h1:mw7qgWloBUl75W/gVH3cQszUg1+gUITj7D6NY7ywVnY=
|
||||
github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ=
|
||||
|
|
@ -240,8 +240,8 @@ github.com/containerd/nri v0.1.0/go.mod h1:lmxnXF6oMkbqs39FiCt1s0R2HSMhcLel9vNL3
|
|||
github.com/containerd/stargz-snapshotter/estargz v0.4.1/go.mod h1:x7Q9dg9QYb4+ELgxmo4gBUeJB0tl5dqH1Sdz0nJU1QM=
|
||||
github.com/containerd/stargz-snapshotter/estargz v0.9.0/go.mod h1:aE5PCyhFMwR8sbrErO5eM2GcvkyXTTJremG883D4qF0=
|
||||
github.com/containerd/stargz-snapshotter/estargz v0.12.0/go.mod h1:AIQ59TewBFJ4GOPEQXujcrJ/EKxh5xXZegW1rkR1P/M=
|
||||
github.com/containerd/stargz-snapshotter/estargz v0.13.0 h1:fD7AwuVV+B40p0d9qVkH/Au1qhp8hn/HWJHIYjpEcfw=
|
||||
github.com/containerd/stargz-snapshotter/estargz v0.13.0/go.mod h1:m+9VaGJGlhCnrcEUod8mYumTmRgblwd3rC5UCEh2Yp0=
|
||||
github.com/containerd/stargz-snapshotter/estargz v0.14.1 h1:n9M2GDSWM96pyipFTA0DaU+zdtzi3Iwsnj/rIHr1yFM=
|
||||
github.com/containerd/stargz-snapshotter/estargz v0.14.1/go.mod h1:uPtMw6ucGJYwImjhxk/oghZmfElF/841u86wReNggNk=
|
||||
github.com/containerd/ttrpc v0.0.0-20190828154514-0e0f228740de/go.mod h1:PvCDdDGpgqzQIzDW1TphrGLssLDZp2GuS+X5DkEJB8o=
|
||||
github.com/containerd/ttrpc v0.0.0-20190828172938-92c8520ef9f8/go.mod h1:PvCDdDGpgqzQIzDW1TphrGLssLDZp2GuS+X5DkEJB8o=
|
||||
github.com/containerd/ttrpc v0.0.0-20191028202541-4f1b8fe65a5c/go.mod h1:LPm1u0xBw8r8NOKoOdNMeVHSawSsltak+Ihv+etqsE8=
|
||||
|
|
@ -285,8 +285,8 @@ github.com/containers/psgo v1.8.0 h1:2loGekmGAxM9ir5OsXWEfGwFxorMPYnc6gEDsGFQvhY
|
|||
github.com/containers/psgo v1.8.0/go.mod h1:T8ZxnX3Ur4RvnhxFJ7t8xJ1F48RhiZB4rSrOaR/qGHc=
|
||||
github.com/containers/storage v1.37.0/go.mod h1:kqeJeS0b7DO2ZT1nVWs0XufrmPFbgV3c+Q/45RlH6r4=
|
||||
github.com/containers/storage v1.43.0/go.mod h1:uZ147thiIFGdVTjMmIw19knttQnUCl3y9zjreHrg11s=
|
||||
github.com/containers/storage v1.45.3 h1:GbtTvTtp3GW2/tcFg5VhgHXcYMwVn2KfZKiHjf9FAOM=
|
||||
github.com/containers/storage v1.45.3/go.mod h1:OdRUYHrq1HP6iAo79VxqtYuJzC5j4eA2I60jKOoCT7g=
|
||||
github.com/containers/storage v1.45.5 h1:0sLd/JxRcS0pQ42jVzOv/u6N9RypAGYhaFUzWHgRWxs=
|
||||
github.com/containers/storage v1.45.5/go.mod h1:OdRUYHrq1HP6iAo79VxqtYuJzC5j4eA2I60jKOoCT7g=
|
||||
github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
|
||||
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
|
||||
github.com/coreos/go-iptables v0.4.5/go.mod h1:/mVI274lEDI2ns62jHCDnCyBF9Iwsmekav8Dbxlm1MU=
|
||||
|
|
@ -708,7 +708,6 @@ github.com/klauspost/compress v1.11.13/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdY
|
|||
github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
|
||||
github.com/klauspost/compress v1.15.7/go.mod h1:PhcZ0MbTNciWF3rruxRgKxI5NkcHHrHUDtV4Yw2GlzU=
|
||||
github.com/klauspost/compress v1.15.9/go.mod h1:PhcZ0MbTNciWF3rruxRgKxI5NkcHHrHUDtV4Yw2GlzU=
|
||||
github.com/klauspost/compress v1.15.12/go.mod h1:QPwzmACJjUTFsnSHH934V6woptycfrDDJnH7hvFVbGM=
|
||||
github.com/klauspost/compress v1.15.15 h1:EF27CXIuDsYJ6mmvtBRlEuB2UVOqHG1tAXgZ7yIO+lw=
|
||||
github.com/klauspost/compress v1.15.15/go.mod h1:ZcK2JAFqKOpnBlxcLsJzYfrS9X1akm9fHZNnD9+Vo/4=
|
||||
github.com/klauspost/pgzip v1.2.5/go.mod h1:Ch1tH69qFZu15pkjo5kYi6mth2Zzwzt50oCQKQE9RUs=
|
||||
|
|
@ -869,8 +868,9 @@ github.com/opencontainers/runtime-spec v1.0.2-0.20190207185410-29686dbc5559/go.m
|
|||
github.com/opencontainers/runtime-spec v1.0.2/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0=
|
||||
github.com/opencontainers/runtime-spec v1.0.3-0.20200929063507-e6143ca7d51d/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0=
|
||||
github.com/opencontainers/runtime-spec v1.0.3-0.20210326190908-1c3f411f0417/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0=
|
||||
github.com/opencontainers/runtime-spec v1.0.3-0.20220825212826-86290f6a00fb h1:1xSVPOd7/UA+39/hXEGnBJ13p6JFB0E1EvQFlrRDOXI=
|
||||
github.com/opencontainers/runtime-spec v1.0.3-0.20220825212826-86290f6a00fb/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0=
|
||||
github.com/opencontainers/runtime-spec v1.1.0-rc.1 h1:wHa9jroFfKGQqFHj0I1fMRKLl0pfj+ynAqBxo3v6u9w=
|
||||
github.com/opencontainers/runtime-spec v1.1.0-rc.1/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0=
|
||||
github.com/opencontainers/runtime-tools v0.0.0-20181011054405-1d69bd0f9c39/go.mod h1:r3f7wjNzSs2extwzU3Y+6pKfobzPh+kKFJ3ofN+3nfs=
|
||||
github.com/opencontainers/runtime-tools v0.9.1-0.20221014010322-58c91d646d86 h1:AaK4/fBxOmEFtb1bs/7KrJsQIgVPnhIrtgJ92RaqM60=
|
||||
github.com/opencontainers/runtime-tools v0.9.1-0.20221014010322-58c91d646d86/go.mod h1:BRHJJd0E+cx42OybVYSgUvZmU0B8P9gZuRXlZUP7TKI=
|
||||
|
|
@ -880,8 +880,8 @@ github.com/opencontainers/selinux v1.8.2/go.mod h1:MUIHuUEvKB1wtJjQdOyYRgOnLD2xA
|
|||
github.com/opencontainers/selinux v1.8.5/go.mod h1:HTvjPFoGMbpQsG886e3lQwnsRWtE4TC1OF3OUvG9FAo=
|
||||
github.com/opencontainers/selinux v1.9.1/go.mod h1:2i0OySw99QjzBBQByd1Gr9gSjvuho1lHsJxIJ3gGbJI=
|
||||
github.com/opencontainers/selinux v1.10.1/go.mod h1:2i0OySw99QjzBBQByd1Gr9gSjvuho1lHsJxIJ3gGbJI=
|
||||
github.com/opencontainers/selinux v1.10.2 h1:NFy2xCsjn7+WspbfZkUd5zyVeisV7VFbPSP96+8/ha4=
|
||||
github.com/opencontainers/selinux v1.10.2/go.mod h1:cARutUbaUrlRClyvxOICCgKixCs6L05aUsohzA3EkHQ=
|
||||
github.com/opencontainers/selinux v1.11.0 h1:+5Zbo97w3Lbmb3PeqQtpmTkMwsW5nRI3YaLpt7tQ7oU=
|
||||
github.com/opencontainers/selinux v1.11.0/go.mod h1:E5dMC3VPuVvVHDYmi78qvhJp8+M586T4DlDRYpFkyec=
|
||||
github.com/openshift/imagebuilder v1.2.4-0.20220711175835-4151e43600df h1:vf6pdI10F2Tim5a9JKiVVl4/dpNz1OEhz4EnfLdLtiA=
|
||||
github.com/openshift/imagebuilder v1.2.4-0.20220711175835-4151e43600df/go.mod h1:TRYHe4CH9U6nkDjxjBNM5klrLbJBrRbpJE5SaRwUBsQ=
|
||||
github.com/opentracing/opentracing-go v1.2.0 h1:uEJPy/1a5RIPAJ0Ov+OIO8OxWu77jEv+1B0VhjKrZUs=
|
||||
|
|
|
|||
|
|
@ -153,7 +153,7 @@ func TestPostDeleteHooks(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
|
||||
stateRegexp := `{"ociVersion":"1\.0\.2-dev","id":"123abc","status":"stopped","bundle":"` + dir + `","annotations":{"a":"b"}}`
|
||||
stateRegexp := `{"ociVersion":"1\.1\.0\-rc\.1","id":"123abc","status":"stopped","bundle":"` + dir + `","annotations":{"a":"b"}}`
|
||||
for _, p := range []string{statePath, copyPath} {
|
||||
path := p
|
||||
t.Run(path, func(t *testing.T) {
|
||||
|
|
|
|||
38
vendor/github.com/Microsoft/hcsshim/internal/hcs/process.go
generated
vendored
38
vendor/github.com/Microsoft/hcsshim/internal/hcs/process.go
generated
vendored
|
|
@ -161,7 +161,39 @@ func (process *Process) Kill(ctx context.Context) (bool, error) {
|
|||
return true, nil
|
||||
}
|
||||
|
||||
resultJSON, err := vmcompute.HcsTerminateProcess(ctx, process.handle)
|
||||
// HCS serializes the signals sent to a target pid per compute system handle.
|
||||
// To avoid SIGKILL being serialized behind other signals, we open a new compute
|
||||
// system handle to deliver the kill signal.
|
||||
// If the calls to opening a new compute system handle fail, we forcefully
|
||||
// terminate the container itself so that no container is left behind
|
||||
hcsSystem, err := OpenComputeSystem(ctx, process.system.id)
|
||||
if err != nil {
|
||||
// log error and force termination of container
|
||||
log.G(ctx).WithField("err", err).Error("OpenComputeSystem() call failed")
|
||||
err = process.system.Terminate(ctx)
|
||||
// if the Terminate() call itself ever failed, log and return error
|
||||
if err != nil {
|
||||
log.G(ctx).WithField("err", err).Error("Terminate() call failed")
|
||||
return false, err
|
||||
}
|
||||
process.system.Close()
|
||||
return true, nil
|
||||
}
|
||||
defer hcsSystem.Close()
|
||||
|
||||
newProcessHandle, err := hcsSystem.OpenProcess(ctx, process.Pid())
|
||||
if err != nil {
|
||||
// Return true only if the target process has either already
|
||||
// exited, or does not exist.
|
||||
if IsAlreadyStopped(err) {
|
||||
return true, nil
|
||||
} else {
|
||||
return false, err
|
||||
}
|
||||
}
|
||||
defer newProcessHandle.Close()
|
||||
|
||||
resultJSON, err := vmcompute.HcsTerminateProcess(ctx, newProcessHandle.handle)
|
||||
if err != nil {
|
||||
// We still need to check these two cases, as processes may still be killed by an
|
||||
// external actor (human operator, OOM, random script etc).
|
||||
|
|
@ -185,9 +217,9 @@ func (process *Process) Kill(ctx context.Context) (bool, error) {
|
|||
}
|
||||
}
|
||||
events := processHcsResult(ctx, resultJSON)
|
||||
delivered, err := process.processSignalResult(ctx, err)
|
||||
delivered, err := newProcessHandle.processSignalResult(ctx, err)
|
||||
if err != nil {
|
||||
err = makeProcessError(process, operation, err, events)
|
||||
err = makeProcessError(newProcessHandle, operation, err, events)
|
||||
}
|
||||
|
||||
process.killSignalDelivered = delivered
|
||||
|
|
|
|||
2
vendor/github.com/containers/storage/VERSION
generated
vendored
2
vendor/github.com/containers/storage/VERSION
generated
vendored
|
|
@ -1 +1 @@
|
|||
1.45.3
|
||||
1.45.5
|
||||
|
|
|
|||
5
vendor/github.com/containers/storage/drivers/overlay/overlay.go
generated
vendored
5
vendor/github.com/containers/storage/drivers/overlay/overlay.go
generated
vendored
|
|
@ -314,7 +314,10 @@ func Init(home string, options graphdriver.Options) (graphdriver.Driver, error)
|
|||
}
|
||||
fsName, ok := graphdriver.FsNames[fsMagic]
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("filesystem type %#x reported for %s is not supported with 'overlay': %w", fsMagic, filepath.Dir(home), graphdriver.ErrIncompatibleFS)
|
||||
if opts.mountProgram == "" {
|
||||
return nil, fmt.Errorf("filesystem type %#x reported for %s is not supported with 'overlay': %w", fsMagic, filepath.Dir(home), graphdriver.ErrIncompatibleFS)
|
||||
}
|
||||
fsName = "<unknown>"
|
||||
}
|
||||
backingFs = fsName
|
||||
|
||||
|
|
|
|||
11
vendor/github.com/opencontainers/runtime-spec/specs-go/config.go
generated
vendored
11
vendor/github.com/opencontainers/runtime-spec/specs-go/config.go
generated
vendored
|
|
@ -319,6 +319,10 @@ type LinuxMemory struct {
|
|||
DisableOOMKiller *bool `json:"disableOOMKiller,omitempty"`
|
||||
// Enables hierarchical memory accounting
|
||||
UseHierarchy *bool `json:"useHierarchy,omitempty"`
|
||||
// CheckBeforeUpdate enables checking if a new memory limit is lower
|
||||
// than the current usage during update, and if so, rejecting the new
|
||||
// limit.
|
||||
CheckBeforeUpdate *bool `json:"checkBeforeUpdate,omitempty"`
|
||||
}
|
||||
|
||||
// LinuxCPU for Linux cgroup 'cpu' resource management
|
||||
|
|
@ -327,6 +331,9 @@ type LinuxCPU struct {
|
|||
Shares *uint64 `json:"shares,omitempty"`
|
||||
// CPU hardcap limit (in usecs). Allowed cpu time in a given period.
|
||||
Quota *int64 `json:"quota,omitempty"`
|
||||
// CPU hardcap burst limit (in usecs). Allowed accumulated cpu time additionally for burst in a
|
||||
// given period.
|
||||
Burst *uint64 `json:"burst,omitempty"`
|
||||
// CPU period to be used for hardcapping (in usecs).
|
||||
Period *uint64 `json:"period,omitempty"`
|
||||
// How much time realtime scheduling may use (in usecs).
|
||||
|
|
@ -645,6 +652,10 @@ const (
|
|||
// LinuxSeccompFlagSpecAllow can be used to disable Speculative Store
|
||||
// Bypass mitigation. (since Linux 4.17)
|
||||
LinuxSeccompFlagSpecAllow LinuxSeccompFlag = "SECCOMP_FILTER_FLAG_SPEC_ALLOW"
|
||||
|
||||
// LinuxSeccompFlagWaitKillableRecv can be used to switch to the wait
|
||||
// killable semantics. (since Linux 5.19)
|
||||
LinuxSeccompFlagWaitKillableRecv LinuxSeccompFlag = "SECCOMP_FILTER_FLAG_WAIT_KILLABLE_RECV"
|
||||
)
|
||||
|
||||
// Additional architectures permitted to be used for system calls
|
||||
|
|
|
|||
6
vendor/github.com/opencontainers/runtime-spec/specs-go/version.go
generated
vendored
6
vendor/github.com/opencontainers/runtime-spec/specs-go/version.go
generated
vendored
|
|
@ -6,12 +6,12 @@ const (
|
|||
// VersionMajor is for an API incompatible changes
|
||||
VersionMajor = 1
|
||||
// VersionMinor is for functionality in a backwards-compatible manner
|
||||
VersionMinor = 0
|
||||
VersionMinor = 1
|
||||
// VersionPatch is for backwards-compatible bug fixes
|
||||
VersionPatch = 2
|
||||
VersionPatch = 0
|
||||
|
||||
// VersionDev indicates development branch. Releases will be empty string.
|
||||
VersionDev = "-dev"
|
||||
VersionDev = "-rc.1"
|
||||
)
|
||||
|
||||
// Version is the specification version that the package types support.
|
||||
|
|
|
|||
22
vendor/github.com/opencontainers/selinux/go-selinux/label/label.go
generated
vendored
22
vendor/github.com/opencontainers/selinux/go-selinux/label/label.go
generated
vendored
|
|
@ -78,6 +78,9 @@ func ReleaseLabel(label string) error {
|
|||
// Deprecated: use selinux.DupSecOpt
|
||||
var DupSecOpt = selinux.DupSecOpt
|
||||
|
||||
// FormatMountLabel returns a string to be used by the mount command. Using
|
||||
// the SELinux `context` mount option. Changing labels of files on mount
|
||||
// points with this option can never be changed.
|
||||
// FormatMountLabel returns a string to be used by the mount command.
|
||||
// The format of this string will be used to alter the labeling of the mountpoint.
|
||||
// The string returned is suitable to be used as the options field of the mount command.
|
||||
|
|
@ -85,12 +88,27 @@ var DupSecOpt = selinux.DupSecOpt
|
|||
// the first parameter. Second parameter is the label that you wish to apply
|
||||
// to all content in the mount point.
|
||||
func FormatMountLabel(src, mountLabel string) string {
|
||||
return FormatMountLabelByType(src, mountLabel, "context")
|
||||
}
|
||||
|
||||
// FormatMountLabelByType returns a string to be used by the mount command.
|
||||
// Allow caller to specify the mount options. For example using the SELinux
|
||||
// `fscontext` mount option would allow certain container processes to change
|
||||
// labels of files created on the mount points, where as `context` option does
|
||||
// not.
|
||||
// FormatMountLabelByType returns a string to be used by the mount command.
|
||||
// The format of this string will be used to alter the labeling of the mountpoint.
|
||||
// The string returned is suitable to be used as the options field of the mount command.
|
||||
// If you need to have additional mount point options, you can pass them in as
|
||||
// the first parameter. Second parameter is the label that you wish to apply
|
||||
// to all content in the mount point.
|
||||
func FormatMountLabelByType(src, mountLabel, contextType string) string {
|
||||
if mountLabel != "" {
|
||||
switch src {
|
||||
case "":
|
||||
src = fmt.Sprintf("context=%q", mountLabel)
|
||||
src = fmt.Sprintf("%s=%q", contextType, mountLabel)
|
||||
default:
|
||||
src = fmt.Sprintf("%s,context=%q", src, mountLabel)
|
||||
src = fmt.Sprintf("%s,%s=%q", src, contextType, mountLabel)
|
||||
}
|
||||
}
|
||||
return src
|
||||
|
|
|
|||
34
vendor/github.com/opencontainers/selinux/go-selinux/rchcon.go
generated
vendored
34
vendor/github.com/opencontainers/selinux/go-selinux/rchcon.go
generated
vendored
|
|
@ -1,34 +0,0 @@
|
|||
//go:build linux && go1.16
|
||||
// +build linux,go1.16
|
||||
|
||||
package selinux
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"io/fs"
|
||||
"os"
|
||||
|
||||
"github.com/opencontainers/selinux/pkg/pwalkdir"
|
||||
)
|
||||
|
||||
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) {
|
||||
return nil
|
||||
}
|
||||
return e
|
||||
})
|
||||
}
|
||||
22
vendor/github.com/opencontainers/selinux/go-selinux/rchcon_go115.go
generated
vendored
22
vendor/github.com/opencontainers/selinux/go-selinux/rchcon_go115.go
generated
vendored
|
|
@ -1,22 +0,0 @@
|
|||
//go:build linux && !go1.16
|
||||
// +build linux,!go1.16
|
||||
|
||||
package selinux
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"os"
|
||||
|
||||
"github.com/opencontainers/selinux/pkg/pwalk"
|
||||
)
|
||||
|
||||
func rchcon(fpath, label string) error {
|
||||
return pwalk.Walk(fpath, func(p string, _ os.FileInfo, _ error) error {
|
||||
e := lSetFileLabel(p, label)
|
||||
// Walk a file tree can race with removal, so ignore ENOENT.
|
||||
if errors.Is(e, os.ErrNotExist) {
|
||||
return nil
|
||||
}
|
||||
return e
|
||||
})
|
||||
}
|
||||
30
vendor/github.com/opencontainers/selinux/go-selinux/selinux.go
generated
vendored
30
vendor/github.com/opencontainers/selinux/go-selinux/selinux.go
generated
vendored
|
|
@ -23,8 +23,13 @@ var (
|
|||
// ErrEmptyPath is returned when an empty path has been specified.
|
||||
ErrEmptyPath = errors.New("empty path")
|
||||
|
||||
// ErrInvalidLabel is returned when an invalid label is specified.
|
||||
ErrInvalidLabel = errors.New("invalid Label")
|
||||
|
||||
// InvalidLabel is returned when an invalid label is specified.
|
||||
InvalidLabel = errors.New("Invalid Label")
|
||||
//
|
||||
// Deprecated: use [ErrInvalidLabel].
|
||||
InvalidLabel = ErrInvalidLabel
|
||||
|
||||
// ErrIncomparable is returned two levels are not comparable
|
||||
ErrIncomparable = errors.New("incomparable levels")
|
||||
|
|
@ -144,7 +149,7 @@ func CalculateGlbLub(sourceRange, targetRange string) (string, error) {
|
|||
// of the program is finished to guarantee another goroutine does not migrate to the current
|
||||
// thread before execution is complete.
|
||||
func SetExecLabel(label string) error {
|
||||
return setExecLabel(label)
|
||||
return writeCon(attrPath("exec"), label)
|
||||
}
|
||||
|
||||
// SetTaskLabel sets the SELinux label for the current thread, or an error.
|
||||
|
|
@ -152,21 +157,21 @@ func SetExecLabel(label string) error {
|
|||
// be wrapped in runtime.LockOSThread()/runtime.UnlockOSThread() to guarantee
|
||||
// the current thread does not run in a new mislabeled thread.
|
||||
func SetTaskLabel(label string) error {
|
||||
return setTaskLabel(label)
|
||||
return writeCon(attrPath("current"), label)
|
||||
}
|
||||
|
||||
// SetSocketLabel takes a process label and tells the kernel to assign the
|
||||
// label to the next socket that gets created. Calls to SetSocketLabel
|
||||
// should be wrapped in runtime.LockOSThread()/runtime.UnlockOSThread() until
|
||||
// the the socket is created to guarantee another goroutine does not migrate
|
||||
// the socket is created to guarantee another goroutine does not migrate
|
||||
// to the current thread before execution is complete.
|
||||
func SetSocketLabel(label string) error {
|
||||
return setSocketLabel(label)
|
||||
return writeCon(attrPath("sockcreate"), label)
|
||||
}
|
||||
|
||||
// SocketLabel retrieves the current socket label setting
|
||||
func SocketLabel() (string, error) {
|
||||
return socketLabel()
|
||||
return readCon(attrPath("sockcreate"))
|
||||
}
|
||||
|
||||
// PeerLabel retrieves the label of the client on the other side of a socket
|
||||
|
|
@ -185,7 +190,7 @@ func SetKeyLabel(label string) error {
|
|||
|
||||
// KeyLabel retrieves the current kernel keyring label setting
|
||||
func KeyLabel() (string, error) {
|
||||
return keyLabel()
|
||||
return readCon("/proc/self/attr/keycreate")
|
||||
}
|
||||
|
||||
// Get returns the Context as a string
|
||||
|
|
@ -208,6 +213,11 @@ func ReserveLabel(label string) {
|
|||
reserveLabel(label)
|
||||
}
|
||||
|
||||
// MLSEnabled checks if MLS is enabled.
|
||||
func MLSEnabled() bool {
|
||||
return isMLSEnabled()
|
||||
}
|
||||
|
||||
// EnforceMode returns the current SELinux mode Enforcing, Permissive, Disabled
|
||||
func EnforceMode() int {
|
||||
return enforceMode()
|
||||
|
|
@ -220,7 +230,7 @@ func SetEnforceMode(mode int) error {
|
|||
}
|
||||
|
||||
// DefaultEnforceMode returns the systems default SELinux mode Enforcing,
|
||||
// Permissive or Disabled. Note this is is just the default at boot time.
|
||||
// Permissive or Disabled. Note this is just the default at boot time.
|
||||
// EnforceMode tells you the systems current mode.
|
||||
func DefaultEnforceMode() int {
|
||||
return defaultEnforceMode()
|
||||
|
|
@ -266,7 +276,7 @@ func CopyLevel(src, dest string) (string, error) {
|
|||
return copyLevel(src, dest)
|
||||
}
|
||||
|
||||
// Chcon changes the fpath file object to the SELinux label label.
|
||||
// Chcon changes the fpath file object to the SELinux label.
|
||||
// If fpath is a directory and recurse is true, then Chcon walks the
|
||||
// directory tree setting the label.
|
||||
//
|
||||
|
|
@ -284,7 +294,7 @@ func DupSecOpt(src string) ([]string, error) {
|
|||
// DisableSecOpt returns a security opt that can be used to disable SELinux
|
||||
// labeling support for future container processes.
|
||||
func DisableSecOpt() []string {
|
||||
return disableSecOpt()
|
||||
return []string{"disable"}
|
||||
}
|
||||
|
||||
// GetDefaultContextWithLevel gets a single context for the specified SELinux user
|
||||
|
|
|
|||
185
vendor/github.com/opencontainers/selinux/go-selinux/selinux_linux.go
generated
vendored
185
vendor/github.com/opencontainers/selinux/go-selinux/selinux_linux.go
generated
vendored
|
|
@ -8,16 +8,16 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"io/fs"
|
||||
"math/big"
|
||||
"os"
|
||||
"os/user"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/opencontainers/selinux/pkg/pwalkdir"
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
|
|
@ -35,17 +35,17 @@ const (
|
|||
)
|
||||
|
||||
type selinuxState struct {
|
||||
mcsList map[string]bool
|
||||
selinuxfs string
|
||||
selinuxfsOnce sync.Once
|
||||
enabledSet bool
|
||||
enabled bool
|
||||
selinuxfsOnce sync.Once
|
||||
selinuxfs string
|
||||
mcsList map[string]bool
|
||||
sync.Mutex
|
||||
}
|
||||
|
||||
type level struct {
|
||||
sens uint
|
||||
cats *big.Int
|
||||
sens uint
|
||||
}
|
||||
|
||||
type mlsRange struct {
|
||||
|
|
@ -54,10 +54,10 @@ type mlsRange struct {
|
|||
}
|
||||
|
||||
type defaultSECtx struct {
|
||||
user, level, scon string
|
||||
userRdr, defaultRdr io.Reader
|
||||
|
||||
verifier func(string) error
|
||||
userRdr io.Reader
|
||||
verifier func(string) error
|
||||
defaultRdr io.Reader
|
||||
user, level, scon string
|
||||
}
|
||||
|
||||
type levelItem byte
|
||||
|
|
@ -155,7 +155,7 @@ func findSELinuxfs() string {
|
|||
}
|
||||
|
||||
// check if selinuxfs is available before going the slow path
|
||||
fs, err := ioutil.ReadFile("/proc/filesystems")
|
||||
fs, err := os.ReadFile("/proc/filesystems")
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
|
|
@ -292,7 +292,7 @@ func readCon(fpath string) (string, error) {
|
|||
}
|
||||
|
||||
func readConFd(in *os.File) (string, error) {
|
||||
data, err := ioutil.ReadAll(in)
|
||||
data, err := io.ReadAll(in)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
|
@ -305,7 +305,7 @@ func classIndex(class string) (int, error) {
|
|||
permpath := fmt.Sprintf("class/%s/index", class)
|
||||
indexpath := filepath.Join(getSelinuxMountPoint(), permpath)
|
||||
|
||||
indexB, err := ioutil.ReadFile(indexpath)
|
||||
indexB, err := os.ReadFile(indexpath)
|
||||
if err != nil {
|
||||
return -1, err
|
||||
}
|
||||
|
|
@ -391,21 +391,19 @@ func lFileLabel(fpath string) (string, error) {
|
|||
return string(label), nil
|
||||
}
|
||||
|
||||
// setFSCreateLabel tells kernel the label to create all file system objects
|
||||
// created by this task. Setting label="" to return to default.
|
||||
func setFSCreateLabel(label string) error {
|
||||
return writeAttr("fscreate", label)
|
||||
return writeCon(attrPath("fscreate"), label)
|
||||
}
|
||||
|
||||
// fsCreateLabel returns the default label the kernel which the kernel is using
|
||||
// for file system objects created by this task. "" indicates default.
|
||||
func fsCreateLabel() (string, error) {
|
||||
return readAttr("fscreate")
|
||||
return readCon(attrPath("fscreate"))
|
||||
}
|
||||
|
||||
// currentLabel returns the SELinux label of the current process thread, or an error.
|
||||
func currentLabel() (string, error) {
|
||||
return readAttr("current")
|
||||
return readCon(attrPath("current"))
|
||||
}
|
||||
|
||||
// pidLabel returns the SELinux label of the given pid, or an error.
|
||||
|
|
@ -416,7 +414,7 @@ func pidLabel(pid int) (string, error) {
|
|||
// ExecLabel returns the SELinux label that the kernel will use for any programs
|
||||
// that are executed by the current process thread, or an error.
|
||||
func execLabel() (string, error) {
|
||||
return readAttr("exec")
|
||||
return readCon(attrPath("exec"))
|
||||
}
|
||||
|
||||
func writeCon(fpath, val string) error {
|
||||
|
|
@ -462,18 +460,10 @@ func attrPath(attr string) string {
|
|||
})
|
||||
|
||||
if haveThreadSelf {
|
||||
return path.Join(threadSelfPrefix, attr)
|
||||
return filepath.Join(threadSelfPrefix, attr)
|
||||
}
|
||||
|
||||
return path.Join("/proc/self/task/", strconv.Itoa(unix.Gettid()), "/attr/", attr)
|
||||
}
|
||||
|
||||
func readAttr(attr string) (string, error) {
|
||||
return readCon(attrPath(attr))
|
||||
}
|
||||
|
||||
func writeAttr(attr, val string) error {
|
||||
return writeCon(attrPath(attr), val)
|
||||
return filepath.Join("/proc/self/task", strconv.Itoa(unix.Gettid()), "attr", attr)
|
||||
}
|
||||
|
||||
// canonicalizeContext takes a context string and writes it to the kernel
|
||||
|
|
@ -560,30 +550,30 @@ func (l *level) parseLevel(levelStr string) error {
|
|||
|
||||
// rangeStrToMLSRange marshals a string representation of a range.
|
||||
func rangeStrToMLSRange(rangeStr string) (*mlsRange, error) {
|
||||
mlsRange := &mlsRange{}
|
||||
levelSlice := strings.SplitN(rangeStr, "-", 2)
|
||||
r := &mlsRange{}
|
||||
l := strings.SplitN(rangeStr, "-", 2)
|
||||
|
||||
switch len(levelSlice) {
|
||||
switch len(l) {
|
||||
// rangeStr that has a low and a high level, e.g. s4:c0.c1023-s6:c0.c1023
|
||||
case 2:
|
||||
mlsRange.high = &level{}
|
||||
if err := mlsRange.high.parseLevel(levelSlice[1]); err != nil {
|
||||
return nil, fmt.Errorf("failed to parse high level %q: %w", levelSlice[1], err)
|
||||
r.high = &level{}
|
||||
if err := r.high.parseLevel(l[1]); err != nil {
|
||||
return nil, fmt.Errorf("failed to parse high level %q: %w", l[1], err)
|
||||
}
|
||||
fallthrough
|
||||
// rangeStr that is single level, e.g. s6:c0,c3,c5,c30.c1023
|
||||
case 1:
|
||||
mlsRange.low = &level{}
|
||||
if err := mlsRange.low.parseLevel(levelSlice[0]); err != nil {
|
||||
return nil, fmt.Errorf("failed to parse low level %q: %w", levelSlice[0], err)
|
||||
r.low = &level{}
|
||||
if err := r.low.parseLevel(l[0]); err != nil {
|
||||
return nil, fmt.Errorf("failed to parse low level %q: %w", l[0], err)
|
||||
}
|
||||
}
|
||||
|
||||
if mlsRange.high == nil {
|
||||
mlsRange.high = mlsRange.low
|
||||
if r.high == nil {
|
||||
r.high = r.low
|
||||
}
|
||||
|
||||
return mlsRange, nil
|
||||
return r, nil
|
||||
}
|
||||
|
||||
// bitsetToStr takes a category bitset and returns it in the
|
||||
|
|
@ -617,17 +607,17 @@ func bitsetToStr(c *big.Int) string {
|
|||
return str
|
||||
}
|
||||
|
||||
func (l1 *level) equal(l2 *level) bool {
|
||||
if l2 == nil || l1 == nil {
|
||||
return l1 == l2
|
||||
func (l *level) equal(l2 *level) bool {
|
||||
if l2 == nil || l == nil {
|
||||
return l == l2
|
||||
}
|
||||
if l1.sens != l2.sens {
|
||||
if l2.sens != l.sens {
|
||||
return false
|
||||
}
|
||||
if l2.cats == nil || l1.cats == nil {
|
||||
return l2.cats == l1.cats
|
||||
if l2.cats == nil || l.cats == nil {
|
||||
return l2.cats == l.cats
|
||||
}
|
||||
return l1.cats.Cmp(l2.cats) == 0
|
||||
return l.cats.Cmp(l2.cats) == 0
|
||||
}
|
||||
|
||||
// String returns an mlsRange as a string.
|
||||
|
|
@ -721,36 +711,13 @@ func readWriteCon(fpath string, val string) (string, error) {
|
|||
return readConFd(f)
|
||||
}
|
||||
|
||||
// setExecLabel sets the SELinux label that the kernel will use for any programs
|
||||
// that are executed by the current process thread, or an error.
|
||||
func setExecLabel(label string) error {
|
||||
return writeAttr("exec", label)
|
||||
}
|
||||
|
||||
// setTaskLabel sets the SELinux label for the current thread, or an error.
|
||||
// This requires the dyntransition permission.
|
||||
func setTaskLabel(label string) error {
|
||||
return writeAttr("current", label)
|
||||
}
|
||||
|
||||
// setSocketLabel takes a process label and tells the kernel to assign the
|
||||
// label to the next socket that gets created
|
||||
func setSocketLabel(label string) error {
|
||||
return writeAttr("sockcreate", label)
|
||||
}
|
||||
|
||||
// socketLabel retrieves the current socket label setting
|
||||
func socketLabel() (string, error) {
|
||||
return readAttr("sockcreate")
|
||||
}
|
||||
|
||||
// peerLabel retrieves the label of the client on the other side of a socket
|
||||
func peerLabel(fd uintptr) (string, error) {
|
||||
label, err := unix.GetsockoptString(int(fd), unix.SOL_SOCKET, unix.SO_PEERSEC)
|
||||
l, err := unix.GetsockoptString(int(fd), unix.SOL_SOCKET, unix.SO_PEERSEC)
|
||||
if err != nil {
|
||||
return "", &os.PathError{Op: "getsockopt", Path: "fd " + strconv.Itoa(int(fd)), Err: err}
|
||||
}
|
||||
return label, nil
|
||||
return l, nil
|
||||
}
|
||||
|
||||
// setKeyLabel takes a process label and tells the kernel to assign the
|
||||
|
|
@ -766,15 +733,10 @@ func setKeyLabel(label string) error {
|
|||
return err
|
||||
}
|
||||
|
||||
// keyLabel retrieves the current kernel keyring label setting
|
||||
func keyLabel() (string, error) {
|
||||
return readCon("/proc/self/attr/keycreate")
|
||||
}
|
||||
|
||||
// get returns the Context as a string
|
||||
func (c Context) get() string {
|
||||
if level := c["level"]; level != "" {
|
||||
return c["user"] + ":" + c["role"] + ":" + c["type"] + ":" + level
|
||||
if l := c["level"]; l != "" {
|
||||
return c["user"] + ":" + c["role"] + ":" + c["type"] + ":" + l
|
||||
}
|
||||
return c["user"] + ":" + c["role"] + ":" + c["type"]
|
||||
}
|
||||
|
|
@ -786,7 +748,7 @@ func newContext(label string) (Context, error) {
|
|||
if len(label) != 0 {
|
||||
con := strings.SplitN(label, ":", 4)
|
||||
if len(con) < 3 {
|
||||
return c, InvalidLabel
|
||||
return c, ErrInvalidLabel
|
||||
}
|
||||
c["user"] = con[0]
|
||||
c["role"] = con[1]
|
||||
|
|
@ -816,14 +778,23 @@ func reserveLabel(label string) {
|
|||
}
|
||||
|
||||
func selinuxEnforcePath() string {
|
||||
return path.Join(getSelinuxMountPoint(), "enforce")
|
||||
return filepath.Join(getSelinuxMountPoint(), "enforce")
|
||||
}
|
||||
|
||||
// isMLSEnabled checks if MLS is enabled.
|
||||
func isMLSEnabled() bool {
|
||||
enabledB, err := os.ReadFile(filepath.Join(getSelinuxMountPoint(), "mls"))
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
return bytes.Equal(enabledB, []byte{'1'})
|
||||
}
|
||||
|
||||
// enforceMode returns the current SELinux mode Enforcing, Permissive, Disabled
|
||||
func enforceMode() int {
|
||||
var enforce int
|
||||
|
||||
enforceB, err := ioutil.ReadFile(selinuxEnforcePath())
|
||||
enforceB, err := os.ReadFile(selinuxEnforcePath())
|
||||
if err != nil {
|
||||
return -1
|
||||
}
|
||||
|
|
@ -837,11 +808,12 @@ func enforceMode() int {
|
|||
// setEnforceMode sets the current SELinux mode Enforcing, Permissive.
|
||||
// Disabled is not valid, since this needs to be set at boot time.
|
||||
func setEnforceMode(mode int) error {
|
||||
return ioutil.WriteFile(selinuxEnforcePath(), []byte(strconv.Itoa(mode)), 0o644)
|
||||
//nolint:gosec // ignore G306: permissions to be 0600 or less.
|
||||
return os.WriteFile(selinuxEnforcePath(), []byte(strconv.Itoa(mode)), 0o644)
|
||||
}
|
||||
|
||||
// defaultEnforceMode returns the systems default SELinux mode Enforcing,
|
||||
// Permissive or Disabled. Note this is is just the default at boot time.
|
||||
// Permissive or Disabled. Note this is just the default at boot time.
|
||||
// EnforceMode tells you the systems current mode.
|
||||
func defaultEnforceMode() int {
|
||||
switch readConfig(selinuxTag) {
|
||||
|
|
@ -941,7 +913,7 @@ func openContextFile() (*os.File, error) {
|
|||
if f, err := os.Open(contextFile); err == nil {
|
||||
return f, nil
|
||||
}
|
||||
return os.Open(filepath.Join(policyRoot(), "/contexts/lxc_contexts"))
|
||||
return os.Open(filepath.Join(policyRoot(), "contexts", "lxc_contexts"))
|
||||
}
|
||||
|
||||
func loadLabels() {
|
||||
|
|
@ -1044,7 +1016,8 @@ func addMcs(processLabel, fileLabel string) (string, string) {
|
|||
|
||||
// securityCheckContext validates that the SELinux label is understood by the kernel
|
||||
func securityCheckContext(val string) error {
|
||||
return ioutil.WriteFile(path.Join(getSelinuxMountPoint(), "context"), []byte(val), 0o644)
|
||||
//nolint:gosec // ignore G306: permissions to be 0600 or less.
|
||||
return os.WriteFile(filepath.Join(getSelinuxMountPoint(), "context"), []byte(val), 0o644)
|
||||
}
|
||||
|
||||
// copyLevel returns a label with the MLS/MCS level from src label replaced on
|
||||
|
|
@ -1073,7 +1046,7 @@ func copyLevel(src, dest string) (string, error) {
|
|||
return tcon.Get(), nil
|
||||
}
|
||||
|
||||
// chcon changes the fpath file object to the SELinux label label.
|
||||
// chcon changes the fpath file object to the SELinux label.
|
||||
// If fpath is a directory and recurse is true, then chcon walks the
|
||||
// directory tree setting the label.
|
||||
func chcon(fpath string, label string, recurse bool) error {
|
||||
|
|
@ -1084,7 +1057,7 @@ func chcon(fpath string, label string, recurse bool) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
exclude_paths := map[string]bool{
|
||||
excludePaths := map[string]bool{
|
||||
"/": true,
|
||||
"/bin": true,
|
||||
"/boot": true,
|
||||
|
|
@ -1112,19 +1085,19 @@ func chcon(fpath string, label string, recurse bool) error {
|
|||
}
|
||||
|
||||
if home := os.Getenv("HOME"); home != "" {
|
||||
exclude_paths[home] = true
|
||||
excludePaths[home] = true
|
||||
}
|
||||
|
||||
if sudoUser := os.Getenv("SUDO_USER"); sudoUser != "" {
|
||||
if usr, err := user.Lookup(sudoUser); err == nil {
|
||||
exclude_paths[usr.HomeDir] = true
|
||||
excludePaths[usr.HomeDir] = true
|
||||
}
|
||||
}
|
||||
|
||||
if fpath != "/" {
|
||||
fpath = strings.TrimSuffix(fpath, "/")
|
||||
}
|
||||
if exclude_paths[fpath] {
|
||||
if excludePaths[fpath] {
|
||||
return fmt.Errorf("SELinux relabeling of %s is not allowed", fpath)
|
||||
}
|
||||
|
||||
|
|
@ -1152,6 +1125,28 @@ func chcon(fpath string, label string, recurse bool) error {
|
|||
return rchcon(fpath, label)
|
||||
}
|
||||
|
||||
func rchcon(fpath, label string) error { //revive:disable:cognitive-complexity
|
||||
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
|
||||
}
|
||||
}
|
||||
err := lSetFileLabel(p, label)
|
||||
// Walk a file tree can race with removal, so ignore ENOENT.
|
||||
if errors.Is(err, os.ErrNotExist) {
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
})
|
||||
}
|
||||
|
||||
// dupSecOpt takes an SELinux process label and returns security options that
|
||||
// can be used to set the SELinux Type and Level for future container processes.
|
||||
func dupSecOpt(src string) ([]string, error) {
|
||||
|
|
@ -1180,12 +1175,6 @@ func dupSecOpt(src string) ([]string, error) {
|
|||
return dup, nil
|
||||
}
|
||||
|
||||
// disableSecOpt returns a security opt that can be used to disable SELinux
|
||||
// labeling support for future container processes.
|
||||
func disableSecOpt() []string {
|
||||
return []string{"disable"}
|
||||
}
|
||||
|
||||
// findUserInContext scans the reader for a valid SELinux context
|
||||
// match that is verified with the verifier. Invalid contexts are
|
||||
// skipped. It returns a matched context or an empty string if no
|
||||
|
|
|
|||
44
vendor/github.com/opencontainers/selinux/go-selinux/selinux_stub.go
generated
vendored
44
vendor/github.com/opencontainers/selinux/go-selinux/selinux_stub.go
generated
vendored
|
|
@ -3,9 +3,20 @@
|
|||
|
||||
package selinux
|
||||
|
||||
func setDisabled() {
|
||||
func attrPath(string) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func readCon(fpath string) (string, error) {
|
||||
return "", nil
|
||||
}
|
||||
|
||||
func writeCon(string, string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func setDisabled() {}
|
||||
|
||||
func getEnabled() bool {
|
||||
return false
|
||||
}
|
||||
|
|
@ -62,22 +73,6 @@ func calculateGlbLub(sourceRange, targetRange string) (string, error) {
|
|||
return "", nil
|
||||
}
|
||||
|
||||
func setExecLabel(label string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func setTaskLabel(label string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func setSocketLabel(label string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func socketLabel() (string, error) {
|
||||
return "", nil
|
||||
}
|
||||
|
||||
func peerLabel(fd uintptr) (string, error) {
|
||||
return "", nil
|
||||
}
|
||||
|
|
@ -86,17 +81,12 @@ func setKeyLabel(label string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func keyLabel() (string, error) {
|
||||
return "", nil
|
||||
}
|
||||
|
||||
func (c Context) get() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func newContext(label string) (Context, error) {
|
||||
c := make(Context)
|
||||
return c, nil
|
||||
return Context{}, nil
|
||||
}
|
||||
|
||||
func clearLabels() {
|
||||
|
|
@ -105,6 +95,10 @@ func clearLabels() {
|
|||
func reserveLabel(label string) {
|
||||
}
|
||||
|
||||
func isMLSEnabled() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func enforceMode() int {
|
||||
return Disabled
|
||||
}
|
||||
|
|
@ -152,10 +146,6 @@ func dupSecOpt(src string) ([]string, error) {
|
|||
return nil, nil
|
||||
}
|
||||
|
||||
func disableSecOpt() []string {
|
||||
return []string{"disable"}
|
||||
}
|
||||
|
||||
func getDefaultContextWithLevel(user, level, scon string) (string, error) {
|
||||
return "", nil
|
||||
}
|
||||
|
|
|
|||
10
vendor/github.com/opencontainers/selinux/pkg/pwalk/pwalk.go
generated
vendored
10
vendor/github.com/opencontainers/selinux/pkg/pwalk/pwalk.go
generated
vendored
|
|
@ -8,6 +8,10 @@ import (
|
|||
"sync"
|
||||
)
|
||||
|
||||
// WalkFunc is the type of the function called by Walk to visit each
|
||||
// file or directory. It is an alias for [filepath.WalkFunc].
|
||||
//
|
||||
// Deprecated: use [github.com/opencontainers/selinux/pkg/pwalkdir] and [fs.WalkDirFunc].
|
||||
type WalkFunc = filepath.WalkFunc
|
||||
|
||||
// Walk is a wrapper for filepath.Walk which can call multiple walkFn
|
||||
|
|
@ -29,6 +33,8 @@ type WalkFunc = filepath.WalkFunc
|
|||
// - if more than one walkFn instance will return an error, only one
|
||||
// of such errors will be propagated and returned by Walk, others
|
||||
// will be silently discarded.
|
||||
//
|
||||
// Deprecated: use [github.com/opencontainers/selinux/pkg/pwalkdir.Walk]
|
||||
func Walk(root string, walkFn WalkFunc) error {
|
||||
return WalkN(root, walkFn, runtime.NumCPU()*2)
|
||||
}
|
||||
|
|
@ -38,6 +44,8 @@ func Walk(root string, walkFn WalkFunc) error {
|
|||
// num walkFn will be called at any one time.
|
||||
//
|
||||
// Please see Walk documentation for caveats of using this function.
|
||||
//
|
||||
// Deprecated: use [github.com/opencontainers/selinux/pkg/pwalkdir.WalkN]
|
||||
func WalkN(root string, walkFn WalkFunc, num int) error {
|
||||
// make sure limit is sensible
|
||||
if num < 1 {
|
||||
|
|
@ -110,6 +118,6 @@ func WalkN(root string, walkFn WalkFunc, num int) error {
|
|||
// walkArgs holds the arguments that were passed to the Walk or WalkN
|
||||
// functions.
|
||||
type walkArgs struct {
|
||||
path string
|
||||
info *os.FileInfo
|
||||
path string
|
||||
}
|
||||
|
|
|
|||
2
vendor/github.com/opencontainers/selinux/pkg/pwalkdir/pwalkdir.go
generated
vendored
2
vendor/github.com/opencontainers/selinux/pkg/pwalkdir/pwalkdir.go
generated
vendored
|
|
@ -111,6 +111,6 @@ func WalkN(root string, walkFn fs.WalkDirFunc, num int) error {
|
|||
// walkArgs holds the arguments that were passed to the Walk or WalkN
|
||||
// functions.
|
||||
type walkArgs struct {
|
||||
path string
|
||||
entry fs.DirEntry
|
||||
path string
|
||||
}
|
||||
|
|
|
|||
14
vendor/modules.txt
vendored
14
vendor/modules.txt
vendored
|
|
@ -14,7 +14,7 @@ github.com/Microsoft/go-winio/internal/socket
|
|||
github.com/Microsoft/go-winio/pkg/guid
|
||||
github.com/Microsoft/go-winio/pkg/security
|
||||
github.com/Microsoft/go-winio/vhd
|
||||
# github.com/Microsoft/hcsshim v0.9.6
|
||||
# github.com/Microsoft/hcsshim v0.9.7
|
||||
## explicit; go 1.13
|
||||
github.com/Microsoft/hcsshim
|
||||
github.com/Microsoft/hcsshim/computestorage
|
||||
|
|
@ -79,8 +79,8 @@ github.com/containerd/containerd/log
|
|||
github.com/containerd/containerd/pkg/userns
|
||||
github.com/containerd/containerd/platforms
|
||||
github.com/containerd/containerd/sys
|
||||
# github.com/containerd/stargz-snapshotter/estargz v0.13.0
|
||||
## explicit; go 1.16
|
||||
# github.com/containerd/stargz-snapshotter/estargz v0.14.1
|
||||
## explicit; go 1.19
|
||||
github.com/containerd/stargz-snapshotter/estargz
|
||||
github.com/containerd/stargz-snapshotter/estargz/errorutil
|
||||
# github.com/containernetworking/cni v1.1.2
|
||||
|
|
@ -276,7 +276,7 @@ github.com/containers/psgo/internal/dev
|
|||
github.com/containers/psgo/internal/host
|
||||
github.com/containers/psgo/internal/proc
|
||||
github.com/containers/psgo/internal/process
|
||||
# github.com/containers/storage v1.45.3
|
||||
# github.com/containers/storage v1.45.5
|
||||
## explicit; go 1.17
|
||||
github.com/containers/storage
|
||||
github.com/containers/storage/drivers
|
||||
|
|
@ -718,7 +718,7 @@ github.com/opencontainers/runc/libcontainer/devices
|
|||
github.com/opencontainers/runc/libcontainer/user
|
||||
github.com/opencontainers/runc/libcontainer/userns
|
||||
github.com/opencontainers/runc/libcontainer/utils
|
||||
# github.com/opencontainers/runtime-spec v1.0.3-0.20220825212826-86290f6a00fb
|
||||
# github.com/opencontainers/runtime-spec v1.1.0-rc.1
|
||||
## explicit
|
||||
github.com/opencontainers/runtime-spec/specs-go
|
||||
# github.com/opencontainers/runtime-tools v0.9.1-0.20221014010322-58c91d646d86
|
||||
|
|
@ -729,8 +729,8 @@ github.com/opencontainers/runtime-tools/generate
|
|||
github.com/opencontainers/runtime-tools/generate/seccomp
|
||||
github.com/opencontainers/runtime-tools/specerror
|
||||
github.com/opencontainers/runtime-tools/validate
|
||||
# github.com/opencontainers/selinux v1.10.2
|
||||
## explicit; go 1.13
|
||||
# github.com/opencontainers/selinux v1.11.0
|
||||
## explicit; go 1.19
|
||||
github.com/opencontainers/selinux/go-selinux
|
||||
github.com/opencontainers/selinux/go-selinux/label
|
||||
github.com/opencontainers/selinux/pkg/pwalk
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue