From fbdfdc6d81b6893bb500a22c98e36744a24ae527 Mon Sep 17 00:00:00 2001 From: qinzhiben Date: Mon, 15 May 2023 21:56:14 +0800 Subject: [PATCH] add Method of deleting the content in the specified file --- security-tool.sh | 30 ++++++++++++++++++++++++++++++ security-tool.spec | 5 ++++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/security-tool.sh b/security-tool.sh index c6bc4e7..75676e0 100644 --- a/security-tool.sh +++ b/security-tool.sh @@ -662,6 +662,7 @@ function fn_handle_umask() #============================================================================= # Function Name: fn_handle_ln +# Description : delete the content in the specified file # Returns : 0 on success, otherwise on fail #============================================================================= function fn_handle_ln() @@ -675,6 +676,27 @@ function fn_handle_ln() return $? } +#============================================================================= +# Function Name: fn_handle_ufs +# Returns : 0 on success, otherwise on fail +#============================================================================= +function fn_handle_ufs(){ + fn_test_params_num 3 + + file_name=$1 + string=$2 + if [ -n "$3" ];then + string=$2"@"$3 + fi + + if [ -f "$file_name" ] ; then + # 删除文件中的指定字符串 + sed -i "s/$string//g" "$file_name" + fi + + return $? +} + #============================================================================= # Function Name: fn_harden_rootfs @@ -759,6 +781,10 @@ function fn_harden_rootfs() fn_handle_ln "$f3" "$f4" "$f5" status=$? ;; + ufs) + fn_handle_ln "$f3" "$f4" "$f5" + status=$? + ;; *) fn_handle_command "$f2" "$f3" status=$? @@ -861,6 +887,10 @@ IFS=$PRE_IFS fn_handle_ln "$f3" "$f4" "$f5" status=$? ;; + ufs) + fn_handle_ln "$f3" "$f4" "$f5" + status=$? + ;; *) fn_handle_command "$f2" "$f3" status=$? diff --git a/security-tool.spec b/security-tool.spec index 71bb65b..39b4048 100644 --- a/security-tool.spec +++ b/security-tool.spec @@ -1,7 +1,7 @@ Summary: openEuler Security Tool Name : security-tool Version: 2.0 -Release: 1.51 +Release: 1.52 Source0: %{name}-%{version}.tar.bz2 Source1: security Source2: security.conf @@ -120,6 +120,9 @@ fi %attr(0500,root,root) %{_sbindir}/security-tool.sh %changelog +* Mon May 15 2023 qinzhiben - 2.0-1.52 +- add method of deleting the content in the specified file + * Tue Dec 27 2022 zhengxiaoxiao - 2.0-1.51 - add requires findutils -- Gitee