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

Commit edc23801 authored by Christopher Ferris's avatar Christopher Ferris
Browse files

Set groups before dropping privileges.

The code for dumping tombstones tries to read the log data. This was
silently failing after the change to drop root privileges. Fix this
by explicitly setting the groups allowed before dropping privileges.

Bug: 28590884
Change-Id: Iaccb1d2928268fc9fc855f6e3814c31ce019badf
parent a7431cfa
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -513,13 +513,21 @@ static bool perform_dump(const debugger_request_t& request, int fd, int tombston
}

static bool drop_privileges() {
  // AID_LOG: for reading the logs data associated with the crashing process.
  // AID_READPROC: for reading /proc/<PID>/{comm,cmdline}.
  gid_t groups[] = { AID_DEBUGGERD, AID_LOG, AID_READPROC };
  if (setgroups(sizeof(groups)/sizeof(groups[0]), groups) != 0) {
    ALOGE("debuggerd: failed to setgroups: %s", strerror(errno));
    return false;
  }

  if (setresgid(AID_DEBUGGERD, AID_DEBUGGERD, AID_DEBUGGERD) != 0) {
    ALOGE("debuggerd: failed to setresgid");
    ALOGE("debuggerd: failed to setresgid: %s", strerror(errno));
    return false;
  }

  if (setresuid(AID_DEBUGGERD, AID_DEBUGGERD, AID_DEBUGGERD) != 0) {
    ALOGE("debuggerd: failed to setresuid");
    ALOGE("debuggerd: failed to setresuid: %s", strerror(errno));
    return false;
  }