From 4b46f2b70cd40834334d484dfdd55456e8caa72f Mon Sep 17 00:00:00 2001 From: shirou Date: Tue, 10 Oct 2023 23:05:52 +0900 Subject: [PATCH] [host][darwin]: fix Users --- host/host_darwin.go | 3 +++ host/host_test.go | 1 + 2 files changed, 4 insertions(+) diff --git a/host/host_darwin.go b/host/host_darwin.go index f045d4f17..873ed4aee 100644 --- a/host/host_darwin.go +++ b/host/host_darwin.go @@ -64,6 +64,9 @@ func UsersWithContext(ctx context.Context) ([]UserStat, error) { return ret, err } + // Skip macOS utmpx header part + buf = buf[604:] + u := Utmpx{} entrySize := int(unsafe.Sizeof(u)) count := len(buf) / entrySize diff --git a/host/host_test.go b/host/host_test.go index 17ced6dac..0aa092598 100644 --- a/host/host_test.go +++ b/host/host_test.go @@ -89,6 +89,7 @@ func TestUsers(t *testing.T) { if u == empty { t.Errorf("Could not Users %v", v) } + t.Log(u) } }