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

Commit 26c4157a authored by Felipe Leme's avatar Felipe Leme
Browse files

Fixed RunCommandDropRoot when running as Shell.

BUG: 26379932
BUG: 31807540

Test: mmm -j32 frameworks/native/cmds/dumpstate/ && adb push ${ANDROID_PRODUCT_OUT}/data/nativetest/dumpstate_test* /data/nativetest&& adb unroot && adb shell /data/nativetest/dumpstate_test/dumpstate_test

Change-Id: Id582f5fbd4d6282a2eacce602ae1a6d1f62d5c61
parent d80e6b61
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -306,7 +306,7 @@ TEST_F(DumpstateTest, RunCommandDropRoot) {
    EXPECT_EQ(0, RunCommand("", {simpleCommand, "--uid"},
                            CommandOptions::WithTimeout(1).DropRoot().Build()));
    EXPECT_THAT(out, StrEq("2000\nstdout\n"));
    EXPECT_THAT(err, StrEq("stderr\n"));
    EXPECT_THAT(err, StrEq("drop_root_user(): already running as Shell\nstderr\n"));
}

TEST_F(DumpstateTest, RunCommandAsRootUserBuild) {
+1 −1
Original line number Diff line number Diff line
@@ -925,7 +925,7 @@ void Dumpstate::RunDumpsys(const std::string& title, const std::vector<std::stri

bool drop_root_user() {
    if (getgid() == AID_SHELL && getuid() == AID_SHELL) {
        MYLOGD("drop_root_user(): already running as Shell");
        MYLOGD("drop_root_user(): already running as Shell\n");
        return true;
    }
    /* ensure we will keep capabilities when we drop root */