nss-resolve: don't set scopeindex for non-link-local addresses
Apparently some apps don't like that. And given that this isn't necessary for link-local addresses, let's suppress this information. Fixes: #4465
This commit is contained in:
parent
28830a6410
commit
27007efff6
|
@ -110,6 +110,20 @@ static int count_addresses(sd_bus_message *m, int af, const char **canonical) {
|
|||
return c;
|
||||
}
|
||||
|
||||
static uint32_t ifindex_to_scopeid(int family, const void *a, int ifindex) {
|
||||
struct in6_addr in6;
|
||||
|
||||
if (family != AF_INET6)
|
||||
return 0;
|
||||
|
||||
/* Some apps can't deal with the scope ID attached to non-link-local addresses. Hence, let's suppress that. */
|
||||
|
||||
assert(sizeof(in6) == FAMILY_ADDRESS_SIZE(AF_INET));
|
||||
memcpy(&in6, a, sizeof(struct in6_addr));
|
||||
|
||||
return IN6_IS_ADDR_LINKLOCAL(&in6) ? ifindex : 0;
|
||||
}
|
||||
|
||||
enum nss_status _nss_resolve_gethostbyname4_r(
|
||||
const char *name,
|
||||
struct gaih_addrtuple **pat,
|
||||
|
@ -245,7 +259,7 @@ enum nss_status _nss_resolve_gethostbyname4_r(
|
|||
r_tuple->next = i == c-1 ? NULL : (struct gaih_addrtuple*) ((char*) r_tuple + ALIGN(sizeof(struct gaih_addrtuple)));
|
||||
r_tuple->name = r_name;
|
||||
r_tuple->family = family;
|
||||
r_tuple->scopeid = ifindex;
|
||||
r_tuple->scopeid = ifindex_to_scopeid(family, a, ifindex);
|
||||
memcpy(r_tuple->addr, a, sz);
|
||||
|
||||
idx += ALIGN(sizeof(struct gaih_addrtuple));
|
||||
|
|
Loading…
Reference in New Issue