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

Commit 73f635f4 authored by Ningyuan Wang's avatar Ningyuan Wang
Browse files

Remove Q-only code in DnsResolver

This CL removes code paths that only runs on Q and older, which is no
longer supported.

Test: Treehugger

Merged-In: Ia29e0b9a1b1ad2a17eaed2ab94a4f07825fcd065
Change-Id: Ia29e0b9a1b1ad2a17eaed2ab94a4f07825fcd065
parent 4c6cabbd
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -242,8 +242,7 @@ inline void resolv_tag_socket(int sock, uid_t uid, pid_t pid) {
        }
    }

    // fchown() apps' uid only in R+, since it's incompatible with Q's ebpf vpn isolation feature.
    if (fchown(sock, (android::net::gApiLevel >= 30) ? uid : AID_DNS, -1) == -1) {
    if (fchown(sock, uid, -1) == -1) {
        PLOG(WARNING) << "Failed to chown socket";
    }
}
+0 −12
Original line number Diff line number Diff line
@@ -163,25 +163,13 @@ TEST_F(CallbackTest, tagSocketCallback) {
}

TEST_F(CallbackTest, tagSocketFchown) {
    const uint64_t tmpApiLevel = gApiLevel;

    // Expect the given socket will be fchown() with given uid.
    gApiLevel = 30;  // R
    unique_fd sk(socket(AF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0));
    EXPECT_GE(sk, 3);
    resolv_tag_socket(sk, TEST_UID, -1);
    struct stat sb;
    EXPECT_EQ(fstat(sk, &sb), 0);
    EXPECT_EQ(sb.st_uid, TEST_UID);

    // Expect the given socket will be fchown() with AID_DNS.
    gApiLevel = 29;  // Q
    resolv_tag_socket(sk, TEST_UID, -1);
    EXPECT_EQ(fstat(sk, &sb), 0);
    EXPECT_EQ(sb.st_uid, static_cast<uid_t>(AID_DNS));

    // restore API level.
    gApiLevel = tmpApiLevel;
}

}  // end of namespace android::net