mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
syscall: handle getsockname for unix sockets on openbsd 5.2
On OpenBSD 5.2, calling getsockname on an unbound Unix domain socket results in a successful syscall, however the AF is unset and the length is returned as zero. This has been changed to more portable behaviour, which will be included in the OpenBSD 5.3 release. For now, work around this by treating a successful getsockname() call that returns a family of AF_UNSPEC and length of zero as a AF_UNIX socket. Makes TestPassFD work on OpenBSD 5.2. Fixes #4956. R=golang-dev, minux.ma, rsc, mikioh.mikioh CC=golang-dev https://golang.org/cl/7449046
This commit is contained in:
parent
add3349867
commit
1b36bcc3b5
2 changed files with 5 additions and 4 deletions
|
|
@ -327,6 +327,11 @@ func Getsockname(fd int) (sa Sockaddr, err error) {
|
|||
if err = getsockname(fd, &rsa, &len); err != nil {
|
||||
return
|
||||
}
|
||||
// TODO(jsing): Remove after OpenBSD 5.4 is released (see issue 3349).
|
||||
if runtime.GOOS == "openbsd" && rsa.Addr.Family == AF_UNSPEC && rsa.Addr.Len == 0 {
|
||||
rsa.Addr.Family = AF_UNIX
|
||||
rsa.Addr.Len = SizeofSockaddrUnix
|
||||
}
|
||||
return anyToSockaddr(&rsa)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue