Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -232,19 +232,25 @@ jobs:
rootless) net="$HOME/.config/brig/cni/net.d" ;;
*) net="$prefix/etc/cni/net.d" ;;
esac
# The bundle carries hull, so hull is the default; nerdctl is
# still one setting away.
got="$(launcher)"
[ "$got" = "nerdctl $prefix/bin/nerdctl $net" ] \
|| { echo "default launcher: got '$got'"; exit 1; }
got="$(launcher BRIG_RUNTIME=hull)"
[ "$got" = "hull $prefix/bin/hull $net" ] \
|| { echo "BRIG_RUNTIME=hull launcher: got '$got'"; exit 1; }
|| { echo "default launcher: got '$got'"; exit 1; }
got="$(launcher BRIG_RUNTIME=nerdctl)"
[ "$got" = "nerdctl $prefix/bin/nerdctl $net" ] \
|| { echo "BRIG_RUNTIME=nerdctl launcher: got '$got'"; exit 1; }
got="$(launcher BRIG_RUNTIME=hull BRIG_RUNTIME_BIN=/opt/hull NETCONFPATH=/opt/net)"
[ "$got" = "hull /opt/hull /opt/net" ] \
|| { echo "the launcher overrode the caller's values: got '$got'"; exit 1; }
# Sourced again after a switch of runtime, as a second eval of
# brig-ctl env does, the launcher drops the binary it set the first
# time and names the new runtime's.
# time and names the new runtime's, in both directions.
got="$(env -i HOME="$HOME" PATH=/usr/bin:/bin \
sh -c ". '$t/etc/brig-env.sh'; BRIG_RUNTIME=nerdctl; . '$t/etc/brig-env.sh'; echo \"\$BRIG_RUNTIME \$BRIG_RUNTIME_BIN\"")"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the test that sources the launcher twice now covers only a switch from hull to nerdctl. It previously tested nerdctl to hull, the case the binary reset was written for. Keep both directions.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right, that was the case the reset was written for. Both directions are back in f56ad86: hull to nerdctl, and nerdctl to hull.

[ "$got" = "nerdctl $prefix/bin/nerdctl" ] \
|| { echo "the launcher re-sourced for nerdctl kept hull: got '$got'"; exit 1; }
got="$(env -i HOME="$HOME" PATH=/usr/bin:/bin BRIG_RUNTIME=nerdctl \
sh -c ". '$t/etc/brig-env.sh'; BRIG_RUNTIME=hull; . '$t/etc/brig-env.sh'; echo \"\$BRIG_RUNTIME \$BRIG_RUNTIME_BIN\"")"
[ "$got" = "hull $prefix/bin/hull" ] \
|| { echo "the launcher re-sourced for hull kept nerdctl: got '$got'"; exit 1; }
Expand Down
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,32 +186,32 @@ $ curl -fsSL https://raw.githubusercontent.com/NOFireAI/brig-standalone-linux/ma
[docs/rootless.md](docs/rootless.md) has the detail, including the two things
that still need root once per host, and what a home install gives up.

### hull beside nerdctl
### hull and nerdctl

nerdctl is brig's runtime here. The bundle also carries hull, the runtime brig
drives on macOS, built for Linux: a containerd client that boots the same urunc,
monitors and guest assets. `BRIG_RUNTIME=hull` selects it, and the launcher then
points brig at the bundle's hull rather than its nerdctl:
hull is brig's runtime here, and needs the brig in the bundle to be v0.6.0 or
later: an older brig refuses the shipped profiles on hull. It is the runtime
brig drives on macOS, built for Linux: a containerd client that boots the same urunc, monitors and guest assets,
and puts each networked sandbox on a network gateway of its own, which enforces
the egress policy and serves routes and published ports. nerdctl stays in the
bundle, and `BRIG_RUNTIME=nerdctl` selects it, for instance for an image whose
`USER` is a name, which hull on Linux refuses:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let;s just also mention here that this requires brig v0.6.0 as the comment at scripts/build-bundle.sh:1101-1103

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done in f56ad86: the README says hull as the runtime needs the brig in the bundle to be v0.6.0 or later, and the launcher's comment says the same.


```console
$ BRIG_RUNTIME=hull brig doctor
$ BRIG_RUNTIME=nerdctl brig doctor
```

It needs a brig that drives hull on Linux, which the `v0.5.0` in this bundle
does not. Even then, hull on Linux boots a sandbox on the shared bridge or with
no network, and brig refuses what it cannot enforce there yet: an egress policy,
a route, `network: isolated` and a published port. The shipped agent profiles
ask for an isolated network, so they stay on nerdctl for now. Every value the
launcher sets still defers to the environment, so `BRIG_RUNTIME_BIN` points brig
at another hull.
A sandbox stays on the runtime that booted it, so one booted on nerdctl before
this release needs `BRIG_RUNTIME=nerdctl` until `brig rm` removes it. Every value
the launcher sets still defers to the environment, so `BRIG_RUNTIME_BIN` points
brig at another hull.

The launcher works out the binary each time it is sourced. A shell that has run
`eval "$(brig-ctl env)"` has the bundle's `bin/` first on its `PATH`, so `brig`
there is the binary itself and nothing sources the launcher again: set
`BRIG_RUNTIME` before the eval, or run the eval again after changing it.

```console
# export BRIG_RUNTIME=hull
# export BRIG_RUNTIME=nerdctl
# eval "$(/var/lib/brig/data/bin/brig-ctl env)"
```

Expand Down
12 changes: 9 additions & 3 deletions scripts/build-bundle.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1098,6 +1098,11 @@ fi
# a cross compile in a container of the build host's arch, not a --platform
# build. No TELEMETRY_ENDPOINT is passed, so this hull never sends telemetry.
HULL_INSTALLED=false
# The runtime brig drives when BRIG_RUNTIME names none: hull once the bundle
# carries it, since hull on Linux serves the policies, routes and published
# ports nerdctl does and publishes on a running sandbox too. That takes a brig
# of v0.6.0 or later; an older one refuses the shipped profiles on hull.
DEFAULT_RUNTIME=nerdctl
HULL_PINNED=""
if [ "$VARIANT" != "stock" ]; then
command -v docker >/dev/null 2>&1 || fatal "docker is required to build hull from $HULL_REPO"
Expand Down Expand Up @@ -1140,6 +1145,7 @@ if [ "$VARIANT" != "stock" ]; then
cp "$hsrc/dist/hull_linux_$ARCH" "$DL/hull" || fatal "the hull build left no dist/hull_linux_$ARCH"
chmod 0755 "$DL/hull"
HULL_INSTALLED=true
DEFAULT_RUNTIME=hull
info " built hull $HULL_REF"
fi

Expand Down Expand Up @@ -1531,15 +1537,15 @@ export CNI_PATH="\${CNI_PATH:-$CNI_DIR}"
# install prefixes, but reads the variable in preference, so the export keeps
# hull and nerdctl on one directory, an install at another prefix included.
#
# nerdctl is brig's runtime here, and BRIG_RUNTIME=hull opts in to the hull
# beside it. The binary follows the runtime: a BRIG_RUNTIME=hull handed the
# hull is brig's runtime here when the bundle carries it, and nerdctl
# otherwise; BRIG_RUNTIME names either one. The binary follows the runtime: a BRIG_RUNTIME=hull handed the
# nerdctl path would drive nerdctl with hull's command line. A runtime the
# bundle does not carry gets no binary, so brig looks for it on PATH or says
# it is missing. A BRIG_RUNTIME_BIN that names one of this bundle's runtimes
# came from this file, sourced before for whatever runtime was set then (an
# earlier eval of brig-ctl env), so it is worked out again. Any other value
# is the caller's and stands.
export BRIG_RUNTIME="\${BRIG_RUNTIME:-nerdctl}"
export BRIG_RUNTIME="\${BRIG_RUNTIME:-$DEFAULT_RUNTIME}"
case "\${BRIG_RUNTIME_BIN:-}" in
"$BIN_DIR/nerdctl"|"$BIN_DIR/hull") unset BRIG_RUNTIME_BIN ;;
esac
Expand Down