From 1f9a27732937dba7dd298fb3c23cf3a49e84f269 Mon Sep 17 00:00:00 2001 From: shixuantong Date: Sat, 29 Mar 2025 14:37:42 +0800 Subject: [PATCH] fix period task some bugs and fix env config --- fix-env_file-and-environ_conf.patch | 56 +++++++++++++++++++++++++++++ fix-period-task-some-bugs.patch | 54 ++++++++++++++++++++++++++++ sysSentry.spec | 11 +++++- 3 files changed, 120 insertions(+), 1 deletion(-) create mode 100644 fix-env_file-and-environ_conf.patch create mode 100644 fix-period-task-some-bugs.patch diff --git a/fix-env_file-and-environ_conf.patch b/fix-env_file-and-environ_conf.patch new file mode 100644 index 0000000..b253943 --- /dev/null +++ b/fix-env_file-and-environ_conf.patch @@ -0,0 +1,56 @@ +From 9b376d82972d498def8c85cafd63d3ef58efe432 Mon Sep 17 00:00:00 2001 +From: shixuantong +Date: Sat, 29 Mar 2025 11:16:19 +0800 +Subject: [PATCH] fix env_file and environ_conf + +--- + src/python/syssentry/global_values.py | 13 +++++-------- + 1 file changed, 5 insertions(+), 8 deletions(-) + +diff --git a/src/python/syssentry/global_values.py b/src/python/syssentry/global_values.py +index 9c7800b..48a9f2d 100644 +--- a/src/python/syssentry/global_values.py ++++ b/src/python/syssentry/global_values.py +@@ -75,6 +75,8 @@ class InspectTask: + self.onstart = False + # ccnfig env_file + self.env_file = "" ++ # env conf to popen arg ++ self.environ_conf = None + # start mode + self.conflict = "up" + # alarm id +@@ -112,7 +114,7 @@ class InspectTask: + logging.error("task %s log_file %s open failed", self.name, self.log_file) + logfile = subprocess.PIPE + try: +- child = subprocess.Popen(cmd_list, stdout=logfile, stderr=subprocess.STDOUT, close_fds=True) ++ child = subprocess.Popen(cmd_list, stdout=logfile, stderr=subprocess.STDOUT, close_fds=True, env=self.environ_conf) + except OSError: + logging.error("task %s start Popen error, invalid cmd", cmd_list) + self.result_info["result"] = ResultLevel.FAIL.name +@@ -199,7 +201,7 @@ class InspectTask: + return + + # read config +- environ_conf = {} ++ self.environ_conf = dict(os.environ) + with open(self.env_file, 'r') as file: + for line in file: + line = line.strip() +@@ -210,11 +212,6 @@ class InspectTask: + if not key or not value: + logging.error("env_file = %s format is error, use default environ", self.env_file) + return +- environ_conf[key] = value +- +- # set environ +- for key, value in environ_conf.items(): +- logging.debug("environ key=%s, value=%s", key, value) +- os.environ[key] = value ++ self.environ_conf[key] = value + + logging.debug("the subprocess=[%s] begin to run", self.name) +-- +2.27.0 + diff --git a/fix-period-task-some-bugs.patch b/fix-period-task-some-bugs.patch new file mode 100644 index 0000000..e1d9735 --- /dev/null +++ b/fix-period-task-some-bugs.patch @@ -0,0 +1,54 @@ +From 91385c657853f2cd9f2aebd9decc7c4438b29f23 Mon Sep 17 00:00:00 2001 +From: shixuantong +Date: Sat, 29 Mar 2025 10:41:35 +0800 +Subject: [PATCH] fix period task some bugs + +--- + src/python/syssentry/cron_process.py | 6 ++---- + 1 file changed, 2 insertions(+), 4 deletions(-) + +diff --git a/src/python/syssentry/cron_process.py b/src/python/syssentry/cron_process.py +index 50780b3..cd688a4 100644 +--- a/src/python/syssentry/cron_process.py ++++ b/src/python/syssentry/cron_process.py +@@ -59,7 +59,6 @@ class PeriodTask(InspectTask): + self.result_info["details"] = {} + if not self.period_enabled: + self.period_enabled = True +- self.upgrade_period_timestamp() + + if self.conflict != 'up': + ret = self.check_conflict() +@@ -87,6 +86,7 @@ class PeriodTask(InspectTask): + self.runtime_status = FAILED_STATUS + return False, "period task start popen failed, invalid command" + finally: ++ self.upgrade_period_timestamp() + if isinstance(logfile, io.TextIOWrapper) and not logfile.closed: + logfile.close() + +@@ -127,7 +127,6 @@ class PeriodTask(InspectTask): + res, _ = self.start() + if res: + set_runtime_status(self.name, RUNNING_STATUS) +- self.upgrade_period_timestamp() + + + def period_tasks_handle(): +@@ -142,7 +141,7 @@ def period_tasks_handle(): + logging.debug("period not enabled") + continue + +- if not task.onstart: ++ if not task.onstart and task.last_exec_timestamp == 0: + logging.debug("period onstart not enabled, task: %s", task.name) + continue + +@@ -152,4 +151,3 @@ def period_tasks_handle(): + res, _ = task.start() + if res: + set_runtime_status(task.name, RUNNING_STATUS) +- task.upgrade_period_timestamp() +-- +2.27.0 + diff --git a/sysSentry.spec b/sysSentry.spec index 02ef41b..9affeaf 100644 --- a/sysSentry.spec +++ b/sysSentry.spec @@ -4,7 +4,7 @@ Summary: System Inspection Framework Name: sysSentry Version: 1.0.2 -Release: 76 +Release: 77 License: Mulan PSL v2 Group: System Environment/Daemons Source0: https://gitee.com/openeuler/sysSentry/releases/download/v%{version}/%{name}-%{version}.tar.gz @@ -91,6 +91,8 @@ Patch78: ebpf-adpat-to-the-kylin-platform.patch Patch79: fix-test_ai_block_io-fail.patch Patch80: fix-ai_block_io-bug-and-an-issue-with-printing-error.patch Patch81: ai-block-io-exit-when-stage-is-not-supported.patch +Patch82: fix-period-task-some-bugs.patch +Patch83: fix-env_file-and-environ_conf.patch BuildRequires: cmake gcc-c++ BuildRequires: python3 python3-setuptools @@ -346,6 +348,13 @@ rm -rf %{buildroot} %attr(0550,root,root) %{python3_sitelib}/sentryCollector/__pycache__/collect_plugin* %changelog +* Sat Mar 29 2025 shixuantong - 1.0.2-77 +- Type:bugfix +- CVE:NA +- SUG:NA +- DESC:fix period task some bugs + fix env_file and environ_conf + * Thu Mar 13 2025 luckky - 1.0.2-76 - Type:bugfix - CVE:NA -- Gitee