]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
tweaks
authorRuss Combs <rucombs@cisco.com>
Thu, 2 Oct 2014 12:02:21 +0000 (08:02 -0400)
committerRuss Combs <rucombs@cisco.com>
Thu, 2 Oct 2014 12:02:21 +0000 (08:02 -0400)
src/main/snort_module.cc
src/main/thread.cc
src/parser/parse_stream.cc
src/parser/parser.cc

index 0da5d2b418f5e2060bf3be85fa4e14659862e5d2..f7953b10dc6f112fbe91121b2bc124294e43c343 100644 (file)
@@ -126,7 +126,7 @@ static const Parameter s_params[] =
       "<mode> checksum mode (all,noip,notcp,noudp,noicmp,none)" },
 
     { "-l", Parameter::PT_STRING, nullptr, nullptr, 
-      "<logdir> log to this directory instead of current director" },
+      "<logdir> 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,
       "<filter options> 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,
       "<path> where to find plugins" },
 
index 5710729ccd4aa633444e2ddffeb636e024a0a819..11ae08c825f27a5449ddcf1b48b8bb73d8dc1dcb 100644 (file)
@@ -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;
 
index 6fb748d7ad6032b0b31becad70a8567ecdc3c480..f4cb764d81643d3df9d83ae065ac6e420fb1ee06 100644 (file)
@@ -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;
     }
index 2191f43ae51906b5fab5622fc01cbdb692e70632..c0854161d8c3a6f6a7673296f6dcc8d7c33aa791 100644 (file)
@@ -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();