DivestOS/Patches/LineageOS-17.1/android_system_netd/0002-hosts_toggle.patch

35 lines
1.1 KiB
Diff
Raw Normal View History

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Tad <tad@spotco.us>
Date: Wed, 20 Apr 2022 00:40:53 -0400
Subject: [PATCH] Add a toggle to disable /etc/hosts lookup
[tad@spotco.us]: backport to netd
Signed-off-by: Tad <tad@spotco.us>
Change-Id: Iea165003474e1107dc77980985bf9928c369dbb5
---
resolv/getaddrinfo.cpp | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/resolv/getaddrinfo.cpp b/resolv/getaddrinfo.cpp
index cf8e4d26..245132f6 100644
--- a/resolv/getaddrinfo.cpp
+++ b/resolv/getaddrinfo.cpp
@@ -56,6 +56,7 @@
#include <unistd.h>
#include <android-base/logging.h>
+#include <android-base/properties.h>
#include "netd_resolv/resolv.h"
#include "resolv_cache.h"
@@ -1550,6 +1551,9 @@ found:
}
static bool files_getaddrinfo(const char* name, const addrinfo* pai, addrinfo** res) {
+ if ((android::base::GetIntProperty("persist.security.hosts_disable", 0) != 0) && (strcmp("localhost", name) != 0) && (strcmp("ip6-localhost", name) != 0))
+ return false;
+
struct addrinfo sentinel = {};
struct addrinfo *p, *cur;
FILE* hostf = NULL;