foundry
Foundry OS: the operating system built on the Rustbelt kernel
| author | Grok Bot <grokbot@localhost> | 2026-10-31 20:39:33 -0700 |
|---|---|---|
| commit | b93bef7a3b0cd7e39372f5aa1dedc698ec5a89d3 | |
| parent | 9595759e94aea9facca6dfcf0ccd00b858773b82 | |
| tree | browse files at this commit | |
Root image: files owned by root, not by the build user mke2fs -d copied uid/gid 1000 from the build machine (ls -l showed tyler:tyler on /etc/passwd). mkimage-v2.sh now sets every file to 0:0 and /home/tyler to 1000:1000 with debugfs; check-v2-image.sh checks a few.
| M | docs/plan.md | +5 -3 |
| M | scripts/check-v2-image.sh | +6 -0 |
| M | scripts/mkimage-v2.sh | +11 -0 |
3 files changed, 22 insertions, 3 deletions
@@ -134,9 +134,11 @@ no default password, setuid programs) need care and tests, not just code. - A check in `make test` fails if the release image has any shadow entry that is not locked. 7. **Owners and modes set by the image build** (`mke2fs -d` copies modes- but takes owners from `root_owner`; per-file fixes go through- `debugfs -w` `set_inode_field` or an ext2 build step that reads a- small table like `root/permissions.txt`):+ *and* the build machine's owners; `root_owner` only covers the top+ directory. Since M4, scripts/mkimage-v2.sh makes every file root:root+ and `/home/tyler` 1000:1000 with `debugfs -w` `set_inode_field`, and+ check-v2-image.sh checks a few. M6 extends that to a small table like+ `root/permissions.txt` for modes such as setuid): | path | owner | mode | |---|---|---|
@@ -52,6 +52,12 @@ done echo "$listing" | grep -q "README.TXT" || bad "C:/README.TXT is missing" # A: and B: through e2fsprogs/mtools: the test files are gone, /etc is there. debugfs -R "ls -l /" "$WORK/p1" 2>/dev/null | grep -q "v2-test-root.txt" && bad "A:/v2-test-root.txt should be gone" || true+# Owners (scripts/mkimage-v2.sh): root's files, except tyler's home.+for f in /etc/passwd /sbin/init /bin/dash /scripts /home/tyler; do+ want=0; [ "$f" = /home/tyler ] && want=1000+ got=$(debugfs -R "stat $f" "$WORK/p1" 2>/dev/null | sed -n 's/.*User: *\([0-9]*\) *Group: *\([0-9]*\).*/\1:\2/p')+ [ "$got" = "$want:$want" ] && ok "A:$f is owned by $got" || bad "A:$f is owned by '$got', want $want:$want"+done [ "$(debugfs -R 'cat /etc/motd' "$WORK/p1" 2>/dev/null)" = "Welcome to Foundry OS, running on the Rustbelt kernel." ] \ && ok "A:/etc/motd reads back through debugfs" || bad "A:/etc/motd" MTOOLS_SKIP_CHECK=1 mdir -b -i "$WORK/p2" ::/ 2>/dev/null | grep -qi "v2-test-b" && bad "B:/v2-test-b.txt should be gone" || true
@@ -30,6 +30,17 @@ rm -f "$IMAGE" "$IMAGE".p? mke2fs -q -t ext2 -b 1024 -m 0 -L foundry-root -U 466f756e-6472-794f-5300-726f6f740001 \ -E root_owner=0:0,hash_seed=466f756e-6472-794f-5300-726f6f740002 \ -d "$STAGING/root" "$IMAGE.p1" $((ROOT_MIB * 1024))+# mke2fs -d copies each file's owner from the build machine (root_owner only+# covers the top directory), so everything would belong to whoever ran+# `make` (uid 1000 here). Make every file root's (uid 0, gid 0), and give+# /home/tyler to tyler (1000:1000, as in /etc/passwd), with debugfs.+( cd "$STAGING/root" && find . -mindepth 1 | LC_ALL=C sort | sed 's|^\.||' |+ while read -r f; do+ case $f in /home/tyler) u=1000 ;; *) u=0 ;; esac+ echo "sif $f uid $u"; echo "sif $f gid $u"+ done ) > "$IMAGE.owners"+debugfs -w -f "$IMAGE.owners" "$IMAGE.p1" > /dev/null 2>&1+rm -f "$IMAGE.owners" # p2: FAT32, filled with mtools: the top level, then bin/ in ORDER. mkfs.vfat -F 32 -s 1 -n FOUNDRY -i 466f6e64 -C "$IMAGE.p2" $((DATA_MIB * 1024)) >/dev/null