LeOS-GSI/patches/leos/platform_packages_modules_D.../0002-hosts_toggle.patch

34 lines
1.1 KiB
Diff
Raw Normal View History

2023-12-16 09:20:57 +01:00
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
2023-12-13 10:41:07 +01:00
2023-12-16 09:20:57 +01:00
Signed-off-by: Tad <tad@spotco.us>
Change-Id: Iea165003474e1107dc77980985bf9928c369dbb5
2023-12-13 10:41:07 +01:00
---
2023-12-16 09:20:57 +01:00
getaddrinfo.cpp | 4 ++++
1 file changed, 4 insertions(+)
2023-12-13 10:41:07 +01:00
diff --git a/getaddrinfo.cpp b/getaddrinfo.cpp
2023-12-16 09:20:57 +01:00
index d8542939..4760f7fd 100644
2023-12-13 10:41:07 +01:00
--- a/getaddrinfo.cpp
+++ b/getaddrinfo.cpp
2023-12-16 09:20:57 +01:00
@@ -57,6 +57,7 @@
#include <future>
2023-12-13 10:41:07 +01:00
#include <android-base/logging.h>
+#include <android-base/properties.h>
2023-12-16 09:20:57 +01:00
2023-12-13 10:41:07 +01:00
#include "Experiments.h"
#include "netd_resolv/resolv.h"
2023-12-16 09:20:57 +01:00
@@ -1556,6 +1557,9 @@ static struct addrinfo* getCustomHosts(const size_t netid, const char* _Nonnull
2023-12-13 10:41:07 +01:00
static bool files_getaddrinfo(const size_t netid, 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 = nullptr;