Renaming the default loaded "init" scripts and added command line arg for "bare-mode"

- bro.init was renamed to base/init-bare.bro and base/all.bro
  was renamed to init-default.bro.

- To run in "bare mode" with only the init-bare.bro and no other
  scripts from base/, use either -b or --bare-mode.

- The environment variable to run in "bare mode" has been removed.
This commit is contained in:
Seth Hall 2011-08-08 13:40:43 -04:00
parent e60213ac11
commit c4f4df6a79
28 changed files with 43 additions and 38 deletions

View file

@ -1,10 +1,8 @@
##! This script loads everything in the base/ script directory. If you want ##! This script loads everything in the base/ script directory. If you want
##! to run Bro without all of these scripts loaded by default, you can define ##! to run Bro without all of these scripts loaded by default, you can use
##! the BRO_NO_BASE_SCRIPTS environment variable to any value. You can also ##! the -b (--bare-mode) command line argument. You can also copy the "@load"
##! copy the "@load" lines from this script to your own script to load only ##! lines from this script to your own script to load only the scripts that
##! the scripts that you actually want. ##! you actually want.
@if ( getenv("BRO_NO_BASE_SCRIPTS") == "" )
@load base/utils/site @load base/utils/site
@load base/utils/addrs @load base/utils/addrs
@ -17,7 +15,8 @@
@load base/utils/strings @load base/utils/strings
@load base/utils/thresholds @load base/utils/thresholds
# This has some weird interplay between types and BiFs so it's loaded in bro.init # This has some deep interplay between types and BiFs so it's
# loaded in base/init-bare.bro
#@load base/frameworks/logging #@load base/frameworks/logging
@load base/frameworks/notice @load base/frameworks/notice
@load base/frameworks/dpd @load base/frameworks/dpd
@ -40,5 +39,3 @@
@load base/protocols/ssh @load base/protocols/ssh
@load base/protocols/ssl @load base/protocols/ssl
@load base/protocols/syslog @load base/protocols/syslog
@endif

View file

@ -138,6 +138,7 @@ void usage()
fprintf(stderr, "bro version %s\n", bro_version()); fprintf(stderr, "bro version %s\n", bro_version());
fprintf(stderr, "usage: %s [options] [file ...]\n", prog); fprintf(stderr, "usage: %s [options] [file ...]\n", prog);
fprintf(stderr, " <file> | policy file, or read stdin\n"); fprintf(stderr, " <file> | policy file, or read stdin\n");
fprintf(stderr, " -b|--bare-mode | don't load scripts from the base/ directory\n");
fprintf(stderr, " -d|--debug-policy | activate policy file debugging\n"); fprintf(stderr, " -d|--debug-policy | activate policy file debugging\n");
fprintf(stderr, " -e|--exec <bro code> | augment loaded policies by given code\n"); fprintf(stderr, " -e|--exec <bro code> | augment loaded policies by given code\n");
fprintf(stderr, " -f|--filter <filter> | tcpdump filter\n"); fprintf(stderr, " -f|--filter <filter> | tcpdump filter\n");
@ -349,6 +350,7 @@ int main(int argc, char** argv)
char* seed_load_file = getenv("BRO_SEED_FILE"); char* seed_load_file = getenv("BRO_SEED_FILE");
char* seed_save_file = 0; char* seed_save_file = 0;
char* user_pcap_filter = 0; char* user_pcap_filter = 0;
int bare_mode = false;
int seed = 0; int seed = 0;
int dump_cfg = false; int dump_cfg = false;
int to_xml = 0; int to_xml = 0;
@ -358,6 +360,7 @@ int main(int argc, char** argv)
int RE_level = 4; int RE_level = 4;
static struct option long_opts[] = { static struct option long_opts[] = {
{"bare-mode", no_argument, 0, 'b'},
{"debug-policy", no_argument, 0, 'd'}, {"debug-policy", no_argument, 0, 'd'},
{"dump-config", no_argument, 0, 'g'}, {"dump-config", no_argument, 0, 'g'},
{"exec", required_argument, 0, 'e'}, {"exec", required_argument, 0, 'e'},
@ -438,7 +441,7 @@ int main(int argc, char** argv)
opterr = 0; opterr = 0;
char opts[256]; char opts[256];
safe_strncpy(opts, "B:D:e:f:I:i:K:n:p:R:r:s:T:t:U:w:x:X:y:Y:z:CFGLOPSWdghvZ", safe_strncpy(opts, "B:D:e:f:I:i:K:n:p:R:r:s:T:t:U:w:x:X:y:Y:z:CFGLOPSWbdghvZ",
sizeof(opts)); sizeof(opts));
#ifdef USE_PERFTOOLS #ifdef USE_PERFTOOLS
@ -448,6 +451,10 @@ int main(int argc, char** argv)
int op; int op;
while ( (op = getopt_long(argc, argv, opts, long_opts, &long_optsind)) != EOF ) while ( (op = getopt_long(argc, argv, opts, long_opts, &long_optsind)) != EOF )
switch ( op ) { switch ( op ) {
case 'b':
bare_mode = true;
break;
case 'd': case 'd':
fprintf(stderr, "Policy file debugging ON.\n"); fprintf(stderr, "Policy file debugging ON.\n");
g_policy_debug = true; g_policy_debug = true;
@ -675,8 +682,9 @@ int main(int argc, char** argv)
timer_mgr = new PQ_TimerMgr("<GLOBAL>"); timer_mgr = new PQ_TimerMgr("<GLOBAL>");
// timer_mgr = new CQ_TimerMgr(); // timer_mgr = new CQ_TimerMgr();
add_input_file("base/bro.init"); add_input_file("base/init-bare.bro");
add_input_file("base/all.bro"); if ( ! bare_mode )
add_input_file("base/init-default.bro");
if ( optind == argc && if ( optind == argc &&
read_files.length() == 0 && flow_files.length() == 0 && read_files.length() == 0 && flow_files.length() == 0 &&

View file

@ -1,5 +1,5 @@
# depth name # depth name
0 scripts/base/bro.init 0 scripts/base/init-bare.bro
1 build/src/const.bif.bro 1 build/src/const.bif.bro
1 build/src/types.bif.bro 1 build/src/types.bif.bro
1 build/src/strings.bif.bro 1 build/src/strings.bif.bro
@ -10,7 +10,7 @@
2 scripts/base/frameworks/logging/./main.bro 2 scripts/base/frameworks/logging/./main.bro
3 build/src/logging.bif.bro 3 build/src/logging.bif.bro
2 scripts/base/frameworks/logging/./writers/ascii.bro 2 scripts/base/frameworks/logging/./writers/ascii.bro
0 scripts/base/all.bro 0 scripts/base/init-default.bro
1 scripts/base/utils/site.bro 1 scripts/base/utils/site.bro
2 scripts/base/utils/./patterns.bro 2 scripts/base/utils/./patterns.bro
1 scripts/base/utils/addrs.bro 1 scripts/base/utils/addrs.bro

View file

@ -1,5 +1,5 @@
# @TEST-EXEC: BRO_NO_BASE_SCRIPTS=1 bro %INPUT # @TEST-EXEC: bro -b %INPUT
# @TEST-EXEC: btest-diff ssh-new-default.log # @TEST-EXEC: btest-diff ssh-new-default.log
# @TEST-EXEC: test '!' -e ssh.log # @TEST-EXEC: test '!' -e ssh.log

View file

@ -1,5 +1,5 @@
# #
# @TEST-EXEC: BRO_NO_BASE_SCRIPTS=1 bro %INPUT # @TEST-EXEC: bro -b %INPUT
# @TEST-EXEC: btest-diff ssh.log # @TEST-EXEC: btest-diff ssh.log
module SSH; module SSH;

View file

@ -1,5 +1,5 @@
# #
# @TEST-EXEC: BRO_NO_BASE_SCRIPTS=1 bro %INPUT # @TEST-EXEC: bro -b %INPUT
# @TEST-EXEC: btest-diff ssh.log # @TEST-EXEC: btest-diff ssh.log
redef LogAscii::output_to_stdout = F; redef LogAscii::output_to_stdout = F;

View file

@ -1,5 +1,5 @@
# #
# @TEST-EXEC: BRO_NO_BASE_SCRIPTS=1 bro %INPUT # @TEST-EXEC: bro -b %INPUT
# @TEST-EXEC: btest-diff ssh.log # @TEST-EXEC: btest-diff ssh.log
redef LogAscii::separator = "||"; redef LogAscii::separator = "||";

View file

@ -1,5 +1,5 @@
# #
# @TEST-EXEC: BRO_NO_BASE_SCRIPTS=1 bro %INPUT # @TEST-EXEC: bro -b %INPUT
# @TEST-EXEC: btest-diff ssh.log # @TEST-EXEC: btest-diff ssh.log
redef LogAscii::output_to_stdout = F; redef LogAscii::output_to_stdout = F;

View file

@ -1,5 +1,5 @@
# #
# @TEST-EXEC: BRO_NO_BASE_SCRIPTS=1 bro %INPUT # @TEST-EXEC: bro -b %INPUT
# @TEST-EXEC: btest-diff test.log # @TEST-EXEC: btest-diff test.log
module Test; module Test;

View file

@ -1,5 +1,5 @@
# #
# @TEST-EXEC: BRO_NO_BASE_SCRIPTS=1 bro %INPUT # @TEST-EXEC: bro -b %INPUT
# @TEST-EXEC: btest-diff ssh.log # @TEST-EXEC: btest-diff ssh.log
module SSH; module SSH;

View file

@ -1,5 +1,5 @@
# #
# @TEST-EXEC: BRO_NO_BASE_SCRIPTS=1 bro %INPUT # @TEST-EXEC: bro -b %INPUT
# @TEST-EXEC: btest-diff ssh.log # @TEST-EXEC: btest-diff ssh.log
module SSH; module SSH;

View file

@ -1,5 +1,5 @@
# #
# @TEST-EXEC: BRO_NO_BASE_SCRIPTS=1 bro %INPUT # @TEST-EXEC: bro -b %INPUT
# @TEST-EXEC: test '!' -e ssh.log # @TEST-EXEC: test '!' -e ssh.log
module SSH; module SSH;

View file

@ -1,5 +1,5 @@
# #
# @TEST-EXEC: BRO_NO_BASE_SCRIPTS=1 bro %INPUT # @TEST-EXEC: bro -b %INPUT
# @TEST-EXEC: btest-diff ssh.log # @TEST-EXEC: btest-diff ssh.log
module SSH; module SSH;

View file

@ -1,5 +1,5 @@
# @TEST-EXEC: BRO_NO_BASE_SCRIPTS=1 bro %INPUT >output # @TEST-EXEC: bro -b %INPUT >output
# @TEST-EXEC: btest-diff output # @TEST-EXEC: btest-diff output
module SSH; module SSH;

View file

@ -1,5 +1,5 @@
# #
# @TEST-EXEC: BRO_NO_BASE_SCRIPTS=1 bro %INPUT # @TEST-EXEC: bro -b %INPUT
# @TEST-EXEC: btest-diff ssh.log # @TEST-EXEC: btest-diff ssh.log
module SSH; module SSH;

View file

@ -1,5 +1,5 @@
# #
# @TEST-EXEC: BRO_NO_BASE_SCRIPTS=1 bro %INPUT # @TEST-EXEC: bro -b %INPUT
# @TEST-EXEC: btest-diff ssh.log # @TEST-EXEC: btest-diff ssh.log
module SSH; module SSH;

View file

@ -1,5 +1,5 @@
# #
# @TEST-EXEC: BRO_NO_BASE_SCRIPTS=1 bro %INPUT # @TEST-EXEC: bro -b %INPUT
# @TEST-EXEC: btest-diff ssh.log # @TEST-EXEC: btest-diff ssh.log
module SSH; module SSH;

View file

@ -1,5 +1,5 @@
# #
# @TEST-EXEC: BRO_NO_BASE_SCRIPTS=1 bro %INPUT # @TEST-EXEC: bro -b %INPUT
# @TEST-EXEC: test '!' -e ssh.log # @TEST-EXEC: test '!' -e ssh.log
module SSH; module SSH;

View file

@ -1,5 +1,5 @@
# @TEST-EXEC: BRO_NO_BASE_SCRIPTS=1 bro %INPUT # @TEST-EXEC: bro -b %INPUT
# @TEST-EXEC: ( ls static-*; cat static-* ) >output # @TEST-EXEC: ( ls static-*; cat static-* ) >output
# @TEST-EXEC: btest-diff output # @TEST-EXEC: btest-diff output

View file

@ -1,5 +1,5 @@
# @TEST-EXEC: BRO_NO_BASE_SCRIPTS=1 bro %INPUT # @TEST-EXEC: bro -b %INPUT
# @TEST-EXEC: btest-diff ssh.success.log # @TEST-EXEC: btest-diff ssh.success.log
# @TEST-EXEC: btest-diff ssh.failure.log # @TEST-EXEC: btest-diff ssh.failure.log

View file

@ -1,5 +1,5 @@
# #
# @TEST-EXEC: BRO_NO_BASE_SCRIPTS=1 bro -B logging %INPUT # @TEST-EXEC: bro -b -B logging %INPUT
# @TEST-EXEC: btest-diff ssh.log # @TEST-EXEC: btest-diff ssh.log
# @TEST-EXEC: btest-diff ssh.failure.log # @TEST-EXEC: btest-diff ssh.failure.log

View file

@ -1,5 +1,5 @@
# #
# @TEST-EXEC: BRO_NO_BASE_SCRIPTS=1 bro -r %DIR/rotation.trace %INPUT | egrep "test|test2" | sort >out # @TEST-EXEC: bro -b -r %DIR/rotation.trace %INPUT | egrep "test|test2" | sort >out
# @TEST-EXEC: for i in `ls test*.log | sort`; do printf '> %s\n' $i; cat $i; done | sort | uniq >>out # @TEST-EXEC: for i in `ls test*.log | sort`; do printf '> %s\n' $i; cat $i; done | sort | uniq >>out
# @TEST-EXEC: btest-diff out # @TEST-EXEC: btest-diff out

View file

@ -1,5 +1,5 @@
# #
# @TEST-EXEC: BRO_NO_BASE_SCRIPTS=1 bro %INPUT >output # @TEST-EXEC: bro -b %INPUT >output
# @TEST-EXEC: btest-diff output # @TEST-EXEC: btest-diff output
# @TEST-EXEC: test '!' -e ssh.log # @TEST-EXEC: test '!' -e ssh.log

View file

@ -1,5 +1,5 @@
# #
# @TEST-EXEC: BRO_NO_BASE_SCRIPTS=1 bro %INPUT # @TEST-EXEC: bro -b %INPUT
# @TEST-EXEC: btest-diff ssh.log # @TEST-EXEC: btest-diff ssh.log
module SSH; module SSH;

View file

@ -1,5 +1,5 @@
# #
# @TEST-EXEC: BRO_NO_BASE_SCRIPTS=1 bro %INPUT # @TEST-EXEC: bro -b %INPUT
# @TEST-EXEC: btest-diff ssh.log # @TEST-EXEC: btest-diff ssh.log
# #
# Testing all possible types. # Testing all possible types.

View file

@ -1,5 +1,5 @@
# #
# @TEST-EXEC: BRO_NO_BASE_SCRIPTS=1 bro %INPUT # @TEST-EXEC: bro -b %INPUT
# @TEST-EXEC: btest-diff testing.log # @TEST-EXEC: btest-diff testing.log
redef enum Log::ID += { TESTING }; redef enum Log::ID += { TESTING };

View file

@ -1,5 +1,5 @@
# #
# @TEST-EXEC: BRO_NO_BASE_SCRIPTS=1 bro %INPUT # @TEST-EXEC: bro -b %INPUT
# @TEST-EXEC: btest-diff ssh.log # @TEST-EXEC: btest-diff ssh.log
module SSH; module SSH;