diff --git a/.github/workflows/ci-macos.yml b/.github/workflows/ci-macos.yml index 65ef017caf..541a065c99 100644 --- a/.github/workflows/ci-macos.yml +++ b/.github/workflows/ci-macos.yml @@ -76,6 +76,7 @@ jobs: - "crates/minvmd/**" - "crates/minimald/**" # guest daemon: pid-1 in the e2e/boot VM - "crates/minimal/**" + - "crates/minzoned/**" # the box-name service: the zoned job - "crates/sessions/**" # platform-sensitive: canonicalization, symlinks - "Cargo.toml" - "Cargo.lock" @@ -565,13 +566,55 @@ jobs: if-no-files-found: error retention-days: 3 + zoned: + # The box-name service (minzoned) as a real LaunchDaemon: the + # privileged command `min` hands an operator, run for real, then the + # service proved through the system resolver, its channel, a restart + # and a clean teardown (scripts/zoned-macos-e2e.sh). It needs root, + # and the self-hosted fleet has no sudo because it runs PR code, so + # this runs on a GitHub-hosted runner: ephemeral, sudo without a + # password, no VM needed (a script stands in for the node). The + # debug `min` skips the codesign requirement check, so that part + # stays unproved here. + needs: [changes] + if: github.event_name != 'merge_group' && (github.event_name != 'pull_request' || needs.changes.outputs.macos == 'true') + runs-on: macos-latest + timeout-minutes: 30 + env: + CARGO_PROFILE_DEV_DEBUG: line-tables-only + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 + with: + persist-credentials: false + - name: Toolchain + uses: dtolnay/rust-toolchain@4cda84d5c5c54efe2404f9d843567869ab1699d4 # stable + with: + toolchain: stable + - name: Cache cargo registry and build artifacts + uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2 # zizmor: ignore[cache-poisoning] test-only lane, nothing published; save-if keeps every non-main ref read-only + with: + shared-key: mac-zoned + save-if: ${{ github.ref == 'refs/heads/main' }} + - name: Build minzoned and min + # Two invocations, as the unit job builds its testbed: one + # cargo call would unify features across both packages. + # `min` finds `minzoned` beside its own executable. + run: | + set -euo pipefail + cargo build -p minzoned --locked + cargo build -p minimal --bin min --locked + - name: Prove the service install + env: + MINIMAL_E2E_PRIVILEGED: "1" + run: scripts/zoned-macos-e2e.sh target/debug/min + # Single required status check for this lane (branch-protection context: # ci-macos-success). Green when every gating job succeeded OR was # path-skipped (or the RUN_MACOS_CI kill-switch skipped the e2e); red only # on failure/cancellation. ci-macos-success: if: always() - needs: [changes, artifacts, e2e, unit] + needs: [changes, artifacts, e2e, unit, zoned] runs-on: ubuntu-latest timeout-minutes: 5 steps: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7c8835e14a..c3377f5b70 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -258,6 +258,18 @@ jobs: mv min minimal-linux-amd64 mv minimald minimald-linux-amd64 mv minvmd minvmd-linux-amd64 + mv minzoned minzoned-linux-amd64 + - name: Re-check minzoned links on the renamed artifact + # dist-build.sh gated the binary it built; re-run the same gate + # on the exact file that uploads, so the shipped bytes are the + # checked bytes. + run: scripts/check-zoned-links.sh target/x86_64-unknown-linux-musl/release/minzoned-linux-amd64 + - name: Upload binary (minzoned) + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7 + with: + name: minzoned-linux-amd64 + path: target/x86_64-unknown-linux-musl/release/minzoned-linux-amd64 + retention-days: 7 - name: Upload binary (mip) uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7 with: @@ -378,6 +390,16 @@ jobs: mv mip mip-linux-arm64 mv minimald minimald-linux-arm64 mv minvmd minvmd-linux-arm64 + mv minzoned minzoned-linux-arm64 + - name: Re-check minzoned links on the renamed artifact + # See the amd64 job: the gate runs again on the file that uploads. + run: scripts/check-zoned-links.sh target/aarch64-unknown-linux-musl/release/minzoned-linux-arm64 + - name: Upload binary (minzoned) + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7 + with: + name: minzoned-linux-arm64 + path: target/aarch64-unknown-linux-musl/release/minzoned-linux-arm64 + retention-days: 7 - name: Upload binary (minimal) uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7 with: @@ -428,11 +450,20 @@ jobs: # self-hosted runner is offline — a skip here also skips `release`, which # needs it. runs-on: [self-hosted, macOS, ARM64] - timeout-minutes: 45 + # 60, not 45: the build takes about 15 minutes, and the notarization + # step below waits on Apple's notary service for three submissions. + timeout-minutes: 60 needs: [assert-version] if: vars.RUN_MACOS_CI != 'false' env: MINIMAL_RELEASE_VERSION: ${{ needs.assert-version.outputs.release_version }} + # The signing identity minzoned is signed under below, compiled + # into `min` (option_env! in crates/minimal/src/resolver.rs): the + # session advisory verifies the copy source against the Developer + # ID requirement for this team and identifier, and a `min` built + # without them offers no answerer step on macOS. + MINIMAL_ZONED_TEAMID: 3G47C5HY64 + MINIMAL_ZONED_IDENTIFIER: dev.minimal.minzoned steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 with: @@ -475,12 +506,21 @@ jobs: printf '%s\n' "$bad" >&2 exit 1 fi + - name: Build release minzoned binary + # Its OWN invocation, like minimal above and for the same reason: + # beside `-p minvmd` the libkrun feature would unify into the + # answerer a root host service must never carry. Link-gated as + # built; the gate runs again on the signed artifact below. + run: | + cargo build --release --locked -p minzoned --bin minzoned + scripts/check-zoned-links.sh target/release/minzoned - name: Rename binaries with platform suffix # download-artifact merge-multiple flattens on basename, so the uploaded # file must already carry the platform-suffixed name the release job expects. run: | mv target/release/minvmd target/release/minvmd-macos-arm64 mv target/release/min target/release/minimal-macos-arm64 + mv target/release/minzoned target/release/minzoned-macos-arm64 - name: Codesign binaries with Developer ID # Sign the two shipped Mach-O binaries with the Developer ID # Application identity held in the runner's signing keychain. This @@ -505,9 +545,82 @@ jobs: codesign --force --timestamp --options runtime \ --sign "$IDENTITY" \ target/release/minimal-macos-arm64 + # minzoned: no entitlements at all (no hypervisor, no + # disable-library-validation, no dyld environment, no JIT), + # and an explicit identifier, the one `min` checks it by. + codesign --force --timestamp --options runtime \ + --identifier "$MINIMAL_ZONED_IDENTIFIER" \ + --sign "$IDENTITY" \ + target/release/minzoned-macos-arm64 codesign --verify --strict --verbose=2 target/release/minvmd-macos-arm64 codesign --verify --strict --verbose=2 target/release/minimal-macos-arm64 + # The exact designated requirement the session advisory and + # the privileged step verify the answerer against. + codesign --verify --strict --verbose=2 \ + -R "=anchor apple generic and certificate 1[field.1.2.840.113635.100.6.2.6] exists and certificate leaf[field.1.2.840.113635.100.6.1.13] exists and certificate leaf[subject.OU] = \"$MINIMAL_ZONED_TEAMID\" and identifier \"$MINIMAL_ZONED_IDENTIFIER\"" \ + target/release/minzoned-macos-arm64 + - name: Re-check minzoned links on the signed artifact + # The last check before upload, on the signed and renamed bytes. + run: scripts/check-zoned-links.sh target/release/minzoned-macos-arm64 + - name: Notarize binaries + # Submit each signed binary to Apple's notary service and fail the + # release unless every result is Accepted. Notarization does not + # modify the file, so the uploaded bytes stay the signed, link-gated + # bytes above. notarytool takes a zip, a .pkg or a .dmg, never a + # bare Mach-O, so each binary goes up in a ditto zip that is used + # only for the submission. + # + # No staple: the release ships each binary as a bare Mach-O file, + # and stapler cannot attach a ticket to one (only to an .app, a .pkg + # or a .dmg). Gatekeeper looks the ticket up online instead. + # + # The credentials are a notarytool keychain profile stored in the + # signing keychain; the repository variable MACOS_NOTARY_PROFILE + # names it. + env: + KC_PW: ${{ secrets.KC_PW }} + NOTARY_PROFILE: ${{ vars.MACOS_NOTARY_PROFILE }} + run: | + if [ -z "$NOTARY_PROFILE" ]; then + echo "::error::repository variable MACOS_NOTARY_PROFILE is not set" >&2 + exit 1 + fi + KC=minimal-signing.keychain-db + security unlock-keychain -p "$KC_PW" "$KC" + + work="$RUNNER_TEMP/notarize" + rm -rf "$work" + mkdir -p "$work" + for f in target/release/minvmd-macos-arm64 \ + target/release/minimal-macos-arm64 \ + target/release/minzoned-macos-arm64; do + name=$(basename "$f") + zip="$work/$name.zip" + result="$work/$name.json" + ditto -c -k --keepParent "$f" "$zip" + + echo "Submitting $name for notarization" + xcrun notarytool submit "$zip" \ + --keychain-profile "$NOTARY_PROFILE" \ + --keychain "$HOME/Library/Keychains/$KC" \ + --wait --timeout 15m \ + --output-format json >"$result" || true + cat "$result" + + status=$(plutil -extract status raw -o - "$result" 2>/dev/null || true) + if [ "$status" != "Accepted" ]; then + echo "::error::notarization of $name ended with status '${status:-none}'" >&2 + id=$(plutil -extract id raw -o - "$result" 2>/dev/null || true) + if [ -n "$id" ]; then + xcrun notarytool log "$id" \ + --keychain-profile "$NOTARY_PROFILE" \ + --keychain "$HOME/Library/Keychains/$KC" || true + fi + exit 1 + fi + echo "$name: Accepted" + done - name: Upload binary (minvmd) uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7 with: @@ -520,6 +633,12 @@ jobs: name: minimal-macos-arm64 path: target/release/minimal-macos-arm64 retention-days: 7 + - name: Upload binary (minzoned) + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7 + with: + name: minzoned-macos-arm64 + path: target/release/minzoned-macos-arm64 + retention-days: 7 build-libkrun-macos-arm64: # Build the TRIMMED libkrun.dylib to SHIP in the release, so macOS users diff --git a/Cargo.lock b/Cargo.lock index ac7d8163c6..59608f201a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3983,17 +3983,6 @@ dependencies = [ "unicase", ] -[[package]] -name = "min-answerer" -version = "0.7.0" -dependencies = [ - "anyhow", - "clap", - "minvmd", - "tracing-subscriber", - "version", -] - [[package]] name = "minimal" version = "0.7.0" @@ -4234,6 +4223,17 @@ dependencies = [ "version", ] +[[package]] +name = "minzoned" +version = "0.7.0" +dependencies = [ + "anyhow", + "clap", + "minvmd", + "tracing-subscriber", + "version", +] + [[package]] name = "mio" version = "1.2.2" diff --git a/Cargo.toml b/Cargo.toml index 86bf4e8e9d..ff818a8323 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,7 @@ members = [ "crates/minimald", "crates/minimald-rpc", "crates/minvmd", - "crates/min-answerer", + "crates/minzoned", "crates/mlog", "crates/remote-client", "crates/remote-proto", diff --git a/crates/minimal/src/cli.rs b/crates/minimal/src/cli.rs index 6964593bc7..a73eca892c 100644 --- a/crates/minimal/src/cli.rs +++ b/crates/minimal/src/cli.rs @@ -124,6 +124,15 @@ pub enum Command { /// on Ctrl-C, whichever comes first. #[command(hide = true)] Spin(SpinArgs), + /// Print the privileged command that installs this host's resolver, + /// local range and box-name service (development aid). + /// + /// The command a session start's advisory prints, rendered without a + /// daemon, so the service install can be tested on a host that cannot + /// boot a VM. Debug builds only. + #[cfg(debug_assertions)] + #[command(name = "debug-answerer-command", hide = true)] + DebugAnswererCommand, /// Print session-identifier completion candidates (used by the shell). /// /// The completion path a shell actually takes runs in-process (see diff --git a/crates/minimal/src/cmd/mod.rs b/crates/minimal/src/cmd/mod.rs index 1a6c7b45d1..d1b45ff170 100644 --- a/crates/minimal/src/cmd/mod.rs +++ b/crates/minimal/src/cmd/mod.rs @@ -103,6 +103,14 @@ pub(crate) async fn run_command(cli: Cli) -> Result<(), anyhow::Error> { // logging may need stdout too. Some(Command::Version) => cmd_version(&cli.global_args, &mut std::io::stdout()).await, Some(Command::Spin(args)) => cmd_spin(&cli.global_args, args).await, + #[cfg(debug_assertions)] + Some(Command::DebugAnswererCommand) => { + println!( + "{}", + crate::resolver::answerer_command_for_this_host().await? + ); + Ok(()) + } Some(Command::Init(args)) => cmd_init(&cli.global_args, args) .await .map_err(|e| anyhow::anyhow!("{e}")), diff --git a/crates/minimal/src/resolver.rs b/crates/minimal/src/resolver.rs index f0b46abb7f..6d689abf85 100644 --- a/crates/minimal/src/resolver.rs +++ b/crates/minimal/src/resolver.rs @@ -168,8 +168,23 @@ const COMMAND_RESERVES_THE_RANGE: bool = false; /// command that installs them, and the custody checks over them all name /// this one label beside [`RANGE_UNIT_LABEL`]'s step — one definition, so /// the service the command installs, the step the advisory re-surfaces -/// until it holds, and the unit the bundle records cannot drift apart. -pub(crate) const ANSWERER_UNIT_LABEL: &str = "dev.minimal.zone-answerer"; +/// until it holds, and the unit the bundle records cannot drift apart: +/// [`ANSWERER_LAUNCHD_LABEL`] on macOS, [`ANSWERER_SYSTEMD_UNIT`] elsewhere. +#[cfg(target_os = "macos")] +pub(crate) const ANSWERER_UNIT_LABEL: &str = ANSWERER_LAUNCHD_LABEL; +#[cfg(not(target_os = "macos"))] +pub(crate) const ANSWERER_UNIT_LABEL: &str = ANSWERER_SYSTEMD_UNIT; + +/// launchd's job label for the answerer service (see +/// [`ANSWERER_UNIT_LABEL`]); the plist file is named after it. +#[cfg(any(test, target_os = "macos"))] +const ANSWERER_LAUNCHD_LABEL: &str = "dev.gominimal.zone"; + +/// systemd's unit name stem for the answerer service (see +/// [`ANSWERER_UNIT_LABEL`]): `minzoned.socket` and `minzoned.service`, +/// named after the program they run. +#[cfg(any(test, not(target_os = "macos")))] +const ANSWERER_SYSTEMD_UNIT: &str = "minzoned"; /// The root-owned path the answerer program is copied to — never a /// user-writable binary: `/Library/PrivilegedHelperTools` beside the range @@ -177,20 +192,19 @@ pub(crate) const ANSWERER_UNIT_LABEL: &str = "dev.minimal.zone-answerer"; /// the copy the service runs nor read what the step wrote before the /// ownership converged ([`answerer_step_over`] walks every component). #[cfg(any(test, target_os = "macos"))] -const MACOS_ANSWERER_PROGRAM_PATH: &str = - "/Library/PrivilegedHelperTools/dev.minimal.zone-answerer"; +const MACOS_ANSWERER_PROGRAM_PATH: &str = "/Library/PrivilegedHelperTools/minzoned"; /// The plist the answerer step installs: the file launchd scans at boot, /// which is what makes the service hold the sockets at every one. #[cfg(any(test, target_os = "macos"))] -const ANSWERER_PLIST_PATH: &str = "/Library/LaunchDaemons/dev.minimal.zone-answerer.plist"; +const ANSWERER_PLIST_PATH: &str = "/Library/LaunchDaemons/dev.gominimal.zone.plist"; /// The root-owned path the answerer program is copied to on Linux — never /// a user-writable binary, the same rule as [`MACOS_ANSWERER_PROGRAM_PATH`]'s /// macOS arm: `/usr/local/lib/minimal` is root's alone, and the walk over /// it is what custody means here. #[cfg(any(test, not(target_os = "macos")))] -const LINUX_ANSWERER_PROGRAM_PATH: &str = "/usr/local/lib/minimal/dev.minimal.zone-answerer"; +const LINUX_ANSWERER_PROGRAM_PATH: &str = "/usr/local/lib/minimal/minzoned"; /// The root-owned program copy this host's step installs and its checks /// read back: [`MACOS_ANSWERER_PROGRAM_PATH`] on macOS, @@ -212,13 +226,13 @@ const ANSWERER_PROGRAM_DIR: &str = "/usr/local/lib/minimal"; /// stream channel at the channel's path — and hands them to the service /// at socket activation. #[cfg(any(test, not(target_os = "macos")))] -const ANSWERER_UNIT_SOCKET_PATH: &str = "/etc/systemd/system/dev.minimal.zone-answerer.socket"; +const ANSWERER_UNIT_SOCKET_PATH: &str = "/etc/systemd/system/minzoned.socket"; /// The systemd service unit the answerer step installs: the unit that /// runs the root-owned program copy as the operator and receives the /// sockets the socket unit holds. #[cfg(any(test, not(target_os = "macos")))] -const ANSWERER_UNIT_SERVICE_PATH: &str = "/etc/systemd/system/dev.minimal.zone-answerer.service"; +const ANSWERER_UNIT_SERVICE_PATH: &str = "/etc/systemd/system/minzoned.service"; /// The unit files the step installs — launchd's one plist on macOS, /// systemd's socket+service pair on Linux — in the order the custody @@ -229,8 +243,8 @@ const ANSWERER_UNIT_PATHS: &[&str] = &[ANSWERER_PLIST_PATH]; const ANSWERER_UNIT_PATHS: &[&str] = &[ANSWERER_UNIT_SOCKET_PATH, ANSWERER_UNIT_SERVICE_PATH]; /// The launchd unit the answerer step installs, as the command writes -/// it: label [`ANSWERER_UNIT_LABEL`], `ProgramArguments` the root-owned -/// `min-answerer` copy and nothing else, `UserName` the operator +/// it: label [`ANSWERER_LAUNCHD_LABEL`], `ProgramArguments` the root-owned +/// `minzoned` copy and nothing else, `UserName` the operator /// the service manager runs it as — never root: the channel's uid gate /// serves the uid the unit names, so a root-run service is one no daemon /// of this operator could ever publish to — and the two sockets launchd @@ -258,7 +272,7 @@ const ANSWERER_PLIST_TEMPLATE: &str = "\ \tLabel -\tdev.minimal.zone-answerer +\tdev.gominimal.zone \tProgramArguments \t \t\t__PROGRAM__ @@ -321,14 +335,14 @@ Description=The Minimal box-zone answerer sockets ListenDatagram=127.0.0.1:7656 ListenStream=__CHANNEL__ SocketMode=0666 -__RUNTIME_DIRECTORY__Service=dev.minimal.zone-answerer.service +__RUNTIME_DIRECTORY__Service=minzoned.service [Install] WantedBy=sockets.target "; /// The systemd service unit the answerer step installs, as the command -/// writes it: the root-owned `min-answerer` copy, run as the operator — `User=` is the uid the channel's +/// writes it: the root-owned `minzoned` copy, run as the operator — `User=` is the uid the channel's /// gate serves, the one whose daemons may publish — and restarted when /// it dies, because the sockets it serves belong to the socket unit, not /// the process: a service that comes back serves from the same @@ -795,7 +809,7 @@ pub(crate) enum AnswererStep { /// The protocol version this daemon speaks. daemon: u32, }, - /// The step's copy source — this machine's `min-answerer` — passed the + /// The step's copy source — this machine's `minzoned` — passed the /// identity check the advisory runs before offering the privileged step /// ([`answerer_step_with_source`]), and its bytes are pinned: the /// command carries the step, copying exactly those bytes or nothing. @@ -820,7 +834,7 @@ pub(crate) enum AnswererStep { reason: String, }, /// The step cannot be offered at all, for a named reason no check could - /// change: this release ships no `min-answerer`, or this build carries + /// change: this release ships no `minzoned`, or this build carries /// no signing identity to verify one by. The step is said to be /// unavailable — never silently dropped — and the command carries none. SourceUnavailable { @@ -984,7 +998,7 @@ pub(crate) fn answerer_step_over(facts: &AnswererFacts, daemon: u32) -> Answerer /// The inputs the answerer install renders from that only the running /// machine knows, gathered once per render: the operator the unit runs /// the service as, the machine-global channel the unit holds, the -/// `min-answerer` program on this machine the step copies, and the control +/// `minzoned` program on this machine the step copies, and the control /// sockets of the VM host daemons the step asks to release the hook port. #[derive(Debug, Clone, PartialEq, Eq)] pub(crate) struct AnswererInstall { @@ -994,7 +1008,7 @@ pub(crate) struct AnswererInstall { pub channel: String, /// The channel socket's directory. pub channel_dir: String, - /// The `min-answerer` program the step copies — beside this `min`, or + /// The `minzoned` program the step copies — beside this `min`, or /// on `PATH`; never a bare name the shell might resolve to anything. pub source: String, /// The SHA-256 of the source bytes verified at render time: the @@ -1011,9 +1025,9 @@ pub(crate) struct AnswererInstall { pub controls: Vec, } -/// The program the answerer step copies: `min-answerer`, the dedicated +/// The program the answerer step copies: `minzoned`, the dedicated /// answerer binary — never `minvmd`, and never a bare name. -pub(crate) const ANSWERER_PROGRAM_NAME: &str = "min-answerer"; +pub(crate) const ANSWERER_PROGRAM_NAME: &str = "minzoned"; /// The operator the answerer unit runs the service as: the user this CLI /// runs as, read the way launchd and every login shell record it @@ -1037,7 +1051,7 @@ fn operator_name() -> String { /// Where the answerer program is on this machine, pure over where to look: /// beside the running `min` first (a release ships the two together; a dev /// build puts them in one target dir), then each directory of `path`. Only -/// `min-answerer` is ever named — never `minvmd`, whatever sits beside it — +/// `minzoned` is ever named — never `minvmd`, whatever sits beside it — /// and `None` when no such file exists, so the advisory names no program /// it cannot find. pub(crate) fn answerer_source_in( @@ -1069,7 +1083,7 @@ fn answerer_source() -> Option { /// The stand-in program path the suite's fixed installs carry. #[cfg(test)] -pub(crate) const TEST_ANSWERER_SOURCE: &str = "/opt/minimal-test/bin/min-answerer"; +pub(crate) const TEST_ANSWERER_SOURCE: &str = "/opt/minimal-test/bin/minzoned"; /// The control sockets the answerer step asks to release the hook port, /// set by the session start that renders the advisory (its own state dir's @@ -1137,25 +1151,25 @@ fn unquotable_value(install: &AnswererInstall) -> Option<&str> { .find(|value| value.chars().any(unsafe_char)) } -/// The Developer ID team the release signs `min-answerer` with, compiled in -/// from `MINIMAL_ANSWERER_TEAMID` by the release build of this CLI — the +/// The Developer ID team the release signs `minzoned` with, compiled in +/// from `MINIMAL_ZONED_TEAMID` by the release build of this CLI — the /// `` of [`answerer_requirement`]. A release build without it /// carries no signing identity and offers no answerer step on macOS (see /// [`macos_answerer_requirement`]); there is no fallback to a bare /// `codesign --strict`, which any ad-hoc signature passes. #[cfg(all(target_os = "macos", not(any(test, debug_assertions))))] -const ANSWERER_SIGNING_TEAMID: Option<&str> = option_env!("MINIMAL_ANSWERER_TEAMID"); +const ANSWERER_SIGNING_TEAMID: Option<&str> = option_env!("MINIMAL_ZONED_TEAMID"); -/// The code-signing identifier the release signs `min-answerer` under -/// (`codesign --identifier`), compiled in from `MINIMAL_ANSWERER_IDENTIFIER` +/// The code-signing identifier the release signs `minzoned` under +/// (`codesign --identifier`), compiled in from `MINIMAL_ZONED_IDENTIFIER` /// beside [`ANSWERER_SIGNING_TEAMID`] and required the same way. #[cfg(all(target_os = "macos", not(any(test, debug_assertions))))] -const ANSWERER_SIGNING_IDENTIFIER: Option<&str> = option_env!("MINIMAL_ANSWERER_IDENTIFIER"); +const ANSWERER_SIGNING_IDENTIFIER: Option<&str> = option_env!("MINIMAL_ZONED_IDENTIFIER"); /// The reason the step is unavailable when this machine has no -/// `min-answerer` to copy: the release this `min` came from shipped none +/// `minzoned` to copy: the release this `min` came from shipped none /// beside it, and none is on `PATH`. -const ANSWERER_NOT_SHIPPED: &str = "this release ships no min-answerer"; +const ANSWERER_NOT_SHIPPED: &str = "this release ships no minzoned"; /// The reason the step is unavailable on a macOS release build that was /// compiled without [`ANSWERER_SIGNING_TEAMID`] or @@ -1164,7 +1178,7 @@ const ANSWERER_NOT_SHIPPED: &str = "this release ships no min-answerer"; #[cfg(any(test, all(target_os = "macos", not(debug_assertions))))] const ANSWERER_NO_SIGNING_IDENTITY: &str = "this build carries no signing identity"; -/// The designated requirement `min-answerer` must satisfy on macOS: signed +/// The designated requirement `minzoned` must satisfy on macOS: signed /// by Apple's Developer ID chain (the intermediate's Developer ID marker, /// the leaf's Developer ID Application marker), by this team, under this /// identifier. `None` when either value holds anything but ASCII letters, @@ -1209,7 +1223,7 @@ fn macos_answerer_requirement( /// copy with ([`answerer_requirement`]). #[derive(Debug, Clone, PartialEq, Eq, Serialize)] pub(crate) struct VerifiedSource { - /// The `min-answerer` the step copies. + /// The `minzoned` the step copies. pub path: String, /// Lowercase hex SHA-256 of the bytes verified at render time. pub sha256: String, @@ -1246,7 +1260,7 @@ const ANSWERER_IDENTITY_BOUND: Duration = Duration::from_secs(5); /// Developer ID requirement this build carries ([`answerer_requirement`]), /// or unavailable when it carries none. On Linux the identity is the /// SHA-256 pin alone ([`answerer_step_with_source`]); link-cleanliness is -/// proven at release (`scripts/check-answerer-links.sh`), not here. +/// proven at release (`scripts/check-zoned-links.sh`), not here. /// /// Skipped for debug and test builds under the same gate as the /// channel-path override (`debug_path_override` in minvmd's answerer @@ -2250,7 +2264,7 @@ fn verified_copy_steps(install: &AnswererInstall, dir: &str, dest: &str, macos: {dq}{d}p{dq}{q}, on the path to {dir}, is not a root-owned, non-sticky directory closed \ to group and other writes; the answerer service was not installed{q} >&2 ; exit 1 ; }} \ ; if [ {dq}{d}p{dq} = / ] ; then break ; fi ; p={d}(dirname {dq}{d}p{dq}) ; done \ - ; t={d}(mktemp {q}{dir}/.{ANSWERER_UNIT_LABEL}.XXXXXX{q}) \ + ; t={d}(mktemp {q}{dir}/.{ANSWERER_PROGRAM_NAME}.XXXXXX{q}) \ ; install -m 0755 -o root -g {group} {q}{source}{q} {d}t || {copy_failed} \ ; h={d}({hash} < {d}t || true) ; h={d}{{h%% *}} \ ; case {d}h in {sha}) ;; *) rm -f {d}t ; echo {q}minimal: the answerer copy hashes{q} \ @@ -2263,7 +2277,7 @@ fn verified_copy_steps(install: &AnswererInstall, dir: &str, dest: &str, macos: /// The macOS answerer steps of the privileged command (NET-122's host /// service), after the range's: boot out a running service, copy -/// `min-answerer` to the root-owned path and write the plist naming it, +/// `minzoned` to the root-owned path and write the plist naming it, /// root's both; ask this CLI's VM host daemons to release the hook port /// (the copy's `release` verb, which waits up to 2 s for the port to be /// free); then load the plist and wait up to 5 s for the channel. Either @@ -2288,7 +2302,7 @@ fn macos_answerer_steps(install: &AnswererInstall) -> String { format!("\"{copy}\" release-cancel{controls} ; ") }; format!( - "{{ (launchctl bootout system/{ANSWERER_UNIT_LABEL} 2>/dev/null || true) ; \ + "{{ (launchctl bootout system/{ANSWERER_LAUNCHD_LABEL} 2>/dev/null || true) ; \ rm -f {ANSWERER_PLIST_PATH} \"{copy}\" \"{channel}\" ; {cancel}echo \"minimal: \ {reason}; the answerer service was not installed\" >&2 ; exit 1 ; }}" ) @@ -2303,7 +2317,7 @@ fn macos_answerer_steps(install: &AnswererInstall) -> String { }; format!( "{verified_copy} \ - ; (launchctl bootout system/{ANSWERER_UNIT_LABEL} 2>/dev/null || true) \ + ; (launchctl bootout system/{ANSWERER_LAUNCHD_LABEL} 2>/dev/null || true) \ ; mkdir -p \"{channel_dir}\" \ ; cat > {ANSWERER_PLIST_PATH} <<\\{ANSWERER_PLIST_HEREDOC}\n\ {answerer_plist}\ @@ -2438,7 +2452,7 @@ pub(crate) fn linux_command(port: u16, install: Option<&AnswererInstall>) -> Str /// The Linux answerer steps of the privileged command (NET-122's host /// service), after the resolver's: stop a running service, copy -/// `min-answerer` to the root-owned path, write the socket and service +/// `minzoned` to the root-owned path, write the socket and service /// units naming it, root's all three, and enable the socket for every boot /// without starting it; ask this CLI's VM host daemons to release the hook /// port (the copy's `release` verb, which waits up to 2 s for the port to @@ -2457,7 +2471,7 @@ fn linux_answerer_steps(install: &AnswererInstall) -> String { let controls = control_args(install, '\''); let copy = LINUX_ANSWERER_PROGRAM_PATH; let channel = &install.channel; - let unit = format!("{ANSWERER_UNIT_LABEL}.socket"); + let unit = format!("{ANSWERER_SYSTEMD_UNIT}.socket"); let fail = |reason: &str| { let cancel = if controls.is_empty() { String::new() @@ -2465,7 +2479,7 @@ fn linux_answerer_steps(install: &AnswererInstall) -> String { format!("'{copy}' release-cancel{controls} ; ") }; format!( - "{{ systemctl disable --now {unit} {ANSWERER_UNIT_LABEL}.service 2>/dev/null \ + "{{ systemctl disable --now {unit} {ANSWERER_SYSTEMD_UNIT}.service 2>/dev/null \ || true ; rm -f {ANSWERER_UNIT_SOCKET_PATH} {ANSWERER_UNIT_SERVICE_PATH} \ '{copy}' ; systemctl daemon-reload || true ; {cancel}echo 'minimal: {reason}; \ the answerer service was not installed' >&2 ; exit 1 ; }}" @@ -2481,7 +2495,7 @@ fn linux_answerer_steps(install: &AnswererInstall) -> String { }; format!( "{verified_copy} \ - ; (systemctl stop {unit} {ANSWERER_UNIT_LABEL}.service 2>/dev/null || true) \ + ; (systemctl stop {unit} {ANSWERER_SYSTEMD_UNIT}.service 2>/dev/null || true) \ ; cat > {ANSWERER_UNIT_SOCKET_PATH} <<\\{ANSWERER_SOCKET_HEREDOC}\n\ {answerer_socket}\ {ANSWERER_SOCKET_HEREDOC}\n\ @@ -2510,7 +2524,7 @@ chown root:root {ANSWERER_UNIT_SOCKET_PATH} {ANSWERER_UNIT_SERVICE_PATH} \ /// The exact command that configures this host's resolver for [`ZONE`] at /// `port` — the command NET-122's advisory names. /// `install` is the answerer step's inputs when the step is offered and -/// this machine has a `min-answerer` to copy; `None` renders the resolver +/// this machine has a `minzoned` to copy; `None` renders the resolver /// (and, on macOS, the range) alone. #[cfg(target_os = "macos")] pub(crate) fn command(port: u16, install: Option<&AnswererInstall>) -> String { @@ -2522,6 +2536,28 @@ pub(crate) fn command(port: u16, install: Option<&AnswererInstall>) -> String { linux_command(port, install) } +/// The command [`command`] renders for this host with the answerer step +/// carried, from the same reads a session start's advisory makes — so a +/// test can run the exact privileged command without starting a daemon. +/// An error when the step cannot be carried (no `minzoned` beside this +/// `min` or on `PATH`, or a path the command cannot quote): a test must +/// not pass on a command without the service in it. Debug builds only, +/// where the identity check offers every source (see +/// [`answerer_source_identity`]). +#[cfg(debug_assertions)] +pub(crate) async fn answerer_command_for_this_host() -> anyhow::Result { + let step = read_answerer_step().await; + let install = match &step { + AnswererStep::SourceVerified { source, .. } => answerer_install(source), + _ => None, + } + .ok_or_else(|| anyhow::anyhow!("the answerer service step cannot be carried: {step:?}"))?; + Ok(command( + minvmd::net::answerer::DEFAULT_ANSWERER_PORT, + Some(&install), + )) +} + /// The answerer service's own state as an advisory fact, beside the /// range's. Every state but the first two is a fact the user has no other /// way to see; `carried` is whether the command below carries the service @@ -2613,8 +2649,9 @@ fn answerer_fact(answerer: &AnswererStep, carried: bool) -> Option { /// the command the advisory names is the whole of the host's missing /// configuration: the lead-in says what it does — on macOS "configure /// the host's resolver, reserve the local range, and install the -/// box-zone answerer service", on Linux "configure the host's resolver -/// and install the box-zone answerer service" — and nothing the note +/// Minimal box-name service (DNS and addresses for boxes)", on Linux +/// "configure the host's resolver and install the Minimal box-name service +/// (DNS and addresses for boxes)" — and nothing the note /// asks for stands beside that command unprovided. String assembly only. /// /// `range_step` is what the detection read beside the hook: the range @@ -2811,13 +2848,13 @@ pub(crate) fn advisory_at( install.is_some(), ) { (true, true) => { - "Configure the host's resolver and install the box-zone \ - answerer service with:" + "Configure the host's resolver and install the Minimal box-name \ + service (DNS and addresses for boxes) with:" } (true, false) => "Configure the host's resolver for the zone with:", (false, true) => { "Configure the host's resolver, reserve the local range, and \ - install the box-zone answerer service with:" + install the Minimal box-name service (DNS and addresses for boxes) with:" } (false, false) => "Configure the host's resolver and reserve the local range with:", }; @@ -3549,7 +3586,7 @@ mod tests { /// `step` with a verified, pinned copy source folded in — what /// [`read_answerer_step`] returns for a host that still needs the step - /// and has a `min-answerer` that passed its identity check. + /// and has a `minzoned` that passed its identity check. fn verified(step: AnswererStep) -> AnswererStep { AnswererStep::SourceVerified { service: Box::new(step), @@ -3634,14 +3671,14 @@ mod tests { operator: "operator".to_string(), channel_dir: "/run/minimal".to_string(), channel: "/run/minimal/answerer.sock".to_string(), - source: "/home/operator/.local/bin/min-answerer".to_string(), + source: "/home/operator/.local/bin/minzoned".to_string(), sha256: TEST_ANSWERER_SHA256.to_string(), requirement: None, controls: vec!["/home/operator/.minimal/vm/control.sock".to_string()], }; assert_eq!(unquotable_value(&base), None, "plain paths render"); let spaced = AnswererInstall { - source: "/Users/an operator/Application Support/min-answerer".to_string(), + source: "/Users/an operator/Application Support/minzoned".to_string(), ..base.clone() }; assert_eq!( @@ -3651,7 +3688,7 @@ mod tests { ); for bad in ["'", "\"", "$", "`", "\\", "\n", "\r"] { let source = AnswererInstall { - source: format!("/home/o{bad}brien/min-answerer"), + source: format!("/home/o{bad}brien/minzoned"), ..base.clone() }; assert!( @@ -5869,7 +5906,7 @@ mod tests { } // NET-122's host service, on the advisory's one privileged step: the - // command copies `min-answerer` to a root-owned path and installs the + // command copies `minzoned` to a root-owned path and installs the // service unit pointing at that copy — a launchd plist with socket // activation on macOS, a systemd socket and service pair on Linux — // run as the operator, never at the user-writable binary it copied @@ -5964,7 +6001,7 @@ mod tests { "the copy is in place before the units are written: {linux}" ); let enable_at = linux - .find(&format!("systemctl enable {ANSWERER_UNIT_LABEL}.socket")) + .find(&format!("systemctl enable {ANSWERER_SYSTEMD_UNIT}.socket")) .expect("the Linux step enables the socket unit"); assert!(copy_at < chown_at && chown_at < enable_at, "{linux}"); let socket = answerer_socket_unit(&install); @@ -6038,7 +6075,7 @@ mod tests { .expect("a host without the answerer service is advised"); assert!( advisory.contains("not installed as a host service") - && advisory.contains("install the box-zone answerer service"), + && advisory.contains("install the Minimal box-name service"), "{advisory}" ); assert!( @@ -6154,7 +6191,7 @@ mod tests { }; let dir = tempfile::tempdir().expect("a temp dir"); let source = dir.path().join(ANSWERER_PROGRAM_NAME); - let bytes = b"min-answerer fixture bytes\n"; + let bytes = b"minzoned fixture bytes\n"; std::fs::write(&source, bytes).expect("the fixture source"); let source = source.display().to_string(); let pinned = hex::encode(sha2::Sha256::digest(bytes)); @@ -6189,11 +6226,11 @@ mod tests { "the service state underneath the refusal survives: {advisory}" ); assert!( - !advisory.contains(ANSWERER_UNIT_LABEL) && !advisory.contains(&pinned), + !advisory.contains(ANSWERER_PROGRAM_PATH) && !advisory.contains(&pinned), "no copy of the program is carried: {advisory}" ); assert!( - !advisory.contains("install the box-zone answerer service"), + !advisory.contains("install the Minimal box-name service"), "the lead-in offers no answerer install: {advisory}" ); assert!( @@ -6204,7 +6241,7 @@ mod tests { // A source that passes: verified and pinned to its bytes' SHA-256, // with the requirement the root step re-checks the copy by. let requirement = - answerer_requirement("3G47C5HY64", "dev.minimal.min-answerer").expect("safe values"); + answerer_requirement("3G47C5HY64", "dev.minimal.minzoned").expect("safe values"); let checked = std::sync::Mutex::new(None); let passed = answerer_step_with_source(AnswererStep::Absent, Some(source.clone()), |path| { @@ -6237,7 +6274,7 @@ mod tests { "the rendered command carries the pinned hash: {advisory}" ); assert!( - advisory.contains("install the box-zone answerer service"), + advisory.contains("install the Minimal box-name service"), "the lead-in offers the answerer install: {advisory}" ); #[cfg(target_os = "macos")] @@ -6291,7 +6328,7 @@ mod tests { } } - /// When the release ships no `min-answerer`, or the build carries no + /// When the release ships no `minzoned`, or the build carries no /// signing identity to verify one by, the step is unavailable and the /// advisory says so by name — it never silently drops the step. #[tokio::test] @@ -6325,7 +6362,7 @@ mod tests { let advisory = advise(&unshipped); assert!( advisory.contains( - "this release ships no min-answerer; the answerer service step is unavailable" + "this release ships no minzoned; the answerer service step is unavailable" ), "{advisory}" ); @@ -6335,12 +6372,12 @@ mod tests { ); assert!( advisory.contains(&format!("\n {}", command(port, None))) - && !advisory.contains("install the box-zone answerer service"), + && !advisory.contains("install the Minimal box-name service"), "the command carries no answerer step: {advisory}" ); // A macOS release build with no TEAMID or identifier compiled in. - let no_identity = macos_answerer_requirement(None, Some("dev.minimal.min-answerer")) + let no_identity = macos_answerer_requirement(None, Some("dev.minimal.minzoned")) .expect_err("no TEAMID, no requirement"); assert_eq!( no_identity, @@ -6362,17 +6399,17 @@ mod tests { "{advisory}" ); assert!( - !advisory.contains("install the box-zone answerer service"), + !advisory.contains("install the Minimal box-name service"), "never a fallback to a weaker check: {advisory}" ); // The requirement a build that does carry one checks by. assert_eq!( - macos_answerer_requirement(Some("3G47C5HY64"), Some("dev.minimal.min-answerer")), + macos_answerer_requirement(Some("3G47C5HY64"), Some("dev.minimal.minzoned")), Ok( "anchor apple generic and certificate 1[field.1.2.840.113635.100.6.2.6] exists \ and certificate leaf[field.1.2.840.113635.100.6.1.13] exists and certificate \ - leaf[subject.OU] = \"3G47C5HY64\" and identifier \"dev.minimal.min-answerer\"" + leaf[subject.OU] = \"3G47C5HY64\" and identifier \"dev.minimal.minzoned\"" .to_string() ) ); @@ -6441,7 +6478,7 @@ mod tests { let checked: &'static [u8] = b"the bytes the advisory checked\n"; std::fs::write(&source, checked).unwrap(); let pinned = hex::encode(sha2::Sha256::digest(checked)); - let dest = dest_dir.join("dev.minimal.zone-answerer"); + let dest = dest_dir.join("minzoned"); CopyHarness { _root: root, stubs, @@ -6705,14 +6742,14 @@ mod tests { install.controls[0], install.controls[1] ); let enable_at = linux - .find(&format!("systemctl enable {ANSWERER_UNIT_LABEL}.socket")) + .find(&format!("systemctl enable {ANSWERER_SYSTEMD_UNIT}.socket")) .expect("the units are enabled"); let release_at = linux .find(&release) .expect("the daemons are asked to release"); let start_at = linux .find(&format!( - "systemctl start --no-block {ANSWERER_UNIT_LABEL}.socket" + "systemctl start --no-block {ANSWERER_SYSTEMD_UNIT}.socket" )) .expect("the socket unit is started"); assert!( @@ -6775,7 +6812,7 @@ mod tests { assert!(!direct.contains(" release"), "{direct}"); assert!( direct.contains(&format!( - "systemctl start --no-block {ANSWERER_UNIT_LABEL}.socket" + "systemctl start --no-block {ANSWERER_SYSTEMD_UNIT}.socket" )), "{direct}" ); @@ -6784,7 +6821,7 @@ mod tests { /// NET-122's host service on a native host: the advisory offers the /// same privileged step a VM-backed host gets — the root-owned copy of - /// `min-answerer`, released out of the daemon serving this session and + /// `minzoned`, released out of the daemon serving this session and /// then started as the manager-held answerer — and the socket the /// command asks to release is the native daemon's own, the control /// socket beside its ssh socket in the Minimald provider dir this @@ -6833,7 +6870,7 @@ mod tests { .expect("a native host without the answerer service is advised"); assert!( advisory.contains("not installed as a host service") - && advisory.contains("install the box-zone answerer service"), + && advisory.contains("install the Minimal box-name service"), "the native advisory offers the answerer service step: {advisory}" ); assert!( @@ -6854,7 +6891,7 @@ mod tests { #[cfg(not(target_os = "macos"))] let start_at = advisory .find(&format!( - "systemctl start --no-block {ANSWERER_UNIT_LABEL}.socket" + "systemctl start --no-block {ANSWERER_SYSTEMD_UNIT}.socket" )) .expect("the socket unit is started"); assert!( @@ -6894,9 +6931,9 @@ mod tests { ); } - /// `answerer_source` resolves `min-answerer` — beside this `min`, then + /// `answerer_source` resolves `minzoned` — beside this `min`, then /// on `PATH` — and never names `minvmd`, nor a bare name: with no - /// `min-answerer` anywhere it finds nothing, however many `minvmd`s + /// `minzoned` anywhere it finds nothing, however many `minvmd`s /// sit where it looks. #[test] fn answerer_source_never_names_an_absent_minvmd() { @@ -6909,13 +6946,13 @@ mod tests { assert_eq!( answerer_source_in(Some(beside.path()), Some(&path)), None, - "no min-answerer anywhere: nothing is named" + "no minzoned anywhere: nothing is named" ); std::fs::write(on_path.path().join(ANSWERER_PROGRAM_NAME), b"").expect("on PATH"); let found = answerer_source_in(Some(beside.path()), Some(&path)).expect("the one on PATH is found"); assert!( - found.ends_with("/min-answerer") && found.starts_with('/'), + found.ends_with("/minzoned") && found.starts_with('/'), "{found}" ); std::fs::write(beside.path().join(ANSWERER_PROGRAM_NAME), b"").expect("beside min"); diff --git a/crates/minimald/src/main.rs b/crates/minimald/src/main.rs index 42e8e3e315..ddf8636f27 100644 --- a/crates/minimald/src/main.rs +++ b/crates/minimald/src/main.rs @@ -248,7 +248,7 @@ pub struct ListenArgs { /// deployment pins one — the port the host's resolver is pointed at to /// answer `*.min.internal`, whose documented default is 7656. On a /// native host the daemon is first a client of the installed - /// `min-answerer` service (its rows publish over the machine-global + /// `minzoned` service (its rows publish over the machine-global /// channel and it hosts nothing); the port is the hook port it hosts /// the single-operator interim on while no service serves, and /// unlike the hostname proxy there is no select-when-busy for it: the diff --git a/crates/minimald/src/net/answerer.rs b/crates/minimald/src/net/answerer.rs index 59898f53ca..1814d9f04c 100644 --- a/crates/minimald/src/net/answerer.rs +++ b/crates/minimald/src/net/answerer.rs @@ -5,7 +5,7 @@ //! the other half of resolution — the DNS reply the host's own resolver gets //! when a process looks a box name up, no proxy variable involved. On a //! native host the zone is answered by the machine's *one* answerer -//! (NET-122): the root-installed `min-answerer` service the manager holds +//! (NET-122): the root-installed `minzoned` service the manager holds //! when the host is hooked, and until then the interim this daemon itself //! hosts. The acquisition below decides which — publish-or-host, never both //! — over the machine-global channel (`acquire`), the same machine contract @@ -497,7 +497,7 @@ pub async fn serve(socket: UdpSocket, answerer: ZoneAnswerer) -> io: // ── the acquisition: publish-or-host over the machine-global channel ───────── // // NET-122's host half: on a hooked host the zone is answered by the one -// root-installed `min-answerer` service the service manager holds, and this +// root-installed `minzoned` service the service manager holds, and this // daemon is that answerer's *client* — it connects to the machine-global // channel, says its node id, and keeps its zone rows published there for as // long as the connection lives. Until the host is hooked, nothing serves @@ -531,7 +531,7 @@ pub const GLOBAL_CHANNEL_SOCK: &str = "/run/minimal/answerer.sock"; /// and only whose presence — says the answerer service is installed on /// this host. The channel socket's path existing never says so: a stale /// socket file with no marker beside it is a leftover, not a service. -pub const INSTALL_MARKER: &str = "/etc/systemd/system/dev.minimal.zone-answerer.socket"; +pub const INSTALL_MARKER: &str = "/etc/systemd/system/minzoned.socket"; /// The variable that overrides [`GLOBAL_CHANNEL_SOCK`] — read only by test /// and debug builds (the e2e harness's), never by a release build, so no @@ -3171,7 +3171,7 @@ mod tests { let dir = tempfile::tempdir().expect("a tempdir for the unit and the channel"); let paths = AnswererPaths { channel: dir.path().join("answerer.sock"), - marker: dir.path().join("dev.minimal.zone-answerer.socket"), + marker: dir.path().join("minzoned.socket"), release_window: RELEASE_WINDOW, }; std::fs::write( @@ -3218,7 +3218,7 @@ mod tests { #[test] fn recorded_service_bind_reads_the_installed_unit() { let dir = tempfile::tempdir().expect("a tempdir for the unit"); - let unit = dir.path().join("dev.minimal.zone-answerer.socket"); + let unit = dir.path().join("minzoned.socket"); std::fs::write( &unit, b"[Socket]\nListenDatagram=127.0.0.1:17999\nListenStream=/run/minimal/answerer.sock\n", @@ -3255,7 +3255,7 @@ mod tests { .register_host_net(SessionId::nil(), "web"); let dir = tempfile::tempdir().expect("a tempdir for the channel and the marker"); let channel = dir.path().join("answerer.sock"); - let marker = dir.path().join("dev.minimal.zone-answerer.socket"); + let marker = dir.path().join("minzoned.socket"); std::fs::write(&marker, b"[Socket]\nListenDatagram=not-an-address\n") .expect("the install marker is written"); let service = fake_manager_held_service(channel.clone()); @@ -3326,7 +3326,7 @@ mod tests { let server = crate::test_harness::TestServer::new().await; let dir = tempfile::tempdir().expect("a tempdir for the channel and the marker"); let channel = dir.path().join("answerer.sock"); - let marker = dir.path().join("dev.minimal.zone-answerer.socket"); + let marker = dir.path().join("minzoned.socket"); std::fs::write(&marker, b"[Socket]\nListenDatagram=127.0.0.1:17999\n") .expect("the install marker is written"); let service = fake_manager_held_service(channel.clone()); @@ -3405,7 +3405,7 @@ mod tests { .register_host_net(SessionId::nil(), "web"); let dir = tempfile::tempdir().expect("a tempdir for the channel and the marker"); let channel = dir.path().join("answerer.sock"); - let marker = dir.path().join("dev.minimal.zone-answerer.socket"); + let marker = dir.path().join("minzoned.socket"); std::fs::write(&marker, b"[Socket]\nListenDatagram=127.0.0.1:17656\n") .expect("the install marker is written"); let service = fake_manager_held_service(channel.clone()); @@ -3530,7 +3530,7 @@ mod tests { .register_host_net(SessionId::nil(), "web"); let dir = tempfile::tempdir().expect("a tempdir for the channel and the marker"); let channel = dir.path().join("answerer.sock"); - let marker = dir.path().join("dev.minimal.zone-answerer.socket"); + let marker = dir.path().join("minzoned.socket"); std::fs::write(&marker, b"[Socket]\nListenDatagram=127.0.0.1:17656\n") .expect("the install marker is written"); let service = fake_manager_held_service(channel.clone()); @@ -3836,7 +3836,7 @@ mod tests { status.clone(), AnswererPaths { channel: dir.path().join("answerer.sock"), - marker: dir.path().join("dev.minimal.zone-answerer.socket"), + marker: dir.path().join("minzoned.socket"), release_window: RELEASE_WINDOW, }, shutdown.clone(), @@ -4013,7 +4013,7 @@ mod tests { status.clone(), AnswererPaths { channel: dir.path().join("answerer.sock"), - marker: dir.path().join("dev.minimal.zone-answerer.socket"), + marker: dir.path().join("minzoned.socket"), release_window: Duration::from_secs(1), }, shutdown.clone(), diff --git a/crates/minimald/src/server.rs b/crates/minimald/src/server.rs index b23ca1b0df..8ea18fa970 100644 --- a/crates/minimald/src/server.rs +++ b/crates/minimald/src/server.rs @@ -1273,7 +1273,7 @@ async fn start_host_proxies( // Native (NET-122): the zone is answered by the machine's *one* // answerer, and this daemon is its client before it is its host. The // acquisition below decides publish-or-host — publish this daemon's - // rows into the manager-held `min-answerer` service over the + // rows into the manager-held `minzoned` service over the // machine-global channel when its channel answers, host the // single-operator interim itself only while no channel answers and // the hook port is free, never both — and its status cell feeds the diff --git a/crates/minvmd/src/cmd/answerer.rs b/crates/minvmd/src/cmd/answerer.rs index 4ea9d04e10..ac9eb5755b 100644 --- a/crates/minvmd/src/cmd/answerer.rs +++ b/crates/minvmd/src/cmd/answerer.rs @@ -1,4 +1,4 @@ -//! The `min-answerer` program: the one the privileged step copies to a +//! The `minzoned` program: the one the privileged step copies to a //! root-owned path and installs as the host's box-zone answerer service, //! and the handover's client verbs the same step runs as root. //! @@ -106,7 +106,7 @@ const CONTROL_REPLY_TIMEOUT: std::time::Duration = std::time::Duration::from_sec pub fn release(controls: &[std::path::PathBuf], port: u16) -> Result<()> { for control in controls { if let Some(reply) = ask(control, &minimald_rpc::BoxControlRequest::ReleaseAnswerer)? { - eprintln!("min-answerer: {}: {reply}", control.display()); + eprintln!("minzoned: {}: {reply}", control.display()); } } let deadline = std::time::Instant::now() + PORT_FREE_WAIT; @@ -137,9 +137,9 @@ pub fn release_cancel(controls: &[std::path::PathBuf]) { control, &minimald_rpc::BoxControlRequest::ReleaseAnswererCancel, ) { - Ok(Some(reply)) => eprintln!("min-answerer: {}: {reply}", control.display()), + Ok(Some(reply)) => eprintln!("minzoned: {}: {reply}", control.display()), Ok(None) => {} - Err(error) => eprintln!("min-answerer: {}: {error:#}", control.display()), + Err(error) => eprintln!("minzoned: {}: {error:#}", control.display()), } } } diff --git a/crates/minvmd/src/net/answerer.rs b/crates/minvmd/src/net/answerer.rs index 7ce86edef4..6280399ef0 100644 --- a/crates/minvmd/src/net/answerer.rs +++ b/crates/minvmd/src/net/answerer.rs @@ -16,7 +16,7 @@ //! That rule is **who holds the answerer**. The answerer port is the //! machine's, so exactly one process on the host may serve it — and the one //! that should is the **installed host service** the privileged step -//! installs (NET-122's sub-requirement): `min-answerer`, which the service +//! installs (NET-122's sub-requirement): `minzoned`, which the service //! manager runs as the operator, its listener and its machine-global //! channel socket the manager's own, so the zone survives every session on //! the host. This daemon is one of that service's *nodes*. Whether the @@ -210,10 +210,10 @@ pub const GLOBAL_CHANNEL_SOCK: &str = "/run/minimal/answerer.sock"; /// The channel socket's path existing never says so: a stale socket file /// with no marker beside it is a leftover, not a service. #[cfg(target_os = "macos")] -pub const INSTALL_MARKER: &str = "/Library/LaunchDaemons/dev.minimal.zone-answerer.plist"; +pub const INSTALL_MARKER: &str = "/Library/LaunchDaemons/dev.gominimal.zone.plist"; /// See the macOS arm. #[cfg(not(target_os = "macos"))] -pub const INSTALL_MARKER: &str = "/etc/systemd/system/dev.minimal.zone-answerer.socket"; +pub const INSTALL_MARKER: &str = "/etc/systemd/system/minzoned.socket"; /// The variable that overrides [`GLOBAL_CHANNEL_SOCK`] — read only by test /// and debug builds (the e2e harness's), never by a release build, so no diff --git a/crates/min-answerer/Cargo.toml b/crates/minzoned/Cargo.toml similarity index 79% rename from crates/min-answerer/Cargo.toml rename to crates/minzoned/Cargo.toml index 500805f304..1b64105d5d 100644 --- a/crates/min-answerer/Cargo.toml +++ b/crates/minzoned/Cargo.toml @@ -1,6 +1,6 @@ [package] -name = "min-answerer" -description = "The host's box-zone answerer service program, linked without libkrun, that the privileged step installs." +name = "minzoned" +description = "The host's box-name service (DNS and addresses for boxes), linked without libkrun, that the privileged step installs." rust-version.workspace = true version.workspace = true edition.workspace = true @@ -8,7 +8,7 @@ publish.workspace = true license.workspace = true [[bin]] -name = "min-answerer" +name = "minzoned" path = "src/main.rs" [dependencies] diff --git a/crates/min-answerer/src/main.rs b/crates/minzoned/src/main.rs similarity index 90% rename from crates/min-answerer/src/main.rs rename to crates/minzoned/src/main.rs index 2476149ae8..f23b57215d 100644 --- a/crates/min-answerer/src/main.rs +++ b/crates/minzoned/src/main.rs @@ -1,4 +1,4 @@ -//! `min-answerer`: the host's box-zone answerer service (NET-122's host +//! `minzoned`: the host's box-zone answerer service (NET-122's host //! service), as a program of its own. //! //! The privileged step copies this binary to a root-owned path and installs @@ -21,8 +21,10 @@ use clap::{Parser, Subcommand}; use tracing_subscriber::{EnvFilter, fmt, prelude::*}; #[derive(Parser)] -#[command(name = "min-answerer", version = version::VERSION, long_version = version::LONG_VERSION)] -#[command(about = "The host's box-zone answerer service, run by the service manager")] +#[command(name = "minzoned", version = version::VERSION, long_version = version::LONG_VERSION)] +#[command( + about = "The Minimal box-name service (DNS and addresses for boxes), run by the service manager" +)] struct Cli { /// Print the answerer channel protocol version this copy speaks and exit. #[arg(long)] diff --git a/docs/internal/release-pipeline.md b/docs/internal/release-pipeline.md index 7c71217acc..9303d4c6f5 100644 --- a/docs/internal/release-pipeline.md +++ b/docs/internal/release-pipeline.md @@ -209,7 +209,7 @@ meet the policy yet. | Artifact | How the release run tests it | | --- | --- | | Linux amd64 `min`, `minimald`, `minvmd`, `gvproxy-min` | `smoke-linux-amd64` runs the session e2e on the host daemon. `smoke-linux-kvm` runs it in a KVM microVM. | -| `min-answerer` (every platform that has `min`) | [`scripts/dist-build.sh`](../../scripts/dist-build.sh) runs the link gate ([`scripts/check-answerer-links.sh`](../../scripts/check-answerer-links.sh)) on the binary it built. **Gap:** the frozen release workflow does not build, sign, or upload it yet. Until a code owner applies the workflow patch, the stage treats the artifact as optional and a release goes out without it (gominimal/inbox#899). | +| `minzoned` (every platform that has `min`) | [`scripts/dist-build.sh`](../../scripts/dist-build.sh) runs the link gate ([`scripts/check-zoned-links.sh`](../../scripts/check-zoned-links.sh)) on the binary it built. The release workflow runs the gate again on every renamed and signed artifact before upload. On macOS it also checks the signature against the designated requirement that `min` uses. | | amd64 guest kernel, rootfs, and initramfs | `smoke-linux-kvm` boots them. | | arm64 guest kernel, rootfs, and initramfs | `smoke-macos` boots them. | | macOS arm64 `min`, `minvmd`, `libkrun.1.dylib`, `gvproxy-min` | `smoke-macos` runs the session e2e with the signed files in the installer layout. **Gap:** when the `RUN_MACOS_CI` variable is `false`, this job skips and the run counts the skip as a pass. | @@ -291,11 +291,13 @@ whose `package.version` is stale or not above the newest `v*` tag. The job checks that each binary is static and that `minvmd` contains the KVM backend. - `build-release-macos-arm64` runs on the self-hosted Apple Silicon runner - when `RUN_MACOS_CI` is not `false`. It builds `minvmd` and `min`, changes - the libkrun link path in `minvmd` to `@rpath` + when `RUN_MACOS_CI` is not `false`. It builds `minvmd`, `min`, and + `minzoned`, changes the libkrun link path in `minvmd` to `@rpath` ([`scripts/rewrite-macos-linkage.sh`](../../scripts/rewrite-macos-linkage.sh)), - and checks that `min` links only system libraries. It signs both binaries - with the Developer ID, the hardened runtime, and a timestamp. + and checks that `min` and `minzoned` link only system libraries. It + signs `minvmd`, `min`, and `minzoned` with the Developer ID, the + hardened runtime, and a timestamp. Then it notarizes all of them. See the + **Notarization** paragraph below. - `build-libkrun-macos-arm64` builds the `libkrun.1.dylib` for macOS users on a hosted runner. `sign-macos-artifacts` signs it and the macOS `gvproxy` with the Developer ID on the self-hosted runner. @@ -308,45 +310,44 @@ whose `package.version` is stale or not above the newest `v*` tag. Release name uses it. On a versioned run, the job checks that it equals the release version. -**min-answerer.** Every release that publishes `min` must also publish the +**minzoned.** Every release that publishes `min` must also publish the box-zone answerer binary. The session-start advisory (NET-122) copies it into a root-owned host-service path. The scripts in this repository do their half of the work: -- [`scripts/dist-build.sh`](../../scripts/dist-build.sh) builds `min-answerer` +- [`scripts/dist-build.sh`](../../scripts/dist-build.sh) builds `minzoned` in its own cargo invocation. A build beside `-p minvmd` or a `--workspace` build unifies the KVM backend into the binary, and a root host service must never contain it. The script then runs the link gate - ([`scripts/check-answerer-links.sh`](../../scripts/check-answerer-links.sh)) + ([`scripts/check-zoned-links.sh`](../../scripts/check-zoned-links.sh)) on the binary. Every library must resolve from a system directory. The binary must have no embedded search path, and its interpreter must be a system loader. If the gate fails, the build fails. - [`scripts/stage-release.sh`](../../scripts/stage-release.sh) stages - `bin/min-answerer` beside `bin/min` on every platform that has `min`. The + `bin/minzoned` beside `bin/min` on every platform that has `min`. The staged copy is only the source that the advisory copies. No unit file and no `launchd` property list refers to it at its user-writable path. - [`scripts/package-nfpm.sh`](../../scripts/package-nfpm.sh) and [`packaging/nfpm.yaml`](../../packaging/nfpm.yaml) put - `/usr/bin/min-answerer` in every `.deb`, `.rpm`, and `.apk`. The packages + `/usr/bin/minzoned` in every `.deb`, `.rpm`, and `.apk`. The packages do not install a service. The advisory's privileged command is the only privileged step. - [`scripts/install.sh`](../../scripts/install.sh) installs it beside `min` and replaces it on upgrade, like every other `bin` row. -*Optional until the workflow builds it.* Because the release workflow does -not build or upload `min-answerer` yet, `stage-release.sh` and `package-nfpm.sh` -accept a missing `min-answerer` artifact with a warning that names the -omitted row. They stage or package all other artifacts. A release staged -without it gives no `min-answerer` to the host. The advisory then shows the -state `this release ships no min-answerer; the answerer service step is -unavailable` and does not offer the step. This state is temporary. -gominimal/inbox#899 tracks the removal of both optional lists after the -workflow uploads the artifact on every platform. +*Still optional in the scripts.* The release workflow uploads `minzoned` +on every platform, but `stage-release.sh` and `package-nfpm.sh` still accept +a missing `minzoned` artifact with a warning that names the omitted row. +They stage or package all other artifacts. A release staged without it gives +no `minzoned` to the host. The advisory then shows the state `this release +ships no minzoned; the answerer service step is unavailable` and does not +offer the step. Both optional lists go after a release publishes the +artifact on every platform. *Identity model.* Each check runs where it has meaning: - **The release proves link-cleanliness.** The link gate runs on the binary - that `dist-build.sh` built. The workflow patch runs it again on every signed + that `dist-build.sh` built. The release workflow runs it again on every signed and renamed artifact, as the last check before upload. The uploaded bytes are then the bytes that the gate checked. The user's machine does not run the gate. @@ -356,7 +357,7 @@ workflow uploads the artifact on every platform. ID designated requirement. The requirement names Apple's Developer ID chain, the team in `subject.OU`, and the signing identifier. - The release build of `min` gets the team ID and the identifier at compile - time, from `MINIMAL_ANSWERER_TEAMID` and `MINIMAL_ANSWERER_IDENTIFIER`. + time, from `MINIMAL_ZONED_TEAMID` and `MINIMAL_ZONED_IDENTIFIER`. Without them, a release `min` does not offer the step, and it gives the reason `this build carries no signing identity`. It never falls back to `codesign --strict` alone, because any ad-hoc signature passes that check. @@ -377,34 +378,29 @@ workflow uploads the artifact on every platform. again. Then it renames the copy into place. Only after that does it write the unit or property list that names the copy. -The workflow half is a change that a code owner must apply, because -[`.github/workflows/`](../../.github/workflows/) is frozen and CODEOWNER-gated. -The body of the pull request that added this section contains the change as -a unified diff to `release.yml`. That patch is the needs-human item that -blocks the first release that offers the answerer service step. It follows -the steps that the other binaries have: +The release workflow +([`.github/workflows/release.yml`](../../.github/workflows/release.yml)) +handles `minzoned` with the same steps that the other binaries have: - `build-release-linux-{amd64,arm64}`: the shared entry point builds and - link-gates `min-answerer` already. The rename step adds - `mv min-answerer min-answerer-linux-`. A new step runs the link gate + link-gates `minzoned` already. The rename step adds + `mv minzoned minzoned-linux-`. A new step runs the link gate on the renamed file, and one `upload-artifact` step uploads it. - `build-release-macos-arm64`: the job's `env` gets - `MINIMAL_ANSWERER_TEAMID` and `MINIMAL_ANSWERER_IDENTIFIER`, so the `min` - that it builds has the signing identity. The job builds `min-answerer` in + `MINIMAL_ZONED_TEAMID` and `MINIMAL_ZONED_IDENTIFIER`, so the `min` + that it builds has the signing identity. The job builds `minzoned` in its own invocation, link-gates it, and renames it to - `min-answerer-macos-arm64`. + `minzoned-macos-arm64`. - The job signs it with the Developer ID, the hardened runtime, a timestamp, - and `--identifier "$MINIMAL_ANSWERER_IDENTIFIER"`. The signature has no + and `--identifier "$MINIMAL_ZONED_IDENTIFIER"`. The signature has no entitlements, unlike the `minvmd` signature. There is no hypervisor entitlement, no `disable-library-validation`, no `allow-dyld-environment-variables`, and no JIT. The job then checks the signature with the designated requirement that `min` uses. - After the signature check, the link gate runs again on the signed artifact, and the job uploads it. -- The patch does not notarize `min-answerer`. The pipeline notarizes no - macOS binary today, and - [gominimal/inbox#900](https://github.com/gominimal/inbox/issues/900) - tracks notarization for all of them. +- The job notarizes `minzoned` with the other macOS binaries. See + the **Notarization** paragraph below. - The release job and the stage-installer job stay the same. They collect artifacts by the platform-suffixed names, so the new names go into the GitHub Release, the `components` manifest, and the packages. The SHA-256 @@ -423,6 +419,36 @@ This section does not close these residuals: [`scripts/session-e2e.sh`](../../scripts/session-e2e.sh) skips it there. A privileged macOS e2e runner is still necessary for that proof. +**Notarization.** After the signature checks and the last link gate, +`build-release-macos-arm64` sends `min`, `minvmd`, and `minzoned` to +the Apple notary service before it uploads them. The step puts each binary +in a zip made with `ditto`, because `notarytool` does not take a bare +Mach-O file. It runs `xcrun notarytool submit --wait` on each zip. The +release fails unless each result is `Accepted`. On any other result, the +step prints the notary log for that submission. Notarization does not +change the file, so the job uploads the same signed bytes. + +The job does not staple. The release publishes each binary as a bare Mach-O +file, and `stapler` can attach a ticket only to an app bundle, a `.pkg`, or +a `.dmg`. Gatekeeper gets the ticket from Apple online when it checks a +binary. + +The step needs two things that the workflow cannot set up: + +- A `notarytool` keychain profile in the signing keychain + (`minimal-signing.keychain-db`) on the self-hosted macOS runner. Create it + as the runner user with + `xcrun notarytool store-credentials --keychain + ~/Library/Keychains/minimal-signing.keychain-db`. Give it an App Store + Connect API key (`--key`, `--key-id`, `--issuer`), or an Apple ID with an + app-specific password and team `3G47C5HY64`. The step unlocks the keychain + with the `KC_PW` secret, as the signing steps do. +- The repository variable `MACOS_NOTARY_PROFILE`, set to the profile name. + If the variable is empty, the step fails before it submits anything. + +`libkrun.1.dylib` and the macOS `gvproxy`, which `sign-macos-artifacts` +signs, are not notarized. + **release job.** This job downloads all build outputs. It writes the release notes with `scripts/next-version.sh --notes` and generates shell completions for `mip`, `min`, and `minimald`. On a versioned run it builds the `.deb`, @@ -546,16 +572,16 @@ installer, in strict POSIX `sh`. It works in these steps: The components come from the `COMPONENTS` table in `stage-release.sh`: -- Linux amd64 and arm64: `bin/min`, `bin/min-answerer`, `bin/mip`, +- Linux amd64 and arm64: `bin/min`, `bin/minzoned`, `bin/mip`, `bin/minimald`, `bin/minvmd`, `bin/gvproxy-min`, a `git-remote-min` symlink, the guest files (`data/vmlinuz`, `data/rootfs.img`, `data/initramfs.cpio`), and the AppArmor profile, tunable, and loader under `data/`. -- macOS arm64: `bin/min`, `bin/min-answerer`, `bin/minvmd`, +- macOS arm64: `bin/min`, `bin/minzoned`, `bin/minvmd`, `bin/gvproxy-min`, `lib/libkrun.1.dylib`, the `git-remote-min` symlink, and the same guest files. Only macOS has a `lib/` folder, because the Linux `minvmd` links libkrun statically. -`bin/min-answerer` is the box-zone answerer binary that the session-start +`bin/minzoned` is the box-zone answerer binary that the session-start advisory copies into its root-owned service path. The installer puts it beside `min`, and nothing else refers to it there. Manifest rows write no unit file and no `launchd` property list. None of them names the root-owned diff --git a/justfile b/justfile index 3ceda7d615..2fc34b1069 100644 --- a/justfile +++ b/justfile @@ -148,17 +148,17 @@ minvmd-build: libkrun-static # across the packages one build selects, and minvmd's default `libkrun` # feature would stamp libkrun's load command into this root-run program. # -# Build the box-zone answerer service program, without libkrun. -answerer-build: - cargo build -p min-answerer --locked +# Build minzoned, the box-name service program, without libkrun. +zoned-build: + cargo build -p minzoned --locked # The root-installed answerer copy must resolve no library from a # user-writable dir (a dylib reached through an rpath there is a root # escalation): otool -L on macOS, ldd on Linux, system paths only. # -# Check that min-answerer links only system libraries. -answerer-link-check: answerer-build - scripts/check-answerer-links.sh target/debug/min-answerer +# Check that minzoned links only system libraries. +zoned-link-check: zoned-build + scripts/check-zoned-links.sh target/debug/minzoned # Build the `min` CLI. minimal-cli: @@ -467,12 +467,12 @@ hooks: # # The local PR gate set, cheapest first. [linux] -ci: fmt-check check-version clippy clippy-strict deny test doctest test-ignored answerer-link-check +ci: fmt-check check-version clippy clippy-strict deny test doctest test-ignored zoned-link-check @echo "ci: local PR gates green" # The local PR gate set, cheapest first (`just test-cross` covers the Linux-only crates). [macos] -ci: fmt-check check-version clippy clippy-strict deny test doctest answerer-link-check +ci: fmt-check check-version clippy clippy-strict deny test doctest zoned-link-check @echo "ci: local PR gates green" # Run the curl|sh installer's tests under every POSIX sh. CI: ci-shell-installer.yml. @@ -685,7 +685,7 @@ test-root-integration: _nextest gvproxy # minvmd-build is LAST so its macOS codesign is the final touch on the binary. # # The unified session e2e against the VM-backed daemon. CI: the session e2e steps. -e2e: _kvm artifacts gvproxy initramfs minimal-cli answerer-build minvmd-build +e2e: _kvm artifacts gvproxy initramfs minimal-cli zoned-build minvmd-build {{e2e-env}} MINVMD_GVPROXY_BIN="{{gvproxy}}" ./scripts/session-e2e.sh # CI: ci-linux-native.yml `native-daemon-e2e`. diff --git a/packaging/nfpm.yaml b/packaging/nfpm.yaml index 775c75066f..8fb86ab4a4 100644 --- a/packaging/nfpm.yaml +++ b/packaging/nfpm.yaml @@ -9,7 +9,7 @@ # NFPM_ARCH amd64 or arm64 (one nfpm run per arch) # ARTIFACT_DIR per-arch dir of the staged static binaries, already # renamed to their installed names (min, minimald, mip, -# minvmd, gvproxy-min, min-answerer) +# minvmd, gvproxy-min, minzoned) # COMPLETIONS_DIR completions generated from the built `min` (the # scripts/dist-build.sh technique) # APPARMOR_DIR the repo's packaging/apparmor tree @@ -75,7 +75,7 @@ contents: expand: true file_info: mode: 0755 - # min-answerer, the box-zone answerer binary NET-122's session advisory + # minzoned, the box-zone answerer binary NET-122's session advisory # finds beside `min` and copies into its root-owned service path. The # package ships the binary and nothing else: it installs and enables no # answerer service — no systemd unit file, no postinstall step — so the @@ -84,13 +84,13 @@ contents: # Optional until release.yml builds it (temporary, gominimal/inbox#899): # scripts/package-nfpm.sh drops the marked block when the artifact is # missing, so keep the markers on their own lines. - # BEGIN optional min-answerer - - src: ${ARTIFACT_DIR}/min-answerer - dst: /usr/bin/min-answerer + # BEGIN optional minzoned + - src: ${ARTIFACT_DIR}/minzoned + dst: /usr/bin/minzoned expand: true file_info: mode: 0755 - # END optional min-answerer + # END optional minzoned # git-remote-min is a symlink to min. For nfpm symlink entries, src is # the link target and dst the link path — both inside the installed # package, unlike regular files where src is a build-environment path. diff --git a/scripts/check-answerer-links.sh b/scripts/check-zoned-links.sh similarity index 91% rename from scripts/check-answerer-links.sh rename to scripts/check-zoned-links.sh index ba9eece03e..6d164d3879 100755 --- a/scripts/check-answerer-links.sh +++ b/scripts/check-zoned-links.sh @@ -1,9 +1,9 @@ #!/usr/bin/env bash # -# check-answerer-links.sh — the min-answerer binary must resolve only system +# check-zoned-links.sh — the minzoned binary must resolve only system # libraries. # -# WHY: min-answerer is the always-on box-zone answerer the host's service +# WHY: minzoned is the always-on box-zone answerer the host's service # manager holds as a root service (NET-122 to NET-128 in # docs/specs/18-spec-box-networking): every process on the machine resolves # `*.min.internal` through it, so it starts as root and runs unattended. A @@ -49,7 +49,7 @@ # who ran the gate or on what their environment would have injected into # the loader's search path. # -# Usage: scripts/check-answerer-links.sh +# Usage: scripts/check-zoned-links.sh # # Exit codes: 0 = resolves only system libraries, no embedded search path; # 1 = at least one offender named, or the binary could not be verified @@ -60,7 +60,7 @@ set -euo pipefail # die — print it with the script prefix on stderr and exit 1. die() { - printf 'check-answerer-links: %s\n' "$1" >&2 + printf 'check-zoned-links: %s\n' "$1" >&2 exit 1 } @@ -88,7 +88,7 @@ offender_names="" offender() { offenders=$((offenders + 1)) offender_names="${offender_names:+$offender_names; }$1" - printf 'check-answerer-links: %s — verdict: offender (%s)\n' "$1" "$2" + printf 'check-zoned-links: %s — verdict: offender (%s)\n' "$1" "$2" } # system_dir — the system directory a path lives under, or nothing. @@ -152,7 +152,7 @@ classify_dep() { offender "$item" "carries a '..' path component; the loader walks it to wherever it lands, which is not provably a system directory" ;; *) - printf 'check-answerer-links: %s — verdict: ok (%s)\n' "$item" "$state" + printf 'check-zoned-links: %s — verdict: ok (%s)\n' "$item" "$state" ;; esac } @@ -163,7 +163,7 @@ linux_check() { command -v ldd >/dev/null 2>&1 || die "ldd is not on PATH — cannot inspect $bin" command -v readelf >/dev/null 2>&1 || die "readelf is not on PATH — cannot inspect $bin" - printf 'check-answerer-links: checking %s (Linux: readelf -l, ldd, readelf -d)\n' "$bin" + printf 'check-zoned-links: checking %s (Linux: readelf -l, ldd, readelf -d)\n' "$bin" # The program interpreter first: root runs it before any library, and # the string is baked into the binary, so a loader path that is not @@ -186,7 +186,7 @@ linux_check() { offender "interpreter $interp" "the program interpreter carries a '..' path component; the loader walks it to wherever it lands, which is not provably a system loader" ;; *) - printf 'check-answerer-links: interpreter %s — verdict: ok (%s)\n' "$interp" "$interp_state" + printf 'check-zoned-links: interpreter %s — verdict: ok (%s)\n' "$interp" "$interp_state" ;; esac done < <( @@ -200,7 +200,7 @@ linux_check() { ' <<<"$interp_out" ) if [ "$interp_seen" -eq 0 ]; then - printf 'check-answerer-links: no program interpreter (statically linked) — verdict: ok\n' + printf 'check-zoned-links: no program interpreter (statically linked) — verdict: ok\n' fi # ldd, under a scrubbed loader environment: the answerer is started by @@ -213,7 +213,7 @@ linux_check() { # ldd exits 1 for a binary with no dynamic section as well — that is # the static case this gate passes, not an error. if grep -qE 'not a dynamic executable|statically linked' <<<"$ldd_out"; then - printf 'check-answerer-links: not dynamically linked — no dynamic dependencies to check\n' + printf 'check-zoned-links: not dynamically linked — no dynamic dependencies to check\n' else if [ "$ldd_rc" -ne 0 ]; then die "ldd could not inspect $bin: $ldd_out" @@ -221,7 +221,7 @@ linux_check() { while IFS=$'\t' read -r state item path; do case "$state" in vdso) - printf 'check-answerer-links: %s — verdict: ok (the kernel vDSO)\n' "$item" + printf 'check-zoned-links: %s — verdict: ok (the kernel vDSO)\n' "$item" ;; missing) offender "$item" "a dependency that resolves from nowhere is not provably a system library" @@ -271,7 +271,7 @@ linux_check() { ' <<<"$rpath_out" ) if [ "$saw_rpath" -eq 0 ]; then - printf 'check-answerer-links: no RPATH or RUNPATH entries — verdict: ok\n' + printf 'check-zoned-links: no RPATH or RUNPATH entries — verdict: ok\n' fi } @@ -279,7 +279,7 @@ linux_check() { macos_check() { command -v otool >/dev/null 2>&1 || die "otool is not on PATH (install the Xcode Command Line Tools) — cannot inspect $bin" - printf 'check-answerer-links: checking %s (macOS: otool -L + otool -l)\n' "$bin" + printf 'check-zoned-links: checking %s (macOS: otool -L + otool -l)\n' "$bin" local deps_out deps_rc=0 path deps_out="$(otool -L "$bin" 2>&1)" || deps_rc=$? @@ -325,7 +325,7 @@ macos_check() { ' <<<"$lc_out" ) if [ "$saw_lcrpath" -eq 0 ]; then - printf 'check-answerer-links: no LC_RPATH load commands — verdict: ok\n' + printf 'check-zoned-links: no LC_RPATH load commands — verdict: ok\n' fi } @@ -351,4 +351,4 @@ if [ "$offenders" -gt 0 ]; then die "$offenders offender(s) in $bin: $offender_names — a root answerer that resolves any of these runs user-chosen code as root; link the system libraries only and strip every rpath entry, or do not ship this build" fi -printf 'check-answerer-links: %s resolves only system libraries with no embedded search path — verdict: ok\n' "$bin" +printf 'check-zoned-links: %s resolves only system libraries with no embedded search path — verdict: ok\n' "$bin" diff --git a/scripts/check-answerer-links_test.sh b/scripts/check-zoned-links_test.sh similarity index 98% rename from scripts/check-answerer-links_test.sh rename to scripts/check-zoned-links_test.sh index a1e280746d..3b91315986 100755 --- a/scripts/check-answerer-links_test.sh +++ b/scripts/check-zoned-links_test.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash # -# check-answerer-links_test.sh — test harness for -# scripts/check-answerer-links.sh. +# check-zoned-links_test.sh — test harness for +# scripts/check-zoned-links.sh. # # Two halves: # @@ -37,8 +37,8 @@ set -euo pipefail here="$(cd "$(dirname "$0")" && pwd)" -script="$here/check-answerer-links.sh" -[ -f "$script" ] || { echo "cannot find check-answerer-links.sh next to test" >&2; exit 1; } +script="$here/check-zoned-links.sh" +[ -f "$script" ] || { echo "cannot find check-zoned-links.sh next to test" >&2; exit 1; } pass=0 fail=0 skip=0 # ok / bad / skip — count and print one case. @@ -68,7 +68,7 @@ expect() { build() { local out="$1"; shift if ! "$@" -o "$out"; then - printf 'check-answerer-links_test: cannot build fixture %s with: %s\n' "$out" "$*" >&2 + printf 'check-zoned-links_test: cannot build fixture %s with: %s\n' "$out" "$*" >&2 exit 1 fi } diff --git a/scripts/dist-build.sh b/scripts/dist-build.sh index bfe998fc65..c63ebcb347 100755 --- a/scripts/dist-build.sh +++ b/scripts/dist-build.sh @@ -11,7 +11,7 @@ # Build shape (extracted from those jobs; do not recollapse without cutting # the release profile's link-time memory first): # - ONE cargo invocation per package (mip, minimal, minimald, minvmd, -# min-answerer), not one combined build. `[profile.release]` is fat LTO with +# minzoned), not one combined build. `[profile.release]` is fat LTO with # codegen-units = 1, so a combined build lets cargo schedule all the final # LTO links concurrently — the peak that SIGTERMed the arm64 release job # (exit 143). Sequential invocations share dependency artifacts through @@ -20,7 +20,7 @@ # - `minvmd` is built in its OWN invocation, after the rest: `min` depends # on the minvmd crate with default-features = false, and one combined # invocation would unify the `libkrun` feature into the CLI's copy. -# `min-answerer` is the rule pointed the other way: it also depends on +# `minzoned` is the rule pointed the other way: it also depends on # the minvmd crate with default-features = false, and beside `-p minvmd` # it would unify the KVM backend into the answerer a root host service # must never carry — so it gets its OWN invocation too, and its built @@ -132,15 +132,15 @@ case "$TARGET" in ;; esac -# min-answerer: its OWN invocation, never beside `-p minvmd` and never +# minzoned: its OWN invocation, never beside `-p minvmd` and never # through a `--workspace` build, for the feature-unification reason the # header's last bullet names. It is the crate T71 created — no libkrun, no # KVM backend, only what a root host service needs — and this is the step # that keeps a release build from growing them back. -cargo build --release --locked --target "$TARGET" --package min-answerer +cargo build --release --locked --target "$TARGET" --package minzoned # THE link gate on what this script just built (the rule -# scripts/check-answerer-links.sh documents): the answerer runs as a root +# scripts/check-zoned-links.sh documents): the answerer runs as a root # host service that every process on the machine resolves through, so a # dynamic dependency in a user-writable path — or an RPATH/RUNPATH entry # baked into the binary pointing at one — is user-chosen code as root. The @@ -148,7 +148,7 @@ cargo build --release --locked --target "$TARGET" --package min-answerer # leaves this machine as a release artifact; the release workflow runs it # again on every signed and renamed artifact before upload, so the shipped # bytes stay the checked bytes. -"$ROOT/scripts/check-answerer-links.sh" "$BIN_DIR/min-answerer" +"$ROOT/scripts/check-zoned-links.sh" "$BIN_DIR/minzoned" # Completions from the built `min`, the technique packaging/arch/PKGBUILD-bin.tmpl # uses: XDG @@ -200,4 +200,4 @@ else echo "dist-build: completions -> $COMPLETIONS_DIR" fi -echo "dist-build: $TARGET built -> $BIN_DIR (mip, min, minimald, minvmd, min-answerer)" +echo "dist-build: $TARGET built -> $BIN_DIR (mip, min, minimald, minvmd, minzoned)" diff --git a/scripts/install.sh b/scripts/install.sh index bd6eb8e294..e10e7dfeb3 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -36,8 +36,8 @@ # stripped by its markers). # # Every component the manifest carries installs by the same generic loop, and -# one of them carries a contract worth naming: `min-answerer` (NET-122's -# box-zone answerer) installs as `bin/min-answerer` beside `min` on every +# one of them carries a contract worth naming: `minzoned` (NET-122's +# box-zone answerer) installs as `bin/minzoned` beside `min` on every # platform the manifest ships `min` for, and an upgrade replaces it like every # other `bin` row — same SHA-256 compare, same swap. The installed copy is # ONLY the copy source: the session-start advisory finds it beside `min` and diff --git a/scripts/install_test.sh b/scripts/install_test.sh index c0fa1f491d..4d1af3c359 100755 --- a/scripts/install_test.sh +++ b/scripts/install_test.sh @@ -160,7 +160,7 @@ MOCKEOF printf 'linux-amd64-minimald-body\n' >"$mock/versions/v1/minimald-linux-amd64" write_min_stub "$mock/versions/v1/minimal-linux-amd64" linux-amd64 # The answerer NET-122's advisory copies from beside min (NET-122). -printf 'linux-amd64-answerer-body\n' >"$mock/versions/v1/min-answerer-linux-amd64" +printf 'linux-amd64-answerer-body\n' >"$mock/versions/v1/minzoned-linux-amd64" printf 'linux-amd64-minvmd-body\n' >"$mock/versions/v1/minvmd-linux-amd64" printf 'linux-amd64-initramfs-body\n' >"$mock/versions/v1/initramfs-amd64.cpio" printf 'linux-amd64-rootfs-body\n' >"$mock/versions/v1/rootfs-amd64.img" @@ -172,7 +172,7 @@ printf 'mock-gvproxy-switch-body\n' >"$mock/versions/v1/gvproxy-min-linux-a # Linux arm64 release artifacts, including the VM stack (NET-050). printf 'linux-arm64-minimald-body\n' >"$mock/versions/v1/minimald-linux-arm64" write_min_stub "$mock/versions/v1/minimal-linux-arm64" linux-arm64 -printf 'linux-arm64-answerer-body\n' >"$mock/versions/v1/min-answerer-linux-arm64" +printf 'linux-arm64-answerer-body\n' >"$mock/versions/v1/minzoned-linux-arm64" printf 'linux-arm64-minvmd-body\n' >"$mock/versions/v1/minvmd-linux-arm64" printf 'linux-arm64-initramfs-body\n' >"$mock/versions/v1/initramfs-arm64.cpio" printf 'linux-arm64-rootfs-body\n' >"$mock/versions/v1/rootfs-arm64.img" @@ -182,7 +182,7 @@ printf 'mock-gvproxy-switch-arm64-body\n' >"$mock/versions/v1/gvproxy-min-linux- # macOS arm64 guest payload (kept distinct from the linux arm64 rootfs so each # architecture is exercised with its own artifact and hash). write_min_stub "$mock/versions/v1/minimal-darwin-arm64" darwin-arm64 -printf 'darwin-arm64-answerer-body\n' >"$mock/versions/v1/min-answerer-macos-arm64" +printf 'darwin-arm64-answerer-body\n' >"$mock/versions/v1/minzoned-macos-arm64" printf 'darwin-arm64-rootfs-body\n' >"$mock/versions/v1/rootfs-darwin-arm64.img" # AppArmor components: noarch text (the loader is a runnable stub here), shipped @@ -194,7 +194,7 @@ printf '#!/bin/sh\n# mock apparmor loader\n' >"$mock/versions/v1/install-apparmo # Hashes for every artifact referenced by the component table below. h_minimald="$(hash_file "$mock/versions/v1/minimald-linux-amd64")" h_minimal="$(hash_file "$mock/versions/v1/minimal-linux-amd64")" -h_answerer="$(hash_file "$mock/versions/v1/min-answerer-linux-amd64")" +h_answerer="$(hash_file "$mock/versions/v1/minzoned-linux-amd64")" h_minvmd="$(hash_file "$mock/versions/v1/minvmd-linux-amd64")" h_initramfs="$(hash_file "$mock/versions/v1/initramfs-amd64.cpio")" h_rootfs="$(hash_file "$mock/versions/v1/rootfs-amd64.img")" @@ -203,7 +203,7 @@ h_gvmin="$(hash_file "$mock/versions/v1/gvproxy-min-linux-amd64")" h_minimald_arm="$(hash_file "$mock/versions/v1/minimald-linux-arm64")" h_minimal_arm="$(hash_file "$mock/versions/v1/minimal-linux-arm64")" -h_answerer_arm="$(hash_file "$mock/versions/v1/min-answerer-linux-arm64")" +h_answerer_arm="$(hash_file "$mock/versions/v1/minzoned-linux-arm64")" h_minvmd_arm="$(hash_file "$mock/versions/v1/minvmd-linux-arm64")" h_initramfs_arm="$(hash_file "$mock/versions/v1/initramfs-arm64.cpio")" h_rootfs_arm="$(hash_file "$mock/versions/v1/rootfs-arm64.img")" @@ -211,7 +211,7 @@ h_vmlinuz_arm="$(hash_file "$mock/versions/v1/vmlinuz-arm64")" h_gvmin_arm="$(hash_file "$mock/versions/v1/gvproxy-min-linux-arm64")" h_dmin="$(hash_file "$mock/versions/v1/minimal-darwin-arm64")" -h_danswerer="$(hash_file "$mock/versions/v1/min-answerer-macos-arm64")" +h_danswerer="$(hash_file "$mock/versions/v1/minzoned-macos-arm64")" h_drootfs="$(hash_file "$mock/versions/v1/rootfs-darwin-arm64.img")" h_aaprof="$(hash_file "$mock/versions/v1/minimald.apparmor")" @@ -234,7 +234,7 @@ write_manifest() { # The answerer installs beside min on every platform min ships for # (NET-122); the installed copy is only the advisory's copy source. printf '%-12s %-7s %-7s %-9s %-64s %-6s %-20s %s\n' \ - min-answerer linux amd64 v1 "$h_answerer" file bin/min-answerer versions/v1/min-answerer-linux-amd64 + minzoned linux amd64 v1 "$h_answerer" file bin/minzoned versions/v1/minzoned-linux-amd64 printf '%-12s %-7s %-7s %-9s %-64s %-6s %-20s %s\n' \ gvproxy-min linux amd64 v1 "$h_gvmin" file bin/gvproxy-min versions/v1/gvproxy-min-linux-amd64 printf '%-12s %-7s %-7s %-9s %-64s %-6s %-20s %s\n' \ @@ -251,7 +251,7 @@ write_manifest() { printf '%-12s %-7s %-7s %-9s %-64s %-6s %-20s %s\n' \ minimal linux arm64 v1 "$h_minimal_arm" file bin/min versions/v1/minimal-linux-arm64 printf '%-12s %-7s %-7s %-9s %-64s %-6s %-20s %s\n' \ - min-answerer linux arm64 v1 "$h_answerer_arm" file bin/min-answerer versions/v1/min-answerer-linux-arm64 + minzoned linux arm64 v1 "$h_answerer_arm" file bin/minzoned versions/v1/minzoned-linux-arm64 printf '%-12s %-7s %-7s %-9s %-64s %-6s %-20s %s\n' \ gvproxy-min linux arm64 v1 "$h_gvmin_arm" file bin/gvproxy-min versions/v1/gvproxy-min-linux-arm64 printf '%-12s %-7s %-7s %-9s %-64s %-6s %-20s %s\n' \ @@ -266,7 +266,7 @@ write_manifest() { printf '%-12s %-7s %-7s %-9s %-64s %-6s %-20s %s\n' \ minimal darwin arm64 v1 "$h_dmin" file bin/min versions/v1/minimal-darwin-arm64 printf '%-12s %-7s %-7s %-9s %-64s %-6s %-20s %s\n' \ - min-answerer darwin arm64 v1 "$h_danswerer" file bin/min-answerer versions/v1/min-answerer-macos-arm64 + minzoned darwin arm64 v1 "$h_danswerer" file bin/minzoned versions/v1/minzoned-macos-arm64 printf '%-12s %-7s %-7s %-9s %-64s %-6s %-20s %s\n' \ rootfs darwin arm64 v1 "$h_drootfs" file data/rootfs.img versions/v1/rootfs-darwin-arm64.img # AppArmor support files ship to every Linux arch. @@ -2073,16 +2073,16 @@ case_answerer_source_installed() { H_A1="$root/h_ans_amd64"; mkdir -p "$H_A1" run ans_amd64_install "$H_A1" check 0 "$rc" "amd64 install with the answerer row exits 0" - want_ok "amd64: the answerer installs beside min" test -f "$H_A1/bin/min-answerer" + want_ok "amd64: the answerer installs beside min" test -f "$H_A1/bin/minzoned" want_ok "amd64: beside the installed min itself" test -f "$H_A1/bin/min" - want_ok "amd64: the answerer is executable like every bin row" test -x "$H_A1/bin/min-answerer" - check "$h_answerer" "$(hash_file "$H_A1/bin/min-answerer")" \ + want_ok "amd64: the answerer is executable like every bin row" test -x "$H_A1/bin/minzoned" + check "$h_answerer" "$(hash_file "$H_A1/bin/minzoned")" \ "amd64: installed answerer matches the manifest hash" want_ok "amd64: the installer printed the answerer status" \ - grep -qE "^ min-answerer +(installed|current)" "$OUT" + grep -qE "^ minzoned +(installed|current)" "$OUT" _rec="$H_A1/xdg-state/minimal/installed" want_ok "amd64: the answerer is recorded at its user-prefix path" \ - record_has min-answerer "$H_A1/bin/min-answerer" "$_rec" + record_has minzoned "$H_A1/bin/minzoned" "$_rec" # The installed copy is only the copy source: no unit or plist was # written, and no record row names a service-manager path or the # root-owned program path. @@ -2091,20 +2091,20 @@ case_answerer_source_installed() { sh -c 'find "$1" \( -name "*.plist" -o -name "*.service" -o -name "*.socket" \) -print | grep -q .' sh "$H_A1" # shellcheck disable=SC2016 # $2 is awk's second field, not a shell parameter want_ok "no record row names a unit, plist, or root-owned answerer path" \ - awk '$2 ~ /(systemd|launchd|PrivilegedHelperTools|zone-answerer)/ {bad=1} END{exit bad ? 1 : 0}' "$_rec" + awk '$2 ~ /(systemd|launchd|PrivilegedHelperTools|lib\/minimal\/minzoned|dev\.gominimal\.zone)/ {bad=1} END{exit bad ? 1 : 0}' "$_rec" # An upgrade replaces it like the other binaries: a new release's answerer # bytes alone re-download and land. - printf 'linux-amd64-answerer-body-v2\n' >"$mock/versions/v1/min-answerer-linux-amd64-v2" - h_answerer2="$(hash_file "$mock/versions/v1/min-answerer-linux-amd64-v2")" + printf 'linux-amd64-answerer-body-v2\n' >"$mock/versions/v1/minzoned-linux-amd64-v2" + h_answerer2="$(hash_file "$mock/versions/v1/minzoned-linux-amd64-v2")" awk -v h="$h_answerer2" \ - '$1=="min-answerer" && $2=="linux" && $3=="amd64" {$5=h; $8="versions/v1/min-answerer-linux-amd64-v2"} {print}' \ + '$1=="minzoned" && $2=="linux" && $3=="amd64" {$5=h; $8="versions/v1/minzoned-linux-amd64-v2"} {print}' \ "$root/good-components" >"$mock/versions/v1/components" reset_dl run ans_amd64_upgrade "$H_A1" check 0 "$rc" "answerer upgrade install exits 0" check 1 "$(downloads)" "a new manifest hash re-downloads the answerer alone" - check "$h_answerer2" "$(hash_file "$H_A1/bin/min-answerer")" \ + check "$h_answerer2" "$(hash_file "$H_A1/bin/minzoned")" \ "the upgraded answerer replaced the installed copy" cp "$root/good-components" "$mock/versions/v1/components" # restore @@ -2113,7 +2113,7 @@ case_answerer_source_installed() { H_A2="$root/h_ans_arm64"; mkdir -p "$H_A2" run ans_arm64_install "$H_A2" check 0 "$rc" "arm64 install with the answerer row exits 0" - check "$h_answerer_arm" "$(hash_file "$H_A2/bin/min-answerer")" \ + check "$h_answerer_arm" "$(hash_file "$H_A2/bin/minzoned")" \ "arm64: the answerer installs beside min" PLAT_M=x86_64 @@ -2124,11 +2124,11 @@ case_answerer_source_installed() { H_A3="$root/h_ans_darwin"; mkdir -p "$H_A3" run ans_darwin_install "$H_A3" check 0 "$rc" "darwin install with the answerer row exits 0" - want_ok "darwin: the answerer installs beside min" test -f "$H_A3/bin/min-answerer" + want_ok "darwin: the answerer installs beside min" test -f "$H_A3/bin/minzoned" want_ok "darwin: quarantine stripped from the answerer bin (xattr)" \ - grep -q "/bin/min-answerer\.tmp" "$root/xattr.calls" + grep -q "/bin/minzoned\.tmp" "$root/xattr.calls" want_ok "darwin: the answerer is recorded at its user-prefix path" \ - record_has min-answerer "$H_A3/bin/min-answerer" "$H_A3/xdg-state/minimal/installed" + record_has minzoned "$H_A3/bin/minzoned" "$H_A3/xdg-state/minimal/installed" PLAT_S=Linux; PLAT_M=x86_64 } diff --git a/scripts/package-nfpm.sh b/scripts/package-nfpm.sh index b4ec7ed7e8..6ee7c39c7b 100755 --- a/scripts/package-nfpm.sh +++ b/scripts/package-nfpm.sh @@ -188,8 +188,8 @@ trap 'rm -rf "$workdir"' EXIT # name. Same mapping as the PKGBUILD's source arrays # (min::minimal-linux-amd64, ...), plus minvmd, which every staged row # carries — see the file-list decision in packaging/nfpm.yaml's header. -# min-answerer carries the same rule: it packages beside `min` as -# /usr/bin/min-answerer (the copy source NET-122's session advisory finds), +# minzoned carries the same rule: it packages beside `min` as +# /usr/bin/minzoned (the copy source NET-122's session advisory finds), # root-owned like the other packaged binaries, and nothing here installs or # enables the answerer service — the advisory's privileged step stays the # one privileged step, so a package never writes the unit files or plist. @@ -199,17 +199,17 @@ ARTIFACTS=( "mip|mip" "minvmd|minvmd" "gvproxy|gvproxy-min" - "min-answerer|min-answerer" + "minzoned|minzoned" ) artifacts_root="$workdir/artifacts" # Artifacts whose absence warns and packages without them instead of failing. # TEMPORARY (gominimal/inbox#899), the same rule as stage-release.sh's -# OPTIONAL_COMPONENTS: the frozen release.yml does not build min-answerer yet, -# so a versioned release must still package. A package built without it drops -# the config's marked min-answerer block (see packaging/nfpm.yaml). Empty this -# list once release.yml uploads the artifact. -OPTIONAL_ARTIFACTS=(min-answerer) +# OPTIONAL_COMPONENTS: release.yml now uploads minzoned on every platform, but +# this list stays until stage-release.sh's does, so a versioned release without +# the artifact still packages. A package built without it drops the config's +# marked minzoned block (see packaging/nfpm.yaml). Empty both lists together. +OPTIONAL_ARTIFACTS=(minzoned) # is_optional — whether a missing artifact only warns. is_optional() { diff --git a/scripts/session-e2e.sh b/scripts/session-e2e.sh index 8f431b5403..6c736b52a3 100755 --- a/scripts/session-e2e.sh +++ b/scripts/session-e2e.sh @@ -746,11 +746,11 @@ else echo "no usable 'min' on PATH and no build under target/; building the pair this run drives (cargo build --locked -p minimal --bin min -p $min_daemon --bin $min_daemon)" # A VM-backed run also needs the answerer program the advisory's command # copies into place (beside min). It builds in its own invocation, as - # `just answerer-build` does: beside `-p minvmd`, cargo would unify + # `just zoned-build` does: beside `-p minvmd`, cargo would unify # minvmd's `libkrun` feature into the root-run program. if (cd "$ROOT" && cargo build --locked -p minimal --bin min \ -p "$min_daemon" --bin "$min_daemon" \ - && { [ "$min_daemon" != minvmd ] || cargo build --locked -p min-answerer; }) \ + && { [ "$min_daemon" != minvmd ] || cargo build --locked -p minzoned; }) \ >"$WORK/cli-build.log" 2>&1; then for d in "$ROOT/target/debug" "${CARGO_TARGET_DIR:-/nonexistent}/debug"; do if [ -x "$d/min" ]; then @@ -6802,8 +6802,8 @@ proof_local_range_reserved_by_privileged_step() { echo "removing a leftover range unit from a prior run, so this proof starts from the advisory's own premise" range_remove_unit fi - if [ -e /Library/LaunchDaemons/dev.minimal.zone-answerer.plist ] \ - || [ -e /Library/PrivilegedHelperTools/dev.minimal.zone-answerer ]; then + if [ -e /Library/LaunchDaemons/dev.gominimal.zone.plist ] \ + || [ -e /Library/PrivilegedHelperTools/minzoned ]; then echo "removing a leftover answerer service from a prior run, for the same reason" ANSWERER_SERVICE_CHANNEL="${ANSWERER_SERVICE_CHANNEL:-/nonexistent}" answerer_service_teardown @@ -6845,7 +6845,7 @@ proof_local_range_reserved_by_privileged_step() { # on macOS it spans several lines, because the two files' bytes ride # inside it as quoted heredocs, so the extraction runs from the # de-indented `sudo` line to the closing quote. - range_cmd="$(awk -v lead="Configure the host's resolver, reserve the local range, and install the box-zone answerer service with:" -v q="'" ' + range_cmd="$(awk -v lead="Configure the host's resolver, reserve the local range, and install the Minimal box-name service (DNS and addresses for boxes) with:" -v q="'" ' index($0, lead) > 0 { started = 1; next } started && !first { sub(/^ /, ""); first = 1 } started { print; if (substr($0, length($0), 1) == q) exit } @@ -7145,19 +7145,19 @@ range_teardown_unit() { answerer_service_teardown() { [ -n "${ANSWERER_SERVICE_CHANNEL:-}" ] || return 0 if [ "$(uname -s)" = Darwin ]; then - sudo -n launchctl bootout "system/dev.minimal.zone-answerer" >/dev/null 2>&1 || true - sudo -n rm -f "/Library/LaunchDaemons/dev.minimal.zone-answerer.plist" \ - "/Library/PrivilegedHelperTools/dev.minimal.zone-answerer" >/dev/null 2>&1 || true + sudo -n launchctl bootout "system/dev.gominimal.zone" >/dev/null 2>&1 || true + sudo -n rm -f "/Library/LaunchDaemons/dev.gominimal.zone.plist" \ + "/Library/PrivilegedHelperTools/minzoned" >/dev/null 2>&1 || true else - sudo -n systemctl disable --now dev.minimal.zone-answerer.socket \ - dev.minimal.zone-answerer.service >/dev/null 2>&1 || true - sudo -n rm -f /etc/systemd/system/dev.minimal.zone-answerer.socket \ - /etc/systemd/system/dev.minimal.zone-answerer.service \ - /usr/local/lib/minimal/dev.minimal.zone-answerer >/dev/null 2>&1 || true + sudo -n systemctl disable --now minzoned.socket \ + minzoned.service >/dev/null 2>&1 || true + sudo -n rm -f /etc/systemd/system/minzoned.socket \ + /etc/systemd/system/minzoned.service \ + /usr/local/lib/minimal/minzoned >/dev/null 2>&1 || true sudo -n rmdir /usr/local/lib/minimal >/dev/null 2>&1 || true sudo -n systemctl daemon-reload >/dev/null 2>&1 || true - sudo -n systemctl reset-failed dev.minimal.zone-answerer.socket \ - dev.minimal.zone-answerer.service >/dev/null 2>&1 || true + sudo -n systemctl reset-failed minzoned.socket \ + minzoned.service >/dev/null 2>&1 || true fi sudo -n rm -f "$ANSWERER_SERVICE_CHANNEL" >/dev/null 2>&1 || true # And the directory it sat in, when the command made it and it is now @@ -7311,9 +7311,10 @@ proof_native_resolution_without_proxy_env() { # The command the advisory named: the line after its lead-in, de-indented — # exactly what a user would have copied off the terminal. The lead-in's - # shared prefix matches both platforms' wording ("…and install the box-zone - # answerer service with:" on Linux, "…reserve the local range, and install - # the box-zone answerer service with:" on macOS, whose command + # shared prefix matches both platforms' wording ("…and install the Minimal + # box-name service (DNS and addresses for boxes) with:" on Linux, "…reserve the + # local range, and install the Minimal box-name service (DNS and addresses + # for boxes) with:" on macOS, whose command # carries the range step NET-123 folds into it); the range-reserving case # below extracts the multi-line command whole. native_cmd="$(advisory_command_from "$native_err" "Configure the host's resolver")" @@ -7468,7 +7469,7 @@ proof_native_resolution_without_proxy_env() { # (T90); record the channel it binds BEFORE running it, so a # half-failed run still leaves the teardown a service to remove. case "$native_cmd" in - *zone-answerer*) + *minzoned*) ANSWERER_SERVICE_CHANNEL="$(answerer_channel_of "$native_cmd")" if [ -z "$ANSWERER_SERVICE_CHANNEL" ]; then echo "::error::the advisory's command names no answerer channel, so this run could not undo the service it installs; it was not run (got: '$native_cmd')" @@ -8374,7 +8375,7 @@ proof_box_name_resolves_natively_without_proxy() { # A native daemon's advisory carries the manager-held answerer step # (T90); record its channel first so the teardown can remove it. case "$bn_cmd" in - *zone-answerer*) + *minzoned*) ANSWERER_SERVICE_CHANNEL="$(answerer_channel_of "$bn_cmd")" if [ -z "$ANSWERER_SERVICE_CHANNEL" ]; then echo "::error::the advisory's command names no answerer channel, so this run could not undo the service it installs; it was not run (got: '$bn_cmd')" @@ -8733,33 +8734,33 @@ proof_box_name_resolves_natively_without_proxy() { # Every host change — the units, the program copy, the channel socket, the # resolver link (Linux) or file (macOS), the second node — is undone here # and again by the EXIT trap, so the shared runner is left as found. -# Makes the min-answerer program findable for this run: beside `min` or on -# PATH already, or built by `just answerer-build` (else that recipe's own +# Makes the minzoned program findable for this run: beside `min` or on +# PATH already, or built by `just zoned-build` (else that recipe's own # cargo line) and staged on PATH. A lane that can do neither fails: the # case must prove the handover there, never record it as not run. asr_answerer_ready() { local min_dir built min_dir="$(dirname -- "$(command -v min)")" - if [ -x "$min_dir/min-answerer" ]; then - echo "min-answerer: beside min at $min_dir/min-answerer" + if [ -x "$min_dir/minzoned" ]; then + echo "minzoned: beside min at $min_dir/minzoned" return 0 fi - if command -v min-answerer >/dev/null 2>&1; then - echo "min-answerer: on PATH at $(command -v min-answerer)" + if command -v minzoned >/dev/null 2>&1; then + echo "minzoned: on PATH at $(command -v minzoned)" return 0 fi - echo "min-answerer is not beside min or on PATH; building it (just answerer-build)" + echo "minzoned is not beside min or on PATH; building it (just zoned-build)" if command -v just >/dev/null 2>&1; then - (cd "$ROOT" && just answerer-build) >"$WORK/answerer-build.log" 2>&1 || { - echo "::error::'just answerer-build' failed"; tail -20 "$WORK/answerer-build.log"; fail; } + (cd "$ROOT" && just zoned-build) >"$WORK/zoned-build.log" 2>&1 || { + echo "::error::'just zoned-build' failed"; tail -20 "$WORK/zoned-build.log"; fail; } elif command -v cargo >/dev/null 2>&1; then - (cd "$ROOT" && cargo build -p min-answerer --locked) >"$WORK/answerer-build.log" 2>&1 || { - echo "::error::'cargo build -p min-answerer --locked' failed"; tail -20 "$WORK/answerer-build.log"; fail; } + (cd "$ROOT" && cargo build -p minzoned --locked) >"$WORK/zoned-build.log" 2>&1 || { + echo "::error::'cargo build -p minzoned --locked' failed"; tail -20 "$WORK/zoned-build.log"; fail; } else - echo "::error::this lane has no min-answerer and neither just nor cargo to build it; the handover cannot be proved" + echo "::error::this lane has no minzoned and neither just nor cargo to build it; the handover cannot be proved" fail fi - built="${CARGO_TARGET_DIR:-$ROOT/target}/debug/min-answerer" + built="${CARGO_TARGET_DIR:-$ROOT/target}/debug/minzoned" if [ ! -x "$built" ]; then echo "::error::the answerer build left no program at $built" fail @@ -8767,11 +8768,11 @@ asr_answerer_ready() { # Staged alone: target/debug also holds a min and a minvmd this run must # not pick up in place of the lane's own. mkdir -p "$WORK/answerer-bin" - cp "$built" "$WORK/answerer-bin/min-answerer" + cp "$built" "$WORK/answerer-bin/minzoned" # shellcheck disable=SC2031 # other proofs change PATH in their own subshells; this runs in the main shell PATH="$WORK/answerer-bin:$PATH" export PATH - echo "min-answerer: built and staged at $WORK/answerer-bin/min-answerer" + echo "minzoned: built and staged at $WORK/answerer-bin/minzoned" } proof_answerer_survives_session_stop() { @@ -8785,7 +8786,7 @@ proof_answerer_survives_session_stop() { case "$asr_os" in Linux) asr_channel=/run/minimal/answerer.sock - asr_marker=/etc/systemd/system/dev.minimal.zone-answerer.socket + asr_marker=/etc/systemd/system/minzoned.socket if ! command -v systemctl >/dev/null 2>&1 || ! command -v resolvectl >/dev/null 2>&1 \ || ! command -v ip >/dev/null 2>&1 || ! command -v dig >/dev/null 2>&1 \ || ! sudo -n true >/dev/null 2>&1; then @@ -8795,7 +8796,7 @@ proof_answerer_survives_session_stop() { ;; Darwin) asr_channel="/Library/Application Support/minimal/run/answerer.sock" - asr_marker=/Library/LaunchDaemons/dev.minimal.zone-answerer.plist + asr_marker=/Library/LaunchDaemons/dev.gominimal.zone.plist if ! command -v launchctl >/dev/null 2>&1 || ! command -v dig >/dev/null 2>&1 \ || ! sudo -n true >/dev/null 2>&1; then echo "::error::this macOS host cannot install the answerer LaunchDaemon (needs launchctl, dig and passwordless sudo); the case fails rather than self-skips, so the pin is never silent" @@ -8812,8 +8813,8 @@ proof_answerer_survives_session_stop() { # channel client from its first start, so the interim this case hands # over could never exist. Remove it first, the range case's reasoning. if [ -e "$asr_marker" ] || [ -e "$asr_channel" ] \ - || [ -e /usr/local/lib/minimal/dev.minimal.zone-answerer ] \ - || [ -e /Library/PrivilegedHelperTools/dev.minimal.zone-answerer ]; then + || [ -e /usr/local/lib/minimal/minzoned ] \ + || [ -e /Library/PrivilegedHelperTools/minzoned ]; then echo "removing a leftover answerer service from a prior run, so node A starts from the interim" ANSWERER_SERVICE_CHANNEL="$asr_channel" answerer_service_teardown @@ -8959,10 +8960,10 @@ for row in json.load(open(sys.argv[1])): fail } - # The advisory's command copies the min-answerer program found beside + # The advisory's command copies the minzoned program found beside # min or on PATH; a lane whose testbed carries only min and minvmd has # none, and its advisory then omits the step. Build it here, through - # `just answerer-build` — its own invocation, never beside -p minvmd (the + # `just zoned-build` — its own invocation, never beside -p minvmd (the # libkrun feature would unify in) — or that recipe's exact cargo line # where just is absent, and put it on PATH for this run. asr_answerer_ready @@ -9044,7 +9045,7 @@ for row in json.load(open(sys.argv[1])): local asr_cmd asr_cmd="$(advisory_command_from "$asr_a_err" "Configure the host's resolver")" case "$asr_cmd" in - *zone-answerer*) ;; + *minzoned*) ;; *) echo "::error::node A's session start printed no advisory carrying the answerer service step" echo "--- activate stderr ---"; cat "$asr_a_err" 2>/dev/null || true @@ -9103,9 +9104,9 @@ for row in json.load(open(sys.argv[1])): fail fi if [ "$asr_os" = Linux ]; then - if ! systemctl is-active --quiet dev.minimal.zone-answerer.socket; then + if ! systemctl is-active --quiet minzoned.socket; then echo "::error::the answerer socket unit is not active after the command" - systemctl status dev.minimal.zone-answerer.socket 2>&1 | tail -n 15 || true + systemctl status minzoned.socket 2>&1 | tail -n 15 || true fail fi asr_holders="$(sudo -n ss -lunp 2>/dev/null | grep -F -- "127.0.0.1:$asr_port " || true)" @@ -9117,7 +9118,7 @@ for row in json.load(open(sys.argv[1])): esac echo " the hook port's holder: ${asr_holders:-}" else - if ! sudo -n launchctl print system/dev.minimal.zone-answerer >/dev/null 2>&1; then + if ! sudo -n launchctl print system/dev.gominimal.zone >/dev/null 2>&1; then echo "::error::the answerer LaunchDaemon is not loaded after the command" fail fi @@ -9208,15 +9209,15 @@ for row in json.load(open(sys.argv[1])): # ---- 4. a service restart answers both names again ------------------------- local asr_pid_before asr_pid_after if [ "$asr_os" = Linux ]; then - asr_pid_before="$(systemctl show -p MainPID --value dev.minimal.zone-answerer.service)" - sudo -n systemctl restart dev.minimal.zone-answerer.service - asr_pid_after="$(systemctl show -p MainPID --value dev.minimal.zone-answerer.service)" + asr_pid_before="$(systemctl show -p MainPID --value minzoned.service)" + sudo -n systemctl restart minzoned.service + asr_pid_after="$(systemctl show -p MainPID --value minzoned.service)" else - asr_pid_before="$(sudo -n launchctl print system/dev.minimal.zone-answerer 2>/dev/null \ + asr_pid_before="$(sudo -n launchctl print system/dev.gominimal.zone 2>/dev/null \ | sed -n 's/^[[:space:]]*pid = //p' | head -n1)" - sudo -n launchctl kickstart -k system/dev.minimal.zone-answerer + sudo -n launchctl kickstart -k system/dev.gominimal.zone sleep 1 - asr_pid_after="$(sudo -n launchctl print system/dev.minimal.zone-answerer 2>/dev/null \ + asr_pid_after="$(sudo -n launchctl print system/dev.gominimal.zone 2>/dev/null \ | sed -n 's/^[[:space:]]*pid = //p' | head -n1)" fi echo "4. restarted the answerer service (pid ${asr_pid_before:-?} -> ${asr_pid_after:-on demand})" @@ -9369,7 +9370,7 @@ proof_native_answerer_survives_session_stop() { echo "::group::the native daemon publishes into the manager-held answerer, which survives a session stop (NET-122, T90)" local nasr_channel=/run/minimal/answerer.sock - local nasr_marker=/etc/systemd/system/dev.minimal.zone-answerer.socket + local nasr_marker=/etc/systemd/system/minzoned.socket local nasr_base_a="$XDG_STATE_HOME/minimal" local nasr_log_filter="warn,minimald::rpc=info,minimald::net::answerer=info" local nasr_port="" @@ -9378,7 +9379,7 @@ proof_native_answerer_survives_session_stop() { # client from its first start, so the interim this case hands over could # never exist. Remove it first. if [ -e "$nasr_marker" ] || [ -e "$nasr_channel" ] \ - || [ -e /usr/local/lib/minimal/dev.minimal.zone-answerer ]; then + || [ -e /usr/local/lib/minimal/minzoned ]; then echo "removing a leftover answerer service from a prior run, so node A starts from the interim" ANSWERER_SERVICE_CHANNEL="$nasr_channel" answerer_service_teardown @@ -9482,7 +9483,7 @@ proof_native_answerer_survives_session_stop() { fail } - # The advisory's command copies the min-answerer program found beside min + # The advisory's command copies the minzoned program found beside min # or on PATH; the answerer-service case's helper builds and stages it. asr_answerer_ready NASR_SEED_DIR="$(hook_mktemp /tmp/mnlnasr.XXXXXX)" @@ -9519,7 +9520,7 @@ proof_native_answerer_survives_session_stop() { local nasr_cmd nasr_cmd="$(advisory_command_from "$nasr_a_err" "Configure the host's resolver")" case "$nasr_cmd" in - *zone-answerer*) ;; + *minzoned*) ;; *) echo "::error::node A's native session start printed no advisory carrying the answerer service step" echo "--- activate stderr ---"; cat "$nasr_a_err" 2>/dev/null || true @@ -9569,9 +9570,9 @@ proof_native_answerer_survives_session_stop() { nasr_dump_log "$nasr_base_a" fail fi - if ! systemctl is-active --quiet dev.minimal.zone-answerer.socket; then + if ! systemctl is-active --quiet minzoned.socket; then echo "::error::the answerer socket unit is not active after the command" - systemctl status dev.minimal.zone-answerer.socket 2>&1 | tail -n 15 || true + systemctl status minzoned.socket 2>&1 | tail -n 15 || true fail fi local nasr_holders diff --git a/scripts/stage-release.sh b/scripts/stage-release.sh index 159218f2c5..83a51aab3b 100755 --- a/scripts/stage-release.sh +++ b/scripts/stage-release.sh @@ -230,7 +230,7 @@ fi # scripts/fetch-gvproxy.sh); only the installed name is ours, and # `switch::GVPROXY_FILE` is the resolver's matching definition. # -# min-answerer stages as `bin/min-answerer` beside `min` on every platform +# minzoned stages as `bin/minzoned` beside `min` on every platform # that stages `min` — exactly where the session advisory's `answerer_source` # looks for it (beside the running `min` first, then PATH). The staged copy is # only the COPY SOURCE for NET-122's one privileged step: the advisory's @@ -239,16 +239,16 @@ fi # plist references the user-prefix path, and neither does this table. It # carries no lib/ component on any platform: the Linux builds are static musl # and the macOS build links only system libraries (the rule -# scripts/check-answerer-links.sh gates before the binary can leave the build). +# scripts/check-zoned-links.sh gates before the binary can leave the build). # -# min-answerer is OPTIONAL, with a warning, where every other binary is +# minzoned is OPTIONAL, with a warning, where every other binary is # required: see OPTIONAL_COMPONENTS below. COMPONENTS=( # Linux amd64 "minimald|linux|amd64|file|bin/minimald|minimald-linux-amd64" "mip|linux|amd64|file|bin/mip|mip-linux-amd64" "minimal|linux|amd64|file|bin/min|minimal-linux-amd64" - "min-answerer|linux|amd64|file|bin/min-answerer|min-answerer-linux-amd64" + "minzoned|linux|amd64|file|bin/minzoned|minzoned-linux-amd64" "git-remote-min|linux|amd64|symlink|bin/git-remote-min|min" "gvproxy-min|linux|amd64|file|bin/gvproxy-min|gvproxy-linux-amd64" "minvmd|linux|amd64|file|bin/minvmd|minvmd-linux-amd64" @@ -259,7 +259,7 @@ COMPONENTS=( "minimald|linux|arm64|file|bin/minimald|minimald-linux-arm64" "mip|linux|arm64|file|bin/mip|mip-linux-arm64" "minimal|linux|arm64|file|bin/min|minimal-linux-arm64" - "min-answerer|linux|arm64|file|bin/min-answerer|min-answerer-linux-arm64" + "minzoned|linux|arm64|file|bin/minzoned|minzoned-linux-arm64" "git-remote-min|linux|arm64|symlink|bin/git-remote-min|min" "gvproxy-min|linux|arm64|file|bin/gvproxy-min|gvproxy-linux-arm64" "minvmd|linux|arm64|file|bin/minvmd|minvmd-linux-arm64" @@ -268,7 +268,7 @@ COMPONENTS=( "vmlinuz|linux|arm64|file|data/vmlinuz|vmlinuz-arm64" # macOS arm64 (darwin) "minimal|darwin|arm64|file|bin/min|minimal-macos-arm64" - "min-answerer|darwin|arm64|file|bin/min-answerer|min-answerer-macos-arm64" + "minzoned|darwin|arm64|file|bin/minzoned|minzoned-macos-arm64" "git-remote-min|darwin|arm64|symlink|bin/git-remote-min|min" "minvmd|darwin|arm64|file|bin/minvmd|minvmd-macos-arm64" # The trimmed libkrun minvmd links against (built by the release workflow's @@ -296,14 +296,13 @@ COMPONENTS=( ) # Components whose missing artifact warns and is omitted instead of failing -# the stage. TEMPORARY (gominimal/inbox#899): .github/workflows/release.yml does -# not build, sign or upload min-answerer yet, and that workflow is frozen, so -# the patch that adds it waits on a code owner. Until it lands, a release ships -# no min-answerer and the session advisory names that state ("this release -# ships no min-answerer; the answerer service step is unavailable") instead of -# offering the step. Once release.yml uploads the artifact on every platform, +# the stage. TEMPORARY (gominimal/inbox#899): .github/workflows/release.yml now +# builds, signs and uploads minzoned on every platform, but a release cut before +# that change ships no minzoned, and the session advisory names that state +# ("this release ships no minzoned; the answerer service step is unavailable") +# instead of offering the step. Once releases with the artifact are the norm, # empty this list so a missing answerer fails the stage like any other binary. -OPTIONAL_COMPONENTS=(min-answerer) +OPTIONAL_COMPONENTS=(minzoned) # is_optional — whether a missing artifact for it only warns. is_optional() { diff --git a/scripts/stage-release_test.sh b/scripts/stage-release_test.sh index d7c22b48ea..127ff415cb 100755 --- a/scripts/stage-release_test.sh +++ b/scripts/stage-release_test.sh @@ -49,7 +49,7 @@ unset GCLOUD_STUB_EXISTS GCLOUD_STUB_SMOKED GCLOUD_STUB_RM_ERROR RESTAGE VERSION mkdir -p "$root/artifacts" "$root/pkg" printf 'fake min\n' >"$root/artifacts/minimal-linux-amd64" printf 'fake mip\n' >"$root/artifacts/mip-linux-amd64" -printf 'fake answerer\n' >"$root/artifacts/min-answerer-linux-amd64" +printf 'fake answerer\n' >"$root/artifacts/minzoned-linux-amd64" printf 'fake deb\n' >"$root/pkg/minimal_0.6.0_amd64.deb" pass=0 fail=0 @@ -242,25 +242,25 @@ fi expect 1 "--extra needs an existing file" "--extra with a missing file fails before anything runs" -- \ with GCLOUD_STUB_EXISTS=0 -- stage --version 0.6.0 --extra "$root/absent" -# --- min-answerer stages beside min; optional until release.yml ships it ----- +# --- minzoned stages beside min; optional until release.yml ships it ----- -# The answerer row: bin/min-answerer beside bin/min on every platform the +# The answerer row: bin/minzoned beside bin/min on every platform the # manifest ships min for, hashed and uploaded with the rest — it is the copy # source NET-122's session advisory finds, so a release without it is a # release whose advisory cannot offer the host service. answerer_out="$(with GCLOUD_STUB_EXISTS=0 -- stage --version 0.6.0 2>&1)" answerer_rows="$(printf '%s\n' "$answerer_out" | awk ' - $1 == "min-answerer" && $2 == "linux" && $3 == "amd64" && $6 == "file" \ - && $7 == "bin/min-answerer" && $8 == "versions/0.6.0/min-answerer-linux-amd64"')" + $1 == "minzoned" && $2 == "linux" && $3 == "amd64" && $6 == "file" \ + && $7 == "bin/minzoned" && $8 == "versions/0.6.0/minzoned-linux-amd64"')" if [ -n "$answerer_rows" ]; then - ok "the manifest carries min-answerer as bin/min-answerer beside min, hashed from the artifact" + ok "the manifest carries minzoned as bin/minzoned beside min, hashed from the artifact" else - bad "no min-answerer row in the manifest (out: $answerer_out)" + bad "no minzoned row in the manifest (out: $answerer_out)" fi -expect_calls 1 "min-answerer-linux-amd64 .*gs://test-bucket/versions/0.6.0/$" \ +expect_calls 1 "minzoned-linux-amd64 .*gs://test-bucket/versions/0.6.0/$" \ "the answerer artifact uploads with the others in the one artifact cp" -if [ -n "$(printf '%s\n' "$answerer_out" | awk '$1 == "min-answerer" && $7 ~ /^lib\//')" ]; then - bad "min-answerer must carry no lib/ component on any platform" +if [ -n "$(printf '%s\n' "$answerer_out" | awk '$1 == "minzoned" && $7 ~ /^lib\//')" ]; then + bad "minzoned must carry no lib/ component on any platform" else ok "the answerer row stages no lib/ component" fi @@ -279,7 +279,7 @@ mkdir -p "$root/artifacts-no-answerer" awk -F'|' '/^ "[a-z-]+\|(linux|darwin)\|/ && $4 == "file" { sub(/".*$/, "", $6); print $6 }' "$script" | sort -u | while read -r base; do - case "$base" in min-answerer-*) continue ;; esac + case "$base" in minzoned-*) continue ;; esac printf 'fake %s\n' "$base" >"$root/artifacts-no-answerer/$base" done : >"$GCLOUD_STUB_ARGS" @@ -292,10 +292,10 @@ else bad "a missing answerer artifact failed the stage (rc=$no_answerer_rc, out: $no_answerer_out)" fi for plat in linux/amd64 linux/arm64 darwin/arm64; do - if [[ "$no_answerer_out" == *"warning: optional artifact missing, omitting min-answerer/$plat:"* ]]; then - ok "the stage warns that min-answerer/$plat is omitted" + if [[ "$no_answerer_out" == *"warning: optional artifact missing, omitting minzoned/$plat:"* ]]; then + ok "the stage warns that minzoned/$plat is omitted" else - bad "no omission warning for min-answerer/$plat (out: $no_answerer_out)" + bad "no omission warning for minzoned/$plat (out: $no_answerer_out)" fi done if [[ "$no_answerer_out" == *"gominimal/inbox#899"* ]]; then @@ -303,10 +303,10 @@ if [[ "$no_answerer_out" == *"gominimal/inbox#899"* ]]; then else bad "the warning does not name gominimal/inbox#899 (out: $no_answerer_out)" fi -if [ -z "$(printf '%s\n' "$no_answerer_out" | awk '$1 == "min-answerer" && $6 == "file"')" ]; then - ok "the manifest carries no min-answerer row when the artifact is missing" +if [ -z "$(printf '%s\n' "$no_answerer_out" | awk '$1 == "minzoned" && $6 == "file"')" ]; then + ok "the manifest carries no minzoned row when the artifact is missing" else - bad "the manifest carries a min-answerer row with no artifact behind it (out: $no_answerer_out)" + bad "the manifest carries a minzoned row with no artifact behind it (out: $no_answerer_out)" fi if [ -n "$(printf '%s\n' "$no_answerer_out" | awk '$1 == "minimal" && $2 == "darwin" && $7 == "bin/min"')" ] \ && [ -n "$(printf '%s\n' "$no_answerer_out" | awk '$1 == "minvmd" && $2 == "linux" && $3 == "arm64"')" ]; then @@ -316,7 +316,7 @@ else fi expect_calls 1 "/components gs://test-bucket/versions/0.6.0/components$" \ "the manifest still uploads when only the answerer is missing" -expect_calls 0 "min-answerer" "no answerer artifact is uploaded when it is missing" +expect_calls 0 "minzoned" "no answerer artifact is uploaded when it is missing" # Every other binary stays required: the same fixture without minvmd's arm64 # artifact fails the stage naming it. diff --git a/scripts/zoned-e2e-publisher.py b/scripts/zoned-e2e-publisher.py new file mode 100755 index 0000000000..ae760d062c --- /dev/null +++ b/scripts/zoned-e2e-publisher.py @@ -0,0 +1,108 @@ +#!/usr/bin/env python3 +"""A stand-in node for scripts/zoned-macos-e2e.sh: publishes one box row +into the installed minzoned service over its channel, the way a VM host +daemon does, without a VM. + +The channel is newline-delimited JSON over a unix stream +(crates/minvmd/src/net/answerer.rs): a hello, then an address allocation for +the box, then a publish of the box's row. The service holds the row only +while the connection stays open, so `hold` keeps it open, and reconnects and +re-publishes when the service restarts, as a node does. + + zoned-e2e-publisher.py once CHANNEL NODE BOX VERSION + Connect, hello, allocate, publish, print the reply lines, exit. + Exits non-zero if any reply is not ok. + zoned-e2e-publisher.py hold CHANNEL NODE BOX VERSION ADDRESS_FILE + Publish, write the allocated address to ADDRESS_FILE, and hold the + connection until SIGTERM; reconnect and re-publish when it drops. + +Stdlib only. +""" + +import json +import os +import signal +import socket +import sys +import time + + +def request(stream, sock, message): + sock.sendall((json.dumps(message) + "\n").encode()) + line = stream.readline() + if not line: + raise ConnectionError("the channel closed before replying") + reply = json.loads(line) + print(json.dumps({"sent": message, "reply": reply}), flush=True) + return reply + + +def publish(channel, node, box, version): + """Connect and publish the box's row. Returns (socket, address), or + raises with the refusal the service gave.""" + sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) + sock.connect(channel) + stream = sock.makefile("r") + hello = request(stream, sock, {"node": node, "version": version}) + if not hello.get("ok"): + raise PermissionError(hello.get("error", "hello refused")) + allocated = request(stream, sock, {"allocate": box}) + if not allocated.get("ok") or not allocated.get("address"): + raise RuntimeError(f"allocation refused: {allocated}") + address = allocated["address"] + row = {"name": f"{box}.min.internal", "address": address, "live": True} + published = request(stream, sock, {"rows": [row]}) + if not published.get("ok") or published.get("refused"): + raise RuntimeError(f"publish refused: {published}") + return sock, address + + +def hold(channel, node, box, version, address_file): + stopping = [] + signal.signal(signal.SIGTERM, lambda *_: stopping.append(True)) + while not stopping: + try: + sock, address = publish(channel, node, box, version) + except (OSError, ConnectionError, RuntimeError) as error: + print(f"publish failed, retrying: {error}", flush=True) + time.sleep(0.25) + continue + tmp = address_file + ".tmp" + with open(tmp, "w") as f: + f.write(address + "\n") + os.replace(tmp, address_file) + # Block until the service drops the connection (a restart) or + # SIGTERM arrives; the timeout lets the loop see the signal. + sock.settimeout(0.25) + while not stopping: + try: + if not sock.recv(1): + print("the channel closed; reconnecting", flush=True) + break + except socket.timeout: + continue + except OSError: + break + sock.close() + + +def main(argv): + if len(argv) >= 5 and argv[0] == "once": + _, channel, node, box, version = argv[:5] + try: + sock, _ = publish(channel, node, box, int(version)) + except (OSError, ConnectionError, PermissionError, RuntimeError) as error: + print(f"refused: {error}", flush=True) + return 1 + sock.close() + return 0 + if len(argv) >= 6 and argv[0] == "hold": + _, channel, node, box, version, address_file = argv[:6] + hold(channel, node, box, int(version), address_file) + return 0 + print(__doc__, file=sys.stderr) + return 2 + + +if __name__ == "__main__": + sys.exit(main(sys.argv[1:])) diff --git a/scripts/zoned-macos-e2e.sh b/scripts/zoned-macos-e2e.sh new file mode 100755 index 0000000000..6ae26632cf --- /dev/null +++ b/scripts/zoned-macos-e2e.sh @@ -0,0 +1,270 @@ +#!/usr/bin/env bash +# +# zoned-macos-e2e.sh — prove the macOS box-name service install end to end: +# the privileged command `min` hands an operator, run for real, leaves a +# root-owned minzoned LaunchDaemon that answers `*.min.internal` through the +# system resolver, serves its channel to the operator, refuses root, survives +# a restart, and tears down without a trace. +# +# WHY: session-e2e.sh holds these proofs too, but behind +# MINIMAL_E2E_PRIVILEGED=1, and the self-hosted Mac fleet runs without sudo +# (it runs PR code, so sudo there is root for any PR). GitHub-hosted macOS +# runners are ephemeral and grant sudo, but cannot boot a VM — so this +# script proves the service with no VM: scripts/zoned-e2e-publisher.py +# stands in for the node and publishes a box row over the channel. +# +# What it does NOT prove: the codesign requirement. A debug `min` pins the +# installed copy by SHA but skips the signing-identity check, and the hosted +# runner has no signing identity to check against. +# +# Usage: MINIMAL_E2E_PRIVILEGED=1 scripts/zoned-macos-e2e.sh MIN_BIN +# MIN_BIN is a debug `min` with `minzoned` beside it. The script refuses a +# host that already carries the service or the resolver file, and its EXIT +# trap removes everything the command installed. +set -euo pipefail + +LABEL=dev.gominimal.zone +PLIST=/Library/LaunchDaemons/$LABEL.plist +PROGRAM=/Library/PrivilegedHelperTools/minzoned +CHANNEL="/Library/Application Support/minimal/run/answerer.sock" +RANGE_LABEL=dev.minimal.local-range +RANGE_PROGRAM=/Library/PrivilegedHelperTools/$RANGE_LABEL +RANGE_PLIST=/Library/LaunchDaemons/$RANGE_LABEL.plist +RESOLVER=/etc/resolver/min.internal +PORT=7656 +BOX=zoned-e2e +NODE=zoned-e2e-node + +here="$(cd "$(dirname "$0")" && pwd)" +publisher="$here/zoned-e2e-publisher.py" + +fail() { + echo "::error::$*" + exit 1 +} + +# --- 0. Preconditions -------------------------------------------------------- + +[ "$(uname -s)" = Darwin ] || fail "this proof is macOS only" +[ "${MINIMAL_E2E_PRIVILEGED:-}" = 1 ] \ + || fail "set MINIMAL_E2E_PRIVILEGED=1: this script installs a root LaunchDaemon" +sudo -n true 2>/dev/null || fail "this proof needs sudo without a password" +[ $# = 1 ] || fail "usage: $0 MIN_BIN" +min_bin="$1" +zoned_bin="$(dirname "$min_bin")/minzoned" +[ -x "$min_bin" ] || fail "no executable min at $min_bin" +[ -x "$zoned_bin" ] || fail "no executable minzoned beside min at $zoned_bin" +for tool in dig python3 plutil launchctl lsof dscacheutil; do + command -v "$tool" >/dev/null 2>&1 || fail "$tool is not on PATH" +done +for path in "$PLIST" "$RANGE_PLIST" "$RESOLVER"; do + [ ! -e "$path" ] || fail "$path already exists; this proof needs a host without the service" +done + +work="$(mktemp -d)" +publisher_pid= + +# --- Teardown ---------------------------------------------------------------- + +# Removes everything the command installs, idempotently and best-effort. +remove_service() { + sudo launchctl bootout "system/$LABEL" >/dev/null 2>&1 || true + sudo launchctl bootout "system/$RANGE_LABEL" >/dev/null 2>&1 || true + sudo rm -f "$PLIST" "$PROGRAM" "$CHANNEL" "$RANGE_PLIST" "$RANGE_PROGRAM" "$RESOLVER" || true + sudo rmdir "$(dirname "$CHANNEL")" 2>/dev/null || true + for n in $(seq 1 254); do + sudo ifconfig lo0 -alias 127.0.64."$n" >/dev/null 2>&1 || true + done +} + +stop_publisher() { + [ -n "$publisher_pid" ] || return 0 + kill "$publisher_pid" 2>/dev/null || true + wait "$publisher_pid" 2>/dev/null || true + publisher_pid= +} + +on_exit() { + local status=$? + set +e + stop_publisher + if [ "$status" != 0 ]; then + echo "--- publisher log" + cat "$work/publisher.log" 2>/dev/null + echo "--- launchctl print system/$LABEL" + sudo launchctl print "system/$LABEL" 2>&1 | head -60 + echo "--- minzoned log" + sudo log show --last 5m --style compact --predicate 'process == "minzoned"' 2>/dev/null | tail -60 + fi + remove_service + rm -rf "$work" + exit "$status" +} +trap on_exit EXIT + +# Answers for NAME from the service, as `STATUS ADDRESS...`. +query() { + local out status + out="$(dig +time=2 +tries=1 -p "$PORT" @127.0.0.1 "$1" A +noall +comments +answer)" + status="$(sed -n 's/.*status: \([A-Z]*\),.*/\1/p' <<<"$out" | head -1)" + echo "$status $(awk '$4 == "A" { print $5 }' <<<"$out" | xargs)" +} + +# Waits up to ~10 s for NAME to answer EXPECTED (`STATUS ADDRESS...`). +expect_answer() { + local name="$1" expected="$2" got= + for _ in $(seq 1 40); do + got="$(query "$name" 2>/dev/null || true)" + got="${got% }" + [ "$got" = "$expected" ] && return 0 + sleep 0.25 + done + fail "$name answered '$got', expected '$expected'" +} + +service_pid() { + sudo launchctl print "system/$LABEL" 2>/dev/null | awk '$1 == "pid" { print $3; exit }' +} + +# --- 1. The command ---------------------------------------------------------- + +echo "::group::the install command" +cmd="$("$min_bin" debug-answerer-command)" +printf '%s\n' "$cmd" +grep -q "minzoned" <<<"$cmd" || fail "the command does not install minzoned" +grep -q "launchctl bootstrap system $PLIST" <<<"$cmd" \ + || fail "the command does not bootstrap $LABEL" +[ "$(grep -o 'sudo ' <<<"$cmd" | wc -l | tr -d ' ')" = 1 ] \ + || fail "the command must ask for sudo exactly once" +echo "::endgroup::" + +# --- 2. Run it --------------------------------------------------------------- + +echo "::group::run the command" +sh -c "$cmd" || fail "the install command exited non-zero" +echo "::endgroup::" + +# --- 3. Custody -------------------------------------------------------------- + +echo "::group::custody" +for spec in "$PROGRAM 755" "$RANGE_PROGRAM 755" "$PLIST 644" "$RANGE_PLIST 644" "$RESOLVER 644"; do + path="${spec% *}" + mode="${spec##* }" + got="$(stat -f '%u %Lp' "$path")" || fail "$path is missing" + [ "$got" = "0 $mode" ] || fail "$path is '$got' (uid mode), expected '0 $mode'" +done +[ "$(plutil -extract ProgramArguments.0 raw "$PLIST")" = "$PROGRAM" ] \ + || fail "the plist does not run $PROGRAM" +[ "$(plutil -extract UserName raw "$PLIST")" = "$(id -un)" ] \ + || fail "the plist does not run the service as the operator ($(id -un))" +cmp -s "$zoned_bin" "$PROGRAM" || fail "the installed minzoned differs from its source" +version="$("$PROGRAM" --protocol-version)" || fail "the installed minzoned does not run" +echo "channel protocol version $version" +grep -q "port $PORT" "$RESOLVER" || fail "$RESOLVER does not point at port $PORT" +echo "custody OK: root-owned program, plists and resolver file; service runs as $(id -un)" +echo "::endgroup::" + +# --- 4. The service is up ---------------------------------------------------- + +echo "::group::the service is up" +sudo launchctl print "system/$LABEL" >/dev/null || fail "launchd does not hold $LABEL" +for _ in $(seq 1 40); do + [ -S "$CHANNEL" ] && break + sleep 0.25 +done +[ -S "$CHANNEL" ] || fail "the channel socket $CHANNEL is missing" +binds="$(sudo lsof -nP -iUDP:"$PORT" | awk 'NR > 1 { print $9 }' | sort -u)" +[ "$binds" = "127.0.0.1:$PORT" ] || fail "UDP $PORT binds '$binds', expected only 127.0.0.1:$PORT" +expect_answer host.min.internal "NOERROR 127.0.0.1" +expect_answer nobody.min.internal "NXDOMAIN" +got="$(query example.com)" +[ "${got%% *}" = REFUSED ] || fail "an out-of-zone name answered '$got', expected REFUSED" +# The range job adds its aliases one ifconfig call at a time after load, +# so the count climbs for a while. +aliases=0 +for _ in $(seq 1 120); do + aliases="$(ifconfig lo0 | grep -c -- 'inet 127\.0\.64\.' || true)" + [ "$aliases" = 254 ] && break + sleep 0.5 +done +[ "$aliases" = 254 ] || fail "lo0 carries $aliases of 254 range aliases after 60 s" +dscacheutil -q host -a name host.min.internal | grep -q 'ip_address: 127.0.0.1' \ + || fail "the system resolver does not answer host.min.internal" +echo "::endgroup::" + +# --- 5. A node publishes ----------------------------------------------------- + +echo "::group::a node publishes a box" +python3 "$publisher" hold "$CHANNEL" "$NODE" "$BOX" "$version" "$work/address" >"$work/publisher.log" 2>&1 & +publisher_pid=$! +for _ in $(seq 1 40); do + [ -s "$work/address" ] && break + sleep 0.25 +done +[ -s "$work/address" ] || fail "the publisher never got an address" +address="$(cat "$work/address")" +case "$address" in 127.0.64.*) ;; *) fail "the allocated address $address is outside 127.0.64.0/24" ;; esac +expect_answer "$BOX.min.internal" "NOERROR $address" +dscacheutil -q host -a name "$BOX.min.internal" | grep -q "ip_address: $address" \ + || fail "the system resolver does not answer $BOX.min.internal" +echo "$BOX.min.internal -> $address" +echo "::endgroup::" + +echo "::group::root is refused" +# The log is the operator's file: the redirect stays outside sudo on purpose. +# shellcheck disable=SC2024 +if sudo python3 "$publisher" once "$CHANNEL" root-node intruder "$version" \ + >"$work/root.log" 2>&1; then + cat "$work/root.log" + fail "a root publisher was accepted" +fi +grep -q "is refused" "$work/root.log" || { cat "$work/root.log"; fail "root was not refused by the uid gate"; } +expect_answer intruder.min.internal "NXDOMAIN" +echo "::endgroup::" + +# --- 6. Restart -------------------------------------------------------------- + +echo "::group::the service survives a restart" +before="$(service_pid)" +[ -n "$before" ] || fail "the service has no pid" +sudo launchctl kickstart -k "system/$LABEL" || fail "kickstart -k failed" +after= +for _ in $(seq 1 40); do + after="$(service_pid)" + [ -n "$after" ] && [ "$after" != "$before" ] && break + sleep 0.25 +done +if [ -z "$after" ] || [ "$after" = "$before" ]; then + fail "the service pid did not change ($before -> $after)" +fi +expect_answer host.min.internal "NOERROR 127.0.0.1" +expect_answer "$BOX.min.internal" "NOERROR $(cat "$work/address")" +echo "restarted ($before -> $after); the node re-published" +echo "::endgroup::" + +echo "::group::a closed connection withdraws its rows" +stop_publisher +expect_answer "$BOX.min.internal" "NXDOMAIN" +echo "::endgroup::" + +# --- 7. Re-run --------------------------------------------------------------- + +echo "::group::the command re-runs clean" +sh -c "$cmd" || fail "re-running the install command exited non-zero" +expect_answer host.min.internal "NOERROR 127.0.0.1" +echo "::endgroup::" + +# --- 8. Teardown leaves nothing ---------------------------------------------- + +echo "::group::teardown leaves nothing" +remove_service +if sudo launchctl print "system/$LABEL" >/dev/null 2>&1; then fail "launchd still holds $LABEL"; fi +for path in "$PLIST" "$PROGRAM" "$CHANNEL" "$RANGE_PLIST" "$RANGE_PROGRAM" "$RESOLVER"; do + [ ! -e "$path" ] || fail "$path survived the teardown" +done +if sudo lsof -nP -iUDP:"$PORT" >/dev/null 2>&1; then fail "UDP $PORT is still bound"; fi +left="$(ifconfig lo0 | grep -c -- 'inet 127\.0\.64\.' || true)" +[ "$left" = 0 ] || fail "$left range aliases survived the teardown" +echo "::endgroup::" + +echo "minzoned macOS service proof OK" diff --git a/styles/config/vocabularies/Minimal/accept.txt b/styles/config/vocabularies/Minimal/accept.txt index a2bbcd3490..f83dd831bf 100644 --- a/styles/config/vocabularies/Minimal/accept.txt +++ b/styles/config/vocabularies/Minimal/accept.txt @@ -226,6 +226,7 @@ minimald minimald_rpc minirootfs minvmd +minzoned mip miri misconfigure