Switch to fchown() for changing the UID of sockets.
All tests PASS on:
- android/android-3.4
- android/android-3.10
Also, multinetwork_test.py PASSes
- android/android-3.18
Bug: 20733156
Bug: 21832279
Change-Id: I1738ca014e58af35f841e31faad649d485b370c6
diff --git a/net/test/multinetwork_base.py b/net/test/multinetwork_base.py
index 8940258..5952d56 100644
--- a/net/test/multinetwork_base.py
+++ b/net/test/multinetwork_base.py
@@ -430,13 +430,12 @@
raise ValueError("Unknown interface selection mode %s" % mode)
def BuildSocket(self, version, constructor, netid, routing_mode):
- uid = self.UidForNetid(netid) if routing_mode == "uid" else None
- with net_test.RunAsUid(uid):
- family = self.GetProtocolFamily(version)
- s = constructor(family)
+ s = constructor(self.GetProtocolFamily(version))
if routing_mode not in [None, "uid"]:
self.SelectInterface(s, netid, routing_mode)
+ elif routing_mode == "uid":
+ os.fchown(s.fileno(), self.UidForNetid(netid), -1)
return s