fix(heal): restore Rosetta access on intact installations
This commit is contained in:
@@ -8,6 +8,10 @@ heal_suppress() {
|
|||||||
local hosts="${data_mount}/private/etc/hosts"
|
local hosts="${data_mount}/private/etc/hosts"
|
||||||
local ldp="${data_mount}/private/var/db/com.apple.xpc.launchd/disabled.plist"
|
local ldp="${data_mount}/private/var/db/com.apple.xpc.launchd/disabled.plist"
|
||||||
|
|
||||||
|
if [ "$DRY_RUN" != true ] && [ -f "$hosts" ]; then
|
||||||
|
_restore_rosetta_hosts "$hosts" || error_exit "Could not repair old Rosetta hosts blocks."
|
||||||
|
fi
|
||||||
|
|
||||||
local needs_heal=false
|
local needs_heal=false
|
||||||
|
|
||||||
if [ -f "$cfg/.cloudConfigRecordFound" ]; then
|
if [ -f "$cfg/.cloudConfigRecordFound" ]; then
|
||||||
|
|||||||
+33
-3
@@ -2,14 +2,44 @@
|
|||||||
|
|
||||||
suppress_fixture() {
|
suppress_fixture() {
|
||||||
local script="$1" target="$2"
|
local script="$1" target="$2"
|
||||||
|
local action="${3:-suppress_enrollment}" simulation="${4:-false}"
|
||||||
run bash -u -c '
|
run bash -u -c '
|
||||||
source <(sed '\''/^main "\$@"$/d'\'' "$1")
|
source <(sed '\''/^main "\$@"$/d'\'' "$1")
|
||||||
PB=:
|
DRY_RUN="$4"
|
||||||
suppress_enrollment "$2"
|
"$3" "$2"
|
||||||
' "$script" "$script" "$target"
|
' "$script" "$script" "$target" "$action" "$simulation"
|
||||||
[ "$status" -eq 0 ]
|
[ "$status" -eq 0 ]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "heal repairs old Rosetta blocks even when suppression is otherwise intact" {
|
||||||
|
local entrypoint
|
||||||
|
for entrypoint in unleash unleash-standalone.sh; do
|
||||||
|
local script="$BATS_TEST_DIRNAME/../$entrypoint"
|
||||||
|
local target="$BATS_TEST_TMPDIR/$entrypoint" hosts
|
||||||
|
hosts="$target/private/etc/hosts"
|
||||||
|
suppress_fixture "$script" "$target"
|
||||||
|
printf '0.0.0.0 configuration.apple.com\n:: configuration.apple.com\n' >> "$hosts"
|
||||||
|
suppress_fixture "$script" "$target" heal_suppress
|
||||||
|
run grep -q 'configuration[.]apple[.]com' "$hosts"
|
||||||
|
[ "$status" -eq 1 ]
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "heal dry run preserves old Rosetta entries" {
|
||||||
|
local entrypoint
|
||||||
|
for entrypoint in unleash unleash-standalone.sh; do
|
||||||
|
local script="$BATS_TEST_DIRNAME/../$entrypoint"
|
||||||
|
local target="$BATS_TEST_TMPDIR/$entrypoint" hosts
|
||||||
|
hosts="$target/private/etc/hosts"
|
||||||
|
suppress_fixture "$script" "$target"
|
||||||
|
printf '0.0.0.0 configuration.apple.com\n:: configuration.apple.com\n' >> "$hosts"
|
||||||
|
cp "$hosts" "$target/original"
|
||||||
|
suppress_fixture "$script" "$target" heal_suppress true
|
||||||
|
cmp "$target/original" "$hosts"
|
||||||
|
[ ! -e "$hosts.unleash-rosetta.bak" ]
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
@test "suppression does not add hosts blocks for Rosetta configuration" {
|
@test "suppression does not add hosts blocks for Rosetta configuration" {
|
||||||
local entrypoint
|
local entrypoint
|
||||||
for entrypoint in unleash unleash-standalone.sh; do
|
for entrypoint in unleash unleash-standalone.sh; do
|
||||||
|
|||||||
@@ -990,6 +990,10 @@ heal_suppress() {
|
|||||||
local hosts="${data_mount}/private/etc/hosts"
|
local hosts="${data_mount}/private/etc/hosts"
|
||||||
local ldp="${data_mount}/private/var/db/com.apple.xpc.launchd/disabled.plist"
|
local ldp="${data_mount}/private/var/db/com.apple.xpc.launchd/disabled.plist"
|
||||||
|
|
||||||
|
if [ "$DRY_RUN" != true ] && [ -f "$hosts" ]; then
|
||||||
|
_restore_rosetta_hosts "$hosts" || error_exit "Could not repair old Rosetta hosts blocks."
|
||||||
|
fi
|
||||||
|
|
||||||
local needs_heal=false
|
local needs_heal=false
|
||||||
|
|
||||||
if [ -f "$cfg/.cloudConfigRecordFound" ]; then
|
if [ -f "$cfg/.cloudConfigRecordFound" ]; then
|
||||||
|
|||||||
Reference in New Issue
Block a user