Logging: Remove macros and methods for Secure* logs. 83/24283/1
authorMarcin Lis <m.lis@samsung.com>
Wed, 9 Jul 2014 15:42:23 +0000 (17:42 +0200)
committerMarcin Lis <m.lis@samsung.com>
Wed, 9 Jul 2014 15:53:13 +0000 (17:53 +0200)
Secure logs, inherited from security-server are no longer needed.
Replace calls to Secure* logs with their non-secure equivalents.

This is an initial commit in logging adaptation series. It should be
verified by successful build.

Change-Id: I908851f8927c46474489a6bf5053f480d65ac22d
Signed-off-by: Marcin Lis <m.lis@samsung.com>
src/dpl/log/include/dpl/log/abstract_log_provider.h
src/dpl/log/include/dpl/log/dlog_log_provider.h
src/dpl/log/include/dpl/log/log.h
src/dpl/log/include/dpl/log/old_style_log_provider.h
src/dpl/log/src/dlog_log_provider.cpp
src/dpl/log/src/log.cpp
src/dpl/log/src/old_style_log_provider.cpp
src/server/service/installer.cpp

index a3ad299..db4e654 100644 (file)
@@ -51,22 +51,6 @@ class AbstractLogProvider
                           const char *fileName,
                           int line,
                           const char *function) = 0;
-    virtual void SecureDebug(const char *message,
-                       const char *fileName,
-                       int line,
-                       const char *function) = 0;
-    virtual void SecureInfo(const char *message,
-                      const char *fileName,
-                      int line,
-                      const char *function) = 0;
-    virtual void SecureWarning(const char *message,
-                         const char *fileName,
-                         int line,
-                         const char *function) = 0;
-    virtual void SecureError(const char *message,
-                       const char *fileName,
-                       int line,
-                       const char *function) = 0;
 
   protected:
     static const char *LocateSourceFileName(const char *filename);
index 6b19e09..b5e39fc 100644 (file)
@@ -63,22 +63,6 @@ class DLOGLogProvider :
                           const char *fileName,
                           int line,
                           const char *function);
-    virtual void SecureDebug(const char *message,
-                       const char *fileName,
-                       int line,
-                       const char *function);
-    virtual void SecureInfo(const char *message,
-                      const char *fileName,
-                      int line,
-                      const char *function);
-    virtual void SecureWarning(const char *message,
-                         const char *fileName,
-                         int line,
-                         const char *function);
-    virtual void SecureError(const char *message,
-                       const char *fileName,
-                       int line,
-                       const char *function);
 
     // Set global Tag according to DLOG
     void SetTag(const char *tag);
index 74792cc..df8e1ff 100644 (file)
@@ -91,38 +91,6 @@ class LogSystem :
                   const char *function);
 
     /**
-     * Log pedantic message with secure macro
-     */
-    void SecureDebug(const char *message,
-               const char *filename,
-               int line,
-               const char *function);
-
-    /**
-     * Log info message with secure macro
-     */
-    void SecureInfo(const char *message,
-              const char *filename,
-              int line,
-              const char *function);
-
-    /**
-     * Log warning message with secure macro
-     */
-    void SecureWarning(const char *message,
-                 const char *filename,
-                 int line,
-                 const char *function);
-
-    /**
-     * Log error message with secure macro
-     */
-    void SecureError(const char *message,
-               const char *filename,
-               int line,
-               const char *function);
-
-    /**
      * Set default's DLOG provider Tag
      */
     void SetTag(const char *tag);
@@ -189,24 +157,17 @@ do                                                                         \
 
 /* Errors must be always logged. */
 #define  LogError(message) DPL_MACRO_FOR_LOGGING(message, Error)
-#define  LogSecureError(message) DPL_MACRO_FOR_LOGGING(message, SecureError)
 
 #ifdef BUILD_TYPE_DEBUG
     #define LogDebug(message) DPL_MACRO_FOR_LOGGING(message, Debug)
     #define LogInfo(message) DPL_MACRO_FOR_LOGGING(message, Info)
     #define LogWarning(message) DPL_MACRO_FOR_LOGGING(message, Warning)
     #define LogPedantic(message) DPL_MACRO_FOR_LOGGING(message, Pedantic)
-    #define LogSecureDebug(message) DPL_MACRO_FOR_LOGGING(message, SecureDebug)
-    #define LogSecureInfo(message) DPL_MACRO_FOR_LOGGING(message, SecureInfo)
-    #define LogSecureWarning(message) DPL_MACRO_FOR_LOGGING(message, SecureWarning)
 #else
     #define LogDebug(message) DPL_MACRO_DUMMY_LOGGING(message, Debug)
     #define LogInfo(message) DPL_MACRO_DUMMY_LOGGING(message, Info)
     #define LogWarning(message) DPL_MACRO_DUMMY_LOGGING(message, Warning)
     #define LogPedantic(message) DPL_MACRO_DUMMY_LOGGING(message, Pedantic)
-    #define LogSecureDebug(message) DPL_MACRO_DUMMY_LOGGING(message, SecureDebug)
-    #define LogSecureInfo(message) DPL_MACRO_DUMMY_LOGGING(message, SecureInfo)
-    #define LogSecureWarning(message) DPL_MACRO_DUMMY_LOGGING(message, SecureWarning)
 #endif // BUILD_TYPE_DEBUG
 
 #endif // SECURITYMANAGER_LOG_H
index da1117a..9eb5dde 100644 (file)
@@ -77,22 +77,6 @@ class OldStyleLogProvider :
                           const char *fileName,
                           int line,
                           const char *function);
-    virtual void SecureDebug(const char *message,
-                       const char *fileName,
-                       int line,
-                       const char *function);
-    virtual void SecureInfo(const char *message,
-                      const char *fileName,
-                      int line,
-                      const char *function);
-    virtual void SecureWarning(const char *message,
-                         const char *fileName,
-                         int line,
-                         const char *function);
-    virtual void SecureError(const char *message,
-                       const char *fileName,
-                       int line,
-                       const char *function);
 };
 }
 } // namespace SecurityManager
index b2a59f9..79a7fd4 100644 (file)
@@ -105,41 +105,5 @@ void DLOGLogProvider::Pedantic(const char *message,
                                               function).c_str());
 }
 
-void DLOGLogProvider::SecureDebug(const char *message UNUSED,
-                            const char *filename UNUSED,
-                            int line UNUSED,
-                            const char *function UNUSED)
-{
-    SECURE_SLOG(LOG_DEBUG, m_tag.get(), "%s",
-        FormatMessage(message, filename, line, function).c_str());
-}
-
-void DLOGLogProvider::SecureInfo(const char *message UNUSED,
-                           const char *filename UNUSED,
-                           int line UNUSED,
-                           const char *function UNUSED)
-{
-    SECURE_SLOG(LOG_INFO, m_tag.get(), "%s",
-        FormatMessage(message, filename, line, function).c_str());
-}
-
-void DLOGLogProvider::SecureWarning(const char *message UNUSED,
-                              const char *filename UNUSED,
-                              int line UNUSED,
-                              const char *function UNUSED)
-{
-    SECURE_SLOG(LOG_WARN, m_tag.get(), "%s",
-        FormatMessage(message, filename, line, function).c_str());
-}
-
-void DLOGLogProvider::SecureError(const char *message UNUSED,
-                            const char *filename UNUSED,
-                            int line UNUSED,
-                            const char *function UNUSED)
-{
-    SECURE_SLOG(LOG_ERROR, m_tag.get(), "%s",
-        FormatMessage(message, filename, line, function).c_str());
-}
-
 } // nemespace Log
 } // namespace SecurityManager
index a237fdb..fd43a2f 100644 (file)
@@ -224,57 +224,5 @@ void LogSystem::Pedantic(const char *message,
     }
 }
 
-void LogSystem::SecureInfo(const char *message,
-                         const char *filename,
-                         int line,
-                         const char *function)
-{
-    for (AbstractLogProviderPtrList::iterator iterator = m_providers.begin();
-         iterator != m_providers.end();
-         ++iterator)
-    {
-        (*iterator)->SecureInfo(message, filename, line, function);
-    }
-}
-
-void LogSystem::SecureDebug(const char *message,
-                         const char *filename,
-                         int line,
-                         const char *function)
-{
-    for (AbstractLogProviderPtrList::iterator iterator = m_providers.begin();
-         iterator != m_providers.end();
-         ++iterator)
-    {
-        (*iterator)->SecureDebug(message, filename, line, function);
-    }
-}
-
-void LogSystem::SecureError(const char *message,
-                         const char *filename,
-                         int line,
-                         const char *function)
-{
-    for (AbstractLogProviderPtrList::iterator iterator = m_providers.begin();
-         iterator != m_providers.end();
-         ++iterator)
-    {
-        (*iterator)->SecureError(message, filename, line, function);
-    }
-}
-
-void LogSystem::SecureWarning(const char *message,
-                         const char *filename,
-                         int line,
-                         const char *function)
-{
-    for (AbstractLogProviderPtrList::iterator iterator = m_providers.begin();
-         iterator != m_providers.end();
-         ++iterator)
-    {
-        (*iterator)->SecureWarning(message, filename, line, function);
-    }
-}
-
 }
 } // namespace SecurityManager
index 0317862..d302131 100644 (file)
@@ -198,105 +198,5 @@ void OldStyleLogProvider::Pedantic(const char *message,
     }
 }
 
-void OldStyleLogProvider::SecureDebug(const char *message,
-                                const char *filename,
-                                int line,
-                                const char *function)
-{
-#ifdef _SECURE_LOG
-    if (m_showDebug) {
-        if (m_printStdErr) {
-            fprintf(stderr, "%s%s%s\n", DEBUG_BEGIN,
-                    FormatMessage(message, filename, line,
-                        function).c_str(), DEBUG_END);
-        } else {
-            fprintf(stdout, "%s%s%s\n", DEBUG_BEGIN,
-                    FormatMessage(message, filename, line,
-                        function).c_str(), DEBUG_END);
-        }
-    }
-#else
-    (void)message;
-    (void)filename;
-    (void)line;
-    (void)function;
-#endif
-}
-
-void OldStyleLogProvider::SecureInfo(const char *message,
-                               const char *filename,
-                               int line,
-                               const char *function)
-{
-#ifdef _SECURE_LOG
-    if (m_showInfo) {
-        if (m_printStdErr) {
-            fprintf(stderr, "%s%s%s\n", INFO_BEGIN,
-                    FormatMessage(message, filename, line,
-                        function).c_str(), INFO_END);
-        } else {
-            fprintf(stdout, "%s%s%s\n", INFO_BEGIN,
-                    FormatMessage(message, filename, line,
-                        function).c_str(), INFO_END);
-        }
-    }
-#else
-    (void)message;
-    (void)filename;
-    (void)line;
-    (void)function;
-#endif
-}
-
-void OldStyleLogProvider::SecureWarning(const char *message,
-                                  const char *filename,
-                                  int line,
-                                  const char *function)
-{
-#ifdef _SECURE_LOG
-    if (m_showWarning) {
-        if (m_printStdErr) {
-            fprintf(stderr, "%s%s%s\n", WARNING_BEGIN,
-                    FormatMessage(message, filename, line,
-                        function).c_str(), WARNING_END);
-        } else {
-            fprintf(stdout, "%s%s%s\n", WARNING_BEGIN,
-                    FormatMessage(message, filename, line,
-                        function).c_str(), WARNING_END);
-        }
-    }
-#else
-    (void)message;
-    (void)filename;
-    (void)line;
-    (void)function;
-#endif
-}
-
-void OldStyleLogProvider::SecureError(const char *message,
-                                const char *filename,
-                                int line,
-                                const char *function)
-{
-#ifdef _SECURE_LOG
-    if (m_showError) {
-        if (m_printStdErr) {
-            fprintf(stderr, "%s%s%s\n", ERROR_BEGIN,
-                    FormatMessage(message, filename, line,
-                        function).c_str(), ERROR_END);
-        } else {
-            fprintf(stdout, "%s%s%s\n", ERROR_BEGIN,
-                    FormatMessage(message, filename, line,
-                        function).c_str(), ERROR_END);
-        }
-    }
-#else
-    (void)message;
-    (void)filename;
-    (void)line;
-    (void)function;
-#endif
-}
-
 }
 } // namespace SecurityManager
index 0481961..fc993e0 100644 (file)
@@ -68,14 +68,14 @@ typedef std::function<FileDecision(const FTSENT*)> LabelDecisionFn;
 
 FileDecision labelAll(const FTSENT *ftsent __attribute__((unused)))
 {
-    LogSecureDebug("Entering function: " << __func__);
+    LogDebug("Entering function: " << __func__);
 
     return FileDecision::LABEL;
 }
 
 FileDecision labelDirs(const FTSENT *ftsent)
 {
-    LogSecureDebug("Entering function: " << __func__);
+    LogDebug("Entering function: " << __func__);
 
     // label only directories
     if (S_ISDIR(ftsent->fts_statp->st_mode))
@@ -85,7 +85,7 @@ FileDecision labelDirs(const FTSENT *ftsent)
 
 FileDecision labelExecs(const FTSENT *ftsent)
 {
-    LogSecureDebug("Entering function: " << __func__);
+    LogDebug("Entering function: " << __func__);
 
     LogDebug("Mode = " << ftsent->fts_statp->st_mode);
     // label only regular executable files
@@ -97,7 +97,7 @@ FileDecision labelExecs(const FTSENT *ftsent)
 
 FileDecision labelLinksToExecs(const FTSENT *ftsent)
 {
-    LogSecureDebug("Entering function: " << __func__);
+    LogDebug("Entering function: " << __func__);
 
     struct stat buf;
 
@@ -108,17 +108,17 @@ FileDecision labelLinksToExecs(const FTSENT *ftsent)
     std::unique_ptr<char, std::function<void(void*)>> target(realpath(ftsent->fts_path, NULL), free);
 
     if (!target.get()) {
-        LogSecureError("Getting link target for " << ftsent->fts_path << " failed (Error = " << strerror(errno) << ")");
+        LogError("Getting link target for " << ftsent->fts_path << " failed (Error = " << strerror(errno) << ")");
         return FileDecision::ERROR;
     }
 
     if (-1 == stat(target.get(), &buf)) {
-        LogSecureError("stat failed for " << target.get() << " (Error = " << strerror(errno) << ")");
+        LogError("stat failed for " << target.get() << " (Error = " << strerror(errno) << ")");
         return FileDecision::ERROR;
     }
     // skip if link target is not a regular executable file
     if (buf.st_mode != (buf.st_mode | S_IXUSR | S_IFREG)) {
-        LogSecureDebug(target.get() << "is not a regular executable file. Skipping.");
+        LogDebug(target.get() << "is not a regular executable file. Skipping.");
         return FileDecision::SKIP;
     }
 
@@ -128,7 +128,7 @@ FileDecision labelLinksToExecs(const FTSENT *ftsent)
 bool dirSetSmack(const std::string &path, const std::string &label,
         const char *xattr_name, LabelDecisionFn fn)
 {
-    LogSecureDebug("Entering function: "<< __func__ <<". Params:"
+    LogDebug("Entering function: "<< __func__ <<". Params:"
             " path=" << path << ", label=" << label << ", xattr=" << xattr_name);
 
 
@@ -179,7 +179,7 @@ bool dirSetSmack(const std::string &path, const std::string &label,
 bool labelDir(const std::string &path, const std::string &label,
         bool set_transmutable, bool set_executables)
 {
-    LogSecureDebug("Entering function: "<< __func__ <<". Params:"
+    LogDebug("Entering function: "<< __func__ <<". Params:"
             " path=" << path << " label= " << label
             << " set_transmutable= " << set_transmutable
             << " set_executables= " << set_executables);