From: jin-gyu.kim Date: Mon, 27 Mar 2017 10:04:22 +0000 (+0900) Subject: Optimize the testing time of root_minimization.sh X-Git-Tag: submit/tizen/20170328.062627~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=24bcc55a185717d2d0741d70481538ee330d08fa;p=platform%2Fcore%2Fsecurity%2Fsecurity-config.git Optimize the testing time of root_minimization.sh Change-Id: I5db5bcf93deabd583062c5fff505ec88b1276c9d --- diff --git a/test/root_test/root_minimization.sh b/test/root_test/root_minimization.sh index 19a09ac..98f0067 100755 --- a/test/root_test/root_minimization.sh +++ b/test/root_test/root_minimization.sh @@ -328,63 +328,43 @@ checkServiceFile(){ fi # Try to find root service - for line in $(/bin/cat $ROOT_LIST) - do - # awk filters 1st value from "," e.g alarm-server.service,systemd - service_name=`/bin/echo $line | /usr/bin/awk -F "," '{print $1}'` - # compare $1 to service_name in root_daemon_list - if [ $1 = $service_name ]; then - /bin/echo "## $service_path is in root_daemon_list" - /bin/echo "=======================================================================" - # stop below code lines and return success to find - return 0 - fi - done - + temp=$(cat $ROOT_LIST | grep $service_name) + if [ -n "$temp" ] + then + /bin/echo "## $service_path is in root_daemon_list" + /bin/echo "=======================================================================" + return 0 + fi # Try to find non-daemon service - for line in $(/bin/cat $NON_DAEMON_LIST) - do - service_name=`/bin/echo $line | /usr/bin/awk -F "," '{print $1}'` - if [ $1 = $service_name ]; then - /bin/echo "## $service_path is in non_daemon_list" - /bin/echo "=======================================================================" - # stop below code lines and retrun success to find - return 0 - fi - done + temp=$(cat $NON_DAEMON_LIST | grep $service_name) + if [ -n "$temp" ] + then + /bin/echo "## $service_path is in non_daemon_list" + /bin/echo "=======================================================================" + return 0 + fi # Try to find exception case - for line in $(/bin/cat $EXCEPTION_LIST) - do - service_name=`/bin/echo $line | /usr/bin/awk -F "," '{print $1}'` - exception_case=`/bin/echo $line | /usr/bin/awk -F "," '{print $3}'` - if [ $1 = $service_name ]; then - if [ "$exception_case" = "EXCEPTED" ]; then - /bin/echo "## $service_path is in exception_list" - /bin/echo "=======================================================================" - # stop below code lines and retrun success to find - return 0 - fi - fi - done + temp=$(cat $EXCEPTION_LIST | grep $service_name | grep "EXCEPTED") + if [ -n "$temp" ] + then + /bin/echo "## $service_path is in exception_list" + /bin/echo "=======================================================================" + return 0 + fi # Try to find non-root daemon service - for line in $(/bin/cat $NON_ROOT_LIST) - do - service_name=`/bin/echo $line | /usr/bin/awk -F "," '{print $1}'` - if [ $1 = $service_name ]; then - /bin/echo "## $service_path is in non_root_list" - # Found, - # 1st extract service type, uid, gid from our list - service_type=`/bin/echo $line | /usr/bin/awk -F "," '{print $2}'` - expected_uid=`/bin/echo $line | /usr/bin/awk -F "," '{print $3}'` - expected_gid=`/bin/echo $line | /usr/bin/awk -F "," '{print $4}'` - # 2nd call checkNonRootList (pass service name, service type, uid, gid) - checkNonRootList $service_name $service_type $expected_uid $expected_gid - # If found non-Root, then should retrun success to find - return 0 - fi - done + temp=$(cat $NON_ROOT_LIST | grep $service_name) + if [ -n "$temp" ] + then + /bin/echo "## $service_path is in non_root_list" + service_name=`/bin/echo $temp | /usr/bin/awk -F "," '{print $1}'` + service_type=`/bin/echo $temp | /usr/bin/awk -F "," '{print $2}'` + expected_uid=`/bin/echo $temp | /usr/bin/awk -F "," '{print $3}'` + expected_gid=`/bin/echo $temp | /usr/bin/awk -F "," '{print $4}'` + checkNonRootList $service_name $service_type $expected_uid $expected_gid + return 0 + fi # ## This service would be new daemon / service ## checkWhetherNewRoot $1 $2