Repository navigation
fix(desktop): .deb upgrades no longer remove the AppArmor profile - #40341
juliusmarminge wants to merge 2 commits into
Conversation
electron-builder's default postrm unloads and deletes /etc/apparmor.d/t3code on every invocation, including the old package's postrm during an upgrade. An upgrade interrupted before the new postinst left T3 Code crashing at launch with a SUID-sandbox FATAL on Ubuntu 24.04+. Ship our own after-remove template that only cleans up on remove/purge. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… upgrade The remove/purge guard only applies to postrm scripts of packages built with it. Upgrading from a release with electron-builder's stock postrm still ran that unguarded script, so an interrupted upgrade still lost the AppArmor profile. Add a preinst, which dpkg runs before the old postrm, that inserts the same guard into the installed postrm on upgrade. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
On Ubuntu 24.04 and later, an in-app .deb update interrupted partway (for example by force-quitting the frozen window) left T3 Code crashing at every launch until
sudo dpkg --configure -awas run. The old package's post-remove script deleted and unloaded the AppArmor profile even during an upgrade.apps/desktop/resources/linux/after-remove.tplreplaces electron-builder's stock postrm and only removes the profile and the/usr/bin/t3codelink when the package is actually removed or purged.apps/desktop/resources/linux/before-install.shis a new preinst. On upgrade it adds the same remove/purge guard to the installed release's postrm, which dpkg runs next. This protects the first upgrade from releases that still have the stock script.Fixes #40294
Reproduction on main
Commit: origin/main 6644126 (packaging unchanged on main; used the published preview .debs built from it). Ubuntu 24.04.4 VM with kernel.apparmor_restrict_unprivileged_userns = 1. (1) sudo dpkg -i T3-Code-0.1.12-preview.20261121.5023-amd64.deb -> dpkg -l shows ii, /etc/apparmor.d/t3code present and the t3code profile loaded (aa-status); launching '/opt/T3 Code (Beta)/t3code' with the Chromium sandbox on, under Xvfb with an isolated HOME, stays running for 15s (label 't3code (unconfined)'). (2) sudo dpkg --unpack T3-Code-0.1.12-preview.20261121.5025-amd64.deb, which matches a dpkg -i interrupted after old-postrm and before configure -> dpkg -l shows iU, /etc/apparmor.d/t3code is gone and the profile is no longer loaded. (3) Launching again exits immediately with code 133 (Trace/breakpoint trap) and '[FATAL:sandbox/linux/suid/client/setuid_sandbox_host.cc:166] The SUID sandbox helper binary was found, but is not configured correctly'; the kernel log shows apparmor="DENIED" operation="capable" profile="unprivileged_userns" comm="t3code" capname="sys_admin", the same as the report. (4) sudo dpkg --configure -a -> ii, profile restored, the app launches normally again. Confirmed that the shipped postrm (dpkg-deb -e) unloads and deletes the profile with no check on $1. Confirmed that electron-updater 6.8.9 DebUpdater.doInstall runs dpkg -i through spawnSyncLog (child_process.spawnSync), so the main thread blocks while the window stays open.
Evidence
Being captured: before and after in the real app. This section is filled in before the pull request can merge.
Tests
sudo dpkg -i/dpkg --unpack/dpkg --configure -a/dpkg -Pon synthetic packages built from the stock and new scripts: stock->fixed and fixed->fixed interrupted upgrades keep the profile loaded; downgrade and re-upgrade keep it; purge removes it--before-install: the produced .deb's preinst is identical tobefore-install.shvp run check:changed: pass (format, lint, knip, typecheck of 2 packages, 1 test file)Not in this change
pkexec dpkg -ithrough spawnSync on the main thread while app windows stay open until before-quit-for-update, so the window looks frozen during the install.Who did the work
Run by the t3code factory in T3 Code.