mirror of
https://github.com/Divested-Mobile/DivestOS-Build.git
synced 2024-10-01 01:35:54 -04:00
ad466bd3e4
- 17.1: Add more captive portal server options like 18.1+, disabled: needs fixes - 17.1: Add the hosts toggle like 18.1+ - 18.1: fix junk in patch - 17.1+: hosts toggle: bugfix: fixup localhost handling by switching to strcmp - 15.1: fixes to get hmalloc to compile, does NOT boot Signed-off-by: Tad <tad@spotco.us>
36 lines
1.2 KiB
Diff
36 lines
1.2 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Tad <tad@spotco.us>
|
|
Date: Wed, 20 Apr 2022 00:40:52 -0400
|
|
Subject: [PATCH] Add a toggle to disable /etc/hosts lookup
|
|
|
|
Signed-off-by: Tad <tad@spotco.us>
|
|
Change-Id: I92679c57e73228dc194e61a86ea1a18b2ac90e04
|
|
---
|
|
libc/dns/net/getaddrinfo.c | 6 ++++++
|
|
1 file changed, 6 insertions(+)
|
|
|
|
diff --git a/libc/dns/net/getaddrinfo.c b/libc/dns/net/getaddrinfo.c
|
|
index cc94b21e2..12294da04 100644
|
|
--- a/libc/dns/net/getaddrinfo.c
|
|
+++ b/libc/dns/net/getaddrinfo.c
|
|
@@ -83,6 +83,7 @@
|
|
#include <sys/stat.h>
|
|
#include <sys/param.h>
|
|
#include <sys/socket.h>
|
|
+#include <sys/system_properties.h>
|
|
#include <sys/un.h>
|
|
#include <net/if.h>
|
|
#include <netinet/in.h>
|
|
@@ -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 && strcmp(name, "localhost") != 0 && strcmp(name, "ip6-localhost") != 0)
|
|
+ return NS_NOTFOUND;
|
|
+
|
|
memset(&sentinel, 0, sizeof(sentinel));
|
|
cur = &sentinel;
|
|
int gai_error = hc_getaddrinfo(name, NULL, pai, &cur);
|