Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion validate/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ func (v *Validator) CheckProcess() (errs error) {
errs = multierror.Append(errs, v.CheckCapabilities())
}

if len(process.ApparmorProfile) > 0 {
if len(process.ApparmorProfile) > 0 && v.spec.Root != nil {
profilePath := filepath.Join(v.bundlePath, v.spec.Root.Path, "/etc/apparmor.d", process.ApparmorProfile)
_, err := os.Stat(profilePath)
if err != nil {
Expand Down
14 changes: 14 additions & 0 deletions validate/validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,20 @@ func TestCheckProcess(t *testing.T) {
platform: "solaris",
expected: specerror.PosixProcRlimitsTypeValueError,
},
{
// Root is optional in the runtime spec; an apparmorProfile
// with no root must not panic the validator.
val: rspec.Spec{
Version: "1.0.0",
Process: &rspec.Process{
Args: []string{"sh"},
Cwd: "/",
ApparmorProfile: "docker-default",
},
},
platform: "linux",
expected: specerror.NonError,
},
}
for _, c := range cases {
v, err := NewValidator(&c.val, ".", false, c.platform)
Expand Down