diff --git a/0001-KubeOS-fix-the-hostshell-cannot-obtain-the-lib.patch b/0001-KubeOS-fix-the-hostshell-cannot-obtain-the-lib.patch new file mode 100644 index 0000000000000000000000000000000000000000..f0cfb25497e9e4f05e7b15141c954ae7716fb08c --- /dev/null +++ b/0001-KubeOS-fix-the-hostshell-cannot-obtain-the-lib.patch @@ -0,0 +1,75 @@ +From 470e190db2de92b65e7fa720864823e7245c51e9 Mon Sep 17 00:00:00 2001 +From: liyuanr +Date: Mon, 7 Aug 2023 19:09:18 +0800 +Subject: [PATCH] KubeOS: fix the hostshell cannot obtain the lib + +Fix the hostshell cannot obtain the lib + +Signed-off-by: liyuanr +--- + cmd/admin-container/main.go | 40 +++++++++++++++++++++++++------------ + 1 file changed, 27 insertions(+), 13 deletions(-) + +diff --git a/cmd/admin-container/main.go b/cmd/admin-container/main.go +index f6a7293..5fa0838 100644 +--- a/cmd/admin-container/main.go ++++ b/cmd/admin-container/main.go +@@ -22,28 +22,42 @@ import ( + "github.com/sirupsen/logrus" + ) + ++const ( ++ bashPath = "/usr/bin/bash" ++ usrBin = "/usr/bin" ++ usrSbin = "/usr/sbin" ++ localBin = "/usr/local/bin" ++ localSbin = "/usr/local/sbin" ++ usrLib = "/usr/lib" ++ usrLib64 = "/usr/lib64" ++ lib = "/lib" ++ lib64 = "/lib64" ++ envPathPrefix = "PATH=$PATH:" ++ envLdLibrarPathPrefix = "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:" ++) ++ + func main() { + EUID := os.Geteuid() + rootEUID := 0 // 0 indicates that the process has the permission of the root user. + if EUID != rootEUID { + logrus.Error("please use root to run hostshell") +- return ++ + } + PPID := os.Getppid() + rootFsPath := "/proc/" + strconv.Itoa(PPID) + "/root" +- bashPath := "/usr/bin/bash" +- usrBin := "/usr/bin" +- usrSbin := "/usr/sbin" +- localBin := "/usr/local/bin" +- localSbin := "/usr/local/sbin" +- paths := []string{usrBin, usrSbin, localBin, localSbin} +- for i, p := range paths { +- paths[i] = rootFsPath + p +- } +- path := "PATH=$PATH:" + strings.Join(paths, ":") +- lib := "LD_LIBRARY_PATH=/lib:/lib64:/usr/lib:/usr/lib64:$LD_LIBRARY_PATH" ++ path := concatenateEnvPath(rootFsPath, envPathPrefix, []string{usrBin, usrSbin, localBin, localSbin}) ++ libPath := concatenateEnvPath(rootFsPath, envLdLibrarPathPrefix, []string{usrLib, usrLib64, lib, lib64}) + if err := syscall.Exec("/usr/bin/nsenter", []string{"nsenter", "-t", "1", "-a", +- "env", "-i", path, lib, rootFsPath + bashPath}, os.Environ()); err != nil { ++ "env", "-i", path, libPath, rootFsPath + bashPath}, os.Environ()); err != nil { + logrus.Error("nsenter excute error", err) + } + } ++ ++func concatenateEnvPath(prefix string, envVarPrefix string, paths []string) string { ++ for i, p := range paths { ++ paths[i] = prefix + p ++ } ++ pathLine := envVarPrefix + strings.Join(paths, ":") ++ pathEnv := os.ExpandEnv(pathLine) ++ return pathEnv ++} +-- +2.33.0.windows.2 + diff --git a/KubeOS.spec b/KubeOS.spec index 52453ab18eeefafb63b542e98f63fdd652cae327..1e01e6204a6a1fb2a59260d34978cd9bfb4f65f8 100644 --- a/KubeOS.spec +++ b/KubeOS.spec @@ -2,10 +2,11 @@ Name: KubeOS Version: 1.0.4 -Release: 1 +Release: 2 Summary: O&M platform used to update the whole OS as an entirety License: Mulan PSL v2 Source0: https://gitee.com/openeuler/KubeOS/repository/archive/v%{version}.tar.gz +Patch1: 0001-KubeOS-fix-the-hostshell-cannot-obtain-the-lib.patch BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRequires: make @@ -82,6 +83,12 @@ install -p -m 0600 ./scripts/admin-container/set-ssh-pub-key.service %{buildroot rm -rfv %{buildroot} %changelog +* Mon Aug 07 2023 liyuanrong - 1.0.4-2 +- Type:requirement +- CVE:NA +- SUG:restart +- DESC:fix the hostshell cannot obtain the lib + * Wed Aug 02 2023 liyuanrong - 1.0.4-1 - Type:requirement - CVE:NA