Repository navigation
feat: implement the IMPROVEMENTS.md items (SSH, recipe safety, service, CI and more) - #36
Merged
Merged
Conversation
Every install used the root/alpine password and the Dropbear host keys baked into base.qcow2. - The app generates a random root password on first use, keeps it encrypted with an Android Keystore AES-GCM key (SecretStore.kt) and passes it to the guest through QEMU fw_cfg (opt/root_password), like the API token. It is redacted from the logged QEMU command line. - /sbin/init (new images) and init_bootstrap.sh (older images) apply it with chpasswd, generate an ed25519 host key on first boot, delete the baked RSA/ECDSA keys and restart only the listening Dropbear. - The image build no longer bakes host keys. - The terminal and the SSH status ping log in with the per-install password through SshCredentials.connect. If the guest still accepts only the legacy password (kernel without fw_cfg), the app logs in with it once and sets the per-install password. - Settings > Security > SSH access shows the password (hidden, with copy) and a key-only switch: the guest creates an app key pair (POST /ssh/app-key), the private key is stored with the Keystore key, and Dropbear runs with -s from the next VM start. Key-only is only passed to the guest when the app holds a key. - Instrumentation tests log in with the per-install password.
Recipes from AI2TH/linxr-marketplace run as root and could replace a built-in recipe with the same id, over an unauthenticated channel. - A community recipe can no longer replace a built-in id; such entries are dropped. Remote recipes are marked and filterable as "Community". - recipes.json is checked against a detached Ed25519 signature (recipes.json.sig, base64 of the raw 64-byte signature) with the public key embedded in the app (pinenacl, already used by dartssh2). A bad signature is always rejected. An unsigned catalog loads with a warning unless Settings > Security > "Require signed community recipes" is on (off by default until linxr-marketplace signs). - A script recipe shows its full script, with a warning if it switches apk to http, before its first run and again when the script changes. - Built-in native recipes no longer rewrite apk repositories to http.
Settings showed "Auto" as free storage minus 2 GB, but VmManager creates user.qcow2 at the base image size (4 GB) when no size is set. Show the real size, passed from VmManager.getDeviceInfo (autoDiskGb), and show a set size after the same free-storage cap VmManager applies.
The custom /sbin/init never runs OpenRC, so the k3s service registered by the installer did not start after a reboot. init_bootstrap.sh now starts "k3s server" in the background when /usr/local/bin/k3s exists and no server is running, with /etc/rancher/k3s/k3s.env (GODEBUG=tlsmlkem=0) exported and --disable traefik when the installed service uses it. Log: /var/log/k3s.log.
Keep foregroundServiceType="dataSync" rather than moving to specialUse: specialUse needs a Play Console declaration and review, and a rejected or pending one would block Play releases. The manifest comment explains how to switch later. - onTimeout (Android 15's 6 h in 24 limit) still stops the service cleanly and now posts a notification telling the user to open Linxr. MainActivity.onResume starts the service again while the VM runs, since bringing the app to the foreground resets the limit. - A START_STICKY restart (null intent, after Android killed the app process) re-checks the VM: without a running VM the service stops instead of showing "VM is running". startForeground is still called first so a startForegroundService() start never times out.
After a recipe deploys, the app lists its declared ports and offers to add them as custom host -> guest forwards. PortForwardPlanner skips ports Linxr already forwards to the same guest port and reports collisions (host port forwarded elsewhere, used twice by the recipe, or reserved for SSH/API). The guest port is the container port for script recipes and host-network containers, and the published port otherwise. UDP ports are not supported (SLIRP hostfwd is set up for TCP only); the dialog says so, and notes it for well-known UDP services such as SIP on 5060. Forwards apply after the VM restarts.
The API server gets GET /system/release, which reads /etc/linxr-release (written by the image build since #34) and falls back to /etc/alpine-release and the running kernel for older images. Settings gets an About section with the app version, Alpine version, kernel version and image build date, read when the VM is running.
Settings > Package mirror offers the Alpine CDN (default), kernel.org, Aliyun and Tsinghua TUNA. VmManager passes the choice to the guest through QEMU fw_cfg (opt/apk_mirror), accepting only https URLs of plain URL characters, and init_bootstrap.sh writes /etc/apk/repositories from it on every boot (validated again, falling back to the CDN). The repositories now use https instead of http. The image build also defaults to the CDN instead of mirrors.aliyun.com.
VmDiskResizeTest sets a 16 GB disk, resets storage, boots the VM and asserts that /dev/vda is 16 GB and that df / reports more than 15 GB once init_bootstrap.sh has grown the filesystem (polled for up to 10 minutes, since resize2fs runs in the background). It is skipped on devices with less than 18 GB free, because VmManager caps the disk to free storage minus 2 GB. Needs a device and the VM assets; not run in CI.
So the new CI checks start green: - flutter analyze: document and silence the non-const IconData in MarketplaceItem (builds use --no-tree-shake-icons), drop an unnecessary cast, and use the Disk Cap card's note to show when a set size is capped by free storage. - shellcheck: find the -virt kernel directory with a glob instead of ls | grep, and fix the quoting of an echo in build_qcow2.sh. - pyflakes: remove an unused import and an unused exception variable in api_server.py.
On pushes to main and on pull requests: - flutter analyze (infos are not fatal) and flutter test; - shellcheck at warning level on scripts/*.sh and init_bootstrap.sh (linxr-desktop.sh is left out while the desktop is being rewritten), and pyflakes on api_server.py; - ./gradlew compileDebugKotlin compileDebugAndroidTestKotlin. The VM assets that are not in the repository (kernel, initramfs, base image, QEMU libraries) are not needed to compile.
Covers per-install SSH credentials, recipe safety, the Auto disk size, k3s after reboot, the foreground service, recipe port forwards, the VM versions in About, the apk mirror picker, CI and the disk resize test.
Flutter 3.50 (the current stable) refuses to apply its Gradle plugin with a Gradle version below 9.3.1, so the Kotlin compile job failed while configuring the project. Pin both Flutter jobs to 3.44.0, the version the analyzer and tests were run with, until the wrapper is upgraded.
Running compileDebugAndroidTestKotlin from the root also built the plugin modules' test variants, and package_info_plus's test manifest (minSdk 19) fails to merge with androidx.exifinterface (minSdk 21). Run :app:compileDebugKotlin and :app:compileDebugAndroidTestKotlin.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This implements the items listed in
IMPROVEMENTS.md(#35). It is stacked on #34 (fix/code-review-2026-11). Merge #34 first; this PR's diff is against that branch. Each item is in its own commit.Items
validate.jsis in AI2TH/linxr-marketplace (AI2TH/linxr-marketplace#2)dataSync, see below)feat/desktop-gui-reliability; 9, 12, 13 and 14 are measurements and releases1. Per-install SSH credentials (P0)
SecretStore.kt: the app generates a random 20-character root password and encrypts it with an AES-256-GCM key in Android Keystore. It goes to the guest through QEMU-fw_cfg name=opt/root_password(not the kernel command line) and is redacted from the logged QEMU command./sbin/initsets the password, generates the Dropbear ed25519 host key on first boot and then starts Dropbear with-rfor that key. The image build no longer bakes host keys.init_bootstrap.shdoes the same early in boot. It removes the baked RSA/ECDSA keys and restarts only the listening Dropbear, so open sessions stay connected.SshCredentials.connect(terminal and status ping) logs in with the per-install password or the app key. If the guest still accepts onlyalpine(a kernel without fw_cfg), the app logs in with that once and runschpasswdto set the per-install password.POST /ssh/app-keycreates a key pair in the guest. The guest keeps the public key inauthorized_keys, returns the private key and deletes its copy. The app stores the private key with the Keystore key. Dropbear gets-sfrom the next start. Key-only is passed to the guest only when the app holds a key, so the app cannot lock itself out.2. Community recipes (P0)
id; it is dropped. Remote recipes are labelled and filterable as "Community".recipes.jsonis checked against a detached Ed25519 signaturerecipes.json.sig, using the public key embedded inrecipe_signature.dart(pinenacl, already a dartssh2 dependency).crypto.sign(null, data, key)and publishes the base64 result asrecipes.json.sig.7. Why
dataSyncand notspecialUsespecialUseneeds a Play Console declaration and review, and a rejected or pending declaration would block releases.dataSyncneeds no new review.onTimeoutstops the service cleanly and notifies the user.MainActivity.onResumestarts the service again. Bringing the app to the foreground resets the limit.START_STICKYrestart without a running VM stops the service instead of showing "VM is running".specialUselater.Other items
5: "Auto" shows the size the app really creates (4 GB, from
getDeviceInfo().autoDiskGb). A set size shows the free-storage cap.6:
init_bootstrap.shstartsk3s serverwhen/usr/local/bin/k3sexists and no server is running. It usesk3s.env(GODEBUG) and adds--disable traefikwhen the installed service has it.8: after a deploy, the app offers to add the recipe's ports as forwards. It skips forwards that already exist and reports collisions (host port in use, a duplicate, or reserved 2222/7081). The dialog notes that UDP, for example SIP on 5060, is not forwarded. Forwards apply after a VM restart.
10:
GET /system/releasereads/etc/linxr-release, with a fallback for older images. It is shown in Settings → About.11: Settings → Package mirror offers the Alpine CDN (default), kernel.org, Aliyun and TUNA. The choice goes to the guest through
fw_cfg opt/apk_mirrorand is validated on both sides; only https is accepted. The image build also defaults to the CDN.15:
.github/workflows/ci.ymlruns:flutter analyze --no-fatal-infosandflutter testscripts/*.shandinit_bootstrap.sh, and pyflakes onapi_server.py./gradlew compileDebugKotlin compileDebugAndroidTestKotlin. The build does not need the VM assets that are not in the repository.A separate commit fixes the existing analyzer, shellcheck and pyflakes warnings so the checks start green.
4:
VmDiskResizeTestsets a 16 GB disk, boots, and asserts/dev/vdais 16 GB anddf /is over 15 GB. It is skipped with less than 18 GB free.Overlap with
feat/desktop-gui-reliabilityThat branch did not exist on the remote when this PR was opened. This PR does not touch
linxr-desktop.sh, the/desktopendpoints,desktop_screen.dartordesktop_service.dart. It does edit files that also hold desktop code, in other sections:api_server.py: new/ssh/app-keyand/system/releaseVmManager.kt,MainActivity.kt,VmApiClient.kt: new methodsinit_bootstrap.sh: the desktop install block is unchangedmain.dart: one line in_SshInfoCardCI skips
linxr-desktop.shfor now.Checks run
Run locally on the PR head:
flutter analyze --no-fatal-infos(Flutter 3.44, Dockerghcr.io/cirruslabs/flutter:stable): 0 errors, 0 warnings, 118 infos (all existingwithOpacity-style deprecations). Exit code 0.flutter test: 27 tests passed, including the newrecipe_safety_test.dart(signature, merge rule, http detection) andport_forward_planner_test.dart.-S warning) onscripts/*.shandinit_bootstrap.sh: clean. The generated/sbin/initwas extracted and checked: one existing note-level unused variable.api_server.py: clean.api_server.pysmoke test inalpine:3.20:/healthreturns 200.POST /ssh/app-keywithout a token returns 401.authorized_keys(0600, in a 0700 directory). A second call replaces the key; it does not add a second one.GET /system/releaseparses a sample/etc/linxr-releaseand falls back without one.crypto.signverifies in the Dart test against the embedded key.kotlinjob runs:app:compileDebugKotlin :app:compileDebugAndroidTestKotlinon ubuntu-latest, which compiles the new and changed app and instrumentation-test Kotlin. It could not run on the local arm64 Mac because AAPT2 is x86-64 only.:app, because a plugin's test manifest fails to merge.Device test checklist (not run: no device available)
ssh root@localhost -p 2222.alpineis rejected./etc/dropbearhas only the ed25519 key.ls /sys/firmware/qemu_fw_cfg/by_name/opt/showsroot_password,ssh_key_onlyandapk_mirror. If fw_cfg is missing, the app'schpasswdfallback still moves the guest offalpine.build_essentials,grafanaandmosquittoare listed under Community. Turning on "Require signed" hides them.nginx-nativeetc.) install over https apk.kubectl get nodesworks without a manual start./etc/apk/repositoriesandapk update../gradlew connectedDebugAndroidTest -Pandroid.testInstrumentationRunnerArguments.class=com.ai2th.linxr.VmDiskResizeTestASSETS_VERSIONbump (item 14, not in this PR).