登录
注册
开源
企业版
高校版
搜索
帮助中心
使用条款
关于我们
开源
企业版
高校版
私有云
模力方舟
AI 队友
登录
注册
代码拉取完成,页面将自动刷新
开源项目
>
开发工具
>
编译/构建/部署
&&
捐赠
捐赠前请先登录
取消
前往登录
扫描微信二维码支付
取消
支付完成
支付提示
将跳转至支付宝完成支付
确定
取消
Watch
不关注
关注所有动态
仅关注版本发行动态
关注但不提醒动态
14
Star
56
Fork
32
openEuler
/
isula-build
代码
Issues
6
Pull Requests
0
Wiki
统计
流水线
服务
质量分析
Jenkins for Gitee
腾讯云托管
腾讯云 Serverless
悬镜安全
阿里云 SAE
Codeblitz
SBOM
我知道了,不再自动展开
更新失败,请稍后重试!
移除标识
内容风险标识
本任务被
标识为内容中包含有代码安全 Bug 、隐私泄露等敏感信息,仓库外成员不可访问
selinux开启环境下,isula-build构建失败
已完成
#I4UTFN
缺陷
meilier
创建于
2022-02-22 20:17
【标题描述】 selinux开启环境下,isula-build 构建镜像失败 且构建时文件相关扩展属性仅在构建时生效,生成的镜像为默认的selinux属性,是否合理? 【问题复现步骤】 修改selinux为enable ``` [root@iZbp127ckxl0m5wxvebokkZ db]# vim /etc/selinux/config SELINUX=enable ``` 构建镜像使用copy命令 ``` [root@iZbp127ckxl0m5wxvebokkZ ib]# cat dockerfile FROM docker.io/library/alpine:latest COPY a.txt / [root@iZbp127ckxl0m5wxvebokkZ ib]# cat a.txt aaa [root@iZbp127ckxl0m5wxvebokkZ ib]# isula-build ctr-img build -f dockerfile -t test:al STEP 1: FROM docker.io/library/alpine:latest STEP 2: COPY a.txt / error runBuild: rpc error: code = Unknown desc = building image for stage[0] failed: handle command COPY failed: lsetxattr /var/lib/isula-build/storage/overlay/fb75f8972ee37d3f333bf984135842ad5f2a09a0ab1f441275999579c7fd7dd7/merged/a.txt: operation not supported [root@iZbp127ckxl0m5wxvebokkZ ib]# sestatus SELinux status: enabled SELinuxfs mount: /sys/fs/selinux SELinux root directory: /etc/selinux Loaded policy name: targeted Current mode: permissive Mode from config file: error (Success) Policy MLS status: enabled Policy deny_unknown status: allowed Memory protection checking: actual (secure) Max kernel policy version: 33 [root@iZbp127ckxl0m5wxvebokkZ ib]# ``` **切换到 0.9.4版本再构建,可以正常构建**,后续再查看具体的原因,**疑为overlayfs权限参数设置问题。** 出现概率: 必现 【预期结果】 可以正常构建,并且selinux合理设置 【实际结果】 构建失败,在mountpoint 为 `/var/lib/isula-build/storage/overlay/c77a038da5875b5af79f84dfd029fac1a80af87e23c455b95048b54569c4b69f/merged`的overlay merge目录权限不支持(手动使用setfattr同样不可以)。(0.9.4版本可以正常构建和setfattr) util/util.go:278 ``` func copyXattrByKey(src, dest, key string) error { attrValue, err := system.Lgetxattr(src, key) if err != nil && err != unix.EOPNOTSUPP { return err } if attrValue == nil { return nil } return system.Lsetxattr(dest, key, attrValue, 0) } ``` 【原因分析】 经过选取不同版本的storage依赖库,确定导致该issue出现的提交为:[overlay: add support for squash_to_?id](https://github.com/containers/storage/commit/11f2c322b65d442aa0eaead53e1e5d15d730c8bb),最终问题为升级storage库而升级的go-selinux依赖,而导致label_selinux被正常编译不使用label_stub.go空函数填充。这时我们再尝试修改overlayfs mountpoint merge路径的时候,已经恢复正常的selinux会加入相应的权限label `context="system_u:object_r:container_file_t:s0:c479,c818"`,这时就无法使用Lsetxattr系统调用修改merge路径中的文件扩展属性,会导致Operation not supported错误。 v0.9.4版本 isula-build 依赖的storage库依赖v1.6.0版本的selinux,其中: * [label_selinux.go](https://github.com/opencontainers/selinux/blob/v1.6.0/go-selinux/label/label_selinux.go) 使用条件编译`// +build selinux,linux` **不被编译,怀疑selinux标签不生效始终为false,导致下方stub文件被编译** * [label_stub.go](https://github.com/opencontainers/selinux/blob/v1.6.0/go-selinux/label/label_stub.go) 使用条件编译 `// +build !selinux !linux` 当前版本 * [label_selinux.go](https://github.com/opencontainers/selinux/blob/main/go-selinux/label/label_linux.go) 不使用条件编译 * [label_stub.go](https://github.com/opencontainers/selinux/blob/main/go-selinux/label/label_stub.go) 使用条件编译 `// +build !linux` **不被编译** 【解决方案】 **失效的方案,还是要修改merge路径,并赋予权限** > 不修改merge路径,临时修改diff路径,如有使用上述selinux的context的label,则需要做进一步的分析. ```使用diff路径 upperDir := strings.TrimSuffix(finalDest, "merged/") diffDir := fmt.Sprintf("%sdiff/", upperDir) ``` 需要进一步确认,ima属性是否能够最终带入到镜像中。 【可能以后会遇到的问题】 [Gracefully handle xattr not supported](https://github.com/containers/buildah/issues/2774)
【标题描述】 selinux开启环境下,isula-build 构建镜像失败 且构建时文件相关扩展属性仅在构建时生效,生成的镜像为默认的selinux属性,是否合理? 【问题复现步骤】 修改selinux为enable ``` [root@iZbp127ckxl0m5wxvebokkZ db]# vim /etc/selinux/config SELINUX=enable ``` 构建镜像使用copy命令 ``` [root@iZbp127ckxl0m5wxvebokkZ ib]# cat dockerfile FROM docker.io/library/alpine:latest COPY a.txt / [root@iZbp127ckxl0m5wxvebokkZ ib]# cat a.txt aaa [root@iZbp127ckxl0m5wxvebokkZ ib]# isula-build ctr-img build -f dockerfile -t test:al STEP 1: FROM docker.io/library/alpine:latest STEP 2: COPY a.txt / error runBuild: rpc error: code = Unknown desc = building image for stage[0] failed: handle command COPY failed: lsetxattr /var/lib/isula-build/storage/overlay/fb75f8972ee37d3f333bf984135842ad5f2a09a0ab1f441275999579c7fd7dd7/merged/a.txt: operation not supported [root@iZbp127ckxl0m5wxvebokkZ ib]# sestatus SELinux status: enabled SELinuxfs mount: /sys/fs/selinux SELinux root directory: /etc/selinux Loaded policy name: targeted Current mode: permissive Mode from config file: error (Success) Policy MLS status: enabled Policy deny_unknown status: allowed Memory protection checking: actual (secure) Max kernel policy version: 33 [root@iZbp127ckxl0m5wxvebokkZ ib]# ``` **切换到 0.9.4版本再构建,可以正常构建**,后续再查看具体的原因,**疑为overlayfs权限参数设置问题。** 出现概率: 必现 【预期结果】 可以正常构建,并且selinux合理设置 【实际结果】 构建失败,在mountpoint 为 `/var/lib/isula-build/storage/overlay/c77a038da5875b5af79f84dfd029fac1a80af87e23c455b95048b54569c4b69f/merged`的overlay merge目录权限不支持(手动使用setfattr同样不可以)。(0.9.4版本可以正常构建和setfattr) util/util.go:278 ``` func copyXattrByKey(src, dest, key string) error { attrValue, err := system.Lgetxattr(src, key) if err != nil && err != unix.EOPNOTSUPP { return err } if attrValue == nil { return nil } return system.Lsetxattr(dest, key, attrValue, 0) } ``` 【原因分析】 经过选取不同版本的storage依赖库,确定导致该issue出现的提交为:[overlay: add support for squash_to_?id](https://github.com/containers/storage/commit/11f2c322b65d442aa0eaead53e1e5d15d730c8bb),最终问题为升级storage库而升级的go-selinux依赖,而导致label_selinux被正常编译不使用label_stub.go空函数填充。这时我们再尝试修改overlayfs mountpoint merge路径的时候,已经恢复正常的selinux会加入相应的权限label `context="system_u:object_r:container_file_t:s0:c479,c818"`,这时就无法使用Lsetxattr系统调用修改merge路径中的文件扩展属性,会导致Operation not supported错误。 v0.9.4版本 isula-build 依赖的storage库依赖v1.6.0版本的selinux,其中: * [label_selinux.go](https://github.com/opencontainers/selinux/blob/v1.6.0/go-selinux/label/label_selinux.go) 使用条件编译`// +build selinux,linux` **不被编译,怀疑selinux标签不生效始终为false,导致下方stub文件被编译** * [label_stub.go](https://github.com/opencontainers/selinux/blob/v1.6.0/go-selinux/label/label_stub.go) 使用条件编译 `// +build !selinux !linux` 当前版本 * [label_selinux.go](https://github.com/opencontainers/selinux/blob/main/go-selinux/label/label_linux.go) 不使用条件编译 * [label_stub.go](https://github.com/opencontainers/selinux/blob/main/go-selinux/label/label_stub.go) 使用条件编译 `// +build !linux` **不被编译** 【解决方案】 **失效的方案,还是要修改merge路径,并赋予权限** > 不修改merge路径,临时修改diff路径,如有使用上述selinux的context的label,则需要做进一步的分析. ```使用diff路径 upperDir := strings.TrimSuffix(finalDest, "merged/") diffDir := fmt.Sprintf("%sdiff/", upperDir) ``` 需要进一步确认,ima属性是否能够最终带入到镜像中。 【可能以后会遇到的问题】 [Gracefully handle xattr not supported](https://github.com/containers/buildah/issues/2774)
评论 (
2
)
登录
后才可以发表评论
状态
已完成
待办的
已挂起
修复中
已确认
已完成
已验收
已取消
负责人
未设置
meilier
meilier
负责人
协作者
+负责人
+协作者
标签
sig/iSulad
未设置
项目
未立项任务
未立项任务
里程碑
openEuler-22.03-LTS-round-2
未关联里程碑
Pull Requests
未关联
未关联
关联的 Pull Requests 被合并后可能会关闭此 issue
分支
未关联
分支 (1)
标签 (7)
master
v0.9.6
v0.9.5
v0.9.4
v0.9.3
v0.9.2
v0.9.1
v0.9.0
开始日期   -   截止日期
-
置顶选项
不置顶
置顶等级:高
置顶等级:中
置顶等级:低
优先级
不指定
严重
主要
次要
不重要
预计工期
(小时)
参与者(1)
Go
1
https://gitee.com/openeuler/isula-build.git
git@gitee.com:openeuler/isula-build.git
openeuler
isula-build
isula-build
点此查找更多帮助
搜索帮助
Git 命令在线学习
如何在 Gitee 导入 GitHub 仓库
Git 仓库基础操作
企业版和社区版功能对比
SSH 公钥设置
如何处理代码冲突
仓库体积过大,如何减小?
如何找回被删除的仓库数据
Gitee 产品配额说明
GitHub仓库快速导入Gitee及同步更新
什么是 Release(发行版)
将 PHP 项目自动发布到 packagist.org
仓库举报
回到顶部
登录提示
该操作需登录 Gitee 帐号,请先登录后再操作。
立即登录
没有帐号,去注册