mirror of
https://github.com/netbirdio/netbird.git
synced 2026-04-19 08:46:38 +00:00
36 lines
727 B
Go
36 lines
727 B
Go
//go:build darwin && !ios
|
|
|
|
package system
|
|
|
|
import (
|
|
"context"
|
|
"os/exec"
|
|
"strings"
|
|
"time"
|
|
|
|
log "github.com/sirupsen/logrus"
|
|
)
|
|
|
|
// detectDiskEncryption detects FileVault encryption status on macOS.
|
|
func detectDiskEncryption(ctx context.Context) DiskEncryptionInfo {
|
|
info := DiskEncryptionInfo{}
|
|
|
|
cmdCtx, cancel := context.WithTimeout(ctx, 5*time.Second)
|
|
defer cancel()
|
|
|
|
cmd := exec.CommandContext(cmdCtx, "fdesetup", "status")
|
|
output, err := cmd.Output()
|
|
if err != nil {
|
|
log.Debugf("execute fdesetup: %v", err)
|
|
return info
|
|
}
|
|
|
|
encrypted := strings.Contains(string(output), "FileVault is On")
|
|
info.Volumes = append(info.Volumes, DiskEncryptionVolume{
|
|
Path: "/",
|
|
Encrypted: encrypted,
|
|
})
|
|
|
|
return info
|
|
}
|