      struct addrinfo* result = NULL;
      uint32_t rv = android_getaddrinfofornetcontext(mHost, mService, mHints, &mNetContext, &result);
      if (rv) {
-@@ -345,6 +367,10 @@ void DnsProxyListener::GetHostByNameHandler::run() {
+@@ -345,6 +366,10 @@ void DnsProxyListener::GetHostByNameHandler::run() {
          ALOGD("DnsProxyListener::GetHostByNameHandler::run\n");
      }
  

From 1c229037f7444cd1887756dc3eb324723153f90b Mon Sep 17 00:00:00 2001
From: Rusty Bird <rustybird@openmailbox.org>
Date: Mon, 22 Feb 2016 16:25:00 +0000
Subject: [system/netd] Copy client's uid and gid into thread's fsuid and fsgid

Inspired by
https://github.com/cernekee/dnsproxy2/commit/0708140aa747764a125b5189cace005773e30a24

Change-Id: Iff5ac21c0ee57f337bbc414a53aea6dfe9704aae
---
 server/DnsProxyListener.cpp | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/server/DnsProxyListener.cpp b/server/DnsProxyListener.cpp
index 6c71c5b..1d27284 100644
--- a/server/DnsProxyListener.cpp
+++ b/server/DnsProxyListener.cpp
@@ -27,6 +27,8 @@
 #include <pthread.h>
 #include <resolv_netid.h>
 #include <net/if.h>
+#include <unistd.h>
+#include <sys/syscall.h>
 
 #define LOG_TAG "DnsProxyListener"
 #define DBG 0
@@ -41,6 +43,22 @@
 #include "NetworkController.h"
 #include "ResponseCode.h"
 

+static bool setfsids(SocketClient* c) {
+    bool success = true;
+
+    if (setfsuid(c->getUid()) != 0) {
+        ALOGE("setfsids setfsuid errno: %s\n", strerror(errno));
+        success = false;
+    }
+    if (setfsgid(c->getGid()) != 0) {
+        ALOGE("setfsids setfsgid errno: %s\n", strerror(errno));
+        success = false;
+    }
