Skip to contentSkip to conversation

The sepolicy generate template uses the wrong time format for ausearch

DISCUSSION andria_girl 1 participant 1 message Jan 3 SELinux security module

lore
Share & tools
lore
#0 lore raw

When running [sepolicy generate's compile template](https://github.com/SELinuxProject/selinux/blob/0ab542a4458f28530e0e9380a903f5c3aa9b1526/python/sepolicy/sepolicy/templates/script.py#L36-L38) it fails to use the correct time format. If the system's locale time representation is 12-hour format, it passes that 12-hour time (sans the AM/PM) to ausearch, which only supports 24-hour time format. So if it's 4 pm or 16:00 it'll look up all the alerts from 4 am even if you just ran --update a minute ago.

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

TEMPLATEFILE

`

Changing the --time-style from +%x %X (locale's time representation) to +%x %T (time; same as %H:%M:%S) seems to fix it just fine.

Thanks,
andria_girl (fae/faer)