Skip to content

Commit 3d80c7f

Browse files
jlucovskyvictorjulien
authored andcommitted
main/options: Limit verbose option count
Issue: 7389 Continue to recognize multiple 'v' specifications up to the maximum recognized. The maximum recognized is the number of slots between the NOTICE and DEBUG levels. When debug is configured, `-vvvv` is required to set the log level to debug. Specifying 4 or more `v` will maintain debug level. When debug is not configured, `-vvvv` and more `v`'s will cause config messages to be printed.
1 parent 09e50ac commit 3d80c7f

1 file changed

Lines changed: 16 additions & 3 deletions

File tree

src/suricata.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,9 @@ SC_ATOMIC_DECLARE(unsigned int, engine_stage);
168168
/* Max packets processed simultaneously per thread. */
169169
#define DEFAULT_MAX_PENDING_PACKETS 1024
170170

171+
/* Maximum number of v's supported */
172+
#define VERBOSE_MAX (SC_LOG_DEBUG - SC_LOG_NOTICE)
173+
171174
/** suricata engine control flags */
172175
volatile uint8_t suricata_ctl_flags = 0;
173176

@@ -2087,9 +2090,15 @@ TmEcode SCParseCommandLine(int argc, char **argv)
20872090

20882091
SetBpfStringFromFile(optarg);
20892092
break;
2090-
case 'v':
2091-
suri->verbose++;
2092-
break;
2093+
case 'v': {
2094+
static bool ignore_extra = false;
2095+
if (suri->verbose < VERBOSE_MAX)
2096+
suri->verbose++;
2097+
else if (!ignore_extra) {
2098+
SCLogNotice("extraneous verbose option(s) ignored");
2099+
ignore_extra = true;
2100+
}
2101+
} break;
20932102
case 'k':
20942103
if (optarg == NULL) {
20952104
SCLogError("no option argument (optarg) for -k");
@@ -3056,6 +3065,10 @@ void SuricataInit(void)
30563065
if (suricata.run_mode == RUNMODE_CONF_TEST)
30573066
SCLogInfo("Running suricata under test mode");
30583067

3068+
if (suricata.verbose) {
3069+
SCLogInfo("Running with verbose level %d", suricata.verbose);
3070+
}
3071+
30593072
if (ParseInterfacesList(suricata.aux_run_mode, suricata.pcap_dev) != TM_ECODE_OK) {
30603073
exit(EXIT_FAILURE);
30613074
}

0 commit comments

Comments
 (0)