mirror of
https://github.com/rwinkhart/peercred-mini.git
synced 2026-09-03 15:47:31 -04:00
Add FreeBSD support
For FreeBSD 12.2 and before I think we could use SCM_CREDS to get the pid of the peer. For FreeBSD 13.x and later, the Xucred is extended with a pid. For now we'll leave it unimplemented and expect to add FreeBSD 13+ support whern it is released. Signed-off-by: Denton Gentry <dgentry@tailscale.com>
This commit is contained in:
committed by
Denton Gentry
parent
88448a8ba5
commit
6ba7dd52e8
+13
-7
@@ -3,7 +3,7 @@
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build go1.15
|
||||
// +build linux darwin
|
||||
// +build linux darwin freebsd
|
||||
|
||||
package peercred // import "inet.af/peercred"
|
||||
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
"net"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"testing"
|
||||
)
|
||||
|
||||
@@ -59,11 +60,16 @@ func TestUnixSock(t *testing.T) {
|
||||
t.Errorf("UID = %q; want %q", got, want)
|
||||
}
|
||||
pid, ok := creds.PID()
|
||||
if !ok {
|
||||
t.Errorf("no PID")
|
||||
if runtime.GOOS == "freebsd" {
|
||||
if ok {
|
||||
t.Error("PID ok; want !ok. Thank you for fixing FreeBSD, please update the test.")
|
||||
}
|
||||
} else {
|
||||
if !ok {
|
||||
t.Errorf("no PID")
|
||||
}
|
||||
if got, want := pid, os.Getpid(); got != want {
|
||||
t.Errorf("PID = %v; want %v", got, want)
|
||||
}
|
||||
}
|
||||
if got, want := pid, os.Getpid(); got != want {
|
||||
t.Errorf("PID = %v; want %v", got, want)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user