From 3e7a8f2482d56df32669842161bd1a0156397edf Mon Sep 17 00:00:00 2001 From: Kenny Root Date: Wed, 13 Mar 2019 11:34:08 +0900 Subject: [PATCH] More robust ausearch time input Depending on what locale you were using, you may have time that would show AM or PM. This would cause the time to be incorrect on noon and midnight rollovers. This change allows all the output of strptime's %x and %X to be captured and provided to ausearch. --- python/sepolicy/sepolicy/templates/script.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/python/sepolicy/sepolicy/templates/script.py b/python/sepolicy/sepolicy/templates/script.py index c79738b87d..8f5f8caa14 100644 --- a/python/sepolicy/sepolicy/templates/script.py +++ b/python/sepolicy/sepolicy/templates/script.py @@ -34,8 +34,9 @@ if [ $# -eq 1 ]; then if [ "$1" = "--update" ] ; then - time=`ls -l --time-style="+%x %X" TEMPLATEFILE.te | awk '{ printf "%s %s", $6, $7 }'` - rules=`ausearch --start $time -m avc --raw -se TEMPLATETYPE` + time=`date -r TEMPLATETYPE.te "+%x"` + date=`date -r TEMPLATETYPE.te "+%X"` + rules=`ausearch --start "$time" "$date" -m avc --raw -se TEMPLATETYPE` if [ x"$rules" != "x" ] ; then echo "Found avc's to update policy with" echo -e "$rules" | audit2allow -R