bastion 0.63.1
ci / personal-data (push) Successful in 4s
ci / test (push) Successful in 4m58s
ci / fuzz (push) Successful in 3m33s

This commit is contained in:
Privatae
2026-11-03 22:56:18 +00:00
parent 2043fa5e9e
commit 48899b41a9
78 changed files with 10366 additions and 307 deletions
+35
View File
@@ -0,0 +1,35 @@
//go:build darwin
package main
import (
"os"
"os/exec"
"strings"
"syscall"
)
// anchorPolicyPlist is the machine-wide managed preference domain a
// configuration profile (MDM) installs for the bastion. The folder is root's
// and the system writes it; a file there not owned by root is not a policy.
const anchorPolicyPlist = "/Library/Managed Preferences/ai.privatae.bastion.plist"
func readAnchorPolicyOS() *anchorPolicy {
fi, err := os.Lstat(anchorPolicyPlist)
if err != nil || !fi.Mode().IsRegular() || fi.Mode().Perm()&0o022 != 0 {
return nil
}
if st, ok := fi.Sys().(*syscall.Stat_t); !ok || st.Uid != 0 {
return nil
}
// defaults reads the binary and the XML form alike.
out, err := exec.Command("/usr/bin/defaults", "read", strings.TrimSuffix(anchorPolicyPlist, ".plist"), "AnchorHost").Output()
if err != nil {
return nil
}
v := strings.TrimSpace(string(out))
if v == "" {
return nil
}
return &anchorPolicy{Host: v, Source: "the managed preference ai.privatae.bastion AnchorHost"}
}