diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2023-11-17 20:23:56 +0000 |
---|---|---|
committer | Laurent Bercot <ska@appnovation.com> | 2023-11-17 20:23:56 +0000 |
commit | d06529686f89074fd4fa574ac6012f8a873e7857 (patch) | |
tree | e2fd4e499d8a633feeff288a9d42e904abca8903 | |
parent | 9d432bd8a07dd36247339c40fa6bf2719600fdb2 (diff) | |
download | s6-dns-d06529686f89074fd4fa574ac6012f8a873e7857.tar.xz |
Prepare for 2.3.7.0; ignore link-local addresses in /etc/hosts
Signed-off-by: Laurent Bercot <ska@appnovation.com>
-rw-r--r-- | INSTALL | 2 | ||||
-rw-r--r-- | NEWS | 9 | ||||
-rw-r--r-- | doc/index.html | 4 | ||||
-rw-r--r-- | doc/s6-dns-hosts-compile.html | 5 | ||||
-rw-r--r-- | doc/upgrade.html | 7 | ||||
-rw-r--r-- | package/deps.mak | 6 | ||||
-rw-r--r-- | package/info | 2 | ||||
-rw-r--r-- | src/clients/s6-dnsip.c | 13 | ||||
-rw-r--r-- | src/clients/s6-dnsip4.c | 13 | ||||
-rw-r--r-- | src/clients/s6-dnsip6.c | 13 | ||||
-rw-r--r-- | src/clients/s6-dnsname.c | 9 | ||||
-rw-r--r-- | src/include/s6-dns/s6dns.h | 5 | ||||
-rw-r--r-- | src/libs6dns/s6dns_hosts_compile.c | 26 | ||||
-rw-r--r-- | src/libs6dns/s6dns_hosts_compile.txt | 18 | ||||
-rw-r--r-- | src/libs6dns/s6dns_init.c | 4 |
15 files changed, 71 insertions, 65 deletions
@@ -6,7 +6,7 @@ Build Instructions - A POSIX-compliant C development environment - GNU make version 3.81 or later - - skalibs version 2.14.0.0 or later: https://skarnet.org/software/skalibs/ + - skalibs version 2.14.0.1 or later: https://skarnet.org/software/skalibs/ This software will run on any operating system that implements POSIX.1-2008, available at: @@ -1,5 +1,14 @@ Changelog for s6-dns. +In 2.3.7.0 +---------- + + - New s6dns_init_options() function, +to choose whether to support /etc/hosts or not. + - Properly ignore link-local addresses in /etc/hosts +instead of erroring out on them. + + In 2.3.6.0 ---------- diff --git a/doc/index.html b/doc/index.html index 1c3e2a2..1b5a7cb 100644 --- a/doc/index.html +++ b/doc/index.html @@ -58,7 +58,7 @@ to the s6 ecosystem. <li> A POSIX-compliant system with a standard C development environment </li> <li> GNU make, version 3.81 or later </li> <li> <a href="//skarnet.org/software/skalibs/">skalibs</a> version -2.14.0.0 or later. It's a build-time requirement. It's also a run-time +2.14.0.1 or later. It's a build-time requirement. It's also a run-time requirement if you link against the shared version of the skalibs library. </li> </ul> @@ -72,7 +72,7 @@ requirement if you link against the shared version of the skalibs library. </li> <h3> Download </h3> <ul> - <li> The current released version of s6-dns is <a href="s6-dns-2.3.6.0.tar.gz">2.3.6.0</a>. </li> + <li> The current released version of s6-dns is <a href="s6-dns-2.3.7.0.tar.gz">2.3.7.0</a>. </li> <li> Alternatively, you can checkout a copy of the <a href="//git.skarnet.org/cgi-bin/cgit.cgi/s6-dns/">s6-dns git repository</a>: diff --git a/doc/s6-dns-hosts-compile.html b/doc/s6-dns-hosts-compile.html index 537c025..2fecdc1 100644 --- a/doc/s6-dns-hosts-compile.html +++ b/doc/s6-dns-hosts-compile.html @@ -70,6 +70,11 @@ than <tt>/etc/hosts.cdb</tt>, they will not use <tt>/etc/hosts.cdb</tt> and will perform the compilation step into a temporary file. So, remember to run s6-dns-hosts-compile after modifying your <tt>/etc/hosts</tt> if you want to keep the tiny performance improvement. </li> + <li> Some tools write link-local addresses in <tt>/etc/hosts</tt> i.e. IPv6 addresses +followed by a <tt>%</tt> (percent) and a network interface name. This is nonstandard +and unusable with the DNS protocol, which does not take interface names into +account. <tt>s6-dns-hosts-compile</tt> will ignore such lines if they appear in +your hosts file. </li> </ul> </body> diff --git a/doc/upgrade.html b/doc/upgrade.html index b6c1b67..db26b1c 100644 --- a/doc/upgrade.html +++ b/doc/upgrade.html @@ -18,6 +18,13 @@ <h1> What has changed in s6-dns </h1> +<h2> in 2.3.7.0 </h2> + +<ul> + <li> <a href="//skarnet.org/software/skalibs/">skalibs</a> +dependency bumped to 2.14.0.1. </li> +</ul> + <h2> in 2.3.6.0 </h2> <ul> diff --git a/package/deps.mak b/package/deps.mak index 400420e..459e13e 100644 --- a/package/deps.mak +++ b/package/deps.mak @@ -28,11 +28,11 @@ src/caches/shibari_whitelist_add6.o src/caches/shibari_whitelist_add6.lo: src/ca src/caches/shibari_whitelist_ip4_match.o src/caches/shibari_whitelist_ip4_match.lo: src/caches/shibari_whitelist_ip4_match.c src/caches/shibari-internal.h src/caches/shibari_whitelist_ip6_match.o src/caches/shibari_whitelist_ip6_match.lo: src/caches/shibari_whitelist_ip6_match.c src/caches/shibari-internal.h src/caches/shibari_whitelist_read.o src/caches/shibari_whitelist_read.lo: src/caches/shibari_whitelist_read.c src/caches/shibari-internal.h -src/clients/s6-dnsip.o src/clients/s6-dnsip.lo: src/clients/s6-dnsip.c src/include/s6-dns/hosts.h src/include/s6-dns/s6dns-rci.h src/include/s6-dns/s6dns-resolve.h +src/clients/s6-dnsip.o src/clients/s6-dnsip.lo: src/clients/s6-dnsip.c src/include/s6-dns/s6dns.h src/clients/s6-dnsip4-filter.o src/clients/s6-dnsip4-filter.lo: src/clients/s6-dnsip4-filter.c src/include/s6-dns/s6dns-constants.h src/include/s6-dns/s6dns-message.h src/clients/s6dns-generic-filter.h -src/clients/s6-dnsip4.o src/clients/s6-dnsip4.lo: src/clients/s6-dnsip4.c src/include/s6-dns/hosts.h src/include/s6-dns/s6dns-rci.h src/include/s6-dns/s6dns-resolve.h +src/clients/s6-dnsip4.o src/clients/s6-dnsip4.lo: src/clients/s6-dnsip4.c src/include/s6-dns/s6dns.h src/clients/s6-dnsip6-filter.o src/clients/s6-dnsip6-filter.lo: src/clients/s6-dnsip6-filter.c src/include/s6-dns/s6dns-constants.h src/include/s6-dns/s6dns-message.h src/clients/s6dns-generic-filter.h -src/clients/s6-dnsip6.o src/clients/s6-dnsip6.lo: src/clients/s6-dnsip6.c src/include/s6-dns/hosts.h src/include/s6-dns/s6dns-rci.h src/include/s6-dns/s6dns-resolve.h +src/clients/s6-dnsip6.o src/clients/s6-dnsip6.lo: src/clients/s6-dnsip6.c src/include/s6-dns/s6dns.h src/clients/s6-dnsmx.o src/clients/s6-dnsmx.lo: src/clients/s6-dnsmx.c src/include/s6-dns/s6dns.h src/clients/s6-dnsname-filter.o src/clients/s6-dnsname-filter.lo: src/clients/s6-dnsname-filter.c src/include/s6-dns/s6dns-constants.h src/include/s6-dns/s6dns-domain.h src/include/s6-dns/s6dns-message.h src/clients/s6dns-generic-filter.h src/clients/s6-dnsname.o src/clients/s6-dnsname.lo: src/clients/s6-dnsname.c src/include/s6-dns/s6dns.h diff --git a/package/info b/package/info index f17f611..debd059 100644 --- a/package/info +++ b/package/info @@ -1,4 +1,4 @@ package=s6-dns -version=2.3.6.0 +version=2.3.7.0 category=web package_macro_name=S6_DNS diff --git a/src/clients/s6-dnsip.c b/src/clients/s6-dnsip.c index 68ce62b..b0d724c 100644 --- a/src/clients/s6-dnsip.c +++ b/src/clients/s6-dnsip.c @@ -12,9 +12,7 @@ #include <skalibs/tai.h> #include <skalibs/random.h> -#include <s6-dns/s6dns-rci.h> -#include <s6-dns/hosts.h> -#include <s6-dns/s6dns-resolve.h> +#include <s6-dns/s6dns.h> #define USAGE "s6-dnsip [ -q ] [ -H | -h ] [ -r ] [ -t timeout ] domain" #define dieusage() strerr_dieusage(100, USAGE) @@ -54,13 +52,8 @@ int main (int argc, char const *const *argv) if (t) tain_from_millisecs(&deadline, t) ; else deadline = tain_infinite_relative ; tain_add_g(&deadline, &deadline) ; - if (!s6dns_rci_init(&s6dns_rci_here, "/etc/resolv.conf")) - strerr_diefu1sys(111, "initialize structures from /etc/resolv.conf") ; - if (flaghosts) - { - flaghosts = s6dns_hosts_init(&s6dns_hosts_here, "/etc/hosts", "/etc/hosts.cdb", "/tmp/hosts.cdb") ; - if (flaghosts == -1) strerr_diefu1sys(111, "initialize hosts database from /etc/hosts or /etc/hosts.cdb") ; - } + if (!s6dns_init_options(flaghosts)) + strerr_diefu1sys(111, "parse /etc/resolv.conf or /etc/hosts") ; if (flaghosts) { diff --git a/src/clients/s6-dnsip4.c b/src/clients/s6-dnsip4.c index 370c006..6112e14 100644 --- a/src/clients/s6-dnsip4.c +++ b/src/clients/s6-dnsip4.c @@ -11,9 +11,7 @@ #include <skalibs/tai.h> #include <skalibs/random.h> -#include <s6-dns/s6dns-rci.h> -#include <s6-dns/hosts.h> -#include <s6-dns/s6dns-resolve.h> +#include <s6-dns/s6dns.h> #define USAGE "s6-dnsip4 [ -q ] [ -H | -h ] [ -r ] [ -t timeout ] domain" #define dieusage() strerr_dieusage(100, USAGE) @@ -53,13 +51,8 @@ int main (int argc, char const *const *argv) if (t) tain_from_millisecs(&deadline, t) ; else deadline = tain_infinite_relative ; tain_add_g(&deadline, &deadline) ; - if (!s6dns_rci_init(&s6dns_rci_here, "/etc/resolv.conf")) - strerr_diefu1sys(111, "initialize structures from /etc/resolv.conf") ; - if (flaghosts) - { - flaghosts = s6dns_hosts_init(&s6dns_hosts_here, "/etc/hosts", "/etc/hosts.cdb", "/tmp/hosts.cdb") ; - if (flaghosts == -1) strerr_diefu1sys(111, "initialize hosts database from /etc/hosts or /etc/hosts.cdb") ; - } + if (!s6dns_init_options(flaghosts)) + strerr_diefu1sys(111, "parse from /etc/resolv.conf or /etc/hosts") ; if (flaghosts) { diff --git a/src/clients/s6-dnsip6.c b/src/clients/s6-dnsip6.c index 2fb2f6f..2a7ce8b 100644 --- a/src/clients/s6-dnsip6.c +++ b/src/clients/s6-dnsip6.c @@ -11,9 +11,7 @@ #include <skalibs/tai.h> #include <skalibs/random.h> -#include <s6-dns/s6dns-rci.h> -#include <s6-dns/hosts.h> -#include <s6-dns/s6dns-resolve.h> +#include <s6-dns/s6dns.h> #define USAGE "s6-dnsip6 [ -q ] [ -H | -h ] [ -r ] [ -t timeout ] domain" #define dieusage() strerr_dieusage(100, USAGE) @@ -53,13 +51,8 @@ int main (int argc, char const *const *argv) if (t) tain_from_millisecs(&deadline, t) ; else deadline = tain_infinite_relative ; tain_add_g(&deadline, &deadline) ; - if (!s6dns_rci_init(&s6dns_rci_here, "/etc/resolv.conf")) - strerr_diefu1sys(111, "initialize structures from /etc/resolv.conf") ; - if (flaghosts) - { - flaghosts = s6dns_hosts_init(&s6dns_hosts_here, "/etc/hosts", "/etc/hosts.cdb", "/tmp/hosts.cdb") ; - if (flaghosts == -1) strerr_diefu1sys(111, "initialize hosts database from /etc/hosts or /etc/hosts.cdb") ; - } + if (!s6dns_init_options(flaghosts)) + strerr_diefu1sys(111, "parse /etc/resolv.conf or /etc/hosts") ; if (flaghosts) { diff --git a/src/clients/s6-dnsname.c b/src/clients/s6-dnsname.c index 7c35f06..6531534 100644 --- a/src/clients/s6-dnsname.c +++ b/src/clients/s6-dnsname.c @@ -67,13 +67,8 @@ int main (int argc, char const *const *argv) if (t) tain_from_millisecs(&deadline, t) ; else deadline = tain_infinite_relative ; tain_add_g(&deadline, &deadline) ; - if (!s6dns_rci_init(&s6dns_rci_here, "/etc/resolv.conf")) - strerr_diefu1sys(111, "initialize structures from /etc/resolv.conf") ; - if (flaghosts) - { - flaghosts = s6dns_hosts_init(&s6dns_hosts_here, "/etc/hosts", "/etc/hosts.cdb", "/tmp/hosts.cdb") ; - if (flaghosts == -1) strerr_diefu1sys(111, "initialize hosts database from /etc/hosts or /etc/hosts.cdb") ; - } + if (!s6dns_init_options(flaghosts)) + strerr_diefu1sys(111, "parse /etc/resolv.conf or /etc/hosts") ; if (flaghosts) { diff --git a/src/include/s6-dns/s6dns.h b/src/include/s6-dns/s6dns.h index de8c085..e19ae8d 100644 --- a/src/include/s6-dns/s6dns.h +++ b/src/include/s6-dns/s6dns.h @@ -3,6 +3,8 @@ #ifndef S6DNS_H #define S6DNS_H +#include <stdint.h> + #include <s6-dns/s6dns-constants.h> #include <s6-dns/s6dns-ip46.h> #include <s6-dns/s6dns-domain.h> @@ -13,7 +15,8 @@ #include <s6-dns/s6dns-fmt.h> #include <s6-dns/hosts.h> -extern int s6dns_init (void) ; +#define s6dns_init() s6dns_init_options(0) +extern int s6dns_init_options (uint32_t) ; extern void s6dns_finish (void) ; #endif diff --git a/src/libs6dns/s6dns_hosts_compile.c b/src/libs6dns/s6dns_hosts_compile.c index b57ffd3..0d537d7 100644 --- a/src/libs6dns/s6dns_hosts_compile.c +++ b/src/libs6dns/s6dns_hosts_compile.c @@ -144,20 +144,20 @@ static void *byipv6_dtok (uint32_t d, void *aux) static inline uint8_t cclass (char c) { - static uint8_t const ctable[128] = "09999999913111999999999999999999199299999999945977777777776999999888888888888888888888888889999898888888888888888888888888899999" ; + static uint8_t const ctable[128] = "0999999991311199999999999999999919929:999999945977777777776999999888888888888888888888888889999898888888888888888888888888899999" ; return c & 0x80 ? 9 : ctable[(uint8_t)c] - '0' ; } static int s6dns_hosts_parse (buffer *b, hostdata *hd) { - static uint8_t const table[6][10] = + static uint8_t const table[6][11] = { - { 0x0a, 0x00, 0x01, 0x00, 0x0b, 0x0b, 0x12, 0x12, 0x12, 0x0b }, - { 0x0a, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }, - { 0x2a, 0x23, 0x0b, 0x20, 0x0b, 0x12, 0x12, 0x12, 0x12, 0x0b }, - { 0x0a, 0x03, 0x01, 0x00, 0x0b, 0x0b, 0x0b, 0x0b, 0x14, 0x0b }, - { 0x4a, 0xc4, 0x0b, 0x40, 0x14, 0x14, 0x0b, 0x14, 0x14, 0x0b }, - { 0x0a, 0x05, 0x01, 0x00, 0x0b, 0x0b, 0x0b, 0x0b, 0x14, 0x0b } + { 0x0a, 0x00, 0x01, 0x00, 0x0b, 0x0b, 0x12, 0x12, 0x12, 0x0b, 0x0b }, + { 0x0a, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }, + { 0x2a, 0x23, 0x0b, 0x20, 0x0b, 0x12, 0x12, 0x12, 0x12, 0x0b, 0x21 }, + { 0x0a, 0x03, 0x01, 0x00, 0x0b, 0x0b, 0x0b, 0x0b, 0x14, 0x0b, 0x0b }, + { 0x4a, 0xc4, 0x0b, 0x40, 0x14, 0x14, 0x0b, 0x14, 0x14, 0x0b, 0x0b }, + { 0x0a, 0x05, 0x01, 0x00, 0x0b, 0x0b, 0x0b, 0x0b, 0x14, 0x0b, 0x0b } } ; node_ip *node = 0 ; size_t mark = hd->storage.len ; @@ -177,6 +177,12 @@ static int s6dns_hosts_parse (buffer *b, hostdata *hd) { char ip[16] ; if (!stralloc_0(&hd->storage)) goto err ; + if (state == 0x01) /* ignore link-local addresses */ + { + if (!ip6_scan(hd->storage.s + mark, ip)) goto errill ; + hd->storage.len = mark ; + continue ; + } if (ip6_scan(hd->storage.s + mark, ip)) { uint32_t d ; @@ -203,7 +209,7 @@ static int s6dns_hosts_parse (buffer *b, hostdata *hd) flags &= ~1 ; node = GENSETDYN_P(node_ip, &hd->ipv4, d) ; } - else goto err ; + else goto errill ; hd->storage.len = mark ; flags &= ~2 ; } @@ -268,6 +274,8 @@ static int s6dns_hosts_parse (buffer *b, hostdata *hd) if (state > 0x0a) return (errno = EILSEQ, 0) ; return 1 ; + errill: + errno = EILSEQ ; err: hostdata_free(hd) ; return 0 ; diff --git a/src/libs6dns/s6dns_hosts_compile.txt b/src/libs6dns/s6dns_hosts_compile.txt index aa71b93..cbcac26 100644 --- a/src/libs6dns/s6dns_hosts_compile.txt +++ b/src/libs6dns/s6dns_hosts_compile.txt @@ -1,25 +1,25 @@ -class | 0 1 2 3 4 5 6 7 8 9 -st\ev | \0 space # \n - . : 0-9 alpha other +class | 0 1 2 3 4 5 6 7 8 9 a +st\ev | \0 space # \n - . : 0-9 alpha other % START | p p p -00 | END START COMMENT START X X IP IP IP X +00 | END START COMMENT START X X IP IP IP X X COMMENT | -01 | END COMMENT COMMENT START COMMENT COMMENT COMMENT COMMENT COMMENT COMMENT +01 | END COMMENT COMMENT START COMMENT COMMENT COMMENT COMMENT COMMENT COMMENT COMMENT -IP | s s s p p p p -02 | END IPDONE X START X IP IP IP IP X +IP | s s s p p p p s +02 | END IPDONE X START X IP IP IP IP X COMMENT IPDONE | p -03 | END IPDONE COMMENT START X X X X NAME X +03 | END IPDONE COMMENT START X X X X NAME X X NAME | f fn f p p p p -04 | END NAMES X START NAME NAME X NAME NAME X +04 | END NAMES X START NAME NAME X NAME NAME X X NAMES | p -05 | END NAMES COMMENT START X X X X NAME X +05 | END NAMES COMMENT START X X X X NAME X X END = 0a X = 0b diff --git a/src/libs6dns/s6dns_init.c b/src/libs6dns/s6dns_init.c index 10dcbf5..5c8a25c 100644 --- a/src/libs6dns/s6dns_init.c +++ b/src/libs6dns/s6dns_init.c @@ -4,10 +4,10 @@ #include <s6-dns/hosts.h> #include <s6-dns/s6dns.h> -int s6dns_init (void) +int s6dns_init_options (uint32_t options) { 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 ; + if (options & 1 && s6dns_hosts_init(&s6dns_hosts_here, "/etc/hosts", "/etc/hosts.cdb", "/tmp/hosts.cdb") == -1) goto err ; return 1 ; err: |