Add SELinux support for pods

All containers within a Pod need to run with the same SELinux
label, unless overwritten by the user.

Also added a bunch of SELinux tests to make sure selinux labels
are correct on namespaces.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
Daniel J Walsh
2020-10-02 12:02:16 -04:00
parent d4e97b35c2
commit d0f3c17912
3 changed files with 145 additions and 0 deletions

View File

@ -327,3 +327,21 @@ func (p *Pod) GetPodStats(previousContainerStats map[string]*define.ContainerSta
}
return newContainerStats, nil
}
// ProcessLabel returns the SELinux label associated with the pod
func (p *Pod) ProcessLabel() (string, error) {
if !p.HasInfraContainer() {
return "", nil
}
id, err := p.InfraContainerID()
if err != nil {
return "", err
}
ctr, err := p.runtime.state.Container(id)
if err != nil {
return "", err
}
return ctr.ProcessLabel(), nil
}