forked from termux/termux-packages
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
golang: Fix hardcoded
/etc/resolv.conf
and friends
- Loading branch information
Showing
4 changed files
with
113 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
--- a/src/net/conf.go | ||
+++ b/src/net/conf.go | ||
@@ -2,7 +2,7 @@ | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
-//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris | ||
+//go:build aix || darwin || dragonfly || freebsd || (linux && !android) || netbsd || openbsd || solaris | ||
|
||
package net | ||
|
||
--- a/src/net/conf_android.go | ||
+++ b/src/net/conf_android.go | ||
@@ -2,7 +2,7 @@ | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
-//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris | ||
+//go:build android | ||
|
||
package net | ||
|
||
@@ -95,10 +95,10 @@ | ||
} | ||
|
||
if runtime.GOOS != "openbsd" { | ||
- confVal.nss = parseNSSConfFile("/etc/nsswitch.conf") | ||
+ confVal.nss = parseNSSConfFile("@TERMUX_PREFIX@/etc/nsswitch.conf") | ||
} | ||
|
||
- confVal.resolv = dnsReadConfig("/etc/resolv.conf") | ||
+ confVal.resolv = dnsReadConfig("@TERMUX_PREFIX@/etc/resolv.conf") | ||
if confVal.resolv.err != nil && !os.IsNotExist(confVal.resolv.err) && | ||
!os.IsPermission(confVal.resolv.err) { | ||
// If we can't read the resolv.conf file, assume it | ||
@@ -108,7 +108,7 @@ | ||
confVal.forceCgoLookupHost = true | ||
} | ||
|
||
- if _, err := os.Stat("/etc/mdns.allow"); err == nil { | ||
+ if _, err := os.Stat("@TERMUX_PREFIX@/etc/mdns.allow"); err == nil { | ||
confVal.hasMDNSAllow = true | ||
} | ||
} | ||
--- a/src/net/dnsclient_unix.go | ||
+++ b/src/net/dnsclient_unix.go | ||
@@ -2,7 +2,7 @@ | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
-//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris | ||
+//go:build aix || darwin || dragonfly || freebsd || (linux && !android) || netbsd || openbsd || solaris | ||
|
||
// DNS client: see RFC 1035. | ||
// Has to be linked into package net for Dial. | ||
--- a/src/net/dnsclient_android.go | ||
+++ b/src/net/dnsclient_android.go | ||
@@ -2,7 +2,7 @@ | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
-//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris | ||
+//go:build android | ||
|
||
// DNS client: see RFC 1035. | ||
// Has to be linked into package net for Dial. | ||
@@ -338,7 +338,7 @@ | ||
// resolv.conf twice the first time. | ||
conf.dnsConfig = systemConf().resolv | ||
if conf.dnsConfig == nil { | ||
- conf.dnsConfig = dnsReadConfig("/etc/resolv.conf") | ||
+ conf.dnsConfig = dnsReadConfig("@TERMUX_PREFIX@/etc/resolv.conf") | ||
} | ||
conf.lastChecked = time.Now() | ||
|
||
@@ -401,7 +401,7 @@ | ||
// For consistency with libc resolvers, report no such host. | ||
return dnsmessage.Parser{}, "", &DNSError{Err: errNoSuchHost.Error(), Name: name, IsNotFound: true} | ||
} | ||
- resolvConf.tryUpdate("/etc/resolv.conf") | ||
+ resolvConf.tryUpdate("@TERMUX_PREFIX@/etc/resolv.conf") | ||
resolvConf.mu.RLock() | ||
conf := resolvConf.dnsConfig | ||
resolvConf.mu.RUnlock() | ||
@@ -578,7 +578,7 @@ | ||
// See comment in func lookup above about use of errNoSuchHost. | ||
return nil, dnsmessage.Name{}, &DNSError{Err: errNoSuchHost.Error(), Name: name, IsNotFound: true} | ||
} | ||
- resolvConf.tryUpdate("/etc/resolv.conf") | ||
+ resolvConf.tryUpdate("@TERMUX_PREFIX@/etc/resolv.conf") | ||
resolvConf.mu.RLock() | ||
conf := resolvConf.dnsConfig | ||
resolvConf.mu.RUnlock() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
for f in src/net/conf_android.go src/net/dnsclient_android.go; do | ||
if [ -e "${f}" ]; then | ||
termux_error_exit "Error: file ${f} already exists." | ||
fi | ||
done | ||
|
||
cp -T src/net/conf.go src/net/conf_android.go | ||
cp -T src/net/dnsclient_unix.go src/net/dnsclient_android.go | ||
|
||
sed -e "s|@TERMUX_PREFIX@|$TERMUX_PREFIX|" \ | ||
${TERMUX_SCRIPTDIR}/packages/golang/fix-hardcoded-etc-resolv-conf.diff \ | ||
| patch --silent -p1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters