Context
CodeRabbit flagged two issues on `scripts/ci/preset-init.sh` in #271:
-
Hardcoded `/24` netmask (preset-init.sh:64) — the kernel `ip=` cmdline format includes a netmask field at position 4, but we always assume /24. Breaks routing on non-/24 networks.
-
Hardcoded Google DNS (preset-init.sh:66-68) — overwrites `/etc/resolv.conf` with `8.8.8.8` / `8.8.4.4` regardless of what the network supplies. Fails on locked-down/airgapped networks.
Both findings are valid. Skipped from #271 because the same patterns exist in the existing openclaw `/init` (builder.py::_base_init_script) — fixing only the layered preset init creates asymmetric behavior.
Fix
Apply CodeRabbit's proposed fixes to both init scripts so layered presets and openclaw stay in sync:
- Parse `NETMASK` from `ip=::::...` and convert to CIDR prefix via a `netmask_to_prefix()` shell helper.
- Use `GATEWAY` as the primary DNS resolver; only fall back to public 8.8.8.8/8.8.4.4 when no gateway is parsed.
Acceptance
- VMs on non-/24 subnets (e.g. /16, /20) get correct routing.
- VMs on networks where the gateway is also a DNS resolver use it; only fall through to Google DNS when the gateway is empty.
- Existing /24 + 8.8.8.8 behavior preserved as fallback for current SmolVM-managed networking (which sets a /24 explicitly).
Files
- `scripts/ci/preset-init.sh` — layered presets
- `src/smolvm/images/builder.py::_base_init_script` — openclaw via the heredoc-generated /init
Context
CodeRabbit flagged two issues on `scripts/ci/preset-init.sh` in #271:
Hardcoded `/24` netmask (preset-init.sh:64) — the kernel `ip=` cmdline format includes a netmask field at position 4, but we always assume /24. Breaks routing on non-/24 networks.
Hardcoded Google DNS (preset-init.sh:66-68) — overwrites `/etc/resolv.conf` with `8.8.8.8` / `8.8.4.4` regardless of what the network supplies. Fails on locked-down/airgapped networks.
Both findings are valid. Skipped from #271 because the same patterns exist in the existing openclaw `/init` (builder.py::_base_init_script) — fixing only the layered preset init creates asymmetric behavior.
Fix
Apply CodeRabbit's proposed fixes to both init scripts so layered presets and openclaw stay in sync:
Acceptance
Files