mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-07-04 01:07:49 +02:00
fix(metadata): detect login user via logname when running under sudo
On Darwin 26.2+, sudo no longer preserves SUDO_USER, LOGNAME, and USER (CVE-2025-43416), so env-based detection fails. Use the logname(1) command on Unix first, then fall back to environment variables and user.Current() so the real login user is still reported correctly.
This commit is contained in:
committed by
Cuong Manh Le
parent
3f30ec30d8
commit
40c68a13a1
@@ -2,10 +2,14 @@ package ctrld
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func Test_metadata(t *testing.T) {
|
||||
m := SystemMetadata(context.Background())
|
||||
t.Logf("metadata: %v", m)
|
||||
t.Logf("SUDO_USER: %s", os.Getenv("SUDO_USER"))
|
||||
t.Logf("LOGNAME: %s", os.Getenv("LOGNAME"))
|
||||
t.Logf("USER: %s", os.Getenv("USER"))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user