From 6c0586fc3a51cd02e488a2fb56370e84797fedfd Mon Sep 17 00:00:00 2001 From: guoxiaoqi Date: Wed, 19 Feb 2020 14:48:54 +0800 Subject: [PATCH] fix problems of script caused by * and multiple spaces --- security-tool.sh | 26 +++++++++++++------------- security-tool.spec | 5 ++++- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/security-tool.sh b/security-tool.sh index 0999160..b745ba7 100644 --- a/security-tool.sh +++ b/security-tool.sh @@ -175,7 +175,7 @@ function fn_exit() if [ $s -eq 0 ]; then local new_initrd=$WORKD`basename $GZ_F`".secure" pushd $ROOTFS - tar -cf "$ROOTFS/$TMPTARGET" * + tar -cf "$ROOTFS/$TMPTARGET" -- * gzip <"$ROOTFS/$TMPTARGET" > $new_initrd fn_info "hardened initrd is $new_initrd" popd @@ -693,7 +693,7 @@ function fn_harden_rootfs() # do configuration traversal, with comments and lines starting with blankspace ignored grep -v '^#' $SCONF| grep -v '^$'| grep -Ev '^[[:space:]]+'| while read line do - f1=`echo $line | awk -F$FIELD_SEP '{print $1}'` + f1=`echo "$line" | awk -F$FIELD_SEP '{print $1}'` if [ $EXECID -ne 0 ] && [ "$EXECID" -ne "$f1" ];then continue fi @@ -731,11 +731,11 @@ function fn_harden_rootfs() f5=${arr[4]} f6=${arr[5]} else - f2=`echo $line | awk -F$FIELD_SEP '{print $2}'` - f3=`echo $line | awk -F$FIELD_SEP '{print $3}'` - f4=`echo $line | awk -F$FIELD_SEP '{print $4}'` - f5=`echo $line | awk -F$FIELD_SEP '{print $5}'` - f6=`echo $line | awk -F$FIELD_SEP '{print $6}'` + f2=`echo "$line" | awk -F$FIELD_SEP '{print $2}'` + f3=`echo "$line" | awk -F$FIELD_SEP '{print $3}'` + f4=`echo "$line" | awk -F$FIELD_SEP '{print $4}'` + f5=`echo "$line" | awk -F$FIELD_SEP '{print $5}'` + f6=`echo "$line" | awk -F$FIELD_SEP '{print $6}'` fi case "$f2" in @@ -794,7 +794,7 @@ function fn_harden_usr_conf() # do configuration traversal, with comments and lines starting with blankspace ignored grep -v '^#' $USR_SCONF| grep -v '^$'| grep -Ev '^[[:space:]]+'| while read line do - f1=`echo $line | awk -F$FIELD_SEP '{print $1}'` + f1=`echo "$line" | awk -F$FIELD_SEP '{print $1}'` if [ $EXECID -ne 0 ] && [ "$EXECID" -ne "$f1" ];then continue fi @@ -833,11 +833,11 @@ IFS=$PRE_IFS f5=${arr[4]} f6=${arr[5]} else - f2=`echo $line | awk -F$FIELD_SEP '{print $2}'` - f3=`echo $line | awk -F$FIELD_SEP '{print $3}'` - f4=`echo $line | awk -F$FIELD_SEP '{print $4}'` - f5=`echo $line | awk -F$FIELD_SEP '{print $5}'` - f6=`echo $line | awk -F$FIELD_SEP '{print $6}'` + f2=`echo "$line" | awk -F$FIELD_SEP '{print $2}'` + f3=`echo "$line" | awk -F$FIELD_SEP '{print $3}'` + f4=`echo "$line" | awk -F$FIELD_SEP '{print $4}'` + f5=`echo "$line" | awk -F$FIELD_SEP '{print $5}'` + f6=`echo "$line" | awk -F$FIELD_SEP '{print $6}'` fi case "$f2" in diff --git a/security-tool.spec b/security-tool.spec index 7b26534..02a877c 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.41 +Release: 1.42 Source0: %{name}-%{version}.tar.bz2 Source1: security Source2: security.conf @@ -124,6 +124,9 @@ fi %attr(0500,root,root) %{_sbindir}/security-tool.sh %changelog +* Wed Jan 22 2020 openEuler Buildteam - 2.0-1.41 +- Fix problems of script caused by "*" and multiple spaces + * Wed Jan 22 2020 openEuler Buildteam - 2.0-1.41 - Fix the problem of dbus-daemon-launch-helper's group -- Gitee