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