From 87f1728c6e34d9f15a8bc97deca3fff48b8ee421 Mon Sep 17 00:00:00 2001 From: Erwan Leboucher Date: Sat, 18 Jul 2026 20:27:48 +0200 Subject: [PATCH] fix(tauri): package full CEF runtime and correct AppImage sandbox handling --- .github/workflows/tauri-build.yml | 19 ++++++------------ scripts/cef-copy-libs.sh | 32 ++++++++++++++++++++----------- 2 files changed, 27 insertions(+), 24 deletions(-) diff --git a/.github/workflows/tauri-build.yml b/.github/workflows/tauri-build.yml index 7077cdbe4..d25ddab7f 100644 --- a/.github/workflows/tauri-build.yml +++ b/.github/workflows/tauri-build.yml @@ -138,11 +138,6 @@ jobs: cargo build --release --features cef --no-default-features \ --manifest-path src-tauri/Cargo.toml - - name: Stage CEF runtime next to the binary - if: matrix.cef - shell: bash - run: scripts/cef-copy-libs.sh release - - name: Build native packages if: matrix.cef shell: bash @@ -150,18 +145,13 @@ jobs: VERSION="${TAG#v}" STAGE="src-tauri/target/release" + # Binary plus the full CEF runtime (cef-copy-libs is the single source + # of truth for the runtime file set). stage_runtime() { local dest="$1" mkdir -p "$dest" cp "$STAGE/sable" "$dest/" - cp -a "$STAGE"/*.so* "$dest/" 2>/dev/null || true - cp -a "$STAGE"/*.pak "$STAGE"/*.dat "$STAGE"/*.bin "$dest/" 2>/dev/null || true - cp -a "$STAGE"/*.json "$dest/" 2>/dev/null || true - cp -a "$STAGE/locales" "$dest/" 2>/dev/null || true - if [ -f "$STAGE/chrome-sandbox" ]; then - cp -a "$STAGE/chrome-sandbox" "$dest/" - chmod 4755 "$dest/chrome-sandbox" - fi + scripts/cef-copy-libs.sh release "$dest" } write_desktop() { @@ -209,6 +199,9 @@ jobs: APPDIR="Sable.AppDir" stage_runtime "$APPDIR/usr/bin" + # nosuid mount: a setuid chrome-sandbox can't work here and would stop + # Chromium from starting, so drop it and use the user-namespace sandbox. + rm -f "$APPDIR/usr/bin/chrome-sandbox" write_desktop "$APPDIR/sable.desktop" cp src-tauri/icons/128x128.png "$APPDIR/sable.png" cat > "$APPDIR/AppRun" <<'EOF' diff --git a/scripts/cef-copy-libs.sh b/scripts/cef-copy-libs.sh index d298c0d7e..881d75d48 100644 --- a/scripts/cef-copy-libs.sh +++ b/scripts/cef-copy-libs.sh @@ -1,14 +1,15 @@ #!/usr/bin/env bash -# Copy the CEF runtime (libcef.so + resources) next to the built binary so it -# is self-contained: works when launched standalone, by the OS via a sable:// -# deep link, or from a release bundle. Pair with the rpath=$ORIGIN that +# Copy the CEF runtime (libcef.so + resources) next to a built binary so the app +# is self-contained: works standalone, when launched by the OS via a sable:// +# deep link, or from a release package. Pair with the rpath=$ORIGIN that # build.rs adds for CEF builds. # -# Usage: scripts/cef-copy-libs.sh [debug|release] (default: debug) +# Usage: scripts/cef-copy-libs.sh [debug|release] [dest-dir] +# dest-dir defaults to src-tauri/target/ (beside the built binary). set -euo pipefail PROFILE="${1:-debug}" ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" -TARGET="$ROOT/src-tauri/target/$PROFILE" +DEST="${2:-$ROOT/src-tauri/target/$PROFILE}" CEF_DIR="$(find "$ROOT/src-tauri/target/$PROFILE/build" -type d -name cef_linux_x86_64 2>/dev/null | head -1)" if [ -z "$CEF_DIR" ]; then @@ -16,9 +17,18 @@ if [ -z "$CEF_DIR" ]; then exit 1 fi -echo "→ copying CEF runtime from $CEF_DIR to $TARGET" -cp -f "$CEF_DIR"/*.so* "$CEF_DIR"/*.pak "$CEF_DIR"/*.dat "$CEF_DIR"/*.bin "$CEF_DIR"/*.json "$TARGET/" 2>/dev/null || true -cp -f "$CEF_DIR"/chrome-sandbox "$TARGET/" 2>/dev/null || true -chmod 4755 "$TARGET/chrome-sandbox" 2>/dev/null || true # setuid sandbox helper -cp -rf "$CEF_DIR"/locales "$TARGET/" 2>/dev/null || true -echo "✅ done. libcef.so is now next to the $PROFILE binary." +mkdir -p "$DEST" +echo "→ copying CEF runtime from $CEF_DIR to $DEST" +# Libraries (libcef.so + ANGLE/SwiftShader), crashpad handler, then resources. +cp -f "$CEF_DIR"/*.so* "$DEST/" 2>/dev/null || true +cp -f "$CEF_DIR"/chrome_crashpad_handler "$DEST/" 2>/dev/null || true +cp -f "$CEF_DIR"/*.pak "$CEF_DIR"/*.dat "$CEF_DIR"/*.bin "$CEF_DIR"/*.json "$DEST/" 2>/dev/null || true +cp -rf "$CEF_DIR"/locales "$DEST/" 2>/dev/null || true + +# The setuid sandbox helper only works when installed as root (deb/rpm). In a +# nosuid context such as an AppImage, drop chrome-sandbox and let Chromium use +# the user-namespace sandbox instead. +if cp -f "$CEF_DIR"/chrome-sandbox "$DEST/" 2>/dev/null; then + chmod 4755 "$DEST/chrome-sandbox" 2>/dev/null || true +fi +echo "✅ done."