diff --git a/sandbox/agent b/sandbox/agent index 7c58ec6..fc81360 100755 --- a/sandbox/agent +++ b/sandbox/agent @@ -75,11 +75,17 @@ for file in "$USER_CONFIG/base.json" "$USER_CONFIG/$profile.json"; do [ -f "$file" ] && configs+=("$file") done -# Outside the folders the agent may change, so it can't change its own rules. -# Named after this process, as srt replaces it (exec below) and nothing is -# left to remove it afterwards; files whose process has ended are removed here. -SETTINGS_DIR="${TMPDIR:-/tmp}/federated-sandbox" -mkdir -m 700 "$SETTINGS_DIR" 2> /dev/null || [ -d "$SETTINGS_DIR" ] || exit 1 +# Outside the folders the agent may change (or read), so it can't change its +# own rules; not in macOS' temp folder, which it may change (below). Named +# after this process, as srt replaces it (exec below) and nothing is left to +# remove it afterwards; files whose process has ended are removed here. +SETTINGS_DIR="$HOME/Library/Application Support/Federated Connector/sandbox-settings" +mkdir -p -m 700 "$SETTINGS_DIR" 2> /dev/null || [ -d "$SETTINGS_DIR" ] || exit 1 + +# macOS' mktemp, and other macOS tools, use your temp folder in /var/folders +# rather than TMPDIR (which srt points at one of its own), so the agent may +# change that folder too +USER_TEMP="$(getconf DARWIN_USER_TEMP_DIR 2> /dev/null)" for old in "$SETTINGS_DIR"/*.json; do pid="${old%.json}" pid="${pid##*.}" @@ -111,13 +117,18 @@ function run(argv) { return a; } var out = argv[0], domains = argv[1].split(" ").filter(function (d) { return d; }); - var config = argv.slice(2).reduce(function (c, path) { return merge(c, read(path)); }, {}); + var userTemp = argv[2]; + var config = argv.slice(3).reduce(function (c, path) { return merge(c, read(path)); }, {}); config.network = config.network || {}; merge(config.network, {allowedDomains: domains}); + if (userTemp) { + config.filesystem = config.filesystem || {}; + merge(config.filesystem, {allowWrite: [userTemp.replace(/\/$/, "")]}); + } if (!$(JSON.stringify(config, null, 2)).writeToFileAtomicallyEncodingError(out, true, $.NSUTF8StringEncoding, null)) { throw new Error("could not write " + out); } -}' "$settings" "$FEDERATED_SANDBOX_DOMAINS" "${configs[@]}" > /dev/null; then +}' "$settings" "$FEDERATED_SANDBOX_DOMAINS" "$USER_TEMP" "${configs[@]}" > /dev/null; then echo "Couldn't read the sandbox config: ${configs[*]}" exit 1 fi diff --git a/smoketest/README.md b/smoketest/README.md index 1472d5b..772983d 100644 --- a/smoketest/README.md +++ b/smoketest/README.md @@ -65,7 +65,7 @@ Each scenario runs on a fresh clone of Cirrus Labs' **vanilla** macOS image (def macOS deliberately allows these only with a click, so test them by hand on a VM (`--keep`) or a Mac. Each scenario notes which apply to it as a `skip` line. - **Installing the profile:** in System Settings > Profiles, choose "Federated Core (...)", then Install. Then check Mail, Calendar and Contacts against a real Core. `configure core` notices the profile was installed. -- **Full Disk Access for Federated Backup:** after granting it, `configure backup` says it can read all your files, and the backup log no longer has permission errors for Documents and Desktop. +- **Full Disk Access for Federated Backup:** after granting it, `configure backup` says it can read all your files, and the next backup includes Desktop, Documents and Downloads, which it leaves out without Full Disk Access (as macOS would otherwise stop it with a prompt). - **Turning on macFUSE's file system extension**, if `85-sftp` couldn't do it with `pluginkit`: then mount an SFTP folder with `configure storage`. With the extension off, `85-sftp` checks that `add_sftp` gives up after 30 seconds rather than hanging. - **Mounting a real SMB share:** the sign-in window, "Remember this password in my keychain", and whether `mount volume "smb://host"` without a share offers a list of shares. - **Tailscale's VPN approval**, and **Nextcloud's sign-in** in the browser. diff --git a/smoketest/scenarios/60-backup.sh b/smoketest/scenarios/60-backup.sh index f023a6a..8ef236f 100644 --- a/smoketest/scenarios/60-backup.sh +++ b/smoketest/scenarios/60-backup.sh @@ -4,7 +4,8 @@ TIER=quick source "$CONNECTOR/configure.d/20-backup.sh" DAV="$HOME/davroot" -SMOKE_FILE="$HOME/Documents/smoke-file.txt" +# Outside Documents, which a backup without Full Disk Access leaves out +SMOKE_FILE="$HOME/Projects/smoke-file.txt" ran() { grep -qE 'Backup (finished|failed)' "$BACKUP_LOG" 2> /dev/null diff --git a/system/backup b/system/backup index d079622..97e10f4 100755 --- a/system/backup +++ b/system/backup @@ -142,6 +142,21 @@ excludes=( # Element's search index for encrypted messages, which it rebuilds "$L/Application Support/Element/EventStore" ) +# Without Full Disk Access, reading these makes macOS ask you, and restic +# waits for the answer, which no one gives at night; the rest that Full Disk +# Access guards (Mail, Messages, Safari...) is just refused +if ! full_disk_access; then + excludes+=( + "$HOME/Desktop" + "$HOME/Documents" + "$HOME/Downloads" + "$L/Containers" + "$L/Group Containers" + # Photos asks too + "$L/Photos" + "$HOME/Pictures/*.photoslibrary" + ) +fi exclude_args=(--exclude-caches) for path in "${excludes[@]}"; do exclude_args+=(--exclude "$path")