Merge pull request #6420 from keszybz/gateway-name
Rename "gateway" to "_gateway" and other resolved changes
This commit is contained in:
@@ -196,8 +196,11 @@ bool is_gateway_hostname(const char *hostname) {
|
||||
* synthetic "gateway" host. */
|
||||
|
||||
return
|
||||
strcaseeq(hostname, "gateway") ||
|
||||
strcaseeq(hostname, "gateway.");
|
||||
strcaseeq(hostname, "_gateway") || strcaseeq(hostname, "_gateway.")
|
||||
#if ENABLE_COMPAT_GATEWAY_HOSTNAME
|
||||
|| strcaseeq(hostname, "gateway") || strcaseeq(hostname, "gateway.")
|
||||
#endif
|
||||
;
|
||||
}
|
||||
|
||||
int sethostname_idempotent(const char *s) {
|
||||
|
||||
@@ -86,7 +86,7 @@ enum nss_status _nss_myhostname_gethostbyname4_r(
|
||||
return NSS_STATUS_NOTFOUND;
|
||||
}
|
||||
|
||||
canonical = "gateway";
|
||||
canonical = "_gateway";
|
||||
|
||||
} else {
|
||||
hn = gethostname_malloc();
|
||||
@@ -356,7 +356,7 @@ enum nss_status _nss_myhostname_gethostbyname3_r(
|
||||
return NSS_STATUS_NOTFOUND;
|
||||
}
|
||||
|
||||
canonical = "gateway";
|
||||
canonical = "_gateway";
|
||||
|
||||
} else {
|
||||
hn = gethostname_malloc();
|
||||
@@ -467,7 +467,7 @@ enum nss_status _nss_myhostname_gethostbyaddr2_r(
|
||||
continue;
|
||||
|
||||
if (memcmp(addr, &a->address, FAMILY_ADDRESS_SIZE(af)) == 0) {
|
||||
canonical = "gateway";
|
||||
canonical = "_gateway";
|
||||
goto found;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -543,6 +543,14 @@ int manager_dns_stub_start(Manager *m) {
|
||||
|
||||
assert(m);
|
||||
|
||||
if (m->dns_stub_listener_mode == DNS_STUB_LISTENER_NO)
|
||||
log_debug("Not creating stub listener.");
|
||||
else
|
||||
log_debug("Creating stub listener using %s.",
|
||||
m->dns_stub_listener_mode == DNS_STUB_LISTENER_UDP ? "UDP" :
|
||||
m->dns_stub_listener_mode == DNS_STUB_LISTENER_TCP ? "TCP" :
|
||||
"UDP/TCP");
|
||||
|
||||
if (IN_SET(m->dns_stub_listener_mode, DNS_STUB_LISTENER_YES, DNS_STUB_LISTENER_UDP))
|
||||
r = manager_dns_stub_udp_fd(m);
|
||||
|
||||
|
||||
@@ -334,7 +334,7 @@ static int synthesize_gateway_ptr(Manager *m, int af, const union in_addr_union
|
||||
if (n < 0)
|
||||
return n;
|
||||
|
||||
return answer_add_addresses_ptr(answer, "gateway", addresses, n, af, address);
|
||||
return answer_add_addresses_ptr(answer, "_gateway", addresses, n, af, address);
|
||||
}
|
||||
|
||||
int dns_synthesize_answer(
|
||||
|
||||
+26
-3
@@ -1274,15 +1274,38 @@ int dns_name_apply_idna(const char *name, char **ret) {
|
||||
|
||||
#if defined(HAVE_LIBIDN2)
|
||||
int r;
|
||||
_cleanup_free_ char *t = NULL;
|
||||
|
||||
assert(name);
|
||||
assert(ret);
|
||||
|
||||
r = idn2_lookup_u8((uint8_t*) name, (uint8_t**) ret,
|
||||
r = idn2_lookup_u8((uint8_t*) name, (uint8_t**) &t,
|
||||
IDN2_NFC_INPUT | IDN2_NONTRANSITIONAL);
|
||||
if (r == IDN2_OK)
|
||||
log_debug("idn2_lookup_u8: %s → %s", name, t);
|
||||
if (r == IDN2_OK) {
|
||||
if (!startswith(name, "xn--")) {
|
||||
_cleanup_free_ char *s = NULL;
|
||||
|
||||
r = idn2_to_unicode_8z8z(t, &s, 0);
|
||||
if (r != IDN2_OK) {
|
||||
log_debug("idn2_to_unicode_8z8z(\"%s\") failed: %d/%s",
|
||||
t, r, idn2_strerror(r));
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!streq_ptr(name, s)) {
|
||||
log_debug("idn2 roundtrip failed: \"%s\" → \"%s\" → \"%s\", ignoring.",
|
||||
name, t, s);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
*ret = t;
|
||||
t = NULL;
|
||||
return 1; /* *ret has been written */
|
||||
log_debug("idn2_lookup_u8(\"%s\") failed: %s", name, idn2_strerror(r));
|
||||
}
|
||||
|
||||
log_debug("idn2_lookup_u8(\"%s\") failed: %d/%s", name, r, idn2_strerror(r));
|
||||
if (r == IDN2_2HYPHEN)
|
||||
/* The name has two hypens — forbidden by IDNA2008 in some cases */
|
||||
return 0;
|
||||
|
||||
@@ -652,6 +652,12 @@ static void test_dns_name_apply_idna(void) {
|
||||
test_dns_name_apply_idna_one("föö.bär.", ret, "xn--f-1gaa.xn--br-via");
|
||||
test_dns_name_apply_idna_one("xn--f-1gaa.xn--br-via", ret, "xn--f-1gaa.xn--br-via");
|
||||
|
||||
test_dns_name_apply_idna_one("_443._tcp.fedoraproject.org", ret2,
|
||||
"_443._tcp.fedoraproject.org");
|
||||
test_dns_name_apply_idna_one("_443", ret2, "_443");
|
||||
test_dns_name_apply_idna_one("gateway", ret, "gateway");
|
||||
test_dns_name_apply_idna_one("_gateway", ret2, "_gateway");
|
||||
|
||||
test_dns_name_apply_idna_one("r3---sn-ab5l6ne7.googlevideo.com", ret2,
|
||||
ret2 ? "r3---sn-ab5l6ne7.googlevideo.com" : "");
|
||||
}
|
||||
|
||||
+1
-1
@@ -491,7 +491,7 @@ static int parse_argv(int argc, char **argv,
|
||||
if (!hostname)
|
||||
return -ENOMEM;
|
||||
|
||||
names = strv_new("localhost", "gateway", "foo_no_such_host", hostname, NULL);
|
||||
names = strv_new("localhost", "_gateway", "foo_no_such_host", hostname, NULL);
|
||||
if (!names)
|
||||
return -ENOMEM;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user