From: Russ Combs Date: Thu, 2 Oct 2014 12:02:21 +0000 (-0400) Subject: tweaks X-Git-Tag: 3.0.0-233~1397^2~28 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=eb9a362238addca9f2bae10d958a9e30efcdfe90;p=thirdparty%2Fsnort3.git tweaks --- diff --git a/src/main/snort_module.cc b/src/main/snort_module.cc index 0da5d2b41..f7953b10d 100644 --- a/src/main/snort_module.cc +++ b/src/main/snort_module.cc @@ -126,7 +126,7 @@ static const Parameter s_params[] = " checksum mode (all,noip,notcp,noudp,noicmp,none)" }, { "-l", Parameter::PT_STRING, nullptr, nullptr, - " log to this directory instead of current director" }, + " log to this directory instead of current directory" }, { "-M", Parameter::PT_IMPLIED, nullptr, nullptr, "log messages to syslog (not alerts)" }, @@ -200,9 +200,6 @@ static const Parameter s_params[] = { "--bpf", Parameter::PT_STRING, nullptr, nullptr, " are standard BPF options, as seen in TCPDump" }, - { "--pedantic", Parameter::PT_IMPLIED, nullptr, nullptr, - "warnings are fatal" }, - { "--create-pidfile", Parameter::PT_IMPLIED, nullptr, nullptr, "create PID file, even when not in Daemon mode" }, @@ -329,6 +326,9 @@ static const Parameter s_params[] = { "--pcap-show", Parameter::PT_IMPLIED, nullptr, nullptr, "print a line saying what pcap is currently being read" }, + { "--pedantic", Parameter::PT_IMPLIED, nullptr, nullptr, + "warnings are fatal" }, + { "--plugin-path", Parameter::PT_STRING, nullptr, nullptr, " where to find plugins" }, diff --git a/src/main/thread.cc b/src/main/thread.cc index 5710729cc..11ae08c82 100644 --- a/src/main/thread.cc +++ b/src/main/thread.cc @@ -208,7 +208,7 @@ const char* get_instance_file(std::string& file, const char* name) sep = true; } - if ( get_instance_id() || snort_conf->id_zero ) + if ( (get_instance_max() > 1) || snort_conf->id_zero ) { char id[8]; snprintf(id, sizeof(id), "%u", get_instance_id()); @@ -216,9 +216,6 @@ const char* get_instance_file(std::string& file, const char* name) sep = true; } - if ( sep ) - file += '_'; - if ( snort_conf->id_subdir ) { file += '/'; @@ -228,6 +225,8 @@ const char* get_instance_file(std::string& file, const char* name) // FIXIT-J getting random 0750 or 0700 (umask not thread local)? mkdir(file.c_str(), 0770); } + else if ( sep ) + file += '_'; file += name; diff --git a/src/parser/parse_stream.cc b/src/parser/parse_stream.cc index 6fb748d7a..f4cb764d8 100644 --- a/src/parser/parse_stream.cc +++ b/src/parser/parse_stream.cc @@ -168,7 +168,7 @@ static TokenType get_token( else if ( c == '\\' ) state = 4; else if ( c == '\n' ) - printf("warning: line break in string on line %d\n", lines-1); + ParseWarning("line break in string on line %d\n", lines-1); break; case 4: // quoted escape s += c; @@ -176,7 +176,7 @@ static TokenType get_token( break; case 5: // unquoted escape if ( c != '\n' && c != '\r' ) - printf("error: invalid escape on line %d\n", lines); + ParseWarning("invalid escape on line %d\n", lines); state = 0; break; case 6: // token @@ -354,33 +354,28 @@ static bool exec( switch ( act ) { case FSM_ACT: - //printf("\nparse act = %s\n", tok.c_str()); + // FIXIT-L if non-rule tok != "END", parsing goes bad + // (need ctl-D to terminate) if ( tok == "END" ) return true; parse_rule_type(sc, tok.c_str(), rps.rtn); break; case FSM_PRO: - //printf("parse pro = %s\n", tok.c_str()); parse_rule_proto(sc, tok.c_str(), rps.rtn); break; case FSM_SIP: - //printf("parse sip = %s\n", tok.c_str()); parse_rule_nets(sc, tok.c_str(), true, rps.rtn); break; case FSM_SP: - //printf("parse sp = %s\n", tok.c_str()); parse_rule_ports(sc, tok.c_str(), true, rps.rtn); break; case FSM_DIR: - //printf("parse dir = %s\n", tok.c_str()); parse_rule_dir(sc, tok.c_str(), rps.rtn); break; case FSM_DIP: - //printf("parse dip = %s\n", tok.c_str()); parse_rule_nets(sc, tok.c_str(), false, rps.rtn); break; case FSM_DP: - //printf("parse dp = %s\n", tok.c_str()); parse_rule_ports(sc, tok.c_str(), false, rps.rtn); break; case FSM_STB: @@ -421,14 +416,12 @@ static bool exec( rps.tbd = true; break; case FSM_SET: - //printf("parse %s:%s = %s\n", rps.key.c_str(), rps.opt.c_str(), rps.val.c_str()); parse_rule_opt_set(sc, rps.key.c_str(), rps.opt.c_str(), rps.val.c_str()); rps.opt.clear(); rps.val.clear(); rps.tbd = false; break; case FSM_END: - //printf("parse %s:%s = %s\n", rps.key.c_str(), rps.opt.c_str(), rps.val.c_str()); if ( rps.opt.size() ) parse_rule_opt_set(sc, rps.key.c_str(), rps.opt.c_str(), rps.val.c_str()); parse_rule_opt_end(sc, rps.key.c_str(), rps.otn); @@ -449,13 +442,11 @@ static bool exec( rps.tbd = true; break; case FSM_INC: - //printf("\nparse %s = %s\n", rps.key.c_str(), tok.c_str()); parse_include(sc, tok.c_str()); break; case FSM_NOP: break; case FSM_ERR: - //printf("error\n"); default: break; } diff --git a/src/parser/parser.cc b/src/parser/parser.cc index 2191f43ae..c0854161d 100644 --- a/src/parser/parser.cc +++ b/src/parser/parser.cc @@ -819,6 +819,7 @@ void ParseRules(SnortConfig *sc) } if ( !idx && sc->stdin_rules ) { + LogMessage("Reading rules until EOF or a line starting with END\n"); push_parse_location("stdin"); parse_stream(std::cin, sc); pop_parse_location();