From b7fdd524cb3758b373d873831dea02bd1499e8b3 Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Fri, 24 May 2024 17:00:38 -0700 Subject: [PATCH] libct: use slices package As we're no longer supporting Go < 1.21. Signed-off-by: Kir Kolyshkin --- libcontainer/container_linux.go | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/libcontainer/container_linux.go b/libcontainer/container_linux.go index 13be71ccb..ad49244a8 100644 --- a/libcontainer/container_linux.go +++ b/libcontainer/container_linux.go @@ -10,6 +10,7 @@ import ( "path" "path/filepath" "reflect" + "slices" "strconv" "strings" "sync" @@ -452,16 +453,6 @@ func (c *Container) includeExecFifo(cmd *exec.Cmd) error { return nil } -// No longer needed in Go 1.21. -func slicesContains[S ~[]E, E comparable](slice S, needle E) bool { - for _, val := range slice { - if val == needle { - return true - } - } - return false -} - func isDmzBinarySafe(c *configs.Config) bool { // Because we set the dumpable flag in nsexec, the only time when it is // unsafe to use runc-dmz is when the container process would be able to @@ -472,9 +463,9 @@ func isDmzBinarySafe(c *configs.Config) bool { // inheritable, or ambient sets). Luckily, most containers do not have this // capability. if c.Capabilities == nil || - (!slicesContains(c.Capabilities.Bounding, "CAP_SYS_PTRACE") && - !slicesContains(c.Capabilities.Inheritable, "CAP_SYS_PTRACE") && - !slicesContains(c.Capabilities.Ambient, "CAP_SYS_PTRACE")) { + (!slices.Contains(c.Capabilities.Bounding, "CAP_SYS_PTRACE") && + !slices.Contains(c.Capabilities.Inheritable, "CAP_SYS_PTRACE") && + !slices.Contains(c.Capabilities.Ambient, "CAP_SYS_PTRACE")) { return true }