代码拉取完成,页面将自动刷新
同步操作将从 src-openEuler/iSulad 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
From 7f13d95572040d30b70edbfac3c4b7350ee8855c Mon Sep 17 00:00:00 2001
From: zhongtao <[email protected]>
Date: Fri, 26 Jan 2024 12:59:45 +0800
Subject: [PATCH 4/6] do not cleanup if the directory does not exist
Signed-off-by: zhongtao <[email protected]>
---
src/cmd/isulad/main.c | 20 ++++++++++++++++++-
.../container/leftover_cleanup/cleanup.c | 13 +++++++++++-
2 files changed, 31 insertions(+), 2 deletions(-)
diff --git a/src/cmd/isulad/main.c b/src/cmd/isulad/main.c
index deca72be..fd0b6e89 100644
--- a/src/cmd/isulad/main.c
+++ b/src/cmd/isulad/main.c
@@ -1270,8 +1270,26 @@ static int do_ensure_isulad_tmpdir_security(const char *isulad_tmp_dir)
int nret;
char tmp_dir[PATH_MAX] = { 0 };
char cleanpath[PATH_MAX] = { 0 };
+ char isulad_tmp_cleanpath[PATH_MAX] = { 0 };
- if (realpath(isulad_tmp_dir, cleanpath) == NULL) {
+ if (util_clean_path(isulad_tmp_dir, isulad_tmp_cleanpath, sizeof(isulad_tmp_cleanpath)) == NULL) {
+ ERROR("Failed to clean path for %s", isulad_tmp_dir);
+ return -1;
+ }
+
+ // Determine whether isulad_tmp_dir exists. If it does not exist, create it
+ // to prevent realpath from reporting errors because the folder does not exist.
+ if (!util_dir_exists(isulad_tmp_cleanpath)) {
+ nret = snprintf(tmp_dir, PATH_MAX, "%s/isulad_tmpdir", isulad_tmp_cleanpath);
+ if (nret < 0 || (size_t)nret >= PATH_MAX) {
+ ERROR("Failed to snprintf");
+ return -1;
+ }
+ INFO("iSulad tmpdir: %s does not exist, create it", isulad_tmp_dir);
+ return recreate_tmpdir(tmp_dir);
+ }
+
+ if (realpath(isulad_tmp_cleanpath, cleanpath) == NULL) {
ERROR("Failed to get real path for %s", tmp_dir);
return -1;
}
diff --git a/src/daemon/modules/container/leftover_cleanup/cleanup.c b/src/daemon/modules/container/leftover_cleanup/cleanup.c
index 08151f42..16dba630 100644
--- a/src/daemon/modules/container/leftover_cleanup/cleanup.c
+++ b/src/daemon/modules/container/leftover_cleanup/cleanup.c
@@ -174,8 +174,19 @@ static void cleanup_path(char *dir)
int nret;
char tmp_dir[PATH_MAX] = { 0 };
char cleanpath[PATH_MAX] = { 0 };
+ char dir_cleanpath[PATH_MAX] = { 0 };
- if (realpath(dir, cleanpath) == NULL) {
+ if (util_clean_path(dir, dir_cleanpath, sizeof(dir_cleanpath)) == NULL) {
+ ERROR("clean path for %s failed", dir);
+ return;
+ }
+
+ // If dir does not exist, skip cleanup
+ if (!util_dir_exists(dir_cleanpath)) {
+ return;
+ }
+
+ if (realpath(dir_cleanpath, cleanpath) == NULL) {
ERROR("get real path for %s failed", tmp_dir);
return;
}
--
2.25.1
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。