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

Commit b440e50b authored by Steve Fung's avatar Steve Fung
Browse files

crash_reporter: Run with supplemental groups

In order to use metrics_lib, crash_reporter needs to be run with
system group permissions.  To use dbus, it needs dbus group
permissions.

Bug: 23406290
Change-Id: Ic679a057afa46aaadd59429aab0aea072c1973c5
parent e13fd9aa
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@
#include <stdint.h>
#include <sys/cdefs.h>  // For __WORDSIZE
#include <sys/types.h>  // For getpwuid_r, getgrnam_r, WEXITSTATUS.
#include <unistd.h>  // For setgroups

#include <string>
#include <vector>
@@ -37,6 +38,7 @@
#include <chromeos/process.h>
#include <chromeos/syslog_logging.h>
#include <cutils/properties.h>
#include <private/android_filesystem_config.h>

static const char kCollectionErrorSignature[] =
    "crash_reporter-user-collection";
@@ -77,6 +79,11 @@ void UserCollector::Initialize(
  core2md_failure_ = core2md_failure;
  directory_failure_ = directory_failure;
  filter_in_ = filter_in;

  gid_t groups[] = { AID_SYSTEM, AID_DBUS };
  if (setgroups(arraysize(groups), groups) != 0) {
    PLOG(FATAL) << "Unable to set groups to system and dbus";
  }
}

UserCollector::~UserCollector() {