Commit Graph
24 Commits
Author SHA1 Message Date
hulthe 249f2e8520 Rebrand to boco
CI / build (push) Successful in 13s
2026-09-11 17:55:53 +02:00
hulthe 8782baa705 Add linux kernel as submodule and check in slim kernel config
CI / build (push) Successful in 13s
2026-09-11 17:35:01 +02:00
hulthe d7613a4987 Rewrite init script in rust and fix non-shell CMDs
CI / build (push) Successful in 14s
2026-09-11 14:40:10 +02:00
marvin 3a99da196d Add --mount flag for 9p host directory sharing
CI / build (push) Successful in 13s
Add support for sharing host directories into the VM via QEMU 9p
(virtio-9p).

The --mount flag can be repeated.

The format is `<host-path>` or `<host-path>:<guest-path>`

Relative guest paths are relative to the configured WORKDIR.

Design:
- QEMU: each --mount gets a short 9p tag (slim0, slim1, …) via
  -virtfs local,path=…,mount_tag=slimN,security_model=mapped-xattr.
  Tags are kept short because 9p mount_tag has a ~31-byte limit.
- Kernel cmdline: the full destination path is passed as
  slim.mount=<tag>:<base64(path)> so the init script knows where to
  mount each tag.  Base64 avoids issues with spaces/special chars.
- slim-init.sh: after networking, parse slim.mount= entries, mkdir -p
  the destination, and mount -t 9p <tag> <dest> -o trans=virtio,version=9p2000.L

Tests verify: 9p share detection via sysfs mount_tag, 9p entry in
mount output, file content accessible at the expected path, and clean
VM exit.
2026-09-11 09:39:34 +02:00
marvin 6111bbeb8d Merge pull request 'Respect USER directive from OCI image config' (#8) from feature/user-directive into master
CI / build (push) Successful in 13s
2026-09-10 12:18:57 +02:00
marvin 524ef3e793 Respect USER directive from OCI image config
CI / build (pull_request) Successful in 12s
Add support for the Dockerfile USER directive so that the container's
CMD/ENTRYPOINT runs as the configured user instead of root.

Changes:
- inject.rs: Add user field to Config struct, write /slim/user at
  build time
- build.rs: Pass config.user through to inject()
- slim-init.sh: Read /slim/user and drop privileges via su before
  executing the command. Numeric uids are resolved to usernames via
  /etc/passwd (BusyBox su does not accept numeric args). When dropping
  privileges, run as a child (not exec) so PID 1 stays root and can
  poweroff after the command exits.
- test.sh: Add test_user verifying build-time CMD and --cmd override
  both run as the configured user

Closes #7
2026-09-10 12:18:13 +02:00
hulthe 5960cfe430 Clean up smelly code in inject.rs
CI / build (push) Successful in 13s
2026-09-08 22:50:39 +02:00
hulthe c2a9f00fc0 Inject universal /slim/init instead of requiring container-specific setup
CI / build (pull_request) Successful in 36s
CI / build (push) Successful in 13s
slim now works with any Containerfile by injecting distro-agnostic scripts
at build time:

- /slim/init: mounts special filesystems, configures networking (static
  QEMU slirp), sets up cgroup2, timezone, and rootless container prereqs.
  Parses slim.cmd=<base64> from the kernel cmdline for runtime overrides,
  otherwise execs /slim/exec.

- /slim/exec: generated from the image's CMD/ENTRYPOINT (via podman image
  inspect), overridable via --cmd at build and run time.

Changes:
- New src/inject.rs: inspect image config, infer command, generate
  /slim/exec script, inject /slim/ into mounted rootfs
- New src/scripts/slim-init.sh: the universal init script (include_str!)
- build.rs: rename --init to --cmd, inject scripts before packing,
  drop Meta::save, restructure to ensure unmount always runs
- qemu.rs: hardcode init=/slim/init, add --cmd (base64 on cmdline),
  drop Meta::load, add -no-reboot
- Remove src/meta.rs and meta.toml (no longer needed)
- Cargo.toml: add serde_json + base64, remove unused walkdir + cpio + toml
- Example Containerfiles simplified to plain FROM + CMD
- New example/test.sh for manual verification
- README updated for new workflow
2026-09-08 21:58:01 +02:00
hulthe 506213ed9a Fixes
CI / build (push) Successful in 14s
2026-09-06 16:09:20 +02:00
hulthe 7dd818db68 Progress
CI / build (push) Successful in 14s
2026-09-04 17:01:46 +02:00
hulthe 286def05c1 Add qcow2 support
CI / build (push) Successful in 13s
2026-08-30 17:08:08 +02:00
hulthe 46a86116b0 Add a --memory flag
CI / build (push) Successful in 10s
2026-08-29 21:12:23 +02:00
hulthe ec05936d2f Add Arch Linux example
CI / build (push) Successful in 10s
2026-08-29 21:04:35 +02:00
hulthe 41bc570bfb Print qemu command 2026-08-29 21:04:27 +02:00
hulthe 56a76ce934 Add basic README.md with an example
CI / build (push) Successful in 11s
2026-08-26 23:46:57 +02:00
hulthe 6af8660f8d Add qemu network device 2026-08-26 23:27:58 +02:00
hulthe 8b544ab688 Add image ls and image rm commands 2026-08-26 23:27:58 +02:00
marvin 37f537184c refactor: split main.rs into registry, build, and qemu modules
CI / build (pull_request) Successful in 10s
CI / build (push) Successful in 11s
main.rs keeps only the CLI definition and command dispatch:
- registry.rs: image-name validation + XDG registry path handling (tests)
- build.rs: podman mount/unmount, vmlinuz extraction, cpio/gzip initrd
- qemu.rs: direct-kernel-boot VM launch

No behavior change; cargo fmt/clippy/test pass, build/run paths
verified against the mock-vm image.
2026-08-26 20:15:16 +00:00
marvin 5b80885207 fix: validate image name before building registry path
CI / build (pull_request) Successful in 10s
CI / build (push) Successful in 10s
The user-supplied image/name argument was interpolated unsanitized into
registry/{name}/initrd, so a name containing '../' (e.g. 'slim run
../../.ssh/authorized_keys') escaped the XDG data dir and let slim
create directories and read/write files at attacker-chosen locations.

validate_image_name now rejects empty names, '.', '..' and anything
outside [A-Za-z0-9._:-] at the registry_dir chokepoint used by both
build and run, plus a defense-in-depth containment check that the
resolved path stays under the registry root.

Fixes sec-2 from the code review.
2026-08-26 20:11:57 +00:00
hulthe d517ab6a1a Fix minor issues
CI / build (push) Successful in 10s
2026-08-26 21:45:26 +02:00
hulthe e3bd77379f Add lockfile
CI / build (push) Successful in 10s
2026-08-26 19:25:20 +02:00
marvin 8dd5267bb4 fix: read rootfs inside podman unshare, always unmount, fail on qemu errors
CI / build (pull_request) Successful in 11s
CI / build (push) Successful in 10s
- build: the rootless overlay mount only exists inside podman unshare's
  user namespace; run the vmlinuz check/copy and the find|cpio pipeline
  there, streaming cpio's stdout to the parent for gzipping (also drops
  the initrd.tmp round-trip and excludes vmlinuz from the archive)
- build: unmount the image on all code paths, not just success
- run: treat timeout's exit 124 as the expected smoke-test timeout and
  error on any other non-zero status (a missing qemu binary no longer
  reports success)

Fixes bug-1, bug-2, bug-3 from the code review.
2026-08-25 20:45:29 +00:00
marvin b9b5e3942b slim-rs v1: initrd build, qemu run, gitea actions
CI / build (push) Successful in 10s
2026-08-25 20:10:03 +00:00
marvin f7ca39117a slim-rs v1: initrd build + qemu run via podman image mount 2026-08-25 19:53:47 +00:00