@@ -10,6 +10,7 @@ import (
1010 "path"
1111 "path/filepath"
1212 "reflect"
13+ "slices"
1314 "strconv"
1415 "strings"
1516 "sync"
@@ -452,16 +453,6 @@ func (c *Container) includeExecFifo(cmd *exec.Cmd) error {
452453 return nil
453454}
454455
455- // No longer needed in Go 1.21.
456- func slicesContains [S ~ []E , E comparable ](slice S , needle E ) bool {
457- for _ , val := range slice {
458- if val == needle {
459- return true
460- }
461- }
462- return false
463- }
464-
465456func isDmzBinarySafe (c * configs.Config ) bool {
466457 // Because we set the dumpable flag in nsexec, the only time when it is
467458 // unsafe to use runc-dmz is when the container process would be able to
@@ -472,9 +463,9 @@ func isDmzBinarySafe(c *configs.Config) bool {
472463 // inheritable, or ambient sets). Luckily, most containers do not have this
473464 // capability.
474465 if c .Capabilities == nil ||
475- (! slicesContains (c .Capabilities .Bounding , "CAP_SYS_PTRACE" ) &&
476- ! slicesContains (c .Capabilities .Inheritable , "CAP_SYS_PTRACE" ) &&
477- ! slicesContains (c .Capabilities .Ambient , "CAP_SYS_PTRACE" )) {
466+ (! slices . Contains (c .Capabilities .Bounding , "CAP_SYS_PTRACE" ) &&
467+ ! slices . Contains (c .Capabilities .Inheritable , "CAP_SYS_PTRACE" ) &&
468+ ! slices . Contains (c .Capabilities .Ambient , "CAP_SYS_PTRACE" )) {
478469 return true
479470 }
480471
0 commit comments