Commit Graph

8 Commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek 5248e7e1f1 resolved,nss-myhostname: use _gateway for the gateway
This changes the symbolic name for the default gateway from "gateway" to
"_gateway". A new configuration option -Dcompat-gateway-hostname=true|false
is added. If it is set, the old name is also supported, but the new name
is used as the canonical name in either case. This is intended as a temporary
measure to make the transition easier, and the option should be removed
after a few releases, at which point only the new name will be used.

The old "gateway" name mostly works OK, but hasn't gained widespread acceptance
because of the following (potential) conflicts:
- it is completely legal to have a host called "gateway"
- there is no guarantee that "gateway" will not be registered as a TLD, even
  though this currently seems unlikely. (Even then, there would be no
  conflict except for the case when the top-level domain itself was being resolved.
  The "gateway" or "_gateway" labels have only special meaning when the
  whole name consists of a single label, so resolution of any subdomain
  of the hypothetical gateway. TLD would still work OK. )
Moving to "_gateway" avoids those issues because underscores are not allowed
in host names (RFC 1123, §2.1) and avoids potential conflicts with local or
global names.

v2:
- simplify the logic to hardcode "_gateway" and allow
  -Dcompat-gateway-hostname=true as a temporary measure.
2017-07-31 14:41:56 -04:00
Zbigniew Jędrzejewski-Szmek 25f027c5ef tree-wide: when %m is used in log_*, always specify errno explicitly
All those uses were correct, but I think it's better to be explicit.
Using implicit errno is too error prone, and with this change we can require
(in the sense of a style guideline) that the code is always specified.

Helpful query: git grep -n -P 'log_[^s][a-z]+\(.*%m'
2017-05-19 14:24:03 -04:00
Zbigniew Jędrzejewski-Szmek 3762b6722e test-nss: fix loading of modules under meson
There is no .libs dirs under meson. Just try both paths.
2017-04-23 21:47:28 -04:00
Philip Withnall 6a909d41e1 test: Fix a maybe-uninitialised compiler warning (#5269)
The compiler warning is a false positive, since n_addresses is always
initialised on the success path from parse_argv(), but the compiler
obviously can’t work that out.

Fixes:
   src/test/test-nss.c:426:9: warning: 'n_addresses' may be used uninitialized in this function [-Wmaybe-uninitialized]
2017-02-08 16:53:01 +01:00
Zbigniew Jędrzejewski-Szmek 9f7672b3bc test-nss: allow the module and names/addresses to be specified (#4258)
Useful for testing a single module. If nothing is specified, behaviour is the
same as before.

$ ./test-nss myhostname 192.168.0.14 localhost
======== myhostname ========
_nss_myhostname_gethostbyname4_r("localhost") → status=NSS_STATUS_SUCCESS
                   pat=buffer+0x38 errno=0/--- h_errno=0/Resolver Error 0 (no error) ttl=0
        "localhost" AF_INET 127.0.0.1 %lo
        "localhost" AF_INET6 ::1 %lo

_nss_myhostname_gethostbyname3_r("localhost", AF_INET) → status=NSS_STATUS_SUCCESS
                   errno=0/--- h_errno=0/Resolver Error 0 (no error) ttl=0
        "localhost"
        AF_INET 127.0.0.1
        canonical: "localhost"

_nss_myhostname_gethostbyname3_r("localhost", AF_INET6) → status=NSS_STATUS_SUCCESS
                   errno=0/--- h_errno=0/Resolver Error 0 (no error) ttl=0
        "localhost"
        AF_INET6 ::1
        canonical: "localhost"

_nss_myhostname_gethostbyname3_r("localhost", *) → status=NSS_STATUS_SUCCESS
                   errno=0/--- h_errno=0/Resolver Error 0 (no error) ttl=0
        "localhost"
        AF_INET 127.0.0.1
        canonical: "localhost"

_nss_myhostname_gethostbyname3_r("localhost", AF_UNIX) → status=NSS_STATUS_UNAVAIL
                   errno=97/EAFNOSUPPORT h_errno=4/No address associated with name ttl=2147483647

_nss_myhostname_gethostbyname2_r("localhost", AF_INET) → status=NSS_STATUS_SUCCESS
                   errno=0/--- h_errno=0/Resolver Error 0 (no error)
        "localhost"
        AF_INET 127.0.0.1

_nss_myhostname_gethostbyname2_r("localhost", AF_INET6) → status=NSS_STATUS_SUCCESS
                   errno=0/--- h_errno=0/Resolver Error 0 (no error)
        "localhost"
        AF_INET6 ::1

_nss_myhostname_gethostbyname2_r("localhost", *) → status=NSS_STATUS_SUCCESS
                   errno=0/--- h_errno=0/Resolver Error 0 (no error)
        "localhost"
        AF_INET 127.0.0.1

_nss_myhostname_gethostbyname2_r("localhost", AF_UNIX) → status=NSS_STATUS_UNAVAIL
                   errno=97/EAFNOSUPPORT h_errno=4/No address associated with name

_nss_myhostname_gethostbyname_r("localhost") → status=NSS_STATUS_SUCCESS
                   errno=0/--- h_errno=0/Resolver Error 0 (no error)
        "localhost"
        AF_INET 127.0.0.1

_nss_myhostname_gethostbyaddr2_r("192.168.0.14") → status=NSS_STATUS_SUCCESS
                   errno=0/--- h_errno=0/Resolver Error 0 (no error) ttl=0
        "laptop"
        AF_INET 192.168.0.14
        AF_INET 192.168.122.1
        AF_INET 169.254.209.76

_nss_myhostname_gethostbyaddr_r("192.168.0.14") → status=NSS_STATUS_SUCCESS
                   errno=0/--- h_errno=0/Resolver Error 0 (no error)
        "laptop"
        AF_INET 192.168.0.14
        AF_INET 192.168.122.1
        AF_INET 169.254.209.76
2016-11-11 13:39:20 +01:00
Lennart Poettering 8e38570ebe tree-wide: htonl() is weird, let's use htobe32() instead (#3538)
Super-important change, yeah!
2016-06-15 01:26:01 +02:00
Martin Pitt 48062f072c build: fix test-nss.c build failure with --disable-{resolved,myhostname} (#3081)
When building without resolved and/or myhostname, test-nss.c failed to build
with

  src/test/test-nss.c: In function 'main':
  src/test/test-nss.c:417:32: error: 'MODULE1' undeclared (first use in this function)
           NULSTR_FOREACH(module, MODULE1 MODULE2 MODULE3 MODULE4) {
                                ^

Ensure that all MODULEx are always defined, and empty if the module is not
available (so that it will be a no-op in the string concatenation).
2016-04-21 12:13:08 +02:00
Zbigniew Jędrzejewski-Szmek 2abb5b3b10 test-nss: test the resolution of various names
nss-dns is also "tested". It should be almost always available,
and provides a reference for comparison.
2016-04-05 23:19:56 -04:00