]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
Drop compat "gateway" name
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 10 Dec 2020 10:10:54 +0000 (11:10 +0100)
committerLennart Poettering <lennart@poettering.net>
Thu, 10 Dec 2020 19:44:41 +0000 (20:44 +0100)
Back in 5248e7e1f11aba6859de0b28f0dd3778b22842f2 (July 2017) we moved over to
"_gateway", with the old name declared to be temporary measure. Since we're
doing a bunch of changes to resolved now, it seems to be a good moment to make
this simplification and not add support for the compat name in new code.

meson.build
meson_options.txt
src/basic/hostname-util.c
src/basic/hostname-util.h
src/resolve/resolved-dns-scope.c

index 513b841ac540bd4b010e7ab342e8dd1ddb305da7..d205f846c76d5aa004ae100a0fa4c09b08e7e597 100644 (file)
@@ -667,9 +667,6 @@ if fallback_hostname == '' or fallback_hostname[0] == '.' or fallback_hostname[0
 endif
 conf.set_quoted('FALLBACK_HOSTNAME', fallback_hostname)
 
-conf.set10('ENABLE_COMPAT_GATEWAY_HOSTNAME', get_option('compat-gateway-hostname'))
-gateway_hostnames = ['_gateway'] + (conf.get('ENABLE_COMPAT_GATEWAY_HOSTNAME') == 1 ? ['gateway'] : [])
-
 default_hierarchy = get_option('default-hierarchy')
 conf.set_quoted('DEFAULT_HIERARCHY_NAME', default_hierarchy,
                 description : 'default cgroup hierarchy as string')
@@ -3688,7 +3685,6 @@ status = [
         'nobody user name:                  @0@'.format(nobody_user),
         'nobody group name:                 @0@'.format(nobody_group),
         'fallback hostname:                 @0@'.format(get_option('fallback-hostname')),
-        'symbolic gateway hostnames:        @0@'.format(', '.join(gateway_hostnames)),
 
         'default DNSSEC mode:               @0@'.format(default_dnssec),
         'default DNS-over-TLS mode:         @0@'.format(default_dns_over_tls),
index cfe11c9ae9e1b3ce8f1de0edbae306db95c3f233..eed3596b9beb49057c1ff050481b39f1db03854f 100644 (file)
@@ -187,8 +187,6 @@ option('install-sysconfdir', type : 'boolean', value : true,
 
 option('fallback-hostname', type : 'string', value : 'localhost',
        description : 'the hostname used if none configured')
-option('compat-gateway-hostname', type : 'boolean', value : 'false',
-       description : 'allow "gateway" as the symbolic name for default gateway')
 option('default-hierarchy', type : 'combo',
        choices : ['legacy', 'hybrid', 'unified'], value : 'unified',
        description : 'default cgroup hierarchy')
index 09e49ccb7d8f78b33c4472cd265866939ee31f03..5c3157fdf20c723c217b0ac1ca7fabf8a65f128e 100644 (file)
@@ -212,20 +212,6 @@ bool is_localhost(const char *hostname) {
                 endswith_no_case(hostname, ".localhost.localdomain.");
 }
 
-bool is_gateway_hostname(const char *hostname) {
-        assert(hostname);
-
-        /* This tries to identify the valid syntaxes for the our
-         * synthetic "gateway" host. */
-
-        return
-                strcaseeq(hostname, "_gateway") || strcaseeq(hostname, "_gateway.")
-#if ENABLE_COMPAT_GATEWAY_HOSTNAME
-                || strcaseeq(hostname, "gateway") || strcaseeq(hostname, "gateway.")
-#endif
-                ;
-}
-
 int sethostname_idempotent(const char *s) {
         char buf[HOST_NAME_MAX + 1] = {};
 
index c1e47a2a53e1a690bef92d9a9437451467778222..34819c2953b571904b76062c80398a3ff5b66d6b 100644 (file)
@@ -5,6 +5,7 @@
 #include <stdio.h>
 
 #include "macro.h"
+#include "strv.h"
 
 bool hostname_is_set(void);
 
@@ -19,7 +20,11 @@ char* hostname_cleanup(char *s);
 #define machine_name_is_valid(s) hostname_is_valid(s, false)
 
 bool is_localhost(const char *hostname);
-bool is_gateway_hostname(const char *hostname);
+
+static inline bool is_gateway_hostname(const char *hostname) {
+        /* This tries to identify the valid syntaxes for the our synthetic "gateway" host. */
+        return STRCASE_IN_SET(hostname, "_gateway", "_gateway.");
+}
 
 int sethostname_idempotent(const char *s);
 
index 666aa892ea991a54deabe6e270011c4bdc7794f4..298ce21ae3f6638aeaeae1339470c8b1d7d48647 100644 (file)
@@ -522,13 +522,8 @@ DnsScopeMatch dns_scope_good_domain(
         if (dns_name_endswith(domain, "invalid") > 0)
                 return DNS_SCOPE_NO;
 
-        /* Never go to network for the _gateway domain, it's something special, synthesized locally. Note
-         * that we don't use is_gateway_hostname() here, since that has support for the legacy "gateway"
-         * hostname (without the prefix underscore), which we don't want to filter on all protocols. i.e. we
-         * don't want to filter "gateway" on classic DNS, since there might very well be such a host inside
-         * some search domain, and we shouldn't block that. We do filter it in LLMNR however (and on mDNS by
-         * side-effect, since it's a single-label name which mDNS doesn't accept anyway). */
-        if (dns_name_equal(domain, "_gateway") > 0)
+        /* Never go to network for the _gateway domain, it's something special, synthesized locally. */
+        if (is_gateway_hostname(domain))
                 return DNS_SCOPE_NO;
 
         switch (s->protocol) {