feat(apps): permission manager equips apps (manifest+consent+decisions in /system), launches via init w/ file grant; shell unprivileged (/home); install/apps/allow/revoke; revoke stops running app; app-image tool; counter app

This commit is contained in:
2026-10-27 22:56:44 +01:00
parent 9bc31a9bbe
commit 90e11eb2e8
51 changed files with 1766 additions and 644 deletions

View File

@@ -1,6 +1,6 @@
#!/bin/bash
# Builds the k-os disk: one ext4 filesystem holding every program init may
# start, in /bin. Init and storage themselves are packed into the kernel image.
# start, in /bin, and the apps (docs/apps.md). Init and storage themselves are packed into the kernel image.
set -euo pipefail
IMG="${IMG:-boot.img}"
@@ -21,9 +21,24 @@ copy() {
fi
}
mkdir -p "${ROOT}/bin"
copy echo echo
copy snake snake
# An app, installed and pre-approved by whoever builds the image, or (staged)
# a folder the owner may install. See docs/apps.md.
APP_IMAGE=(cargo run -q --release -p app-image --)
app() {
local crate="$1"
if [ -f "${BUILD_DIR}/${crate}" ]; then
"${APP_IMAGE[@]}" install "${ROOT}" "crates/apps/${crate}/manifest.toml" "${BUILD_DIR}/${crate}"
fi
}
staged() {
local crate="$1" folder="$2"
if [ -f "${BUILD_DIR}/${crate}" ]; then
"${APP_IMAGE[@]}" stage "${ROOT}/home/${folder}" "crates/apps/${crate}/manifest.toml" "${BUILD_DIR}/${crate}"
fi
}
mkdir -p "${ROOT}/bin" "${ROOT}/apps" "${ROOT}/data" "${ROOT}/system/permissions" "${ROOT}/home"
# System servers and the shell: init starts these.
copy display-qemu display
copy input-qemu input
copy log-server log
@@ -31,11 +46,14 @@ copy permission-manager permission
copy session-server session
copy terminal-server terminal
copy shell shell
copy cat cat
copy ls ls
copy sleep sleep
# Files that ship on the disk, programs' manifests among them.
cp -r disk/. "${ROOT}/"
# Apps.
app cat
app ls
app sleep
app snake
staged counter inbox/counter
# The owner's files.
cp -r disk/home/. "${ROOT}/home/"
# Only the test image: its presence makes init run the self-test.
if [ -n "${SMPTEST:-}" ]; then
copy smptest smptest
@@ -46,4 +64,4 @@ fi
rm -f "${IMG}"
mkfs.ext4 -q -F -b 4096 -L k-os -O "${FEATURES}" -d "${ROOT}" "${IMG}" "${SIZE}"
echo "=== ${IMG}: ext4, ${SIZE} ==="
ls -1 "${ROOT}" "${ROOT}/bin"
find "${ROOT}" -mindepth 1 | sed "s|${ROOT}/||" | sort