diff --git a/Patches/LineageOS-18.1/android_bionic/0003-hosts_toggle.patch b/Patches/LineageOS-18.1/android_bionic/0003-hosts_toggle.patch index 8f808ac5..c2055a02 100644 --- a/Patches/LineageOS-18.1/android_bionic/0003-hosts_toggle.patch +++ b/Patches/LineageOS-18.1/android_bionic/0003-hosts_toggle.patch @@ -1,4 +1,4 @@ -From f5cc53d8d4dfcffe5d1c7b029078803112e79919 Mon Sep 17 00:00:00 2001 +From f4290ee3eceb3843429255aeae9a86dc19b24312 Mon Sep 17 00:00:00 2001 From: Tad Date: Wed, 20 Apr 2022 00:40:52 -0400 Subject: [PATCH] Add a toggle to disable /etc/hosts lookup @@ -10,7 +10,7 @@ Change-Id: I92679c57e73228dc194e61a86ea1a18b2ac90e04 1 file changed, 6 insertions(+) diff --git a/libc/dns/net/getaddrinfo.c b/libc/dns/net/getaddrinfo.c -index cc94b21e2..36c887a38 100644 +index cc94b21e2..12294da04 100644 --- a/libc/dns/net/getaddrinfo.c +++ b/libc/dns/net/getaddrinfo.c @@ -83,6 +83,7 @@ @@ -21,18 +21,18 @@ index cc94b21e2..36c887a38 100644 #include #include #include -@@ -2118,6 +2119,11 @@ found: - static int - _files_getaddrinfo(void *rv, void *cb_data, va_list ap) - { +@@ -2127,6 +2128,11 @@ _files_getaddrinfo(void *rv, void *cb_data, va_list ap) + name = va_arg(ap, char *); + pai = va_arg(ap, struct addrinfo *); + + char value[PROP_VALUE_MAX] = { 0 }; + if (__system_property_get("persist.security.hosts_disable", value) != 0) -+ if (atoi(value) != 0) ++ if (atoi(value) != 0 && strcmp(name, "localhost") != 0 && strcmp(name, "ip6-localhost") != 0) + return NS_NOTFOUND; + - const char *name; - const struct addrinfo *pai; - struct addrinfo sentinel, *cur; + memset(&sentinel, 0, sizeof(sentinel)); + cur = &sentinel; + int gai_error = hc_getaddrinfo(name, NULL, pai, &cur); -- 2.36.0 diff --git a/Patches/LineageOS-18.1/android_packages_modules_DnsResolver/0001-hosts_toggle.patch b/Patches/LineageOS-18.1/android_packages_modules_DnsResolver/0001-hosts_toggle.patch index 9091fc30..7569fd46 100644 --- a/Patches/LineageOS-18.1/android_packages_modules_DnsResolver/0001-hosts_toggle.patch +++ b/Patches/LineageOS-18.1/android_packages_modules_DnsResolver/0001-hosts_toggle.patch @@ -1,4 +1,4 @@ -From 738d94379dccd89de898b2de0d4ad97a57d8c8f8 Mon Sep 17 00:00:00 2001 +From 91bae24269ae01b7c4508276e21e7417c24ce5e4 Mon Sep 17 00:00:00 2001 From: Tad Date: Wed, 20 Apr 2022 00:40:53 -0400 Subject: [PATCH] Add a toggle to disable /etc/hosts lookup @@ -10,7 +10,7 @@ Change-Id: Iea165003474e1107dc77980985bf9928c369dbb5 1 file changed, 4 insertions(+) diff --git a/getaddrinfo.cpp b/getaddrinfo.cpp -index 071f6ac..14891fc 100644 +index 071f6ac..955b5c2 100644 --- a/getaddrinfo.cpp +++ b/getaddrinfo.cpp @@ -57,6 +57,7 @@ @@ -25,7 +25,7 @@ index 071f6ac..14891fc 100644 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) ++ if (android::base::GetIntProperty("persist.security.hosts_disable", 0) != 0 && name != "localhost" && name != "ip6-localhost") + return false; + struct addrinfo sentinel = {};