From c5cdeab8a2b07388511f394336c92bf28b45e095 Mon Sep 17 00:00:00 2001 From: zhongjiawei Date: Sat, 17 Dec 2022 11:33:21 +0800 Subject: [PATCH] runc:support specify umask --- git-commit | 2 +- patch/0140-runc-support-specify-umask.patch | 57 +++++++++++++++++++++ runc-openeuler.spec | 8 ++- series.conf | 1 + 4 files changed, 66 insertions(+), 2 deletions(-) create mode 100644 patch/0140-runc-support-specify-umask.patch diff --git a/git-commit b/git-commit index b409566..7992231 100644 --- a/git-commit +++ b/git-commit @@ -1 +1 @@ -f1708be8345798020decae623fc866212541f986 +1ffb75b05b79fca3919ddfa6cce5e68e143f2b5c diff --git a/patch/0140-runc-support-specify-umask.patch b/patch/0140-runc-support-specify-umask.patch new file mode 100644 index 0000000..c3ece81 --- /dev/null +++ b/patch/0140-runc-support-specify-umask.patch @@ -0,0 +1,57 @@ +From 9e76966232e71cfabc2553c6a0dee1f59ee9216c Mon Sep 17 00:00:00 2001 +From: zhongjiawei +Date: Sat, 17 Dec 2022 11:18:41 +0800 +Subject: [PATCH] runc:support specify umask + +--- + libcontainer/rootfs_linux.go | 7 ++++++- + libcontainer/setns_init_linux.go | 8 ++++++++ + 2 files changed, 14 insertions(+), 1 deletion(-) + +diff --git a/libcontainer/rootfs_linux.go b/libcontainer/rootfs_linux.go +index a1bd7e7..b005429 100644 +--- a/libcontainer/rootfs_linux.go ++++ b/libcontainer/rootfs_linux.go +@@ -140,7 +140,12 @@ func finalizeRootfs(config *configs.Config) (err error) { + } + } + +- syscall.Umask(0022) ++ umask := libcontainerUtils.SearchLabels(config.Labels, "native.umask") ++ if umask == "normal" { ++ syscall.Umask(0022) ++ } else { ++ syscall.Umask(0027) ++ } + return nil + } + +diff --git a/libcontainer/setns_init_linux.go b/libcontainer/setns_init_linux.go +index e6dfbba..1f7ec98 100644 +--- a/libcontainer/setns_init_linux.go ++++ b/libcontainer/setns_init_linux.go +@@ -11,6 +11,7 @@ import ( + "github.com/opencontainers/runc/libcontainer/keys" + "github.com/opencontainers/runc/libcontainer/seccomp" + "github.com/opencontainers/runc/libcontainer/system" ++ "github.com/opencontainers/runc/libcontainer/utils" + "github.com/opencontainers/selinux/go-selinux/label" + ) + +@@ -42,6 +43,13 @@ func (l *linuxSetnsInit) Init() error { + return err + } + } ++ // set exec process umask to 0027 or 0022 according to container's config ++ umask := utils.SearchLabels(l.config.Config.Labels, "native.umask") ++ if umask == "normal" { ++ syscall.Umask(0022) ++ } else { ++ syscall.Umask(0027) ++ } + if l.config.NoNewPrivileges { + if err := system.Prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0); err != nil { + return err +-- +2.30.0 + diff --git a/runc-openeuler.spec b/runc-openeuler.spec index 8325433..e81c51b 100644 --- a/runc-openeuler.spec +++ b/runc-openeuler.spec @@ -4,7 +4,7 @@ Name: docker-runc Version: 1.0.0.rc3 -Release: 307 +Release: 308 Summary: runc is a CLI tool for spawning and running containers according to the OCI specification. License: ASL 2.0 @@ -53,6 +53,12 @@ install -p -m 755 runc $RPM_BUILD_ROOT/%{_bindir}/runc %{_bindir}/runc %changelog +* Sat Dec 17 2022 zhongjiawei - 1.0.0.rc3-308 +- Type:bugfix +- CVE:NA +- SUG:NA +- DESC:support specify umask + * Thu Dec 15 2022 zhongjiawei - 1.0.0.rc3-307 - Type:bugfix - CVE:NA diff --git a/series.conf b/series.conf index 9e3a380..2352d74 100644 --- a/series.conf +++ b/series.conf @@ -138,4 +138,5 @@ patch/0136-runc-add-DT-for-cpuset.preferred_cpus-setting.patch patch/0137-runc-fix-can-t-set-cpuset-cpus-and-cpuset-mems-at-th.patch patch/0138-runc-write-state.json-atomically.patch patch/0139-runc-Make-sure-signalAllProcesses-is-invoked-in-the-.patch +patch/0140-runc-support-specify-umask.patch #end -- Gitee