new mac update for permission issues.

This commit is contained in:
KingKDot
2026-04-13 10:49:36 -05:00
parent 66393d5ba4
commit 792de1e22c
21 changed files with 480 additions and 29 deletions
@@ -0,0 +1,64 @@
//go:build darwin
package sysinfo
import (
"os"
"os/exec"
"path/filepath"
"strings"
)
func IsAdmin() bool {
return os.Getuid() == 0
}
func Elevation() string {
if os.Getuid() == 0 {
return "admin"
}
return ""
}
func DarwinPermissions() map[string]bool {
return map[string]bool{
"screenRecording": checkScreenRecording(),
"accessibility": checkAccessibility(),
"fullDiskAccess": checkFullDiskAccess(),
"root": os.Getuid() == 0,
}
}
func checkScreenRecording() bool {
if os.Getuid() == 0 {
return true
}
exe, err := os.Executable()
if err != nil {
return false
}
if real, err := filepath.EvalSymlinks(exe); err == nil {
exe = real
}
home, err := os.UserHomeDir()
if err != nil || home == "" {
return false
}
db := filepath.Join(home, "Library", "Application Support", "com.apple.TCC", "TCC.db")
safeExe := strings.ReplaceAll(exe, "'", "''")
out, _ := exec.Command("sqlite3", db,
"SELECT auth_value FROM access WHERE service='kTCCServiceScreenCapture' AND client='"+safeExe+"' LIMIT 1",
).CombinedOutput()
return strings.TrimSpace(string(out)) == "2"
}
func checkAccessibility() bool {
err := exec.Command("osascript", "-e",
`tell application "System Events" to get name of first process`).Run()
return err == nil
}
func checkFullDiskAccess() bool {
_, err := os.ReadDir("/Library/Application Support/com.apple.TCC")
return err == nil
}
@@ -1,4 +1,4 @@
//go:build !windows
//go:build !windows && !darwin
package sysinfo
@@ -15,3 +15,7 @@ func Elevation() string {
}
return ""
}
func DarwinPermissions() map[string]bool {
return nil
}
@@ -61,3 +61,7 @@ func isTrustedInstallerSID(sid *windows.SID) bool {
}
return false
}
func DarwinPermissions() map[string]bool {
return nil
}