eBPF-based security platform
testing/vm: name the runtime binary shirudo in the shell vm-ssh opens
John Fastabendc4b4ffe76356
diff --git a/.agents/skills/testing/SKILL.md b/.agents/skills/testing/SKILL.mdindex d2487dd5..984f0c4e 100644--- a/.agents/skills/testing/SKILL.md+++ b/.agents/skills/testing/SKILL.md@@ -238,7 +238,8 @@ make -C testing vm-clean VM_NAME=<name>Adding `VM_SSH_COMMAND='<command>'` to `vm-ssh` runs one command in theguest and returns. In the guest, `shirudo-runtime` is the runtime the-initrd verified; `shirudo-runtime status` shows an initialized target,+initrd verified, and `shirudo` an alias of it only in the shell `vm-ssh`+opens from a terminal; `shirudo-runtime status` shows an initialized target,and `. /etc/shirudo-test-vm.env` sets the environment a family rungives the target tests.The checkout is mounted read-only at `/workspace/shirudo`. Withoutdiff --git a/.github/scripts/check-guides.py b/.github/scripts/check-guides.pyindex ee2c0af3..15eca21e 100644--- a/.github/scripts/check-guides.py+++ b/.github/scripts/check-guides.py@@ -160,6 +160,9 @@ def run(steps):shell_command.append("VM_SSH_COMMAND=" + shlex.join(bash))shell_command.insert(1, "-s")guest = Shell(shell_command)+ # make vm-ssh sets this alias in a terminal's shell only.+ if guest.run("alias shirudo=shirudo-runtime")[0]:+ raise RuntimeError("could not name the runtime binary")continueif mode == "guides":if guest.close(command):diff --git a/Documentation/contribute/code/develop-locally.rst b/Documentation/contribute/code/develop-locally.rstindex 0abf95f5..ea827cc1 100644--- a/Documentation/contribute/code/develop-locally.rst+++ b/Documentation/contribute/code/develop-locally.rst@@ -148,15 +148,9 @@ Boot the targetoperator$ make -C testing vm-ssh VM_NAME=dev-4. Make ``shirudo`` name the trusted binary in this shell:-- .. code-block:: console-- target# alias shirudo=shirudo-runtime-- ``shirudo-runtime`` runs the binary on the runtime image, the only- one the target lets read and change shirudo's state, see- :ref:`runtime-invocation`.+ In this shell ``shirudo`` is an alias of ``shirudo-runtime``, which+ runs the binary on the runtime image, the only one the target lets+ read and change shirudo's state, see :ref:`runtime-invocation`.Connect the target to the registry and the collector----------------------------------------------------diff --git a/Documentation/contribute/testing/testing.rst b/Documentation/contribute/testing/testing.rstindex 3f04b23b..49945025 100644--- a/Documentation/contribute/testing/testing.rst+++ b/Documentation/contribute/testing/testing.rst@@ -607,7 +607,10 @@ Boot an interactive VM# make -C testing vm-ssh VM_NAME=<name>Without ``VM_NAME``, ``vm-ssh`` connects to the most recently created- VM.+ VM. From a terminal, the shell it opens has ``shirudo`` as an alias+ of ``shirudo-runtime``; with ``VM_SSH_COMMAND`` or a script on its+ standard input it sets none, and the command names+ ``shirudo-runtime`` itself.3. Verify that the guest is an initialized target:diff --git a/Documentation/start/guides/attest-target.rst b/Documentation/start/guides/attest-target.rstindex 99385b79..ea14f260 100644--- a/Documentation/start/guides/attest-target.rst+++ b/Documentation/start/guides/attest-target.rst@@ -31,12 +31,14 @@ Before you begindirectory and ``PAYLOAD`` holding the payload digest of``basic.upatch``.- ``jq`` and the ``openssl`` command on the operator host.-- A root shell on the target (``make -C testing vm-ssh- VM_NAME=quickstart``) in which ``shirudo`` runs the runtime binary:+- A root shell on the target, in which ``shirudo`` runs the runtime+ binary:++ .. guide-check: skip.. code-block:: console- target# alias shirudo=shirudo-runtime+ operator$ make vm-ssh VM_NAME=quickstartTake the first evidence-----------------------diff --git a/Documentation/start/guides/first-upatch.rst b/Documentation/start/guides/first-upatch.rstindex d4f096d4..33669d3c 100644--- a/Documentation/start/guides/first-upatch.rst+++ b/Documentation/start/guides/first-upatch.rst@@ -20,12 +20,14 @@ Before you begin- The operator shell from the quickstart: in the root of your checkout,with ``shirudo`` and ``shirudo-build`` on ``PATH`` and ``KEYS`` namingthe test VM's key directory-- A root shell on the target (``make -C testing vm-ssh- VM_NAME=quickstart``) in which ``shirudo`` runs the runtime binary:+- A root shell on the target, in which ``shirudo`` runs the runtime+ binary:++ .. guide-check: skip.. code-block:: console- target# alias shirudo=shirudo-runtime+ operator$ make vm-ssh VM_NAME=quickstartWrite the program-----------------diff --git a/Documentation/start/guides/publish-package.rst b/Documentation/start/guides/publish-package.rstindex 0e6471fd..c3ff92e9 100644--- a/Documentation/start/guides/publish-package.rst+++ b/Documentation/start/guides/publish-package.rst@@ -27,12 +27,14 @@ Before you beginwith ``shirudo`` and ``shirudo-build`` on ``PATH`` and ``KEYS`` namingthe test VM's key directory- Docker on the operator host, for a local registry-- A root shell on the target (``make -C testing vm-ssh- VM_NAME=quickstart``) in which ``shirudo`` runs the runtime binary:+- A root shell on the target, in which ``shirudo`` runs the runtime+ binary:++ .. guide-check: skip.. code-block:: console- target# alias shirudo=shirudo-runtime+ operator$ make vm-ssh VM_NAME=quickstartStart a registry----------------diff --git a/Documentation/start/quickstart.rst b/Documentation/start/quickstart.rstindex f91f3f6e..8b213d3c 100644--- a/Documentation/start/quickstart.rst+++ b/Documentation/start/quickstart.rst@@ -153,25 +153,24 @@ Boot a test targetCommands with the ``target#`` prompt run in this shell.-3. Make ``shirudo`` name the trusted binary in this shell:+3. See that only the trusted binary reads shirudo's state:++ .. guide-check: fail Permission denied.. code-block:: console- target# alias shirudo=shirudo-runtime+ target# /usr/local/bin/shirudo status+ shirudo: image state: Permission deniedOn a target, the trusted ``shirudo`` is the binary on the runtime image,``/run/shirudo/runtime/usr/bin/shirudo``, and the test VM wraps it as``shirudo-runtime``. The LSM gives access to shirudo's state only totasks that executed that binary from the runtime image. The test VM- keeps an identical copy under ``/usr/local/bin``. That copy prints its- version, but every command that reads shirudo's state stops:-- .. guide-check: fail Permission denied-- .. code-block:: console-- target# /usr/local/bin/shirudo status- shirudo: image state: Permission denied+ keeps an identical copy under ``/usr/local/bin``, which prints its+ version and stops at every command that reads shirudo's state. In the+ shell ``make vm-ssh`` opens, ``shirudo`` is an alias of+ ``shirudo-runtime``; a shell you reach another way, such as the+ console, needs ``alias shirudo=shirudo-runtime`` first.4. Change to your checkout inside the guest:diff --git a/testing/vm/run.sh b/testing/vm/run.shindex e47ad565..104b0b61 100755--- a/testing/vm/run.sh+++ b/testing/vm/run.sh@@ -970,6 +970,13 @@ run_ssh()if [[ -n "$VM_SSH_COMMAND" ]]; thenexec ssh "${SSH_ARGS[@]}" [email protected] "$VM_SSH_COMMAND"fi+ # Only the runtime image's binary holds authority in the guest, so+ # the shell a person types in names that one shirudo. A script on+ # stdin gets the plain shell, where an alias would not expand.+ if [[ -t 0 ]]; then+ exec ssh -t "${SSH_ARGS[@]}" [email protected] \+ 'exec bash --rcfile <(cat ~/.bashrc 2>/dev/null; echo "alias shirudo=shirudo-runtime")'+ fiexec ssh "${SSH_ARGS[@]}" [email protected]}