Restore the net.dnsX system properties.

In order to avoid app breakage, we are putting back the system
properties and using selinux to disallow access from apps
targeting the O SDK or above.

This CL is cherry-picked from internal commit
443b6c4049, but with a different
commit description.

Bug: 33308258
Bug: 33807046
Bug: 34028616
Bug: 34115651
Test: system properties are readable as root and shell
Change-Id: I8d51e8e0a620d581c4251fb2f3c1d0a813b929be
This commit is contained in:
Lorenzo Colitti
2017-01-06 10:25:02 +09:00
parent 28631ea268
commit 47c7440d8f

View File

@@ -4564,9 +4564,28 @@ public class ConnectivityService extends IConnectivityManager.Stub
} catch (Exception e) { } catch (Exception e) {
loge("Exception in setDnsConfigurationForNetwork: " + e); loge("Exception in setDnsConfigurationForNetwork: " + e);
} }
final NetworkAgentInfo defaultNai = getDefaultNetwork();
if (defaultNai != null && defaultNai.network.netId == netId) {
setDefaultDnsSystemProperties(dnses);
}
flushVmDnsCache(); flushVmDnsCache();
} }
private void setDefaultDnsSystemProperties(Collection<InetAddress> dnses) {
int last = 0;
for (InetAddress dns : dnses) {
++last;
String key = "net.dns" + last;
String value = dns.getHostAddress();
SystemProperties.set(key, value);
}
for (int i = last + 1; i <= mNumDnsEntries; ++i) {
String key = "net.dns" + i;
SystemProperties.set(key, "");
}
mNumDnsEntries = last;
}
private String getNetworkPermission(NetworkCapabilities nc) { private String getNetworkPermission(NetworkCapabilities nc) {
// TODO: make these permission strings AIDL constants instead. // TODO: make these permission strings AIDL constants instead.
if (!nc.hasCapability(NET_CAPABILITY_NOT_RESTRICTED)) { if (!nc.hasCapability(NET_CAPABILITY_NOT_RESTRICTED)) {
@@ -4783,6 +4802,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
notifyLockdownVpn(newNetwork); notifyLockdownVpn(newNetwork);
handleApplyDefaultProxy(newNetwork.linkProperties.getHttpProxy()); handleApplyDefaultProxy(newNetwork.linkProperties.getHttpProxy());
updateTcpBufferSizes(newNetwork); updateTcpBufferSizes(newNetwork);
setDefaultDnsSystemProperties(newNetwork.linkProperties.getDnsServers());
} }
private void processListenRequests(NetworkAgentInfo nai, boolean capabilitiesChanged) { private void processListenRequests(NetworkAgentInfo nai, boolean capabilitiesChanged) {