My solution is a totally hacky workaround, but doesn't require whitelisting bash
entirely. Update: Slightly less hacky workaround below.
UPDATE:
After some preliminary testing, it looks like a slightly less hacky workaround is to compile a binary (using a compiled language) that calls your bash script. Add that binary to FDA and it seems to work. Add to the root-owned /Library/LaunchDaemons
plist, and you have a way to call it from root
without all the craziness above`.
Example script in Go:
// Runrestic provides a binary to run my restic backup script in MacOS Mojave with Full Disk Access
package main
import (
"log"
"os"
"os/exec"
"path/filepath"
)
func main() {
ex, err := os.Executable()
if err != nil {
log.Fatal(err)
}
dir := filepath.Dir(ex)
script := filepath.Join(dir, "restic-backup.sh")
cmd := exec.Command("/usr/local/bin/bash", script)
if err := cmd.Run(); err != nil {
log.Fatal(err)
}
}
For security, I sudo chown root
and sudo chmod 0700
the resulting binary before adding to Full Disk Access
(although admittedly an attacker could just change the bash script that this calls if it were left undetected).