70 lines
2.2 KiB
Diff
70 lines
2.2 KiB
Diff
From 7746fa7839dc6780379cb732c7122efaa07834f7 Mon Sep 17 00:00:00 2001
|
|
From: zhongjiawei <zhongjiawei1@huawei.com>
|
|
Date: Wed, 26 Jul 2023 15:37:48 +0800
|
|
Subject: [PATCH] runc:support specify umask
|
|
|
|
---
|
|
libcontainer/rootfs_linux.go | 6 ++++++
|
|
libcontainer/setns_init_linux.go | 7 +++++++
|
|
vendor/github.com/sirupsen/logrus/hooks/syslog/syslog.go | 2 +-
|
|
3 files changed, 14 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/libcontainer/rootfs_linux.go b/libcontainer/rootfs_linux.go
|
|
index 499d753..c42e388 100644
|
|
--- a/libcontainer/rootfs_linux.go
|
|
+++ b/libcontainer/rootfs_linux.go
|
|
@@ -192,6 +192,12 @@ func finalizeRootfs(config *configs.Config) (err error) {
|
|
} else {
|
|
unix.Umask(0o022)
|
|
}
|
|
+ umask := utils.SearchLabels(config.Labels, "native.umask")
|
|
+ if umask == "normal" {
|
|
+ unix.Umask(0o022)
|
|
+ } else {
|
|
+ unix.Umask(0o027)
|
|
+ }
|
|
return nil
|
|
}
|
|
|
|
diff --git a/libcontainer/setns_init_linux.go b/libcontainer/setns_init_linux.go
|
|
index 09ab552..e9b8d62 100644
|
|
--- a/libcontainer/setns_init_linux.go
|
|
+++ b/libcontainer/setns_init_linux.go
|
|
@@ -14,6 +14,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"
|
|
)
|
|
|
|
// linuxSetnsInit performs the container's initialization for running a new process
|
|
@@ -54,6 +55,12 @@ func (l *linuxSetnsInit) Init() error {
|
|
return err
|
|
}
|
|
}
|
|
+ umask := utils.SearchLabels(l.config.Config.Labels, "native.umask")
|
|
+ if umask == "normal" {
|
|
+ unix.Umask(0o022)
|
|
+ } else {
|
|
+ unix.Umask(0o027)
|
|
+ }
|
|
if l.config.NoNewPrivileges {
|
|
if err := unix.Prctl(unix.PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0); err != nil {
|
|
return err
|
|
diff --git a/vendor/github.com/sirupsen/logrus/hooks/syslog/syslog.go b/vendor/github.com/sirupsen/logrus/hooks/syslog/syslog.go
|
|
index b6fa374..430f646 100644
|
|
--- a/vendor/github.com/sirupsen/logrus/hooks/syslog/syslog.go
|
|
+++ b/vendor/github.com/sirupsen/logrus/hooks/syslog/syslog.go
|
|
@@ -2,7 +2,7 @@ package logrus_syslog
|
|
|
|
import (
|
|
"fmt"
|
|
- "github.com/Sirupsen/logrus"
|
|
+ "github.com/sirupsen/logrus"
|
|
"log/syslog"
|
|
"os"
|
|
)
|
|
--
|
|
2.33.0
|
|
|