• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang libseccomp-golang.GetNativeArch函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/seccomp/libseccomp-golang.GetNativeArch函数的典型用法代码示例。如果您正苦于以下问题:Golang GetNativeArch函数的具体用法?Golang GetNativeArch怎么用?Golang GetNativeArch使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了GetNativeArch函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: arches

func arches() []types.Arch {
	var native, err = libseccomp.GetNativeArch()
	if err != nil {
		return []types.Arch{}
	}
	var a = native.String()
	switch a {
	case "amd64":
		return []types.Arch{types.ArchX86_64, types.ArchX86, types.ArchX32}
	case "arm64":
		return []types.Arch{types.ArchARM, types.ArchAARCH64}
	case "mips64":
		return []types.Arch{types.ArchMIPS, types.ArchMIPS64, types.ArchMIPS64N32}
	case "mips64n32":
		return []types.Arch{types.ArchMIPS, types.ArchMIPS64, types.ArchMIPS64N32}
	case "mipsel64":
		return []types.Arch{types.ArchMIPSEL, types.ArchMIPSEL64, types.ArchMIPSEL64N32}
	case "mipsel64n32":
		return []types.Arch{types.ArchMIPSEL, types.ArchMIPSEL64, types.ArchMIPSEL64N32}
	case "s390x":
		return []types.Arch{types.ArchS390, types.ArchS390X}
	default:
		return []types.Arch{}
	}
}
开发者ID:kolyshkin,项目名称:docker,代码行数:25,代码来源:seccomp_default.go


示例2: arches

func arches() []string {
	var native, err = libseccomp.GetNativeArch()
	if err != nil {
		return []string{}
	}
	var a = native.String()
	switch a {
	case "amd64":
		return []string{"amd64", "x86", "x32"}
	case "arm64":
		return []string{"arm64", "arm"}
	case "mips64":
		return []string{"mips64", "mips64n32", "mips"}
	case "mips64n32":
		return []string{"mips64", "mips64n32", "mips"}
	case "mipsel64":
		return []string{"mipsel64", "mipsel64n32", "mipsel"}
	case "mipsel64n32":
		return []string{"mipsel64", "mipsel64n32", "mipsel"}
	default:
		return []string{a}
	}
}
开发者ID:gao-feng,项目名称:docker,代码行数:23,代码来源:seccomp_default.go


示例3: arches

func arches() []specs.Arch {
	var native, err = libseccomp.GetNativeArch()
	if err != nil {
		return []specs.Arch{}
	}
	var a = native.String()
	switch a {
	case "amd64":
		return []specs.Arch{specs.ArchX86_64, specs.ArchX86, specs.ArchX32}
	case "arm64":
		return []specs.Arch{specs.ArchAARCH64, specs.ArchARM}
	case "mips64":
		return []specs.Arch{specs.ArchMIPS, specs.ArchMIPS64, specs.ArchMIPS64N32}
	case "mips64n32":
		return []specs.Arch{specs.ArchMIPS, specs.ArchMIPS64, specs.ArchMIPS64N32}
	case "mipsel64":
		return []specs.Arch{specs.ArchMIPSEL, specs.ArchMIPSEL64, specs.ArchMIPSEL64N32}
	case "mipsel64n32":
		return []specs.Arch{specs.ArchMIPSEL, specs.ArchMIPSEL64, specs.ArchMIPSEL64N32}
	default:
		return []specs.Arch{}
	}
}
开发者ID:ailispaw,项目名称:docker,代码行数:23,代码来源:seccomp_default_linux.go


示例4: DefaultProfile


//.........这里部分代码省略.........
		{
			Name:   "vmsplice",
			Action: types.ActAllow,
			Args:   []*types.Arg{},
		},
		{
			Name:   "wait4",
			Action: types.ActAllow,
			Args:   []*types.Arg{},
		},
		{
			Name:   "waitid",
			Action: types.ActAllow,
			Args:   []*types.Arg{},
		},
		{
			Name:   "waitpid",
			Action: types.ActAllow,
			Args:   []*types.Arg{},
		},
		{
			Name:   "write",
			Action: types.ActAllow,
			Args:   []*types.Arg{},
		},
		{
			Name:   "writev",
			Action: types.ActAllow,
			Args:   []*types.Arg{},
		},
	}

	var arch string
	var native, err = libseccomp.GetNativeArch()
	if err == nil {
		arch = native.String()
	}
	switch arch {
	case "arm", "arm64":
		syscalls = append(syscalls, []*types.Syscall{
			{
				Name:   "breakpoint",
				Action: types.ActAllow,
				Args:   []*types.Arg{},
			},
			{
				Name:   "cacheflush",
				Action: types.ActAllow,
				Args:   []*types.Arg{},
			},
			{
				Name:   "set_tls",
				Action: types.ActAllow,
				Args:   []*types.Arg{},
			},
		}...)
	case "amd64", "x32":
		syscalls = append(syscalls, []*types.Syscall{
			{
				Name:   "arch_prctl",
				Action: types.ActAllow,
				Args:   []*types.Arg{},
			},
		}...)
		fallthrough
	case "x86":
开发者ID:lujiwen,项目名称:docker,代码行数:67,代码来源:seccomp_default.go


示例5: setupSeccomp

func setupSeccomp(config *types.Seccomp, rs *specs.Spec) (*specs.Seccomp, error) {
	if config == nil {
		return nil, nil
	}

	// No default action specified, no syscalls listed, assume seccomp disabled
	if config.DefaultAction == "" && len(config.Syscalls) == 0 {
		return nil, nil
	}

	newConfig := &specs.Seccomp{}

	var arch string
	var native, err = libseccomp.GetNativeArch()
	if err == nil {
		arch = native.String()
	}

	if len(config.Architectures) != 0 && len(config.ArchMap) != 0 {
		return nil, errors.New("'architectures' and 'archMap' were specified in the seccomp profile, use either 'architectures' or 'archMap'")
	}

	// if config.Architectures == 0 then libseccomp will figure out the architecture to use
	if len(config.Architectures) != 0 {
		for _, a := range config.Architectures {
			newConfig.Architectures = append(newConfig.Architectures, specs.Arch(a))
		}
	}

	if len(config.ArchMap) != 0 {
		for _, a := range config.ArchMap {
			seccompArch, ok := nativeToSeccomp[arch]
			if ok {
				if a.Arch == seccompArch {
					newConfig.Architectures = append(newConfig.Architectures, specs.Arch(a.Arch))
					for _, sa := range a.SubArches {
						newConfig.Architectures = append(newConfig.Architectures, specs.Arch(sa))
					}
					break
				}
			}
		}
	}

	newConfig.DefaultAction = specs.Action(config.DefaultAction)

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) {
				continue Loop
			}
		}
		if len(call.Excludes.Caps) > 0 {
			for _, c := range call.Excludes.Caps {
				if stringutils.InSlice(rs.Process.Capabilities, c) {
					continue Loop
				}
			}
		}
		if len(call.Includes.Arches) > 0 {
			if !stringutils.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, c) {
					continue Loop
				}
			}
		}

		if call.Name != "" && len(call.Names) != 0 {
			return nil, errors.New("'name' and 'names' were specified in the seccomp profile, use either 'name' or 'names'")
		}

		if call.Name != "" {
			newConfig.Syscalls = append(newConfig.Syscalls, createSpecsSyscall(call.Name, call.Action, call.Args))
		}

		for _, n := range call.Names {
			newConfig.Syscalls = append(newConfig.Syscalls, createSpecsSyscall(n, call.Action, call.Args))
		}
	}

	return newConfig, nil
}
开发者ID:HuKeping,项目名称:docker,代码行数:89,代码来源:seccomp.go



注:本文中的github.com/seccomp/libseccomp-golang.GetNativeArch函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang goerr.NewError函数代码示例发布时间:2022-05-28
下一篇:
Golang assert.Equal函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap