From 85c03350ad57e77fb9179b73fdb3a24b627698f1 Mon Sep 17 00:00:00 2001 From: WangFengTu Date: Tue, 24 May 2022 10:42:05 +0800 Subject: [PATCH] do not mkdir of isulad if no controller found If selinux disable the capibility DAC_OVERRIDE, mkdir isulad may fail when run container. Signed-off-by: WangFengTu --- ...dir-of-isulad-if-no-controller-found.patch | 56 +++++++++++++++++++ iSulad.spec | 9 ++- 2 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 0001-do-not-mkdir-of-isulad-if-no-controller-found.patch diff --git a/0001-do-not-mkdir-of-isulad-if-no-controller-found.patch b/0001-do-not-mkdir-of-isulad-if-no-controller-found.patch new file mode 100644 index 0000000..d5f9a1f --- /dev/null +++ b/0001-do-not-mkdir-of-isulad-if-no-controller-found.patch @@ -0,0 +1,56 @@ +From 9837be14200fecb32db0337652e60532f1adb7be Mon Sep 17 00:00:00 2001 +From: WangFengTu +Date: Mon, 23 May 2022 17:06:19 +0800 +Subject: [PATCH] do not mkdir of isulad if no controller found + +If selinux disable the capibility DAC_OVERRIDE, +mkdir isulad may fail when run container. + +Signed-off-by: WangFengTu +--- + src/daemon/common/sysinfo.c | 22 ++++++++++++++++++++++ + 1 file changed, 22 insertions(+) + +diff --git a/src/daemon/common/sysinfo.c b/src/daemon/common/sysinfo.c +index e60377dd..6fb4ec38 100644 +--- a/src/daemon/common/sysinfo.c ++++ b/src/daemon/common/sysinfo.c +@@ -1303,6 +1303,21 @@ out: + return ret; + } + ++#ifdef __ANDROID__ ++static bool cgroup2_no_controller() { ++ char *controllers_str = NULL; ++ ++ controllers_str = util_read_content_from_file(CGROUP2_CONTROLLERS_PATH); ++ if (controllers_str == NULL || strlen(controllers_str) == 0 || strcmp(controllers_str, "\n") == 0) { ++ free(controllers_str); ++ return true; ++ } ++ ++ free(controllers_str); ++ return false; ++} ++#endif ++ + static int make_sure_cgroup2_isulad_path_exist() + { + int ret = 0; +@@ -1315,6 +1330,13 @@ static int make_sure_cgroup2_isulad_path_exist() + return -1; + } + ++#ifdef __ANDROID__ ++ if (cgroup2_no_controller()) { ++ DEBUG("no cgroup controller found"); ++ return 0; ++ } ++#endif ++ + ret = mkdir(CGROUP_ISULAD_PATH, DEFAULT_CGROUP_DIR_MODE); + if (ret != 0 && (errno != EEXIST || !util_dir_exists(CGROUP_ISULAD_PATH))) { + return -1; +-- +2.25.1 + diff --git a/iSulad.spec b/iSulad.spec index 6a5ddec..b2248d7 100644 --- a/iSulad.spec +++ b/iSulad.spec @@ -1,5 +1,5 @@ %global _version 2.0.14 -%global _release 1 +%global _release 2 %global is_systemd 1 %global enable_shimv2 1 %global is_embedded 1 @@ -13,6 +13,7 @@ URL: https://gitee.com/openeuler/iSulad Source: https://gitee.com/openeuler/iSulad/repository/archive/v%{version}.tar.gz BuildRoot: {_tmppath}/iSulad-%{version} +Patch0001: 0001-do-not-mkdir-of-isulad-if-no-controller-found.patch %ifarch x86_64 aarch64 Provides: libhttpclient.so()(64bit) @@ -240,6 +241,12 @@ fi %endif %changelog +* Tue May 24 2022 wangfengtu - 2.0.14-2 +- Type: enhancement +- ID: NA +- SUG: NA +- DESC: do not mkdir of isulad if no controller found + * Mon May 23 2022 haozi007 - 2.0.14-1 - Type: enhancement - ID: NA