diff options
author | Chao Wang <wangchao.fnst@cn.fujitsu.com> | 2017-11-10 13:18:48 +0800 |
---|---|---|
committer | Chao Wang <wangchao.fnst@cn.fujitsu.com> | 2017-11-10 13:42:38 +0800 |
commit | 5c154cfac89305f7ca9446854e56700e8a660f93 (patch) | |
tree | 10947154b76ba16916a9f34a461da94d2c1d40af /profiles | |
parent | dc90c3047e1cc59770395ded86128305e3d24543 (diff) | |
download | docker-5c154cfac89305f7ca9446854e56700e8a660f93.tar.gz |
Copy Inslice() to those parts that use it
Signed-off-by: Chao Wang <wangchao.fnst@cn.fujitsu.com>
Diffstat (limited to 'profiles')
-rw-r--r-- | profiles/seccomp/seccomp.go | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/profiles/seccomp/seccomp.go b/profiles/seccomp/seccomp.go index 90a3859484..07d522aad6 100644 --- a/profiles/seccomp/seccomp.go +++ b/profiles/seccomp/seccomp.go @@ -8,7 +8,6 @@ import ( "fmt" "github.com/docker/docker/api/types" - "github.com/docker/docker/pkg/stringutils" "github.com/opencontainers/runtime-spec/specs-go" libseccomp "github.com/seccomp/libseccomp-golang" ) @@ -39,6 +38,17 @@ var nativeToSeccomp = map[string]types.Arch{ "s390x": types.ArchS390X, } +// inSlice tests whether a string is contained in a slice of strings or not. +// Comparison is case sensitive +func inSlice(slice []string, s string) bool { + for _, ss := range slice { + if s == ss { + return true + } + } + return false +} + func setupSeccomp(config *types.Seccomp, rs *specs.Spec) (*specs.LinuxSeccomp, error) { if config == nil { return nil, nil @@ -89,25 +99,25 @@ Loop: // Loop through all syscall blocks and convert them to libcontainer format after filtering them for _, call := range config.Syscalls { if len(call.Excludes.Arches) > 0 { - if stringutils.InSlice(call.Excludes.Arches, arch) { + if inSlice(call.Excludes.Arches, arch) { continue Loop } } if len(call.Excludes.Caps) > 0 { for _, c := range call.Excludes.Caps { - if stringutils.InSlice(rs.Process.Capabilities.Effective, c) { + if inSlice(rs.Process.Capabilities.Effective, c) { continue Loop } } } if len(call.Includes.Arches) > 0 { - if !stringutils.InSlice(call.Includes.Arches, arch) { + if !inSlice(call.Includes.Arches, arch) { continue Loop } } if len(call.Includes.Caps) > 0 { for _, c := range call.Includes.Caps { - if !stringutils.InSlice(rs.Process.Capabilities.Effective, c) { + if !inSlice(rs.Process.Capabilities.Effective, c) { continue Loop } } |