devbox/cmd/devbox/fda_darwin.go
shoemoney 03469958d3
Some checks are pending
CI / vet-build-test (push) Waiting to run
chore: prep for public release — MIT license + github.com module path 🌍⚖️
- LICENSE: MIT (enables the adoption push; public repo was all-rights-reserved).
- go.mod + all imports: git.shoemoney.ai/shoemoney/devbox -> github.com/shoemoney/devbox,
  so outsiders can 'go install github.com/shoemoney/devbox/cmd/devbox@latest'. Forgejo
  stays the self-hosted home; the registry (devbox-hub) + public dist (devbox-dist) are
  unchanged. vet + build + go test -race all green after the rename.
- README: document the go install path.

Security: full git-history scan (manual blob sweep + gitleaks, 84 commits) found
ZERO secrets — Forgejo token never committed, no keys/passwords/private keys.
2026-06-23 19:19:09 -05:00

56 lines
1.6 KiB
Go

//go:build darwin
package main
import (
"os"
"path/filepath"
"strings"
"github.com/shoemoney/devbox/internal/config"
)
// protectedMounts returns the local mount paths that live under a macOS TCC-
// protected directory (Desktop/Documents/Downloads/iCloud). A daemon can't sync
// these without Full Disk Access — and being a background agent, it can't even
// show the per-folder prompt, so it just silently fails until FDA is granted.
func protectedMounts(mounts []config.Mount) []string {
home, err := os.UserHomeDir()
if err != nil {
return nil
}
guarded := []string{
filepath.Join(home, "Desktop"),
filepath.Join(home, "Documents"),
filepath.Join(home, "Downloads"),
filepath.Join(home, "Library", "Mobile Documents"), // iCloud Drive
}
var out []string
for _, m := range mounts {
abs, err := filepath.Abs(m.Local)
if err != nil {
continue
}
for _, g := range guarded {
if abs == g || strings.HasPrefix(abs, g+string(os.PathSeparator)) {
out = append(out, m.Local)
break
}
}
}
return out
}
// blockedByTCC returns the protected paths this process currently CANNOT read
// (permission denied) — the honest signal that Full Disk Access is missing, since
// it tests the exact dirs we sync rather than a TCC.db probe that varies by macOS
// version. A path that reads fine, or doesn't exist yet, is not reported.
func blockedByTCC(paths []string) []string {
var blocked []string
for _, p := range paths {
if _, err := os.ReadDir(p); err != nil && os.IsPermission(err) {
blocked = append(blocked, p)
}
}
return blocked
}