Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

Arch packaging: run the uninstall cleanup under pacman, drop the duplicate script and the audit file

milind-soni03e2993a9a4d
diff --git a/CONTRIBUTIONS.md b/CONTRIBUTIONS.md
deleted file mode 100644
index 795fd577e4..0000000000
--- a/CONTRIBUTIONS.md
+++ /dev/null
@@ -1,69 +0,0 @@
-# Contribution Summary: Arch Linux Support & Security Audit
-
-This document outlines the contributions made to **OpenMausBot** for Arch Linux compatibility, native packaging support, and the security vulnerability assessment.
-
----
-
-## 1. Summary of Changes
-
-### A. Arch Linux Native Packaging Support
-- **`electron-builder.yml`**:
- - Added the `pacman` target configuration under Linux distribution targets.
- - Specified Arch Linux system library dependencies (`fuse3`, `gtk3`, `nss`, `alsa-lib`, `libcups`, `mesa`) to ensure reliable installation on fresh Arch/EndeavourOS/CachyOS systems without missing runtime libraries.
- - Configured `afterInstall` and `afterRemove` packaging hooks (`build/linux-after-install.sh` and `build/linux-after-remove.sh`) so package directory modes for the bundled CUA runtime (`0755`) are safely established and preserved across upgrades.
-- **`package.json`**:
- - Added dedicated packaging scripts:
- - `"package:arch"`: prepares dependencies and builds the native `.pacman` package.
- - `"package:pacman"`: alias targeting the pacman builder target.
-- **`docs/linux-desktop.md`**:
- - Documented building from source for Arch Linux via `pnpm package:arch`.
- - Added installation instructions using explicit package path syntax: `sudo pacman -U release/OpenMausBot-<version>-x64.pacman`.
-
-### B. Desktop Environment Verification on Arch / Wayland
-- Built and packaged the desktop bundle on an Arch Linux distribution (CachyOS) running KDE Plasma on Wayland (`kwin_wayland`).
-- Verified direct execution of `./release/linux-unpacked/openmausbot` under Wayland (`--ozone-platform=wayland`).
-- Verified package artifact creation: `release/OpenMausBot-0.1.149-x64.pacman` (238 MB).
-
----
-
-## 2. Security Vulnerability Audit Report (Informational Summary)
-
-> **Note**: This section documents findings from a source code security review conducted across trust boundaries. These findings represent hardening opportunities for future follow-up issues/PRs and are not modified in this packaging PR.
-
-### Finding 1: Single-Pass Path Sanitization in Static File Serving
-- **File**: `server/static-files.ts` (`serveStatic`)
-- **Detail**: Path traversal filtering uses a single-pass `path.replace(/\.\./g, "")` before `join(staticDir, safe)`. Although URL parsing normalizes standard relative segments in typical queries, single-pass substring stripping is fragile for path boundary enforcement across varied inputs.
-- **Recommendation**: Validate canonical directory boundaries (e.g. verifying `const rel = path.relative(resolvedStaticDir, resolvedTargetPath);` and asserting `!rel.startsWith('..') && !path.isAbsolute(rel)`) rather than substring stripping or simple prefix checks (which could match sibling directories sharing a common prefix like `/srv/static-backup`).
-
-### Finding 2: Unauthenticated Loopback Read Access in Desktop Mode
-- **File**: `server/request-auth.ts` (`mutatingPublicRoute`, `resolveRequestAuth`)
-- **Detail**: The private desktop owner token (`x-openmausbot-desktop-owner`) is only required for mutating requests (`POST`, `PUT`, `DELETE` and specific sensitive `GET` routes). General loopback `GET` requests on `127.0.0.1:8799` do not require authentication from non-browser callers.
-- **Recommendation**: On multi-user systems, authenticate read endpoints with the desktop capability or restrict unprivileged loopback peers.
-
-### Finding 3: Unrestricted HTTPS Target Fetching in MCP OAuth Discovery
-- **File**: `server/mcp-oauth-discovery.ts` (`isAllowedAuthUrl`)
-- **Detail**: `isAllowedAuthUrl` allows all `https://` URLs without validating whether the hostname resolves to internal private network addresses (e.g., RFC 1918 private subnets or internal LAN hosts).
-- **Recommendation**: Route MCP discovery requests through the egress IP filtering logic (`server/browser/egress/policy.ts`) or resolve DNS hostnames before fetching.
-
-### Finding 4: Linux Terminal Emulator Detection on Wayland / Non-GNOME Desktop Environments
-- **File**: `electron/terminal-launch.mjs` (`openBlankTerminal`)
-- **Detail**: The terminal launcher checks only `["x-terminal-emulator", "gnome-terminal", "konsole", "xterm"]`. Standalone Wayland tiling environments on Arch (Hyprland, Sway) commonly use modern terminals like `kitty`, `alacritty`, `foot`, or `wezterm`, which would fail terminal hand-offs if none of the 4 defaults are present.
-- **Recommendation**: Expand the candidate list to include `kitty`, `alacritty`, `foot`, and `wezterm`.
-
----
-
-## 3. How to Test & Verify
-
-```bash
-# 1. Install dependencies
-pnpm install --frozen-lockfile
-
-# 2. Build application and native packages
-pnpm package:arch
-
-# 3. Verify generated pacman package
-ls -lh release/*.pacman
-
-# 4. Install locally on Arch Linux (specify exact built version)
-sudo pacman -U release/OpenMausBot-0.1.149-x64.pacman
-```
diff --git a/build/linux-after-remove.sh b/build/linux-after-remove.sh
index 79c380b2fb..1941db4b86 100644
--- a/build/linux-after-remove.sh
+++ b/build/linux-after-remove.sh
@@ -2,9 +2,10 @@
set -eu
# dpkg runs the old postrm during an upgrade too. Keep the installed profile
-# until the package is actually removed or purged.
+# until the package is actually removed or purged. pacman's post_remove runs
+# only on removal and passes the old version instead of an action word.
case "${1:-}" in
- remove|purge) ;;
+ remove|purge|[0-9]*) ;;
*) exit 0 ;;
esac
diff --git a/docs/linux-desktop.md b/docs/linux-desktop.md
index dd3adf6cb6..a4c05c2c52 100644
--- a/docs/linux-desktop.md
+++ b/docs/linux-desktop.md
@@ -87,10 +87,12 @@ For a downloaded release AppImage, use `OpenMausBot.AppImage` in place of the ve
### Arch Linux and EndeavourOS
-Arch-based distributions can run the portable AppImage or install a native `.pacman` package.
+Arch-based distributions are not an official target. The release AppImage runs there, or you can build a native
+`.pacman` package yourself.
#### Native pacman package
-Build the pacman package from source:
+Releases and CI do not build this package and nothing tests it. Removing it cleans up the launcher and browser
+profile; whether a pacman upgrade re-applies the install steps has not been verified. Build it from source:
```sh
pnpm package:arch
diff --git a/package.json b/package.json
index 876683c97a..8d3b452440 100644
--- a/package.json
+++ b/package.json
@@ -74,7 +74,6 @@
"package:win": "pnpm package:prepare && pnpm build:cua:win && electron-builder --win --publish never",
"package:linux": "pnpm package:prepare && pnpm build:cua:linux && electron-builder --linux --x64 --publish never",
"package:arch": "pnpm package:prepare && pnpm build:cua:linux && electron-builder --linux pacman --x64 --publish never",
- "package:pacman": "pnpm package:prepare && pnpm build:cua:linux && electron-builder --linux pacman --x64 --publish never",
"package:linux:offline": "pnpm package:prepare && pnpm build:cua:linux:offline && electron-builder --linux --x64 --publish never",
"smoke:deb-command": "node scripts/smoke-deb-command.mjs",
"smoke:linux-update": "xvfb-run -a electron --no-sandbox scripts/smoke-linux-update.mjs",
diff --git a/scripts/linux-after-install.test.mjs b/scripts/linux-after-install.test.mjs
index 9f5bd9ff58..d0f6e943b2 100644
--- a/scripts/linux-after-install.test.mjs
+++ b/scripts/linux-after-install.test.mjs
@@ -281,6 +281,15 @@ describe.skipIf(process.platform !== "linux")("Linux DEB upgrade hook", () => {
expect(runRemoveHook(appRoot, "purge").status).toBe(0);
});
+ it("treats pacman's post_remove, which passes the old version, as an uninstall", () => {
+ const { appRoot, apparmorDir } = fixture();
+ expect(runHook(appRoot).status).toBe(0);
+ const profile = path.join(apparmorDir, "openmausbot-browser");
+ const removed = runRemoveHook(appRoot, "0.1.149-1");
+ expect(removed.status, removed.stderr).toBe(0);
+ expect(fs.existsSync(profile)).toBe(false);
+ });
+
it("removes an already unloaded profile without asking the kernel again", () => {
const { appRoot, apparmorDir, systemRoot } = fixture();
expect(runHook(appRoot).status).toBe(0);