Merge pull request #1570 from yoheiueda/masked
Set masked and readonly paths based on default Unix spec
This commit is contained in:
commit
b1ee4c0d7b
@ -182,11 +182,15 @@ func (c *criService) containerSpec(id string, sandboxID string, sandboxPid uint3
|
|||||||
if !c.config.DisableProcMount {
|
if !c.config.DisableProcMount {
|
||||||
// Apply masked paths if specified.
|
// Apply masked paths if specified.
|
||||||
// If the container is privileged, this will be cleared later on.
|
// If the container is privileged, this will be cleared later on.
|
||||||
specOpts = append(specOpts, oci.WithMaskedPaths(securityContext.GetMaskedPaths()))
|
if maskedPaths := securityContext.GetMaskedPaths(); maskedPaths != nil {
|
||||||
|
specOpts = append(specOpts, oci.WithMaskedPaths(maskedPaths))
|
||||||
|
}
|
||||||
|
|
||||||
// Apply readonly paths if specified.
|
// Apply readonly paths if specified.
|
||||||
// If the container is privileged, this will be cleared later on.
|
// If the container is privileged, this will be cleared later on.
|
||||||
specOpts = append(specOpts, oci.WithReadonlyPaths(securityContext.GetReadonlyPaths()))
|
if readonlyPaths := securityContext.GetReadonlyPaths(); readonlyPaths != nil {
|
||||||
|
specOpts = append(specOpts, oci.WithReadonlyPaths(readonlyPaths))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if securityContext.GetPrivileged() {
|
if securityContext.GetPrivileged() {
|
||||||
|
@ -959,12 +959,12 @@ func TestMaskedAndReadonlyPaths(t *testing.T) {
|
|||||||
expectedReadonly: defaultSpec.Linux.ReadonlyPaths,
|
expectedReadonly: defaultSpec.Linux.ReadonlyPaths,
|
||||||
privileged: false,
|
privileged: false,
|
||||||
},
|
},
|
||||||
"should always apply CRI specified paths when disable_proc_mount = false": {
|
"should apply default if not specified when disable_proc_mount = false": {
|
||||||
disableProcMount: false,
|
disableProcMount: false,
|
||||||
masked: nil,
|
masked: nil,
|
||||||
readonly: nil,
|
readonly: nil,
|
||||||
expectedMasked: nil,
|
expectedMasked: defaultSpec.Linux.MaskedPaths,
|
||||||
expectedReadonly: nil,
|
expectedReadonly: defaultSpec.Linux.ReadonlyPaths,
|
||||||
privileged: false,
|
privileged: false,
|
||||||
},
|
},
|
||||||
"should be able to specify empty paths": {
|
"should be able to specify empty paths": {
|
||||||
|
Loading…
Reference in New Issue
Block a user