Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.
Python agent-orchestrationai-agentai-coding-assistantclaude-codecoding-agentcomputer-usedesktop-applocal-firstmcppersonal-jarvisvoice-assistantvoice-coding
fix(install): protect piped bootstrap from child stdin reads
rubenluetke10-beepa66170640503
diff --git a/.github/workflows/installer-smoke.yml b/.github/workflows/installer-smoke.ymlindex 441357e999..ce916391e8 100644--- a/.github/workflows/installer-smoke.yml+++ b/.github/workflows/installer-smoke.yml@@ -31,6 +31,7 @@ on:branches: [main]paths:- "install/**"+ - "tests/unit/install/test_install_sh_stage1.py"- "pyproject.toml"- "requirements.txt"- "jarvis/__main__.py"@@ -43,6 +44,7 @@ on:branches: [main]paths:- "install/**"+ - "tests/unit/install/test_install_sh_stage1.py"- "pyproject.toml"- "requirements.txt"- "jarvis/__main__.py"@@ -139,7 +141,7 @@ jobs:echo "----- changed files since $base -----"echo "$changed"echo "-------------------------------------"- if echo "$changed" | grep -qE '^(install/installer\.py|install/install\.sh|pyproject\.toml|requirements\.txt|jarvis/__main__\.py|jarvis/setup/prefetch\.py|jarvis/setup/model_report\.py|jarvis/speech/wake_model_fetch\.py|\.github/workflows/installer-smoke\.yml)$'; then+ if echo "$changed" | grep -qE '^(install/installer\.py|install/install\.sh|tests/unit/install/test_install_sh_stage1\.py|pyproject\.toml|requirements\.txt|jarvis/__main__\.py|jarvis/setup/prefetch\.py|jarvis/setup/model_report\.py|jarvis/speech/wake_model_fetch\.py|\.github/workflows/installer-smoke\.yml)$'; thenecho "run-fresh=true" >> "$GITHUB_OUTPUT"echo "fresh-install smoke RUNS."else@@ -179,6 +181,14 @@ jobs:with:python-version: "3.11"+ - name: Run the real Stage-1 Bash bootstrap through the Linux desktop step+ if: matrix.os == 'ubuntu-latest'+ shell: bash+ run: |+ set -euo pipefail+ bash -n install/install.sh+ python -m unittest discover -s tests/unit/install -p test_install_sh_stage1.py -v+- name: Run the REAL installer end-to-end (runner-appropriate profile)shell: bashrun: |diff --git a/install/install.sh b/install/install.shindex 963f0d7897..245b101bc8 100755--- a/install/install.sh+++ b/install/install.sh@@ -97,11 +97,11 @@ run_spin() {_spin_label="$1"; shiftif [ ! -t 1 ]; thennote "$_spin_label…"- "$@"+ "$@" </dev/nullreturn $?fi_spin_log=$(mktemp)- "$@" >"$_spin_log" 2>&1 &+ "$@" </dev/null >"$_spin_log" 2>&1 &_spin_pid=$!_spin_i=0while kill -0 "$_spin_pid" 2>/dev/null; do@@ -516,10 +516,12 @@ request_prerequisite_consent() {}run_privileged() {+ # `curl | bash` makes stdin the remaining installer source. Package managers+ # must not consume it, even when they claim to be noninteractive.if [ "$(id -u)" -eq 0 ]; then- "$@"+ "$@" </dev/nullelif command -v sudo >/dev/null 2>&1; then- sudo "$@"+ sudo "$@" </dev/nullelsenote 'Administrator access is required, but sudo is unavailable.'return 126@@ -537,7 +539,7 @@ install_with_prerequisite_manager() {_packages=()if [ "$_python_ready" -eq 0 ]; then _packages+=(python); fiif [ "$_git_ready" -eq 0 ]; then _packages+=(git); fi- if "$PREREQ_MANAGER_CMD" install "${_packages[@]}" >"$_log" 2>&1; then _result=0; fi+ if "$PREREQ_MANAGER_CMD" install "${_packages[@]}" </dev/null >"$_log" 2>&1; then _result=0; fi;;apt-get)_packages=()@@ -925,10 +927,10 @@ git_stream_pretty() {# the pipe preserves the git exit code via PIPESTATUS (this is bash).pretty_git() {if [ "$GIT_VERBOSITY" = '--progress' ]; then- "$@" 2>&1 | git_stream_pretty+ "$@" </dev/null 2>&1 | git_stream_prettyreturn "${PIPESTATUS[0]}"fi- "$@"+ "$@" </dev/null}clone_with_retry() {diff --git a/tests/unit/install/test_install_sh_stage1.py b/tests/unit/install/test_install_sh_stage1.pynew file mode 100644index 0000000000..3c8fdc0518--- /dev/null+++ b/tests/unit/install/test_install_sh_stage1.py@@ -0,0 +1,170 @@+"""Execute the public Bash bootstrap through the Linux desktop-tool step.++The regular installer smoke starts at installer.py and cannot catch a Stage-1+shell exit before clone. These cases run the real shell prefix with harmless+package-manager and Git stubs, then stop before any network or venv work.+"""++from __future__ import annotations++import os+import shutil+import subprocess+import sys+import tempfile+import unittest+from pathlib import Path++from jarvis.core.process_utils import NO_WINDOW_CREATIONFLAGS++INSTALL_SH = Path(__file__).resolve().parents[3] / "install" / "install.sh"+STOP_BEFORE_CLONE = 'if [ -d "$INSTALL_DIR/.git" ]; then'++[email protected](sys.platform.startswith("linux"), "Linux bootstrap proof")+class LinuxStage1BootstrapTests(unittest.TestCase):+ def _assert_helper_preserves_script_stream(self, definition: str, invocation: str) -> None:+ script = (+ "set -euo pipefail\n"+ + definition+ + "\ndrain() { cat >/dev/null; }\n"+ + invocation+ + "\nprintf 'SCRIPT_CONTINUED\\n'\n"+ )+ result = subprocess.run(+ [shutil.which("bash") or "bash", "-s"],+ input=script,+ capture_output=True,+ text=True,+ encoding="utf-8",+ creationflags=NO_WINDOW_CREATIONFLAGS,+ timeout=10,+ )+ self.assertEqual(result.returncode, 0, result.stderr + result.stdout)+ self.assertIn("SCRIPT_CONTINUED", result.stdout)++ def _run(+ self,+ *,+ headless: bool,+ display: bool,+ apt_succeeds: bool,+ apt_consumes_stdin: bool = False,+ pretend_unprivileged: bool = False,+ ) -> str:+ with tempfile.TemporaryDirectory() as tmp:+ root = Path(tmp)+ stubs = root / "bin"+ stubs.mkdir()+ git = stubs / "git"+ git.write_text(+ "#!/bin/sh\n"+ '[ "$1" = "--version" ] && { echo "git version 2.47.3"; exit 0; }\n'+ "exit 99\n",+ encoding="utf-8",+ )+ git.chmod(0o755)+ apt = stubs / "apt-get"+ apt.write_text(+ "#!/bin/sh\n"+ + ("cat >/dev/null\n" if apt_consumes_stdin else "")+ + f"exit {0 if apt_succeeds else 1}\n",+ encoding="utf-8",+ )+ apt.chmod(0o755)+ if pretend_unprivileged:+ user_id = stubs / "id"+ user_id.write_text('#!/bin/sh\nprintf "1000\\n"\n', encoding="utf-8")+ user_id.chmod(0o755)+ sudo = stubs / "sudo"+ sudo.write_text('#!/bin/sh\n"$@"\n', encoding="utf-8")+ sudo.chmod(0o755)++ source = INSTALL_SH.read_text(encoding="utf-8")+ self.assertIn(STOP_BEFORE_CLONE, source)+ bootstrap = source.split(STOP_BEFORE_CLONE, 1)[0]+ bootstrap += "\nprintf 'BOOTSTRAP_REACHED_FETCH\\n'\n"+ env = os.environ.copy()+ env.update(+ PATH=f"{stubs}{os.pathsep}{env['PATH']}",+ JARVIS_PYTHON=sys.executable,+ JARVIS_INSTALL_YES="1",+ JARVIS_INSTALL_PREREQS="auto",+ JARVIS_INSTALL_DIR=str(root / "install-target"),+ )+ if display:+ env["DISPLAY"] = ":99"+ else:+ env.pop("DISPLAY", None)+ env.pop("WAYLAND_DISPLAY", None)++ result = subprocess.run(+ [shutil.which("bash") or "bash", "-s", "--", *(["--headless"] if headless else [])],+ input=bootstrap,+ env=env,+ capture_output=True,+ text=True,+ encoding="utf-8",+ creationflags=NO_WINDOW_CREATIONFLAGS,+ timeout=30,+ )+ self.assertEqual(result.returncode, 0, result.stderr + result.stdout)+ self.assertIn("BOOTSTRAP_REACHED_FETCH", result.stdout)+ self.assertIn("2/6", result.stdout)+ return result.stdout++ def test_desktop_apt_success_continues_to_fetch(self) -> None:+ out = self._run(headless=False, display=True, apt_succeeds=True)+ self.assertIn("desktop automation tools installed", out)++ def test_desktop_apt_cannot_steal_the_piped_installer(self) -> None:+ out = self._run(+ headless=False,+ display=True,+ apt_succeeds=True,+ apt_consumes_stdin=True,+ )+ self.assertIn("desktop automation tools installed", out)++ def test_sudo_apt_cannot_steal_the_piped_installer(self) -> None:+ out = self._run(+ headless=False,+ display=True,+ apt_succeeds=True,+ apt_consumes_stdin=True,+ pretend_unprivileged=True,+ )+ self.assertIn("desktop automation tools installed", out)++ def test_desktop_apt_failure_still_continues_to_fetch(self) -> None:+ out = self._run(headless=False, display=True, apt_succeeds=False)+ self.assertIn("Some desktop tools could not be installed", out)++ def test_headless_skips_desktop_packages(self) -> None:+ out = self._run(headless=True, display=True, apt_succeeds=False)+ self.assertIn("Desktop automation tools skipped", out)++ def test_no_display_skips_desktop_packages(self) -> None:+ out = self._run(headless=False, display=False, apt_succeeds=False)+ self.assertIn("No graphical session detected", out)++ def test_spinner_child_cannot_steal_the_piped_installer(self) -> None:+ source = INSTALL_SH.read_text(encoding="utf-8")+ definition = "run_spin() {" + source.split("run_spin() {", 1)[1].split("# The mascot", 1)[0]+ self._assert_helper_preserves_script_stream(+ "note() { :; }\n" + definition, "run_spin 'test' drain\n"+ )++ def test_git_child_cannot_steal_the_piped_installer(self) -> None:+ source = INSTALL_SH.read_text(encoding="utf-8")+ definition = (+ "git_stream_pretty() {"+ + source.split("git_stream_pretty() {", 1)[1].split("clone_with_retry() {", 1)[0]+ )+ self._assert_helper_preserves_script_stream(+ "GIT_VERBOSITY='--quiet'\n" + definition, "pretty_git drain\n"+ )+++if __name__ == "__main__":+ unittest.main()