/* if the unix command socket is enabled we do the background
* stats sync just in case someone runs 'dump-counters' */
- int unix_socket = 0;
- if (ConfGetBool("unix-command.enabled", &unix_socket) != 1)
- unix_socket = 0;
- if (unix_socket == 0) {
+ if (!ConfUnixSocketIsEnable()) {
SCLogWarning(SC_WARN_NO_STATS_LOGGERS, "stats are enabled but no loggers are active");
stats_enabled = FALSE;
SCReturn;
enum DetectEngineTenantSelectors tenant_selector = TENANT_SELECTOR_UNKNOWN;
DetectEngineMasterCtx *master = &g_master_de_ctx;
- int unix_socket = 0;
- (void)ConfGetBool("unix-command.enabled", &unix_socket);
+ int unix_socket = ConfUnixSocketIsEnable();
int failure_fatal = 0;
(void)ConfGetBool("engine.init-failure-fatal", &failure_fatal);
/* In Unix socket runmode, Flow manager is started on demand */
if (suri.run_mode != RUNMODE_UNIX_SOCKET) {
/* Spawn the unix socket manager thread */
- int unix_socket = 0;
- if (ConfGetBool("unix-command.enabled", &unix_socket) != 1)
- unix_socket = 0;
+ int unix_socket = ConfUnixSocketIsEnable();
if (unix_socket == 1) {
UnixManagerThreadSpawn(0);
#ifdef BUILD_UNIX_SOCKET
return NULL;
}
+
+int ConfUnixSocketIsEnable(void)
+{
+ char *value;
+
+ if (ConfGet("unix-command.enabled", &value) != 1) {
+ return 0;
+ }
+
+ if (!strcmp(value, "auto")) {
+#ifdef HAVE_LIBJANSSON
+#ifdef OS_WIN32
+ return 0;
+#else
+ if (TimeModeIsLive()) {
+ SCLogInfo("Running in live mode, activating unix socket");
+ return 1;
+ } else {
+ return 0;
+ }
+#endif
+#else
+ return 0;
+#endif
+ }
+
+ return ConfValIsTrue(value);
+}
ConfNode *ConfFindDeviceConfig(ConfNode *node, const char *iface);
+int ConfUnixSocketIsEnable(void);
+
#endif /* __UTIL_UTIL_CONF_H__ */
# Unix command socket can be used to pass commands to suricata.
# An external tool can then connect to get information from suricata
# or trigger some modifications of the engine. Set enabled to yes
-# to activate the feature. You can use the filename variable to set
+# to activate the feature. In auto mode, the feature will only be
+# activated in live capture mode. You can use the filename variable to set
# the file name of the socket.
unix-command:
- enabled: no
+ enabled: auto
#filename: custom.socket
# Magic file. The extension .mgc is added to the value here.