libdlog: add `enable_secure_logs` config entry 21/232321/2
authorMichal Bloch <m.bloch@samsung.com>
Thu, 30 Apr 2020 16:23:24 +0000 (18:23 +0200)
committerHyotaek Shim <hyotaek.shim@samsung.com>
Mon, 4 May 2020 07:43:05 +0000 (07:43 +0000)
If it is set to 0, __dlog_sec_print will just
return 0. Defaults to 1.

Change-Id: Ie3a00c5aa25bd4035444ae27383d649acf0e1d23
Signed-off-by: Michal Bloch <m.bloch@samsung.com>
configs/dlog.conf
src/libdlog/log.c

index f50a6fd..b150cfc 100644 (file)
@@ -30,6 +30,11 @@ limiter_apply_to_all_buffers=1
 # dynamic config_path - specifies the path to a DIRECTORY to enable dynamic runtime config changes (use dlogctl for control)
 dynamic_config_path=/run/dlog/filters.d/
 
+# Whether secure printing is enabled.
+# If this setting is set to 0, secure logs
+# are dropped and don't go into the buffer.
+enable_secure_logs=1
+
 ##### Settings used by the logging daemon
 # See also 20-pipe.conf for more info
 
index b43bd7a..c6d4606 100644 (file)
@@ -63,6 +63,7 @@ bool limiter;
 static bool dynamic_config;
 static bool plog[LOG_ID_MAX];
 static bool plog_default_values[LOG_ID_MAX];
+static bool enable_secure_logs = true;
 
 static int debugmode;
 static int fatal_assert;
@@ -121,6 +122,7 @@ static void __configure_parameters(struct log_config *config)
        __update_plog(config);
        __set_plog_default_values();
 
+       enable_secure_logs = log_config_get_boolean(config, "enable_secure_logs", enable_secure_logs);
        debugmode = log_config_get_int(config, "debugmode", DEFAULT_CONFIG_DEBUGMODE);
        fatal_assert = access(DEBUGMODE_FILE, F_OK) != -1;
        limiter = log_config_get_boolean(config, "limiter", DEFAULT_CONFIG_LIMITER);
@@ -578,6 +580,9 @@ int __dlog_print(log_id_t log_id, int prio, const char *tag, const char *fmt, ..
  */
 int __dlog_sec_print(log_id_t log_id, int prio, const char *tag, const char *fmt, ...)
 {
+       if (!enable_secure_logs)
+               return 0;
+
        va_list ap;
 
        va_start(ap, fmt);