Commit 3b8b6d50 authored by Yann Dago's avatar Yann Dago Committed by Commit Bot

Add user SID in SYSLOG header

Bug: 980124
Change-Id: I7d290370e6cfb8f336dab7c39753a5c369c16eec
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1690706
Commit-Queue: Yann Dago <ydago@chromium.org>
Reviewed-by: default avatarGabriel Charette <gab@chromium.org>
Reviewed-by: default avatarRobert Liao <robliao@chromium.org>
Cr-Commit-Position: refs/heads/master@{#677050}
parent 0bdcb257
...@@ -6,9 +6,11 @@ ...@@ -6,9 +6,11 @@
#if defined(OS_WIN) #if defined(OS_WIN)
#include <windows.h> #include <windows.h>
#include <sddl.h>
#include "base/bind.h" #include "base/bind.h"
#include "base/callback_helpers.h" #include "base/callback_helpers.h"
#include "base/debug/stack_trace.h" #include "base/debug/stack_trace.h"
#include "base/win/win_util.h"
#elif defined(OS_LINUX) #elif defined(OS_LINUX)
// <syslog.h> defines LOG_INFO, LOG_WARNING macros that could conflict with // <syslog.h> defines LOG_INFO, LOG_WARNING macros that could conflict with
// base::LOG_INFO, base::LOG_WARNING. // base::LOG_INFO, base::LOG_WARNING.
...@@ -29,6 +31,7 @@ namespace { ...@@ -29,6 +31,7 @@ namespace {
std::string* g_event_source_name = nullptr; std::string* g_event_source_name = nullptr;
uint16_t g_category = 0; uint16_t g_category = 0;
uint32_t g_event_id = 0; uint32_t g_event_id = 0;
base::string16* g_user_sid = nullptr;
} // namespace } // namespace
...@@ -39,11 +42,16 @@ void SetEventSource(const std::string& name, ...@@ -39,11 +42,16 @@ void SetEventSource(const std::string& name,
g_event_source_name = new std::string(name); g_event_source_name = new std::string(name);
g_category = category; g_category = category;
g_event_id = event_id; g_event_id = event_id;
DCHECK_EQ(nullptr, g_user_sid);
g_user_sid = new base::string16();
base::win::GetUserSidString(g_user_sid);
} }
void ResetEventSourceForTesting() { void ResetEventSourceForTesting() {
delete g_event_source_name; delete g_event_source_name;
g_event_source_name = nullptr; g_event_source_name = nullptr;
delete g_user_sid;
g_user_sid = nullptr;
} }
#endif // defined(OS_WIN) #endif // defined(OS_WIN)
...@@ -90,10 +98,18 @@ EventLogMessage::~EventLogMessage() { ...@@ -90,10 +98,18 @@ EventLogMessage::~EventLogMessage() {
break; break;
} }
LPCSTR strings[1] = {message.data()}; LPCSTR strings[1] = {message.data()};
if (!ReportEventA(event_log_handle, log_type, g_category, g_event_id, nullptr, PSID user_sid = nullptr;
1, 0, strings, nullptr)) { if (!::ConvertStringSidToSid(g_user_sid->c_str(), &user_sid)) {
stream() << " !!ERROR GETTING USER SID!!";
}
if (!ReportEventA(event_log_handle, log_type, g_category, g_event_id,
user_sid, 1, 0, strings, nullptr)) {
stream() << " !!NOT ADDED TO EVENTLOG!!"; stream() << " !!NOT ADDED TO EVENTLOG!!";
} }
if (user_sid != nullptr)
::LocalFree(user_sid);
#elif defined(OS_LINUX) #elif defined(OS_LINUX)
const char kEventSource[] = "chrome"; const char kEventSource[] = "chrome";
openlog(kEventSource, LOG_NOWAIT | LOG_PID, LOG_USER); openlog(kEventSource, LOG_NOWAIT | LOG_PID, LOG_USER);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment