mirror of
https://github.com/Divested-Mobile/DivestOS-Build.git
synced 2025-06-01 21:02:12 -04:00
18.1: Add toggle for /etc/hosts
TODO: 19.1 and maybe 17.1 Tested working on klte/18.1 Signed-off-by: Tad <tad@spotco.us>
This commit is contained in:
parent
1f721c7845
commit
9a6c7a2684
7 changed files with 316 additions and 8 deletions
|
@ -0,0 +1,58 @@
|
|||
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
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue