From d0f3c17912643aca73372aa87f3eadf757621ccc Mon Sep 17 00:00:00 2001 From: Daniel J Walsh Date: Fri, 2 Oct 2020 12:02:16 -0400 Subject: 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 --- libpod/pod.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'libpod') diff --git a/libpod/pod.go b/libpod/pod.go index a5a0532be..c8f62ca18 100644 --- a/libpod/pod.go +++ b/libpod/pod.go @@ -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 +} -- cgit v1.2.3-54-g00ecf