override list file method
(cherry picked from commit 05c5c2804f86d83d47c2e08cef926ff3c7f17996)
This commit is contained in:
parent
ae5f805fb3
commit
1c4a235e67
58
0005-override-list-file-method.patch
Normal file
58
0005-override-list-file-method.patch
Normal file
@ -0,0 +1,58 @@
|
||||
From 19b611645b9be2e72c81cab5cb456f9a943d3caa Mon Sep 17 00:00:00 2001
|
||||
From: rabbitali <wenxin32@foxmail.com>
|
||||
Date: Wed, 7 Feb 2024 12:23:28 +0800
|
||||
Subject: [PATCH 1/1] override list file method
|
||||
|
||||
---
|
||||
ceres/manages/list_file_manage.py | 26 +++++++++++---------------
|
||||
1 file changed, 11 insertions(+), 15 deletions(-)
|
||||
|
||||
diff --git a/ceres/manages/list_file_manage.py b/ceres/manages/list_file_manage.py
|
||||
index dab55e6..081a714 100644
|
||||
--- a/ceres/manages/list_file_manage.py
|
||||
+++ b/ceres/manages/list_file_manage.py
|
||||
@@ -14,14 +14,9 @@
|
||||
# Description: default
|
||||
# Date: 2023/6/14 16:31
|
||||
import os
|
||||
-import subprocess
|
||||
|
||||
from ceres.function.log import LOGGER
|
||||
-from ceres.function.status import (
|
||||
- UNKNOWN_ERROR,
|
||||
- SUCCESS
|
||||
-)
|
||||
-from ceres.function.util import execute_shell_command
|
||||
+from ceres.function.status import FILE_NOT_FOUND, UNKNOWN_ERROR, SUCCESS, PARAM_ERROR
|
||||
|
||||
|
||||
class ListFileManage:
|
||||
@@ -39,15 +34,16 @@ class ListFileManage:
|
||||
str: status code
|
||||
"""
|
||||
file_list_res = []
|
||||
+
|
||||
+ if not os.path.exists(directory_path):
|
||||
+ return FILE_NOT_FOUND, {"resp": file_list_res}
|
||||
+
|
||||
+ if os.path.isfile(directory_path):
|
||||
+ return PARAM_ERROR, {"resp": file_list_res}
|
||||
+
|
||||
try:
|
||||
- command = [f"ls -l {directory_path}", "awk '{print $9}'"]
|
||||
- _, stdout, _ = execute_shell_command(command)
|
||||
- file_list = stdout.split("\n")
|
||||
- for file in file_list:
|
||||
- if file:
|
||||
- file_path_res = os.path.join(directory_path, file)
|
||||
- file_list_res.append(file_path_res)
|
||||
+ file_list_res = [os.path.join(directory_path, file) for file in os.listdir(directory_path)]
|
||||
return SUCCESS, {"resp": file_list_res}
|
||||
- except Exception as e:
|
||||
- LOGGER.error("list the pam.d file failed, with msg{}".format(e))
|
||||
+ except OSError as e:
|
||||
+ LOGGER.error(f"Failed to read the file list under the path with message {e}")
|
||||
return UNKNOWN_ERROR, {"resp": list()}
|
||||
--
|
||||
2.33.0
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
Name: aops-ceres
|
||||
Version: v1.4.1
|
||||
Release: 5
|
||||
Release: 6
|
||||
Summary: An agent which needs to be adopted in client, it managers some plugins, such as gala-gopher(kpi collection), fluentd(log collection) and so on.
|
||||
License: MulanPSL2
|
||||
URL: https://gitee.com/openeuler/%{name}
|
||||
@ -17,6 +17,7 @@ Patch0001: 0001-improve-status-judgement-and-hotupgrade-logic.patch
|
||||
Patch0002: 0002-support-restore-grubby-if-kabi-check-failed.patch
|
||||
Patch0003: 0003-remove-installed-rpm-if-unreboot-and-improve-log-for-rollback.patch
|
||||
Patch0004: 0004-fix-cve-2021-33633.patch
|
||||
Patch0005: 0005-override-list-file-method.patch
|
||||
|
||||
|
||||
%description
|
||||
@ -90,6 +91,9 @@ install -b -m500 ./extra-tools/da-tool/script/da-tool.sh ${RPM_BUILD_ROOT}
|
||||
%attr(0500, root, root) %{_bindir}/da-tool-analysis
|
||||
|
||||
%changelog
|
||||
* Wed Feb 07 2024 wenxin<wenxin32@foxmail.com> - v1.4.1-6
|
||||
- override list file method
|
||||
|
||||
* Sun Feb 04 2024 wenxin<wenxin32@foxmail.com> - v1.4.1-5
|
||||
- fix cve-2021-33633
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user