diff options
| author | Bernie Innocenti <codewiz@google.com> | 2018-09-05 08:42:58 -0700 |
|---|---|---|
| committer | android-build-merger <android-build-merger@google.com> | 2018-09-05 08:42:58 -0700 |
| commit | 80da2c7f0524f90dec9c494b8da0f274c99b37f9 (patch) | |
| tree | 9663f508ff896ca0051b3af9a2ac96f04152d18f | |
| parent | c61d31723f032f75c658191805cc77328c6ead76 (diff) | |
| parent | 4990176148a487b0272f6b3ec6c57594419eec18 (diff) | |
Merge "Prevent netd from using the libnetd_client wrappers" am: 198fb7b6df
am: 4990176148
Change-Id: Ie0986d87984d10cd8ef369e1f5ceea460930cca4
| -rw-r--r-- | libc/bionic/NetdClient.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/libc/bionic/NetdClient.cpp b/libc/bionic/NetdClient.cpp index a1071d2f46..966cbcc20d 100644 --- a/libc/bionic/NetdClient.cpp +++ b/libc/bionic/NetdClient.cpp @@ -24,6 +24,8 @@ #include <dlfcn.h> #include <pthread.h> +#include <string.h> +#include <unistd.h> template <typename FunctionType> static void netdClientInitFunction(void* handle, const char* symbol, FunctionType* function) { @@ -35,6 +37,14 @@ static void netdClientInitFunction(void* handle, const char* symbol, FunctionTyp } static void netdClientInitImpl() { + // Prevent netd from looping back fwmarkd connections to itself. It would work, but it's + // a deadlock hazard and unnecessary overhead for the resolver. + if (getuid() == 0 && strcmp(getprogname(), "netd") == 0) { + async_safe_format_log(ANDROID_LOG_INFO, "netdClient", + "Skipping libnetd_client init since *we* are netd"); + return; + } + void* netdClientHandle = dlopen("libnetd_client.so", RTLD_NOW); if (netdClientHandle == NULL) { // If the library is not available, it's not an error. We'll just use @@ -54,6 +64,6 @@ static pthread_once_t netdClientInitOnce = PTHREAD_ONCE_INIT; extern "C" __LIBC_HIDDEN__ void netdClientInit() { if (pthread_once(&netdClientInitOnce, netdClientInitImpl)) { - async_safe_format_log(ANDROID_LOG_ERROR, "netdClient", "Failed to initialize netd_client"); + async_safe_format_log(ANDROID_LOG_ERROR, "netdClient", "Failed to initialize libnetd_client"); } } |
