59 lines
1.8 KiB
Diff
59 lines
1.8 KiB
Diff
![]() |
From 2cc44127b3140a9f86787022c5c3b78e0134c5d6 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
|
||
|
|
||
|
Signed-off-by: Tad <tad@spotco.us>
|
||
|
Change-Id: Iea165003474e1107dc77980985bf9928c369dbb5
|
||
|
---
|
||
|
getaddrinfo.cpp | 24 +++++++++++++-----------
|
||
|
1 file changed, 13 insertions(+), 11 deletions(-)
|
||
|
|
||
|
diff --git a/getaddrinfo.cpp b/getaddrinfo.cpp
|
||
|
index 071f6ac..da7333c 100644
|
||
|
--- a/getaddrinfo.cpp
|
||
|
+++ b/getaddrinfo.cpp
|
||
|
@@ -57,6 +57,7 @@
|
||
|
#include <future>
|
||
|
|
||
|
#include <android-base/logging.h>
|
||
|
+#include <android-base/properties.h>
|
||
|
|
||
|
#include "Experiments.h"
|
||
|
#include "netd_resolv/resolv.h"
|
||
|
@@ -1561,19 +1562,20 @@ static bool files_getaddrinfo(const size_t netid, const char* name, const addrin
|
||
|
FILE* hostf = nullptr;
|
||
|
|
||
|
cur = &sentinel;
|
||
|
+ if (android::base::GetIntProperty("persist.security.hosts_disable", 0) == 0) {
|
||
|
+ int hc_error = hc_getaddrinfo(name, pai, &cur);
|
||
|
+ if (hc_error != EAI_SYSTEM) {
|
||
|
+ *res = sentinel.ai_next;
|
||
|
+ return sentinel.ai_next != NULL;
|
||
|
+ }
|
||
|
|
||
|
- int hc_error = hc_getaddrinfo(name, pai, &cur);
|
||
|
- if (hc_error != EAI_SYSTEM) {
|
||
|
- *res = sentinel.ai_next;
|
||
|
- return sentinel.ai_next != NULL;
|
||
|
- }
|
||
|
-
|
||
|
- _sethtent(&hostf);
|
||
|
- while ((p = _gethtent(&hostf, name, pai)) != nullptr) {
|
||
|
- cur->ai_next = p;
|
||
|
- while (cur && cur->ai_next) cur = cur->ai_next;
|
||
|
+ _sethtent(&hostf);
|
||
|
+ while ((p = _gethtent(&hostf, name, pai)) != nullptr) {
|
||
|
+ cur->ai_next = p;
|
||
|
+ while (cur && cur->ai_next) cur = cur->ai_next;
|
||
|
+ }
|
||
|
+ _endhtent(&hostf);
|
||
|
}
|
||
|
- _endhtent(&hostf);
|
||
|
|
||
|
if ((p = getCustomHosts(netid, name, pai)) != nullptr) {
|
||
|
cur->ai_next = p;
|
||
|
--
|
||
|
2.36.0
|
||
|
|