Fix ascii writer to not discard a ".gz" file extension

When Bro writes a compressed log, it uses a file extension of ".gz".
However, upon log rotation the ascii writer script function
"default_rotation_postprocessor_func" was discarding the ".gz"
file extension.  Fixed so that the correct file extension is
preserved after rotation.
This commit is contained in:
Daniel Thayer 2017-08-25 15:39:12 -05:00
parent 5efaaf1368
commit 823fba1713

View file

@ -79,9 +79,12 @@ export {
# runs the writer's default postprocessor command on it. # runs the writer's default postprocessor command on it.
function default_rotation_postprocessor_func(info: Log::RotationInfo) : bool function default_rotation_postprocessor_func(info: Log::RotationInfo) : bool
{ {
# If the filename has a ".gz" extension, then keep it.
local gz = info$fname[-3:] == ".gz" ? ".gz" : "";
# Move file to name including both opening and closing time. # Move file to name including both opening and closing time.
local dst = fmt("%s.%s.log", info$path, local dst = fmt("%s.%s.log%s", info$path,
strftime(Log::default_rotation_date_format, info$open)); strftime(Log::default_rotation_date_format, info$open), gz);
system(fmt("/bin/mv %s %s", info$fname, dst)); system(fmt("/bin/mv %s %s", info$fname, dst));