Stop setting the legacy net.dnsX system properties
These have been locked down via SELinux for a while and thus they should be safe to delete at this point. Test: atest FrameworksNetTest Bug: 33308258 Bug: 148724751 Change-Id: I3a1e9c6ad92c8d2367e0048e5d6cd7d06bbc6e80
This commit is contained in:
@@ -236,7 +236,6 @@ import java.net.UnknownHostException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.ConcurrentModificationException;
|
||||
import java.util.HashMap;
|
||||
@@ -6192,20 +6191,12 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
||||
return; // no updating necessary
|
||||
}
|
||||
|
||||
final NetworkAgentInfo defaultNai = getDefaultNetwork();
|
||||
final boolean isDefaultNetwork = (defaultNai != null && defaultNai.network.netId == netId);
|
||||
|
||||
if (DBG) {
|
||||
final Collection<InetAddress> dnses = newLp.getDnsServers();
|
||||
log("Setting DNS servers for network " + netId + " to " + dnses);
|
||||
}
|
||||
try {
|
||||
mDnsManager.noteDnsServersForNetwork(netId, newLp);
|
||||
// TODO: netd should listen on [::1]:53 and proxy queries to the current
|
||||
// default network, and we should just set net.dns1 to ::1, not least
|
||||
// because applications attempting to use net.dns resolvers will bypass
|
||||
// the privacy protections of things like DNS-over-TLS.
|
||||
if (isDefaultNetwork) mDnsManager.setDefaultDnsSystemProperties(newLp.getDnsServers());
|
||||
mDnsManager.flushVmDnsCache();
|
||||
} catch (Exception e) {
|
||||
loge("Exception in setDnsConfigurationForNetwork: " + e);
|
||||
@@ -6720,8 +6711,6 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
||||
? newNetwork.linkProperties.getHttpProxy() : null);
|
||||
updateTcpBufferSizes(null != newNetwork
|
||||
? newNetwork.linkProperties.getTcpBufferSizes() : null);
|
||||
mDnsManager.setDefaultDnsSystemProperties(null != newNetwork
|
||||
? newNetwork.linkProperties.getDnsServers() : Collections.EMPTY_LIST);
|
||||
notifyIfacesChangedForNetworkStats();
|
||||
// Fix up the NetworkCapabilities of any VPNs that don't specify underlying networks.
|
||||
updateAllVpnsCapabilities();
|
||||
|
||||
@@ -50,7 +50,6 @@ import android.util.Slog;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
@@ -245,7 +244,6 @@ public class DnsManager {
|
||||
private final Map<Integer, LinkProperties> mLinkPropertiesMap;
|
||||
private final Map<Integer, int[]> mTransportsMap;
|
||||
|
||||
private int mNumDnsEntries;
|
||||
private int mSampleValidity;
|
||||
private int mSuccessThreshold;
|
||||
private int mMinSamples;
|
||||
@@ -409,18 +407,6 @@ public class DnsManager {
|
||||
}
|
||||
}
|
||||
|
||||
public void setDefaultDnsSystemProperties(Collection<InetAddress> dnses) {
|
||||
int last = 0;
|
||||
for (InetAddress dns : dnses) {
|
||||
++last;
|
||||
setNetDnsProperty(last, dns.getHostAddress());
|
||||
}
|
||||
for (int i = last + 1; i <= mNumDnsEntries; ++i) {
|
||||
setNetDnsProperty(i, "");
|
||||
}
|
||||
mNumDnsEntries = last;
|
||||
}
|
||||
|
||||
/**
|
||||
* Flush DNS caches and events work before boot has completed.
|
||||
*/
|
||||
@@ -476,16 +462,6 @@ public class DnsManager {
|
||||
return Settings.Global.getInt(mContentResolver, which, dflt);
|
||||
}
|
||||
|
||||
private void setNetDnsProperty(int which, String value) {
|
||||
final String key = "net.dns" + which;
|
||||
// Log and forget errors setting unsupported properties.
|
||||
try {
|
||||
mSystemProperties.set(key, value);
|
||||
} catch (Exception e) {
|
||||
Slog.e(TAG, "Error setting unsupported net.dns property: ", e);
|
||||
}
|
||||
}
|
||||
|
||||
private static String getPrivateDnsMode(ContentResolver cr) {
|
||||
String mode = getStringSetting(cr, PRIVATE_DNS_MODE);
|
||||
if (TextUtils.isEmpty(mode)) mode = getStringSetting(cr, PRIVATE_DNS_DEFAULT_MODE);
|
||||
|
||||
@@ -159,7 +159,6 @@ public class DnsManagerTest {
|
||||
// Send a validation event that is tracked on the alternate netId
|
||||
mDnsManager.updateTransportsForNetwork(TEST_NETID, TEST_TRANSPORT_TYPES);
|
||||
mDnsManager.noteDnsServersForNetwork(TEST_NETID, lp);
|
||||
mDnsManager.setDefaultDnsSystemProperties(lp.getDnsServers());
|
||||
mDnsManager.flushVmDnsCache();
|
||||
mDnsManager.updateTransportsForNetwork(TEST_NETID_ALTERNATE, TEST_TRANSPORT_TYPES);
|
||||
mDnsManager.noteDnsServersForNetwork(TEST_NETID_ALTERNATE, lp);
|
||||
@@ -196,7 +195,6 @@ public class DnsManagerTest {
|
||||
}));
|
||||
mDnsManager.updateTransportsForNetwork(TEST_NETID, TEST_TRANSPORT_TYPES);
|
||||
mDnsManager.noteDnsServersForNetwork(TEST_NETID, lp);
|
||||
mDnsManager.setDefaultDnsSystemProperties(lp.getDnsServers());
|
||||
mDnsManager.flushVmDnsCache();
|
||||
fixedLp = new LinkProperties(lp);
|
||||
mDnsManager.updatePrivateDnsStatus(TEST_NETID, fixedLp);
|
||||
@@ -232,7 +230,6 @@ public class DnsManagerTest {
|
||||
lp.addDnsServer(InetAddress.getByName("3.3.3.3"));
|
||||
mDnsManager.updateTransportsForNetwork(TEST_NETID, TEST_TRANSPORT_TYPES);
|
||||
mDnsManager.noteDnsServersForNetwork(TEST_NETID, lp);
|
||||
mDnsManager.setDefaultDnsSystemProperties(lp.getDnsServers());
|
||||
mDnsManager.flushVmDnsCache();
|
||||
mDnsManager.updatePrivateDnsValidation(
|
||||
new DnsManager.PrivateDnsValidationUpdate(TEST_NETID,
|
||||
@@ -246,7 +243,6 @@ public class DnsManagerTest {
|
||||
mDnsManager.getPrivateDnsConfig());
|
||||
mDnsManager.updateTransportsForNetwork(TEST_NETID, TEST_TRANSPORT_TYPES);
|
||||
mDnsManager.noteDnsServersForNetwork(TEST_NETID, lp);
|
||||
mDnsManager.setDefaultDnsSystemProperties(lp.getDnsServers());
|
||||
mDnsManager.flushVmDnsCache();
|
||||
mDnsManager.updatePrivateDnsValidation(
|
||||
new DnsManager.PrivateDnsValidationUpdate(TEST_NETID_UNTRACKED,
|
||||
@@ -295,7 +291,6 @@ public class DnsManagerTest {
|
||||
mDnsManager.getPrivateDnsConfig());
|
||||
mDnsManager.updateTransportsForNetwork(TEST_NETID, TEST_TRANSPORT_TYPES);
|
||||
mDnsManager.noteDnsServersForNetwork(TEST_NETID, lp);
|
||||
mDnsManager.setDefaultDnsSystemProperties(lp.getDnsServers());
|
||||
mDnsManager.flushVmDnsCache();
|
||||
mDnsManager.updatePrivateDnsValidation(
|
||||
new DnsManager.PrivateDnsValidationUpdate(TEST_NETID,
|
||||
@@ -341,7 +336,6 @@ public class DnsManagerTest {
|
||||
lp.addDnsServer(InetAddress.getByName("4.4.4.4"));
|
||||
mDnsManager.updateTransportsForNetwork(TEST_NETID, TEST_TRANSPORT_TYPES);
|
||||
mDnsManager.noteDnsServersForNetwork(TEST_NETID, lp);
|
||||
mDnsManager.setDefaultDnsSystemProperties(lp.getDnsServers());
|
||||
mDnsManager.flushVmDnsCache();
|
||||
|
||||
final ArgumentCaptor<ResolverParamsParcel> resolverParamsParcelCaptor =
|
||||
|
||||
Reference in New Issue
Block a user