ret = security_server_check_privilege_by_pid(cr.pid, object, access_rights);
- SECURE_LOGD("security_server_check_privilege_by_pid returned %d", ret);
+ LogSecureDebug("security_server_check_privilege_by_pid returned " << ret);
exit:
//Getting path for logs
//If this is only for logs, do we want to log it as error?
LogError("Failed to read executable path for process " << cr.pid);
if (ret == SECURITY_SERVER_API_SUCCESS)
- SECURE_LOGD("SS_SMACK: caller_pid=%d, subject=%s, object=%s, access=%s, result=%d, caller_path=%s",
- cr.pid, subject_p.get() ? subject_p.get() : "NULL", object, access_rights, ret, path.c_str());
+ LogSecureDebug("SS_SMACK: caller_pid=" << cr.pid << ", subject=" <<
+ (subject_p.get() ? subject_p.get() : "NULL") << ", object=" <<
+ object << ", access=" << access_rights << ", result=" <<
+ ret << ", caller_path=" << path.c_str());
else
- SECURE_LOGW("SS_SMACK: caller_pid=%d, subject=%s, object=%s, access=%s, result=%d, caller_path=%s",
- cr.pid, subject_p.get() ? subject_p.get() : "NULL", object, access_rights, ret, path.c_str());
+ LogSecureWarning("SS_SMACK: caller_pid=" << cr.pid << ", subject=" <<
+ (subject_p.get() ? subject_p.get() : "NULL") << ", object=" <<
+ object << ", access=" << access_rights << ", result=" <<
+ ret << ", caller_path=" << path.c_str());
return ret;
}
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);
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);
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);
#define LogWarning(message) DPL_MACRO_FOR_LOGGING(message, Warning)
#define LogError(message) DPL_MACRO_FOR_LOGGING(message, Error)
#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)
+#define LogSecureError(message) DPL_MACRO_FOR_LOGGING(message, SecureError)
#endif // SECURITYSERVER_LOG_H
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 SecurityServer
line,
function).c_str());
}
+
+void DLOGLogProvider::SecureDebug(const char *message,
+ const char *filename,
+ int line,
+ const char *function)
+{
+ SECURE_SLOG(LOG_DEBUG, m_tag.get(), "%s",
+ FormatMessage(message, filename, line, function).c_str());
+}
+
+void DLOGLogProvider::SecureInfo(const char *message,
+ const char *filename,
+ int line,
+ const char *function)
+{
+ SECURE_SLOG(LOG_INFO, m_tag.get(), "%s",
+ FormatMessage(message, filename, line, function).c_str());
+}
+
+void DLOGLogProvider::SecureWarning(const char *message,
+ const char *filename,
+ int line,
+ const char *function)
+{
+ SECURE_SLOG(LOG_WARN, m_tag.get(), "%s",
+ FormatMessage(message, filename, line, function).c_str());
+}
+
+void DLOGLogProvider::SecureError(const char *message,
+ const char *filename,
+ int line,
+ const char *function)
+{
+ SECURE_SLOG(LOG_ERROR, m_tag.get(), "%s",
+ FormatMessage(message, filename, line, function).c_str());
+}
+
}
} // namespace SecurityServer
const char *OLD_STYLE_PEDANTIC_LOGS_ENV_NAME =
"DPL_USE_OLD_STYLE_PEDANTIC_LOGS";
const char *OLD_STYLE_LOGS_MASK_ENV_NAME = "DPL_USE_OLD_STYLE_LOGS_MASK";
-const char *SecurityServer_LOG_OFF = "DPL_LOG_OFF";
+const char *SECURITY_SERVER_LOG_OFF = "DPL_LOG_OFF";
} // namespace anonymous
bool LogSystem::IsLoggingEnabled() const
LogSystem::LogSystem() :
m_dlogProvider(NULL),
m_oldStyleProvider(NULL),
- m_isLoggingEnabled(!getenv(SecurityServer_LOG_OFF))
+ m_isLoggingEnabled(!getenv(SECURITY_SERVER_LOG_OFF))
{
bool oldStyleLogs = false;
bool oldStyleDebugLogs = true;
(*iterator)->Pedantic(message, filename, line, function);
}
}
+
+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 SecurityServer
#include <sstream>
#include <sys/time.h>
#include <unistd.h>
+#include <dlog.h>
namespace SecurityServer {
namespace Log {
}
}
}
+
+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 SecurityServer