Repository navigation
Layer 1 microVM: a securecore.json edit reaches the running guest; per-site php.ini debug settings (#90) - #95
Conversation
The launcher follows the config with the extension's own Reloader, once a second. An invalid file, or one the microVM can't run (the check a start makes), is refused with the reason and the guest keeps its config. A valid one goes to the guest over the control channel (config line), which mounts it over <root>/securecore.json from tmpfs; the extension there reloads it as on a host. layer1 and vault changes apply at the next start and the guest's extension reports restart_needed, as on a host; the host's egress takes layer 2's new hosts at once. --guest-ini <file> carries the site's securecore.debug_* php.ini settings into the guest (any other key is refused): in each start message, and again on every change, with php-fpm started again gracefully. ext-config and ext-attribution check these on the microVM target instead of n/a.
…ig-90 # Conflicts: # ext/fpm/src/guest.rs
…s, the guest decides a delivery (#90 review) - securecore.json and the --guest-ini file are read with the pool user's filesystem ids (setfsuid/setfsgid, this thread only), O_NOFOLLOW, regular files only, within a cap (128 KiB, 16 KiB): a link to another site's config or to /dev/zero is refused and logged. The watcher parses with the config crate's own Config::from_slice and LoadError wording. - --guest-ini values may hold only [a-z0-9_.,:-] (at most 64): no ${VAR}, which PHP would expand from php-fpm's environment, where the vault's secrets are. A refused line is never quoted back. - The guest mounts a delivered config only on <root>/securecore.json opened O_PATH|O_NOFOLLOW and found to be a regular file, through its /proc/self/fd path: never through a link on the site disk. - A delivery whose reply didn't arrive is settled by asking the guest which config it reads now (configsha): if it is the one sent, it stands. - test/lib/na-expected.txt: config 5 and attribution 0 on this branch; ext-config checks that a link in place of securecore.json is refused while the guest keeps its config.
…file as the pool user; --guest-ini as the launcher (#90 review) CI on 4f6… showed the launcher refusing to start: it opened --guest-ini (the operator's file, under a 0700 folder) as the pool user. read_regular now opens the folder as the launcher and only the file in it (openat, O_NOFOLLOW) as the pool user, the way the site disk's copy reaches the site; --guest-ini is read as the launcher, never through a link, regular and capped. A test as root checks that a file only root may read isn't read for the pool user.
Review fixes (#90 review), in b46f3fe (after merging #92 in 5108e40)
Evidence ([xps], head 33f4229; flock + sudo, each logged, exit codes checked; fresh projects
|
…ig-90 # Conflicts: # ext/fpm/src/vm.rs
… does; late answers and ini retries (#90 verification review) - S1/N2: the config watcher and --guest-ini use sitefile::read (no link anywhere in the path, as the folder's owner, regular only, capped), the launcher's start reading; read_regular is gone. The watcher's refusals use LoadError::without_contents. - N5: the guest's configsha answer reads <root>/securecore.json the same way. - N4: a php.ini delivery the guest never answered is sent again on the next look (its own refusal stands); a config delivery whose answer was lost is settled by asking the guest which config it reads on the next looks too (up to 10). - ext-config's microVM checks expect the launcher's contents-free wording.
Verification-review fixes (round 3)
Revert proof (one tree with K2, K4, N1, S1 undone, iMac Colima Rust gate): Also fixed, found by CI on the way (#91 cbb3e6d, merged up to ceae6bf): GitHub's run of the stress had 11 of 240 requests fail right after a SIGUSR2 reload. The guest answered the reload once the new master had started, so the launcher logged "reloaded" and the next requests met no listener. The guest now answers a reload only once 127.0.0.1:9000 takes connections (10 s at most), as it already did for a restart caused by a start message. Revert-and-fail: the CI run of 36ed957 ( Gates ([xps], flock + sudo, each logged and exit-checked; fresh projects)Head 36ed957, the full set: After the reload fix (ceae6bf): -claude |
Symlinked site roots work again (a deployment's
|
Fixes #90: an edited
securecore.jsonreaches the running guest, with the host's behaviour, and the per-site debug settings from php.ini work in the guest. Stacked on #92 (#87) and #91 (#86); this PR targetsclaude/microvm-boot-reason-87.Design
The config: live delivery, no restart. I chose this over the issue's alternative (rebuild the site disk and restart the VM): it is what a host does, and it is faster.
securecore_config::Reloader, the same stamp, loader and messages, once a second. That isWATCH_INTERVAL, the same as the extension'sRELOAD_INTERVAL.<file>: invalid: …; keeping the last valid config in the guest (sha256 …), the extension's wording on a host.live_changeruns the sameplan()check a start runs, so a config the microVM can't run (for exampleunixSockets) is refused and logged, and the guest keeps its config.config <hex>line, accepted only after the start message./run/securecore/securecore-N.json) and bind-mounts it read-only over<root>/securecore.json, on top of the one before.restart_needed, and itssecurecore: reloaded … (sha256 …)line.restart_needed. Layers 2 and 3 change in place. A change tolayer1or the vault is delivered, and the launcher logs that it applies at the next start. The guest's extension reportsrestart_needed=1, as it does on a host, because it compares against the config it started with.RwLock.php.ini:
--guest-ini <file>. php.ini in the guest is the root image's, the same for every site, so the per-site settings come from the launcher:securecore.debug_* = …lines. Any other key is refused with the reason. The rest of php.ini is the image's, and anextension=orsecurecore.config=line from a site has no business in the guest.inicontrol line). The guest writes/run/securecore/conf.d/zz-site.iniand adds it toPHP_INI_SCAN_DIR.Measured
On [xps], from the write of
securecore.jsonto the first request served on the new config: 480–486 ms (3 runs). The launcher delivered it 427–434 ms after the write: the 1 s stat poll, about half a second on average. The control round trip and the guest's mount take 1–2 ms ("delivered … to the running guest in 1 ms").Tests
test/ext-config.shon the microVM. These checks weren/aand are now real:restart_needed=1, and the launcher says it applies at the next start;Still n/a, each with its reason: "status reports off" (the target keeps layer 1 on);
reload_error(the guest never sees the invalid file; the launcher's log check replaces it); thesecurecore.configphp.ini cases.test/ext-attribution.shon the microVM. All 34 former n/a checks are real now: the debug settings go through--guest-ini, and an invalid value stops php-fpm with the extension's reason.test/lib/target.sh.putis one rename.put_deliveredputs a config into the running guest and waits for the launcher's delivered or refused line.launcher_startpasses--guest-ini $tdir/guest.ini.put_livestill restarts on microVM, because suites change site files with it.Unit tests:
a_live_edit_is_refused_when_the_vm_cant_run_it_and_flags_what_needs_a_start;a_sites_ini_carries_only_the_debug_settings;configis accepted only after the start;iniafterenv.Evidence ([xps]; flock + sudo, logged, exit codes checked; fresh projects)
site_sync.No such imagefor my stack's php container, whose image had been removed from the host while the container ran. I don't prune; someone else on [xps] did. After recreating my container it passes.-D warnings(linux target): clean.Revert proof
The same suites against a build with only the launcher's watcher removed (
watch_livenever started):closes #90
-claude