From 67948aa62f61d458f7bedae5a2201c1859b62567 Mon Sep 17 00:00:00 2001 From: "sanghyeok.oh" Date: Wed, 23 Oct 2019 20:13:34 +0900 Subject: [PATCH] policychecker: print error related information Change-Id: I07dbeffd02cf67f98ec0363b7b4aaa55e8f34e02 Signed-off-by: sanghyeok.oh --- policychecker/check.in | 158 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 152 insertions(+), 6 deletions(-) diff --git a/policychecker/check.in b/policychecker/check.in index 393785a..d451840 100755 --- a/policychecker/check.in +++ b/policychecker/check.in @@ -12,6 +12,7 @@ sub_conf_path=("system.d" "session.d") bus_type=-1 config_file=-1 checker_include_all=0 +verbose_mode=0 schema_file="$checker_dir/rules.xsl" system_privileges_file="$tmpdir/privileges_system" @@ -31,13 +32,14 @@ usage() { echo -e "\tfilename dbus policy configuration file" echo -e "\t-s system bus" echo -e "\t-u session bus" + echo -e "\t-d enable verbose mode" echo -e "\t-v include every iso xsls" echo -e "\t-p enable profile mode" } # use "checker opt + config-file" # getopts doesn't support - "checker config-file + opt" -while getopts :suvp opt +while getopts :sudvp opt do case "$opt" in s) if [ $bus_type -eq -1 ]; then bus_type=0 @@ -49,8 +51,11 @@ do case "$opt" in echo "check session bus" fi ;; - v) checker_include_all=1 - echo "use iso_dsdl_include.xsl" + d) echo "enable verbose mode" + verbose_mode=1 + ;; + v) echo "include every xsl. iso_dsdl_include.xsl" + checker_include_all=1 ;; p) echo "enable profile mode" xslt_processor="$xslt_processor --profile" @@ -141,23 +146,164 @@ function check_policy_file(){ echo } +# print_matched_xml (str filename, int policyindex, str allow/deny, int allowindex) +# print_matched_xml "$filename" $policy "" 0 +function print_matched_xml(){ + local cnt_policy=0 + local cnt_allow=0 + local cnt_deny=0 + local filename="$1" + local policy_index=$2 + local allowdeny="$3" + local allow_index=$4 + local found_policy_tag=0 + local print_to_end=0 + local line_cnt=0 + local is_comment=0 + local reg1="^[[:blank:]]*[[:blank:]]*$" + local reg3="^.*-->[[:blank:]]*$" + local reg_start_allow="^[[:blank:]]*<$allowdeny.*$" + local reg_end_tag=".*/>[[:blank:]]*$" + local reg_start_policy="^[[:blank:]]*