Skip to content

AI media harness for planning, generating, and editing locally

TypeScript

Fix AppImage permissions before packaging

Bittif42b4779cad0
diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md
index aae7a2b..b6b55b2 100644
--- a/RELEASE_NOTES.md
+++ b/RELEASE_NOTES.md
@@ -22,6 +22,8 @@ Changes since 0.3.2.
## Fixes and improvements
+- Fixed AppImage launcher permissions for users other than the package builder.
+
- Retired Long Shot from scene choices; use Bridge to connect videos. Existing Long Shot scenes remain compatible.
- Video cards match Shot sizing, show the opening playback frame and open scenes on click; playback shares Timeline's prepared players. Returning to the Video tab restores the open video.
diff --git a/docs/linux.md b/docs/linux.md
index 9439012..673cd53 100644
--- a/docs/linux.md
+++ b/docs/linux.md
@@ -25,7 +25,7 @@ One-time WSL setup on Ubuntu (Rust as for the Linux worker):
```sh
sudo apt-get install -y libwebkit2gtk-4.1-dev libgtk-3-dev libayatana-appindicator3-dev \
- librsvg2-dev libxdo-dev libssl-dev build-essential file patchelf
+ librsvg2-dev libxdo-dev libssl-dev build-essential file patchelf squashfs-tools
```
`release.cmd` passes `TAURI_SIGNING_PRIVATE_KEY` (and its password) into WSL
@@ -74,6 +74,10 @@ VA-API and NVIDIA's driver (`va`, `nvcodec`); VP8/VP9/AV1/Opus have software
codecs. The same plugin removes NVIDIA cuBLAS, which linuxdeploy would otherwise
copy in (over 500 MB) through `libslopfab.so`. After building,
`package-linux-app.sh` fails if FFmpeg, x264/x265 or cuBLAS is in the AppImage.
+Before packaging, the plugin makes the AppDir readable and traversable by all
+users and explicitly enables execution of its launchers. The package script
+uses umask 022 for linuxdeploy's final wrapper and checks permissions again in
+the extracted AppImage, catching restrictive cached launchers such as mode 0770.
AAC audio needs a decoder the AppImage does not ship; the .deb and .rpm use the
system's.
diff --git a/scripts/linux/appimage-permissions.test.sh b/scripts/linux/appimage-permissions.test.sh
new file mode 100644
index 0000000..a056527
--- /dev/null
+++ b/scripts/linux/appimage-permissions.test.sh
@@ -0,0 +1,84 @@
+#!/usr/bin/env bash
+# Run on Linux; run as root to also exercise launch as the unrelated nobody user.
+# Set SLOPUS_TEST_APPIMAGE_PLUGIN to linuxdeploy-plugin-appimage.AppImage to
+# additionally verify a real packaged image without building the desktop app.
+set -euo pipefail
+umask 077
+root=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/../.." && pwd)
+fixture=$(mktemp -d /tmp/slopus-appimage-permissions.XXXXXXXX)
+trap 'rm -rf -- "$fixture"' EXIT
+appdir="$fixture/Test AppDir"
+mkdir -p "$appdir/usr/bin" "$appdir/usr/share" "$fixture/bin" "$fixture/plugins" "$fixture/helpers"
+chmod 0755 "$fixture"
+printf 'readable resource\n' > "$appdir/usr/share/message"
+cat > "$appdir/usr/bin/slopus" <<'EOF'
+#!/bin/sh
+cat "$(dirname "$0")/../share/message"
+EOF
+cat > "$appdir/AppRun" <<'EOF'
+#!/bin/sh
+exec "$(dirname "$0")/AppRun.wrapped" "$@"
+EOF
+cat > "$appdir/AppRun.wrapped" <<'EOF'
+#!/bin/sh
+exec "$(dirname "$0")/usr/bin/slopus" "$@"
+EOF
+cat > "$appdir/slopus.desktop" <<'EOF'
+[Desktop Entry]
+Type=Application
+Name=Slopus permission test
+Exec=slopus
+Icon=slopus
+Categories=AudioVideo;
+EOF
+printf '<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32"><rect width="32" height="32" fill="blue"/></svg>\n' > "$appdir/slopus.svg"
+# Simulate a root-owned 0770 cached launcher, private dirs, and a launcher
+# missing execute bits entirely. Data must become readable, not executable.
+chmod -R 0770 "$appdir"
+chmod 0640 "$appdir/slopus.desktop" "$appdir/slopus.svg"
+chmod 0640 "$appdir/usr/share/message"
+chmod 0600 "$appdir/AppRun"
+printf 'plugin fixture\n' > "$fixture/plugins/libgstcoreelements.so"
+printf '#!/bin/sh\nexit 0\n' > "$fixture/helpers/gst-plugin-scanner"
+printf '#!/bin/sh\nexit 0\n' > "$fixture/helpers/gst-ptp-helper"
+chmod 0700 "$fixture/helpers/"*
+# Isolate dependency discovery and ELF patching; exercise the real deployment
+# plugin, including its permission fix at the end of staging.
+printf '#!/bin/sh\nexit 0\n' > "$fixture/bin/linuxdeploy"
+printf '#!/bin/sh\nexit 0\n' > "$fixture/bin/patchelf"
+chmod 0755 "$fixture/bin/"*
+PATH="$fixture/bin:$PATH" LINUXDEPLOY="$fixture/bin/linuxdeploy" \
+ GSTREAMER_PLUGINS_DIR="$fixture/plugins" GSTREAMER_HELPERS_DIR="$fixture/helpers" \
+ bash "$root/scripts/linux/linuxdeploy-plugin-gstreamer.sh" --appdir "$appdir" > "$fixture/plugin.log"
+bad=$(find "$appdir" \( \( -type d ! -perm -0005 \) -o \( -type f \( ! -perm -0004 -o \( -perm /0111 ! -perm -0001 \) \) \) \) -print)
+[[ -z $bad ]] || { printf 'Inaccessible files: %s\n' "$bad" >&2; exit 1; }
+for launcher in AppRun AppRun.wrapped usr/bin/slopus; do
+ [[ -n $(find "$appdir/$launcher" -maxdepth 0 -perm -0005 -print) ]]
+done
+[[ ! -x $appdir/usr/share/message ]]
+if [[ $(id -u) == 0 ]]; then
+ [[ $(runuser -u nobody -- "$appdir/AppRun") == 'readable resource' ]]
+ echo 'PASS: root-owned AppDir launches and reads resources as nobody'
+else
+ [[ $("$appdir/AppRun") == 'readable resource' ]]
+ echo 'PASS: AppDir mode bits allow unrelated users to read and execute'
+fi
+
+if [[ -n ${SLOPUS_TEST_APPIMAGE_PLUGIN:-} ]]; then
+ image="$fixture/permissions.AppImage"
+ APPIMAGE_EXTRACT_AND_RUN=1 ARCH=x86_64 OUTPUT="$image" \
+ "$SLOPUS_TEST_APPIMAGE_PLUGIN" --appdir "$appdir" > "$fixture/packaging.log" 2>&1 \
+ || { cat "$fixture/packaging.log" >&2; exit 1; }
+ chmod a+rx "$image"
+ mkdir "$fixture/extracted"
+ chmod 0755 "$fixture/extracted"
+ extracted="$fixture/extracted/squashfs-root"
+ unsquashfs -no-progress -offset "$("$image" --appimage-offset)" -d "$extracted" "$image" >/dev/null
+ if [[ $(id -u) == 0 ]]; then
+ [[ $(runuser -u nobody -- "$extracted/AppRun") == 'readable resource' ]]
+ echo 'PASS: packaged AppImage launches as nobody after extraction'
+ else
+ [[ $("$extracted/AppRun") == 'readable resource' ]]
+ echo 'PASS: packaged AppImage launches after extraction'
+ fi
+fi
diff --git a/scripts/linux/linuxdeploy-plugin-gstreamer.sh b/scripts/linux/linuxdeploy-plugin-gstreamer.sh
index 4fe4160..34852b4 100644
--- a/scripts/linux/linuxdeploy-plugin-gstreamer.sh
+++ b/scripts/linux/linuxdeploy-plugin-gstreamer.sh
@@ -93,3 +93,11 @@ export GST_PLUGIN_PATH_1_0="${APPDIR}/usr/lib/gstreamer-1.0"
export GST_PLUGIN_SCANNER_1_0="${APPDIR}/usr/lib/gstreamer1.0/gstreamer-1.0/gst-plugin-scanner"
export GST_PTP_HELPER_1_0="${APPDIR}/usr/lib/gstreamer1.0/gstreamer-1.0/gst-ptp-helper"
EOF
+
+# Tauri's cached AppRun can arrive with mode 0770, which linuxdeploy preserves
+# when renaming it to AppRun.wrapped. Fix the staged tree before the output
+# plugin runs appimagetool; changing the outer AppImage's mode is too late.
+chmod -R a+rX -- "$appdir"
+for launcher in AppRun AppRun.wrapped usr/bin/slopus; do
+ [[ ! -f $appdir/$launcher ]] || chmod a+x -- "$appdir/$launcher"
+done
diff --git a/scripts/package-linux-app.sh b/scripts/package-linux-app.sh
index 9fd0ded..fc5ae8f 100644
--- a/scripts/package-linux-app.sh
+++ b/scripts/package-linux-app.sh
@@ -14,6 +14,9 @@
# Without one the packages are built unsigned and the AppImage cannot be
# offered as an update.
set -euo pipefail
+# linuxdeploy creates the final AppRun wrapper after its input plugins finish.
+# Keep that wrapper and any subsequently created files accessible to all users.
+umask 022
if (($# != 2)); then
printf 'Usage: bash %s <version> <artifacts-dir>\n' "$0" >&2
@@ -41,12 +44,12 @@ missing=()
for module in webkit2gtk-4.1 gtk+-3.0 librsvg-2.0 ayatana-appindicator3-0.1; do
pkg-config --exists "$module" 2>/dev/null || missing+=("$module")
done
-for tool in file patchelf; do
+for tool in file patchelf unsquashfs; do
command -v "$tool" >/dev/null || missing+=("$tool")
done
if ((${#missing[@]})); then
fail "missing build dependencies: ${missing[*]}. On Ubuntu or Debian install them with:
- sudo apt-get install -y libwebkit2gtk-4.1-dev libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev libxdo-dev libssl-dev build-essential file patchelf"
+ sudo apt-get install -y libwebkit2gtk-4.1-dev libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev libxdo-dev libssl-dev build-essential file patchelf squashfs-tools"
fi
runtime="$root/lib/slopfab/libslopfab.so"
@@ -115,13 +118,26 @@ appimage=$(pick appimage '*.AppImage')
# GPL codec or the CUDA toolkit (see scripts/linux/linuxdeploy-plugin-gstreamer.sh).
extract=$(mktemp -d /tmp/slopus-appimage.XXXXXXXX)
trap 'rm -rf -- "$extract"' EXIT
-(cd -- "$extract" && "$appimage" --appimage-extract >/dev/null)
+# Preserve the archived modes: --appimage-extract creates directories as 0700,
+# which would make permission checks report failures unrelated to the package.
+unsquashfs -no-progress -offset "$("$appimage" --appimage-offset)" -d "$extract/squashfs-root" "$appimage" >/dev/null
forbidden=$(find "$extract/squashfs-root" -type f \( -name 'libavcodec.so*' -o -name 'libavformat.so*' \
-o -name 'libavutil.so*' -o -name 'libavfilter.so*' -o -name 'libavdevice.so*' -o -name 'libswscale.so*' \
-o -name 'libswresample.so*' -o -name 'libpostproc.so*' -o -name 'libx264*.so*' -o -name 'libx265*.so*' -o -name 'libgstlibav.so' \
-o -name 'libcublas*.so*' \) -printf '%f\n')
[[ -z $forbidden ]] || fail "the AppImage bundles libraries it must not ship: $(echo $forbidden)"
[[ -f $extract/squashfs-root/usr/lib/Slopus/libslopfab.so ]] || fail 'the AppImage is missing libslopfab.so.'
+# Check mode bits rather than test -r/-x: packaging may run as the file owner
+# or root, while the downloaded AppImage is launched by an unrelated user.
+inaccessible=$(find "$extract/squashfs-root" \( \( -type d ! -perm -0005 \) -o \( -type f \( ! -perm -0004 -o \( -perm /0111 ! -perm -0001 \) \) \) \) -print)
+[[ -z $inaccessible ]] || fail "the AppImage contains files inaccessible to other users: $inaccessible"
+for launcher in AppRun AppRun.wrapped usr/bin/slopus; do
+ path="$extract/squashfs-root/$launcher"
+ [[ $launcher != AppRun.wrapped && ! -f $path ]] && fail "the AppImage is missing $launcher."
+ if [[ -f $path ]] && [[ -z $(find -L "$path" -maxdepth 0 -type f -perm -0005 -print) ]]; then
+ fail "the AppImage launcher is not readable and executable by other users: $launcher"
+ fi
+done
stem="Slopus-$version-linux-x64"
mkdir -p -- "$artifacts"