+# Validate services' configuration.
+#
+services_file_list="`ls -1 /etc/xinetd.d/`"
+if [ -n "$services_file_list" ]; then
+
+ for services_file in $services_file_list; do
+
+ # Get services list from $services_file
+ services_list="`sed -rn "s/^[[:space:]]*service[[:space:]]+(.*)[[:space:]]*$/\1/p" /etc/xinetd.d/$services_file`"
+
+ if [ -n "$services_list" ]; then
+
+ for service in $services_list; do
+
+ service_disable=0
+ service_block="`sed -rn "/^[[:space:]]*service[[:space:]]+$service[[:space:]]*$/,/^}/p" /etc/xinetd.d/$services_file`"
+
+ # Check service's user
+ service_user="`echo "$service_block" | sed -nr "s/^[[:space:]]*user[[:space:]]*=[[:space:]]*(.*)[[:space:]]*$/\1/p"`"
+ if [ -n "$service_user" ]; then
+
+ service_user_chk="`getent passwd "$service_user"`" || true
+ if [ -z "$service_user_chk" ]; then
+ cp_echo "CN: Error in /etc/xinetd.d/$services_file for service '$service' - user '$service_user' does not exist."
+ service_disable=1
+ fi
+ fi
+
+ # Check service's group
+ service_group="`echo "$service_block" | sed -nr "s/^[[:space:]]*group[[:space:]]*=[[:space:]]*(.*)[[:space:]]*$/\1/p"`"
+ if [ -n "$service_group" ]; then
+
+ service_group_chk="`getent passwd "$service_group"`" || true
+ if [ -z "$service_group_chk" ]; then
+ cp_echo "CN: Error in /etc/xinetd.d/$services_file for service '$service' - group '$service_group' does not exist."
+ service_disable=1
+ fi
+ fi
+
+ # Check service's binary
+ service_server="`echo "$service_block" | sed -nr "s/^[[:space:]]*server[[:space:]]*=[[:space:]]*(.*)[[:space:]]*$/\1/p"`"
+ if [ -n "$service_server" ] && [ ! -x "$service_server" ]; then
+ cp_echo "CN: Error in /etc/xinetd.d/$services_file for service '$service' - server '$service_server' does not exist."
+ service_disable=1
+ fi
+
+ if [ $service_disable -eq 1 ]; then
+ backup_and_disable_service "$service" "$services_file"
+ need_restart=1
+ fi
+ done
+ fi
+ done
+fi
+