Skip to content

Commit

Permalink
logs: Send cryptohome_account_id to debugd in logs request
Browse files Browse the repository at this point in the history
In this change we will send cryptohome_account_id to debugd in
GetBigFeedbackLogs api so debugd can return the backed up log if it is
present

BUG=b:149874690
TEST=backup arc bug report, disable arc, send feedback, verify in listnr

Change-Id: Ia3ec438a5320405f9b10336080b70a63e3b1f374
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2148124
Commit-Queue: Muhammad Hasan Khan <mhasank@chromium.org>
Auto-Submit: Muhammad Hasan Khan <mhasank@chromium.org>
Reviewed-by: Alexander Alekseev <alemate@chromium.org>
Reviewed-by: Ryo Hashimoto <hashimoto@chromium.org>
Reviewed-by: Jeffrey Kardatzke <jkardatzke@google.com>
Reviewed-by: J Kardatzke <jkardatzke@chromium.org>
Reviewed-by: Ahmed Fakhry <afakhry@chromium.org>
Cr-Commit-Position: refs/heads/master@{#763016}
  • Loading branch information
mhasank authored and Commit Bot committed Apr 27, 2020
1 parent 4defe64 commit 5c7eabc
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 6 deletions.
10 changes: 8 additions & 2 deletions chrome/browser/chromeos/system_logs/debug_daemon_log_source.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "base/task/thread_pool.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/common/chrome_switches.h"
#include "chromeos/cryptohome/cryptohome_parameters.h"
#include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/dbus/debug_daemon/debug_daemon_client.h"
#include "components/user_manager/user.h"
Expand Down Expand Up @@ -167,8 +168,13 @@ void DebugDaemonLogSource::Fetch(SysLogsSourceCallback callback) {
++num_pending_requests_;

if (scrub_) {
client->GetScrubbedBigLogs(base::BindOnce(&DebugDaemonLogSource::OnGetLogs,
weak_ptr_factory_.GetWeakPtr()));
const user_manager::User* user =
user_manager::UserManager::Get()->GetActiveUser();
client->GetScrubbedBigLogs(
cryptohome::CreateAccountIdentifierFromAccountId(
user ? user->GetAccountId() : EmptyAccountId()),
base::BindOnce(&DebugDaemonLogSource::OnGetLogs,
weak_ptr_factory_.GetWeakPtr()));
} else {
client->GetAllLogs(base::BindOnce(&DebugDaemonLogSource::OnGetLogs,
weak_ptr_factory_.GetWeakPtr()));
Expand Down
2 changes: 2 additions & 0 deletions chromeos/dbus/debug_daemon/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ component("debug_daemon") {
deps = [
"//base",
"//chromeos/dbus:common",
"//chromeos/dbus/cryptohome",
"//chromeos/dbus/cryptohome:cryptohome_proto",
"//dbus",
]

Expand Down
6 changes: 5 additions & 1 deletion chromeos/dbus/debug_daemon/debug_daemon_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
#include "base/task/thread_pool.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/trace_event/trace_config.h"
#include "chromeos/dbus/cryptohome/cryptohome_client.h"
#include "chromeos/dbus/cryptohome/rpc.pb.h"
#include "chromeos/dbus/pipe_reader.h"
#include "dbus/bus.h"
#include "dbus/message.h"
Expand Down Expand Up @@ -232,7 +234,8 @@ class DebugDaemonClientImpl : public DebugDaemonClient {
weak_ptr_factory_.GetWeakPtr(), std::move(callback)));
}

void GetScrubbedBigLogs(GetLogsCallback callback) override {
void GetScrubbedBigLogs(const cryptohome::AccountIdentifier& id,
GetLogsCallback callback) override {
// The PipeReaderWrapper is a self-deleting object; we don't have to worry
// about ownership or lifetime. We need to create a new one for each Big
// Logs requests in order to queue these requests. One request can take a
Expand All @@ -245,6 +248,7 @@ class DebugDaemonClientImpl : public DebugDaemonClient {
debugd::kGetBigFeedbackLogs);
dbus::MessageWriter writer(&method_call);
writer.AppendFileDescriptor(pipe_write_end.get());
writer.AppendString(id.account_id());

DVLOG(1) << "Requesting big feedback logs";
debugdaemon_proxy_->CallMethod(
Expand Down
8 changes: 7 additions & 1 deletion chromeos/dbus/debug_daemon/debug_daemon_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
#include "chromeos/dbus/dbus_method_call_status.h"
#include "third_party/cros_system_api/dbus/service_constants.h"

namespace cryptohome {
class AccountIdentifier;
}
namespace chromeos {

// A DbusLibraryError represents an error response received from D-Bus.
Expand Down Expand Up @@ -97,7 +100,10 @@ class COMPONENT_EXPORT(DEBUG_DAEMON) DebugDaemonClient
// Gets the scrubbed logs from debugd that are very large and cannot be
// returned directly from D-Bus. These logs will include ARC and cheets
// system information.
virtual void GetScrubbedBigLogs(GetLogsCallback callback) = 0;
// |id|: Cryptohome Account identifier for the user to get
// logs for.
virtual void GetScrubbedBigLogs(const cryptohome::AccountIdentifier& id,
GetLogsCallback callback) = 0;

// Gets all logs collected by debugd.
virtual void GetAllLogs(GetLogsCallback callback) = 0;
Expand Down
4 changes: 3 additions & 1 deletion chromeos/dbus/debug_daemon/fake_debug_daemon_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,9 @@ void FakeDebugDaemonClient::GetPerfOutput(
void FakeDebugDaemonClient::StopPerf(uint64_t session_id,
VoidDBusMethodCallback callback) {}

void FakeDebugDaemonClient::GetScrubbedBigLogs(GetLogsCallback callback) {
void FakeDebugDaemonClient::GetScrubbedBigLogs(
const cryptohome::AccountIdentifier& id,
GetLogsCallback callback) {
std::map<std::string, std::string> sample;
sample["Sample Scrubbed Big Log"] = "Your email address is xxxxxxxx";
base::ThreadTaskRunnerHandle::Get()->PostTask(
Expand Down
3 changes: 2 additions & 1 deletion chromeos/dbus/debug_daemon/fake_debug_daemon_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ class COMPONENT_EXPORT(DEBUG_DAEMON) FakeDebugDaemonClient
int file_descriptor,
DBusMethodCallback<uint64_t> callback) override;
void StopPerf(uint64_t session_id, VoidDBusMethodCallback callback) override;
void GetScrubbedBigLogs(GetLogsCallback callback) override;
void GetScrubbedBigLogs(const cryptohome::AccountIdentifier& id,
GetLogsCallback callback) override;
void GetAllLogs(GetLogsCallback callback) override;
void GetLog(const std::string& log_name,
DBusMethodCallback<std::string> callback) override;
Expand Down

0 comments on commit 5c7eabc

Please sign in to comment.