summaryrefslogtreecommitdiff
path: root/src/libs6dns
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2023-07-12 16:53:59 +0000
committerLaurent Bercot <ska@appnovation.com>2023-07-12 16:53:59 +0000
commit207845f50a8fb54fe8e584928078dc3687399caf (patch)
treef58eac67edc2dbaba13a48442a2093f76e869991 /src/libs6dns
parent8cf671e973a4ea2ef7c9ca1321531a7ceeaa5073 (diff)
downloads6-dns-207845f50a8fb54fe8e584928078dc3687399caf.tar.xz
Pass on all clients, add hosts support wherever applicable
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src/libs6dns')
-rw-r--r--src/libs6dns/deps-lib/s6dns71
-rw-r--r--src/libs6dns/s6dns_finish.c1
-rw-r--r--src/libs6dns/s6dns_hosts_init.c6
-rw-r--r--src/libs6dns/s6dns_init.c6
4 files changed, 47 insertions, 37 deletions
diff --git a/src/libs6dns/deps-lib/s6dns b/src/libs6dns/deps-lib/s6dns
index 6eaf610..266b574 100644
--- a/src/libs6dns/deps-lib/s6dns
+++ b/src/libs6dns/deps-lib/s6dns
@@ -1,5 +1,24 @@
+s6dns_analyze_packet.o
+s6dns_analyze_qtype_parse.o
+s6dns_analyze_record.o
+s6dns_analyze_record_a.o
+s6dns_analyze_record_aaaa.o
+s6dns_analyze_record_caa.o
+s6dns_analyze_record_domain.o
+s6dns_analyze_record_hinfo.o
+s6dns_analyze_record_mx.o
+s6dns_analyze_record_soa.o
+s6dns_analyze_record_srv.o
+s6dns_analyze_record_strings.o
+s6dns_analyze_record_unknown.o
+s6dns_analyze_rtypetable.o
s6dns_constants_error.o
s6dns_constants_error_str.o
+s6dns_debug_dumpdt_post_recv.o
+s6dns_debug_dumpdt_post_send.o
+s6dns_debug_dumpdt_pre_send.o
+s6dns_debug_dumpdt_stderr.o
+s6dns_debug_dumpdt_stdout.o
s6dns_debughook_zero.o
s6dns_domain_arpafromip4.o
s6dns_domain_arpafromip6.o
@@ -18,46 +37,49 @@ s6dns_engine_freen.o
s6dns_engine_here.o
s6dns_engine_nextdeadline.o
s6dns_engine_zero.o
+s6dns_finish.o
+s6dns_fmt_caa.o
s6dns_fmt_domainlist.o
s6dns_fmt_hinfo.o
s6dns_fmt_mx.o
s6dns_fmt_soa.o
s6dns_fmt_srv.o
-s6dns_fmt_caa.o
-s6dns_hosts_compile.o
s6dns_hosts_aaaaa_q.o
s6dns_hosts_aaaaa_string.o
+s6dns_hosts_compile.o
+s6dns_hosts_here.o
+s6dns_hosts_init.o
s6dns_hosts_ip_q.o
s6dns_hosts_ip_string.o
s6dns_hosts_name.o
-s6dns_hosts_here.o
+s6dns_init.o
s6dns_message_counts_next.o
s6dns_message_counts_pack.o
s6dns_message_counts_unpack.o
s6dns_message_counts_zero.o
+s6dns_message_get_caa.o
s6dns_message_get_domain.o
s6dns_message_get_domain_nodecode.o
s6dns_message_get_hinfo.o
-s6dns_message_get_string.o
-s6dns_message_get_string_internal.o
-s6dns_message_get_strings.o
s6dns_message_get_mx.o
s6dns_message_get_soa.o
s6dns_message_get_srv.o
-s6dns_message_get_caa.o
+s6dns_message_get_string.o
+s6dns_message_get_string_internal.o
+s6dns_message_get_strings.o
s6dns_message_header_pack.o
s6dns_message_header_unpack.o
s6dns_message_header_zero.o
-s6dns_message_parse_answer_aaaa.o
+s6dns_message_parse.o
s6dns_message_parse_answer_a.o
+s6dns_message_parse_answer_aaaa.o
+s6dns_message_parse_answer_caa.o
s6dns_message_parse_answer_domain.o
s6dns_message_parse_answer_hinfo.o
s6dns_message_parse_answer_mx.o
s6dns_message_parse_answer_soa.o
s6dns_message_parse_answer_srv.o
-s6dns_message_parse_answer_caa.o
s6dns_message_parse_answer_strings.o
-s6dns_message_parse.o
s6dns_message_parse_getrr.o
s6dns_message_parse_init.o
s6dns_message_parse_next.o
@@ -68,36 +90,15 @@ s6dns_rci_here.o
s6dns_rci_init.o
s6dns_rci_zero.o
s6dns_resolve_core.o
-s6dns_resolve_parse.o
-s6dns_resolven_loop.o
-s6dns_resolven_parse.o
s6dns_resolve_dpag.o
s6dns_resolve_mpag.o
s6dns_resolve_name4.o
s6dns_resolve_name6.o
+s6dns_resolve_parse.o
+s6dns_resolven_loop.o
+s6dns_resolven_parse.o
s6dns_resolvenoq.o
-s6dns_resolveq.o
s6dns_resolvenoq_aaaaa.o
+s6dns_resolveq.o
s6dns_resolveq_aaaaa.o
-s6dns_analyze_packet.o
-s6dns_analyze_qtype_parse.o
-s6dns_analyze_record.o
-s6dns_analyze_record_a.o
-s6dns_analyze_record_aaaa.o
-s6dns_analyze_record_hinfo.o
-s6dns_analyze_record_mx.o
-s6dns_analyze_record_soa.o
-s6dns_analyze_record_srv.o
-s6dns_analyze_record_caa.o
-s6dns_analyze_record_domain.o
-s6dns_analyze_record_strings.o
-s6dns_analyze_record_unknown.o
-s6dns_analyze_rtypetable.o
-s6dns_debug_dumpdt_stdout.o
-s6dns_debug_dumpdt_stderr.o
-s6dns_debug_dumpdt_post_recv.o
-s6dns_debug_dumpdt_pre_send.o
-s6dns_debug_dumpdt_post_send.o
-s6dns_init.o
-s6dns_finish.o
-lskarnet
diff --git a/src/libs6dns/s6dns_finish.c b/src/libs6dns/s6dns_finish.c
index f786329..a8a479a 100644
--- a/src/libs6dns/s6dns_finish.c
+++ b/src/libs6dns/s6dns_finish.c
@@ -7,5 +7,6 @@
void s6dns_finish ()
{
s6dns_engine_free(&s6dns_engine_here) ;
+ s6dns_hosts_free(&s6dns_hosts_here) ;
s6dns_rci_free(&s6dns_rci_here) ;
}
diff --git a/src/libs6dns/s6dns_hosts_init.c b/src/libs6dns/s6dns_hosts_init.c
index 762d738..8f78ab1 100644
--- a/src/libs6dns/s6dns_hosts_init.c
+++ b/src/libs6dns/s6dns_hosts_init.c
@@ -5,6 +5,7 @@
#include <errno.h>
#include <stdlib.h>
#include <sys/stat.h>
+#include <time.h>
#include <skalibs/posixplz.h>
#include <skalibs/cdb.h>
@@ -12,7 +13,7 @@
#include <s6-dns/hosts.h>
-int s6dns_hosts_init_r (cdb *c, char const *txtfile, char const *cdbfile, char const *tmpprefix)
+int s6dns_hosts_init (cdb *c, char const *txtfile, char const *cdbfile, char const *tmpprefix)
{
int fdr ;
int fdc = openc_read(cdbfile) ;
@@ -25,7 +26,8 @@ int s6dns_hosts_init_r (cdb *c, char const *txtfile, char const *cdbfile, char c
if (errno == ENOENT) goto useit ;
else goto errc ;
}
- if (stc.st_mtim > str.st_mtim) goto useit ;
+ if (stc.st_mtim.tv_sec > str.st_mtim.tv_sec
+ || (stc.st_mtim.tv_sec == str.st_mtim.tv_sec && stc.st_mtim.tv_nsec > str.st_mtim.tv_nsec)) goto useit ;
fd_close(fdc) ;
}
diff --git a/src/libs6dns/s6dns_init.c b/src/libs6dns/s6dns_init.c
index 7f98d13..10dcbf5 100644
--- a/src/libs6dns/s6dns_init.c
+++ b/src/libs6dns/s6dns_init.c
@@ -1,10 +1,16 @@
/* ISC license. */
#include <s6-dns/s6dns-rci.h>
+#include <s6-dns/hosts.h>
#include <s6-dns/s6dns.h>
int s6dns_init (void)
{
if (!s6dns_rci_init(&s6dns_rci_here, "/etc/resolv.conf")) return 0 ;
+ if (s6dns_hosts_init(&s6dns_hosts_here, "/etc/hosts", "/etc/hosts.cdb", "/tmp/hosts.cdb") == -1) goto err ;
return 1 ;
+
+ err:
+ s6dns_rci_free(&s6dns_rci_here) ;
+ return 0 ;
}