diff --git a/bin/omarchy-install-browser b/bin/omarchy-install-browser index 196e89ccc982..a254f56e35c7 100755 --- a/bin/omarchy-install-browser +++ b/bin/omarchy-install-browser @@ -109,7 +109,7 @@ zen) echo "Installing Zen..." omarchy-pkg-aur-add zen-browser-bin || exit 1 - browser_policy_setup_firefox_distribution /opt/zen-browser/distribution + browser_policy_setup_firefox_distribution /opt/zen-browser-bin/distribution setup_firefox_wayland omarchy-lifecycle-dispatch post-install zen announce_browser_installed "Zen" diff --git a/default/firefox/zen-policies.json b/default/firefox/zen-policies.json new file mode 100644 index 000000000000..994f69643fc8 --- /dev/null +++ b/default/firefox/zen-policies.json @@ -0,0 +1,29 @@ +{ + "policies": { + "DisableAppUpdate": true, + "DefaultSerialGuardSetting": 3, + "DontCheckDefaultBrowser": true, + "Preferences": { + "apz.overscroll.enabled": { + "Value": true, + "Status": "default" + }, + "media.ffmpeg.vaapi.enabled": { + "Value": true, + "Status": "default" + }, + "media.hardware-video-decoding.force-enabled": { + "Value": true, + "Status": "default" + }, + "widget.disable-swipe-tracker": { + "Value": false, + "Status": "default" + }, + "widget.wayland.fractional-scale.enabled": { + "Value": true, + "Status": "default" + } + } + } +} diff --git a/install/helpers/browser-policy.sh b/install/helpers/browser-policy.sh index 9f826af0254a..fb1085a6a578 100644 --- a/install/helpers/browser-policy.sh +++ b/install/helpers/browser-policy.sh @@ -26,7 +26,7 @@ BROWSER_POLICY_PARENT_DIRS=( BROWSER_POLICY_FIREFOX_DIRS=( /usr/lib/firefox/distribution - /opt/zen-browser/distribution + /opt/zen-browser-bin/distribution ) BROWSER_POLICY_DEFAULT_COLOR="#1c2027" @@ -162,9 +162,18 @@ browser_policy_firefox_hardened() { browser_policy_firefox_policy_file_ok "$dir/policies.json" } +# Zen's package ships a policies.json of its own, so its replacement keeps those keys. +browser_policy_firefox_default_policies() { + if [[ $1 == "/opt/zen-browser-bin/distribution" ]]; then + echo "$OMARCHY_PATH/default/firefox/zen-policies.json" + else + echo "$OMARCHY_PATH/default/firefox/policies.json" + fi +} + browser_policy_install_firefox_policies() { local distribution_dir=$1 - local policies=${2:-$OMARCHY_PATH/default/firefox/policies.json} + local policies=${2:-$(browser_policy_firefox_default_policies "$distribution_dir")} as_root install -m 644 -o root -g root -T "$policies" "$distribution_dir/policies.json" } @@ -187,9 +196,8 @@ browser_policy_firefox_skip_default_check() { browser_policy_setup_firefox_distribution() { local distribution_dir=$1 - local policies=${2:-$OMARCHY_PATH/default/firefox/policies.json} browser_policy_setup_parent "$distribution_dir" browser_policy_purge_dir "$distribution_dir" - browser_policy_install_firefox_policies "$distribution_dir" "$policies" + browser_policy_install_firefox_policies "$distribution_dir" "${2:-}" } diff --git a/test/shell.d/browser-policy-dir-test.sh b/test/shell.d/browser-policy-dir-test.sh index 8cb5159e392a..3b8ec930beba 100755 --- a/test/shell.d/browser-policy-dir-test.sh +++ b/test/shell.d/browser-policy-dir-test.sh @@ -311,9 +311,17 @@ if grep -nE 'chmod a\+rwx\b|chmod a\+rw\b|chmod a\+w\b|chmod o\+w|chmod ugo\+w|c fi pass "browser policy setup is not world-writable" -grep -F '/opt/zen-browser/distribution' "$ROOT/install/helpers/browser-policy.sh" >/dev/null || - fail "the shared helper names the Zen distribution directory" -pass "the shared helper names the Zen distribution directory" +# Zen ships its own copy so the package's keys survive; it must not fall behind the stock file. +[[ $(jq -cS '.policies | del(.DisableAppUpdate, .DefaultSerialGuardSetting)' "$ROOT/default/firefox/zen-policies.json") == $(jq -cS '.policies' "$ROOT/default/firefox/policies.json") ]] || + fail "Zen's policies carry every policy Firefox gets" +pass "Zen's policies carry every policy Firefox gets" + +# The hardening migration repairs every directory without naming a file; Zen's must not lose its keys. +[[ $(browser_policy_firefox_default_policies /opt/zen-browser-bin/distribution) == "$ROOT/default/firefox/zen-policies.json" ]] || + fail "a Zen policy repair installs Zen's own policies" +[[ $(browser_policy_firefox_default_policies /usr/lib/firefox/distribution) == "$ROOT/default/firefox/policies.json" ]] || + fail "a Firefox policy repair installs the stock policies" +pass "each Firefox distribution is repaired with its own policies" fx_merge=$test_tmp/fx-merge mkdir -p "$fx_merge" diff --git a/test/shell.d/default-apps-test.sh b/test/shell.d/default-apps-test.sh index fe7787c96822..200e1da2c78e 100755 --- a/test/shell.d/default-apps-test.sh +++ b/test/shell.d/default-apps-test.sh @@ -257,11 +257,11 @@ rm -f "$installed_dir/zen-browser" OMARCHY_TEST_REAL_BROWSER_INSTALL=true omarchy-default-browser --install zen >/dev/null [[ $(<"$install_log") == "pkg:zen-browser-bin" ]] || fail "Zen browser installer installs the package" [[ $(omarchy-default-browser) == "zen" ]] || fail "Zen becomes the default after its full installer succeeds" -grep -Fxq 'sudo:install -d -m 0755 -o root -g root /opt/zen-browser/distribution' "$setup_log" || +grep -Fxq 'sudo:install -d -m 0755 -o root -g root /opt/zen-browser-bin/distribution' "$setup_log" || fail "Zen browser installer creates its distribution directory" -grep -Fxq 'sudo:find /opt/zen-browser/distribution -mindepth 1 -maxdepth 1 ! -user root -exec rm -rf -- {} +' "$setup_log" || +grep -Fxq 'sudo:find /opt/zen-browser-bin/distribution -mindepth 1 -maxdepth 1 ! -user root -exec rm -rf -- {} +' "$setup_log" || fail "Zen browser installer drops non-root files from its distribution directory" -grep -Fxq "sudo:install -m 644 -o root -g root -T $ROOT/default/firefox/policies.json /opt/zen-browser/distribution/policies.json" "$setup_log" || +grep -Fxq "sudo:install -m 644 -o root -g root -T $ROOT/default/firefox/zen-policies.json /opt/zen-browser-bin/distribution/policies.json" "$setup_log" || fail "Zen browser installer copies policies.json without following a destination symlink" [[ -e $installed_dir/zen-browser ]] || fail "Zen browser installer marks zen-browser installed" pass "Zen browser installer restores the complete Omarchy setup"