]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
log/file: use default-log-dir for suricata.log 3777/head
authorVictor Julien <victor@inliniac.net>
Fri, 5 Apr 2019 11:53:59 +0000 (13:53 +0200)
committerVictor Julien <victor@inliniac.net>
Fri, 5 Apr 2019 13:13:43 +0000 (15:13 +0200)
Default to just suricata.log instead of the full path, so that
in user mode we can log in the user mode location.

src/util-debug.c
src/util-debug.h
suricata.yaml.in

index e4f303711a3deb450b6b3aa3de5af787902d0552..678b0e00504742f49b96af6cf8574c8eaf08e413 100644 (file)
@@ -1397,8 +1397,17 @@ void SCLogLoadConfig(int daemon, int verbose)
                     "Logging to file requires a filename");
                 exit(EXIT_FAILURE);
             }
+            char *path = NULL;
+            if (!(PathIsAbsolute(filename))) {
+                path = SCLogGetLogFilename(filename);
+            } else {
+                path = SCStrdup(filename);
+            }
+            if (path == NULL)
+                FatalError(SC_ERR_FATAL, "failed to setup output to file");
             have_logging = 1;
-            op_iface_ctx = SCLogInitFileOPIface(filename, format, level, type);
+            op_iface_ctx = SCLogInitFileOPIface(path, format, level, type);
+            SCFree(path);
         }
         else if (strcmp(output->name, "syslog") == 0) {
             int facility = SC_LOG_DEF_SYSLOG_FACILITY;
@@ -1454,16 +1463,11 @@ void SCLogLoadConfig(int daemon, int verbose)
  */
 static char *SCLogGetLogFilename(const char *filearg)
 {
-    const char *log_dir;
-    char *log_filename;
-
-    log_dir = ConfigGetLogDirectory();
-
-    log_filename = SCMalloc(PATH_MAX);
+    const char *log_dir = ConfigGetLogDirectory();
+    char *log_filename = SCMalloc(PATH_MAX);
     if (unlikely(log_filename == NULL))
         return NULL;
     snprintf(log_filename, PATH_MAX, "%s/%s", log_dir, filearg);
-
     return log_filename;
 }
 
index 85b40bcb25497f6acb37a96ddc9e440eeb55e6ad..b3fdd501610178ce54dc2a5a9e9b18d3ed282081 100644 (file)
@@ -99,7 +99,7 @@ typedef enum {
 #define SC_LOG_DEF_LOG_OP_IFACE SC_LOG_OP_IFACE_CONSOLE
 
 /* The default log file to be used */
-#define SC_LOG_DEF_LOG_FILE "sc_ids_log.log"
+#define SC_LOG_DEF_LOG_FILE "suricata.log"
 
 /* The default syslog facility to be used */
 #define SC_LOG_DEF_SYSLOG_FACILITY_STR "local0"
index e7732fc263a4a9b1683cc0fece0271a1aeb5bec8..1a582522300896893b0a181878d707feb9db06a7 100644 (file)
@@ -596,7 +596,7 @@ logging:
   - file:
       enabled: yes
       level: info
-      filename: @e_logdir@suricata.log
+      filename: suricata.log
       # type: json
   - syslog:
       enabled: no