Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2eddc40f authored by Steve Fung's avatar Steve Fung Committed by Android Git Automerger
Browse files

am ba2c73c1: am 331cc9a8: am 557aa2e9: Merge "crash_reporter: Generate and use own guid"

* commit 'ba2c73c1':
  crash_reporter: Generate and use own guid
parents de26a3b0 ba2c73c1
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@
#include <vector>

#include <base/files/file_util.h>
#include <base/guid.h>
#include <base/logging.h>
#include <base/strings/string_split.h>
#include <base/strings/string_util.h>
@@ -41,6 +42,7 @@ static const char kUserCrashSignal[] =
static const char kKernelCrashDetected[] = "/var/run/kernel-crash-detected";
static const char kUncleanShutdownDetected[] =
    "/var/run/unclean-shutdown-detected";
static const char kGUIDFileName[] = "/data/misc/crash_reporter/guid";

// Enumeration of kinds of crashes to be used in the CrashCounter histogram.
enum CrashKinds {
@@ -122,6 +124,21 @@ static int Initialize(KernelCollector *kernel_collector,
                      const bool clean_shutdown) {
  CHECK(!clean_shutdown) << "Incompatible options";

  // Try to read the GUID from kGUIDFileName.  If the file doesn't exist, is
  // blank, or the read fails, generate a new GUID and write it to the file.
  std::string guid;
  base::FilePath filepath(kGUIDFileName);
  if (!base::ReadFileToString(filepath, &guid) || guid.empty()) {
    guid = base::GenerateGUID();
    // If we can't read or write the file, log an error.  However it is not
    // a fatal error, as the crash server will assign a random GUID based
    // on a hash of the IP address if one is not provided in the report.
    if (base::WriteFile(filepath, guid.c_str(), guid.size()) <= 0) {
      LOG(ERROR) << "Could not write guid " << guid << " to file "
                 << filepath.value();
    }
  }

  bool was_kernel_crash = false;
  bool was_unclean_shutdown = false;
  kernel_collector->Enable();
+3 −4
Original line number Diff line number Diff line
@@ -22,9 +22,8 @@ BRILLO_PRODUCT=Brillo
# Base directory that contains any crash reporter state files.
CRASH_STATE_DIR="/data/misc/crash_reporter"

# File whose existence implies crash reports may be sent, and whose
# contents includes our machine's anonymized guid.
CONSENT_ID="/data/misc/metrics/enabled"
# File containing crash_reporter's anonymized guid.
GUID_FILE="${CRASH_STATE_DIR}/guid"

# Crash sender lock in case the sender is already running.
CRASH_SENDER_LOCK="${CRASH_STATE_DIR}/lock/crash_sender"
@@ -393,7 +392,7 @@ send_crash() {

  # Need to strip dashes ourselves as Chrome preserves it in the file
  # nowadays.  This is also what the Chrome breakpad client does.
  guid=$(tr -d '-' < "${CONSENT_ID}")
  guid=$(tr -d '-' < "${GUID_FILE}")

  local error_type="$(get_key_value "${meta_path}" "error_type")"
  [ "${error_type}" = "undefined" ] && error_type=