mirror of
https://github.com/golang/sys.git
synced 2026-02-08 19:56:04 +03:00
unix: check gid in TestGetsockoptXucred
macOS (and the BSDs) report all groups in Xucred, the first one being the GID. Also use Socketpair/Close from golang.org/x/sys/unix instead of package syscall. Change-Id: I9319ff2b5258f66afc24e3e80c704d816e995dbf Reviewed-on: https://go-review.googlesource.com/c/sys/+/293569 Trust: Tobias Klauser <tobias.klauser@gmail.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
committed by
Tobias Klauser
parent
beda7e5e15
commit
8ebf48af03
@@ -10,7 +10,6 @@ import (
|
||||
"net"
|
||||
"os"
|
||||
"path"
|
||||
"syscall"
|
||||
"testing"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
@@ -221,12 +220,12 @@ func TestFcntlFstore(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetsockoptXucred(t *testing.T) {
|
||||
fds, err := syscall.Socketpair(syscall.AF_LOCAL, syscall.SOCK_STREAM, 0)
|
||||
fds, err := unix.Socketpair(unix.AF_LOCAL, unix.SOCK_STREAM, 0)
|
||||
if err != nil {
|
||||
t.Fatalf("Socketpair: %v", err)
|
||||
}
|
||||
defer syscall.Close(fds[0])
|
||||
defer syscall.Close(fds[1])
|
||||
defer unix.Close(fds[0])
|
||||
defer unix.Close(fds[1])
|
||||
|
||||
srvFile := os.NewFile(uintptr(fds[0]), "server")
|
||||
defer srvFile.Close()
|
||||
@@ -252,4 +251,9 @@ func TestGetsockoptXucred(t *testing.T) {
|
||||
if got, want := cred.Uid, os.Getuid(); int(got) != int(want) {
|
||||
t.Errorf("uid = %v; want %v", got, want)
|
||||
}
|
||||
if cred.Ngroups > 0 {
|
||||
if got, want := cred.Groups[0], os.Getgid(); int(got) != int(want) {
|
||||
t.Errorf("gid = %v; want %v", got, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user