Skip to content

net: nss myhostname incorrectly handles gateway and outbound hostnames #56387

@mateusz834

Description

@mateusz834

nss-myhostname(8):

•The hostname "_gateway" is resolved to all current default routing gateway addresses, ordered by their metric. (...)
•The hostname "_outbound" is resolved to the local IPv4 and IPv6 addresses that are most likely used for communication with other hosts. (...)

But it only checks for the "gateway" hostname which is incorrect, it should check for "_gateway" (as defined in man page), and _outbound.

go/src/net/conf.go

Lines 249 to 251 in 7e72d38

if isLocalhost(hostname) || isGateway(hostname) {
return fallbackOrder
}

go/src/net/conf.go

Lines 348 to 352 in 7e72d38

// isGateway reports whether h should be considered a "gateway"
// name for the myhostname NSS module.
func isGateway(h string) bool {
return stringsEqualFold(h, "gateway")
}

package main

import (
	"fmt"
	"net"
)

func main() {
	fmt.Println(net.LookupHost("localhost"))
	fmt.Println(net.LookupHost("_gateway"))
	fmt.Println(net.LookupHost("_outbound"))
}
[mateusz@arch testtt]$  GODEBUG=netdns=2 go run main.go
go package net: confVal.netCgo = false  netGo = false
go package net: dynamic selection of DNS resolver
go package net: hostLookupOrder(localhost) = cgo
[::1 127.0.0.1] <nil>
go package net: hostLookupOrder(_gateway) = files,dns
[] lookup _gateway on 81.26.0.10:53: no such host
go package net: hostLookupOrder(_outbound) = files,dns
[] lookup _outbound on 81.26.0.10:53: no such host

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions