diff --git a/CHANGES b/CHANGES index 77f6c889b5..42db368d81 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,17 @@ +2.4-78 | 2015-08-06 22:25:19 -0400 + + * Remove build dependency on Perl (now requiring Python instad). + (Daniel Thayer) + + * CID 1314754: Fixing unreachable code in RSH analyzer. (Robin + Sommer) + + * CID 1312752: Add comment to mark 'case' fallthrough as ok. (Robin + Sommer) + + * CID 1312751: Removing redundant assignment. (Robin Sommer) + 2.4-73 | 2015-07-31 08:53:49 -0700 * BIT-1429: SMTP logs now include CC: addresses. (Albert Zaharovits) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7dbf8109ad..2a3251d111 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -61,7 +61,7 @@ if (NOT SED_EXE) endif () endif () -FindRequiredPackage(Perl) +FindRequiredPackage(PythonInterp) FindRequiredPackage(FLEX) FindRequiredPackage(BISON) FindRequiredPackage(PCAP) diff --git a/NEWS b/NEWS index 071677010f..726c6032bf 100644 --- a/NEWS +++ b/NEWS @@ -16,6 +16,8 @@ New Dependencies - Bro now requires the C++ Actor Framework, CAF, which must be installed first. See http://actor-framework.org. +- Bro now requires Python instead of Perl to compile the source code. + New Functionality ----------------- diff --git a/VERSION b/VERSION index 5e220b92fd..7e806db48f 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.4-73 +2.4-78 diff --git a/aux/bro-aux b/aux/bro-aux index 07af9748f4..7012f7bb77 160000 --- a/aux/bro-aux +++ b/aux/bro-aux @@ -1 +1 @@ -Subproject commit 07af9748f40dc47d3a2b3290db494a90dcbddbdc +Subproject commit 7012f7bb7768ffd56282e0d453c5f919b2142551 diff --git a/configure b/configure index ae2f337117..3e844735a5 100755 --- a/configure +++ b/configure @@ -55,7 +55,7 @@ Usage: $0 [OPTION]... [VAR=VALUE]... --with-binpac=PATH path to BinPAC install root --with-flex=PATH path to flex executable --with-bison=PATH path to bison executable - --with-perl=PATH path to perl executable + --with-python=PATH path to Python executable --with-libcaf=PATH path to C++ Actor Framework installation (a required Broker dependency) @@ -63,7 +63,6 @@ Usage: $0 [OPTION]... [VAR=VALUE]... --with-geoip=PATH path to the libGeoIP install root --with-perftools=PATH path to Google Perftools install root --with-jemalloc=PATH path to jemalloc install root - --with-python=PATH path to Python interpreter --with-python-lib=PATH path to libpython --with-python-inc=PATH path to Python headers --with-ruby=PATH path to ruby interpreter @@ -239,9 +238,6 @@ while [ $# -ne 0 ]; do --with-bison=*) append_cache_entry BISON_EXECUTABLE PATH $optarg ;; - --with-perl=*) - append_cache_entry PERL_EXECUTABLE PATH $optarg - ;; --with-geoip=*) append_cache_entry LibGeoIP_ROOT_DIR PATH $optarg ;; diff --git a/doc/install/install.rst b/doc/install/install.rst index eff3ec9728..ff8d83ad97 100644 --- a/doc/install/install.rst +++ b/doc/install/install.rst @@ -45,7 +45,7 @@ To build Bro from source, the following additional dependencies are required: * Libpcap headers (http://www.tcpdump.org) * OpenSSL headers (http://www.openssl.org) * zlib headers - * Perl + * Python .. todo:: @@ -72,7 +72,7 @@ To install the required dependencies, you can use: .. console:: - sudo pkg install bash cmake swig bison python perl5 py27-sqlite3 + sudo pkg install bash cmake swig bison python py27-sqlite3 Note that in older versions of FreeBSD, you might have to use the "pkg_add -r" command instead of "pkg install". @@ -166,7 +166,7 @@ run ``./configure --help``): make install The default installation path is ``/usr/local/bro``, which would typically -require root privileges when doing the ``make install``. A different +require root privileges when doing the ``make install``. A different installation path can be chosen by specifying the ``--prefix`` option. Note that ``/usr`` and ``/opt/bro`` are the standard prefixes for binary Bro packages to be installed, so those are diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index bdbd3839ce..9a807b3182 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -223,16 +223,16 @@ endmacro(COLLECT_HEADERS _var) cmake_policy(POP) -# define a command that's used to run the make_dbg_constants.pl script +# define a command that's used to run the make_dbg_constants.py script # building the bro binary depends on the outputs of this script add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/DebugCmdConstants.h ${CMAKE_CURRENT_BINARY_DIR}/DebugCmdInfoConstants.cc - COMMAND ${PERL_EXECUTABLE} - ARGS ${CMAKE_CURRENT_SOURCE_DIR}/make_dbg_constants.pl + COMMAND ${PYTHON_EXECUTABLE} + ARGS ${CMAKE_CURRENT_SOURCE_DIR}/make_dbg_constants.py ${CMAKE_CURRENT_SOURCE_DIR}/DebugCmdInfoConstants.in - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/make_dbg_constants.pl + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/make_dbg_constants.py ${CMAKE_CURRENT_SOURCE_DIR}/DebugCmdInfoConstants.in - COMMENT "[Perl] Processing debug commands" + COMMENT "[Python] Processing debug commands" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) diff --git a/src/make_dbg_constants.pl b/src/make_dbg_constants.pl deleted file mode 100644 index 29efac8050..0000000000 --- a/src/make_dbg_constants.pl +++ /dev/null @@ -1,143 +0,0 @@ -# Build the DebugCmdConstants.h and DebugCmdInfoConstants.h files from the -# DebugCmdInfoConstants.in file. -# -# We do this via a script rather than maintaining them directly because -# the struct is a little complicated, so has to be initialized from code, -# plus we want to make adding new constants somewhat less painful. -# -# The input filename should be supplied as an argument -# -# DebugCmds are printed to DebugCmdConstants.h -# DebugCmdInfos are printed to DebugCmdInfoConstants.h -# -# The input format is: -# -# cmd: [DebugCmd] -# names: [space delimited names of cmd] -# resume: ['true' or 'false': should execution resume after this command?] -# help: [some help text] -# -# Blank lines are skipped. -# Comments should start with // and should be on a line by themselves. - -use strict; - -open INPUT, $ARGV[0] or die "Input file $ARGV[0] not found."; -open DEBUGCMDS, ">DebugCmdConstants.h" - or die "Unable to open DebugCmdConstants.h"; -open DEBUGCMDINFOS, ">DebugCmdInfoConstants.cc" - or die "Unable to open DebugCmdInfoConstants.cc"; - -my $init_tmpl = -' - { - DebugCmdInfo* info; - @@name_init - info = new DebugCmdInfo (@@cmd, names, @@num_names, @@resume, "@@help", - @@repeatable); - g_DebugCmdInfos.push_back(info); - } -'; - -my $enum_str = " -// -// This file was automatically generated from $ARGV[0] -// DO NOT EDIT. -// -enum DebugCmd { -"; - -my $init_str = " -// -// This file was automatically generated from $ARGV[0] -// DO NOT EDIT. -// - -#include \"util.h\" -void init_global_dbg_constants () { -"; - -my %dbginfo; -# { cmd, num_names, \@names, name_init, resume, help, repeatable } - -no strict "refs"; -sub OutputRecord { - $dbginfo{name_init} .= "const char * const names[] = {\n\t"; - $_ = "\"$_\"" foreach @{$dbginfo{names}}; # put quotes around the strings - my $name_strs = join ",\n\t", @{$dbginfo{names}}; - $dbginfo{name_init} .= "$name_strs\n };\n"; - - $dbginfo{num_names} = scalar @{$dbginfo{names}}; - - # substitute into template - my $init = $init_tmpl; - $init =~ s/(\@\@(\w+))/defined $dbginfo{$2} ? $dbginfo{$2} : ""/eg; - - $init_str .= $init; - - $enum_str .= "\t$dbginfo{cmd},\n"; -} -use strict "refs"; - -sub InitDbginfo - { - my $dbginfo = shift; - %$dbginfo = ( num_names => 0, names => [], resume => 'false', help => '', - repeatable => 'false' ); - } - - -InitDbginfo(\%dbginfo); - -while () { - chomp ($_); - next if $_ =~ /^\s*$/; # skip blank - next if $_ =~ /^\s*\/\//; # skip comments - - $_ =~ /^\s*([a-z]+):\s*(.*)$/ or - die "Error in debug constant file on line: $_"; - - if ($1 eq 'cmd') - { - my $newcmd = $2; - if (defined $dbginfo{cmd}) { # output the previous record - OutputRecord(); - InitDbginfo(\%dbginfo); - } - - $dbginfo{cmd} = $newcmd; - } - elsif ($1 eq 'names') - { - my @names = split / /, $2; - $dbginfo{names} = \@names; - } - elsif ($1 eq 'resume') - { - $dbginfo{resume} = $2; - } - elsif ($1 eq 'help') - { - $dbginfo{help} = $2; - $dbginfo{help} =~ s{\"}{\\\"}g; # escape quotation marks - } - elsif ($1 eq 'repeatable') - { - $dbginfo{repeatable} = $2; - } - else { - die "Unknown command: $_\n"; - } -} - -# output the last record -OutputRecord(); - -$init_str .= " \n}\n"; -$enum_str .= " dcLast\n};\n"; - -print DEBUGCMDS $enum_str; -close DEBUGCMDS; - -print DEBUGCMDINFOS $init_str; -close DEBUGCMDINFOS; diff --git a/src/make_dbg_constants.py b/src/make_dbg_constants.py new file mode 100644 index 0000000000..e18330db87 --- /dev/null +++ b/src/make_dbg_constants.py @@ -0,0 +1,114 @@ +# Build the DebugCmdConstants.h and DebugCmdInfoConstants.cc files from the +# DebugCmdInfoConstants.in file. +# +# We do this via a script rather than maintaining them directly because +# the struct is a little complicated, so has to be initialized from code, +# plus we want to make adding new constants somewhat less painful. +# +# The input filename should be supplied as an argument. +# +# DebugCmds are printed to DebugCmdConstants.h +# DebugCmdInfos are printed to DebugCmdInfoConstants.cc +# +# The input format is: +# +# cmd: [DebugCmd] +# names: [space delimited names of cmd] +# resume: ['true' or 'false': should execution resume after this command?] +# help: [some help text] +# +# Blank lines are skipped. +# Comments should start with // and should be on a line by themselves. + +import sys + +inputfile = sys.argv[1] + +init_tmpl = ''' + { + DebugCmdInfo* info; + %(name_init)s + info = new DebugCmdInfo (%(cmd)s, names, %(num_names)s, %(resume)s, "%(help)s", + %(repeatable)s); + g_DebugCmdInfos.push_back(info); + } +''' + +enum_str = ''' +// +// This file was automatically generated from %s +// DO NOT EDIT. +// +enum DebugCmd { +''' % inputfile + +init_str = ''' +// +// This file was automatically generated from %s +// DO NOT EDIT. +// + +#include "util.h" +void init_global_dbg_constants () { +''' % inputfile + +def outputrecord(): + global init_str, enum_str + + dbginfo["name_init"] = "const char * const names[] = {\n\t%s\n };\n" % ",\n\t".join(dbginfo["names"]) + + dbginfo["num_names"] = len(dbginfo["names"]) + + # substitute into template + init_str += init_tmpl % dbginfo + + enum_str += "\t%s,\n" % dbginfo["cmd"] + +def initdbginfo(): + return {"cmd": "", "name_init": "", "num_names": 0, "names": [], + "resume": "false", "help": "", "repeatable": "false"} + +dbginfo = initdbginfo() + +inputf = open(inputfile, "r") +for line in inputf: + line = line.strip() + if not line or line.startswith("//"): # skip empty lines and comments + continue + + fields = line.split(":", 1) + if len(fields) != 2: + raise RuntimeError("Error in debug constant file on line: %s" % line) + + f1, f2 = fields + f2 = f2.strip() + + if f1 == "cmd": + if dbginfo[f1]: # output the previous record + outputrecord() + dbginfo = initdbginfo() + + dbginfo[f1] = f2 + elif f1 == "names": + # put quotes around the strings + dbginfo[f1] = [ '"%s"' % n for n in f2.split() ] + elif f1 == "help": + dbginfo[f1] = f2.replace('"', '\\"') # escape quotation marks + elif f1 in ("resume", "repeatable"): + dbginfo[f1] = f2 + else: + raise RuntimeError("Unknown command: %s" % line) + +# output the last record +outputrecord() + +init_str += " \n}\n" +enum_str += " dcLast\n};\n" + +debugcmds = open("DebugCmdConstants.h", "w") +debugcmds.write(enum_str) +debugcmds.close() + +debugcmdinfos = open("DebugCmdInfoConstants.cc", "w") +debugcmdinfos.write(init_str) +debugcmdinfos.close()