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

Commit 027f6d41 authored by Mike Yu's avatar Mike Yu Committed by Automerger Merge Worker
Browse files

Rename field forTesting as requireRootPermission in DohProviderEntry am: 3bafc794 am: 5b1ff3d2

Original change: https://android-review.googlesource.com/c/platform/packages/modules/DnsResolver/+/1892099

Change-Id: Ice594b3d27b1c22e4fb2f3b1a440f7aaa8d8e6f2
parents 6247031f 5b1ff3d2
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -461,8 +461,9 @@ int PrivateDnsConfiguration::setDoh(int32_t netId, uint32_t mark,
        const auto& doh = entry.getDohIdentity(sortedServers, name);
        if (!doh.ok()) continue;

        // The internal tests are supposed to have root permission.
        if (entry.forTesting && AIBinder_getCallingUid() != AID_ROOT) continue;
        // Since the DnsResolver is expected to be configured by the system server, add the
        // restriction to prevent ResolverTestProvider from being used other than testing.
        if (entry.requireRootPermission && AIBinder_getCallingUid() != AID_ROOT) continue;

        auto it = mDohTracker.find(netId);
        // Skip if the same server already exists and its status == success.
+3 −1
Original line number Diff line number Diff line
@@ -207,7 +207,7 @@ class PrivateDnsConfiguration {
        std::set<std::string> ips;
        std::string host;
        std::string httpsTemplate;
        bool forTesting;
        bool requireRootPermission;
        base::Result<DohIdentity> getDohIdentity(const std::vector<std::string>& ips,
                                                 const std::string& host) const {
            if (!host.empty() && this->host != host) return Errorf("host {} not matched", host);
@@ -236,6 +236,8 @@ class PrivateDnsConfiguration {
             false},

            // The DoH providers for testing only.
            // Using ResolverTestProvider requires that the DnsResolver is configured by someone
            // who has root permission, which should be run by tests only.
            {"ResolverTestProvider",
             {"127.0.0.3", "::1"},
             "example.com",