]> Cypherpunks repositories - gostls13.git/commitdiff
net: handle correctly the _gateway and _outbound hostnames for nss myhostname
authorMateusz Poliwczak <mpoliwczak34@gmail.com>
Fri, 11 Nov 2022 07:34:15 +0000 (07:34 +0000)
committerGopher Robot <gobot@golang.org>
Fri, 11 Nov 2022 21:19:21 +0000 (21:19 +0000)
Fixes #56387

Change-Id: If412134344600caefec425699398522399986d4d
GitHub-Last-Rev: f33540ef8f90e9a8c09f3947aba8c01155516d39
GitHub-Pull-Request: golang/go#56388
Reviewed-on: https://go-review.googlesource.com/c/go/+/445075
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

src/net/conf.go
src/net/conf_test.go

index 6854f466581659b613b404f7ebe8b73e17bacf94..77099ca100bbc1628dbe991dc919dcc586732108 100644 (file)
@@ -241,7 +241,7 @@ func (c *conf) hostLookupOrder(r *Resolver, hostname string) (ret hostLookupOrde
        var first string
        for _, src := range srcs {
                if src.source == "myhostname" {
-                       if isLocalhost(hostname) || isGateway(hostname) {
+                       if isLocalhost(hostname) || isGateway(hostname) || isOutbound(hostname) {
                                return fallbackOrder
                        }
                        hn, err := getHostname()
@@ -343,5 +343,11 @@ func isLocalhost(h string) bool {
 // isGateway reports whether h should be considered a "gateway"
 // name for the myhostname NSS module.
 func isGateway(h string) bool {
-       return stringsEqualFold(h, "gateway")
+       return stringsEqualFold(h, "_gateway")
+}
+
+// isOutbound reports whether h should be considered a "outbound"
+// name for the myhostname NSS module.
+func isOutbound(h string) bool {
+       return stringsEqualFold(h, "_outbound")
 }
index 86fc4797b95e197852e03c6d016944b4e0353680..c059c3670a6fe1e795798b6082fe5048eb17a6c6 100644 (file)
@@ -271,8 +271,10 @@ func TestConfHostLookupOrder(t *testing.T) {
                                {"myHostname", "myhostname", hostLookupCgo},
                                {"myhostname.dot", "myhostname.dot", hostLookupCgo},
                                {"myHostname.dot", "myhostname.dot", hostLookupCgo},
-                               {"gateway", "myhostname", hostLookupCgo},
-                               {"Gateway", "myhostname", hostLookupCgo},
+                               {"_gateway", "myhostname", hostLookupCgo},
+                               {"_Gateway", "myhostname", hostLookupCgo},
+                               {"_outbound", "myhostname", hostLookupCgo},
+                               {"_Outbound", "myhostname", hostLookupCgo},
                                {"localhost", "myhostname", hostLookupCgo},
                                {"Localhost", "myhostname", hostLookupCgo},
                                {"anything.localhost", "myhostname", hostLookupCgo},