Remove deprecated print_hook event

This commit is contained in:
Jon Siwek 2019-06-27 17:37:51 -07:00
parent 5343924eb9
commit e9fefa6501
9 changed files with 15 additions and 81 deletions

3
NEWS
View file

@ -381,6 +381,7 @@ Removed Functionality
- ``rescan_state``
- ``log_file_name``
- ``open_log_file``
- ``disable_print_hook``
- The following events were deprecated in version 2.6 or below and are completely
removed from this release:
@ -409,6 +410,7 @@ Removed Functionality
- ``software_version_found``
- ``software_unparsed_version_found``
- ``software_parse_error``
- ``print_hook``
- The following types/records were deprecated in version 2.6 or below and are
removed from this release:
@ -437,6 +439,7 @@ Removed Functionality
- ``ssl_ca_certificate``
- ``ssl_private_key``
- ``ssl_passphrase``
- ``suppress_local_output``
- The following constants were used as part of deprecated functionality in version 2.6
or below and are removed from this release:

View file

@ -4723,9 +4723,6 @@ const time_machine_profiling = F &redef;
## If true, warns about unused event handlers at startup.
const check_for_unused_event_handlers = F &redef;
## Deprecated.
const suppress_local_output = F &redef;
## Holds the filename of the trace file given with ``-w`` (empty if none).
##
## .. zeek:see:: record_all_packets

View file

@ -168,7 +168,6 @@ void BroFile::Init()
is_open = 0;
attrs = 0;
buffered = true;
print_hook = true;
raw_output = false;
t = 0;

View file

@ -63,9 +63,6 @@ public:
// Get the file with the given name, opening it if it doesn't yet exist.
static BroFile* GetFile(const char* name);
void DisablePrintHook() { print_hook = false; }
bool IsPrintHookEnabled() const { return print_hook; }
void EnableRawOutput() { raw_output = true; }
bool IsRawOutput() const { return raw_output; }
@ -98,7 +95,6 @@ protected:
Attributes* attrs;
bool buffered;
double open_time;
bool print_hook;
bool raw_output;
static const int MIN_BUFFER_SIZE = 1024;

View file

@ -203,49 +203,25 @@ Val* PrintStmt::DoExec(val_list* vals, stmt_flow_type& /* flow */) const
++offset;
}
bool ph = print_hook && f->IsPrintHookEnabled();
desc_style style = f->IsRawOutput() ? RAW_STYLE : STANDARD_STYLE;
if ( ! (suppress_local_output && ph) )
{
if ( f->IsRawOutput() )
{
ODesc d(DESC_READABLE);
d.SetFlush(0);
d.SetStyle(style);
PrintVals(&d, vals, offset);
f->Write(d.Description(), d.Len());
}
else
{
ODesc d(DESC_READABLE, f);
d.SetFlush(0);
d.SetStyle(style);
PrintVals(&d, vals, offset);
f->Write("\n", 1);
}
}
if ( ph )
if ( f->IsRawOutput() )
{
ODesc d(DESC_READABLE);
d.SetFlush(0);
d.SetStyle(style);
PrintVals(&d, vals, offset);
f->Write(d.Description(), d.Len());
}
else
{
ODesc d(DESC_READABLE, f);
d.SetFlush(0);
d.SetStyle(style);
if ( print_hook )
{
::Ref(f);
// Note, this doesn't do remote printing.
mgr.Dispatch(
new Event(
print_hook,
{new Val(f), new StringVal(d.Len(), d.Description())}),
true);
}
PrintVals(&d, vals, offset);
f->Write("\n", 1);
}
return 0;

View file

@ -813,6 +813,3 @@ event gaobot_signature_found%(c: connection%);
## Shows an IP address anonymization mapping.
event anonymization_mapping%(orig: addr, mapped: addr%);
## Deprecated. Will be removed.
event print_hook%(f:file, s: string%);

View file

@ -4723,28 +4723,10 @@ function file_size%(f: string%) : double
return new Val(double(s.st_size), TYPE_DOUBLE);
%}
## Disables sending :zeek:id:`print_hook` events to remote peers for a given
## file. In a
## distributed setup, communicating Zeek instances generate the event
## :zeek:id:`print_hook` for each print statement and send it to the remote
## side. When disabled for a particular file, these events will not be
## propagated to other peers.
##
## f: The file to disable :zeek:id:`print_hook` events for.
##
## .. zeek:see:: enable_raw_output
function disable_print_hook%(f: file%): any
%{
f->DisablePrintHook();
return 0;
%}
## Prevents escaping of non-ASCII characters when writing to a file.
## This function is equivalent to :zeek:attr:`&raw_output`.
##
## f: The file to disable raw output for.
##
## .. zeek:see:: disable_print_hook
function enable_raw_output%(f: file%): any
%{
f->EnableRawOutput();

View file

@ -4,7 +4,6 @@
# @TEST-EXEC: zeek -b %INPUT
# @TEST-EXEC: tr '\000' 'X' <myfile >output
# @TEST-EXEC: btest-diff output
# @TEST-EXEC: cmp myfile hookfile
event zeek_init()
{
@ -14,10 +13,3 @@ event zeek_init()
print myfile, "hello\x00world", "hi";
close(myfile);
}
event print_hook(f: file, s: string)
{
local hookfile = open("hookfile");
write_file(hookfile, s);
close(hookfile);
}

View file

@ -4,7 +4,6 @@
# @TEST-EXEC: zeek -b %INPUT
# @TEST-EXEC: tr '\000' 'X' <myfile >output
# @TEST-EXEC: btest-diff output
# @TEST-EXEC: cmp myfile hookfile
# first check local variable of file type w/ &raw_output
@ -16,10 +15,3 @@ event zeek_init()
print myfile, "hello\x00world", "hi";
close(myfile);
}
event print_hook(f: file, s: string)
{
local hookfile = open("hookfile");
write_file(hookfile, s);
close(hookfile);
}