fix: harden install.sh against inherited Python env leakage#20680
Merged
Conversation
7 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Salvages the install.sh portion of #20466 onto current main. PR #20466 bundled three unrelated changes under a misleading title; this PR is the install.sh piece alone. The UI padding changes will come in a separate PR.
Summary
Sanitize inherited
PYTHONPATH/PYTHONHOMEduring install, and replace thehermessymlink with a small launcher wrapper that clears them before exec. Prevents a fresh install from being silently overridden when the installer is run from a Python-driven session that hasPYTHONPATHset.Changes
scripts/install.sh: earlyunset PYTHONPATH/unset PYTHONHOME; replaceln -sfshim with a tiny bash wrapper that unsets both beforeexec "$HERMES_BIN" "\$@".tests/test_install_sh_pythonpath_sanitization.py: grep-style regression tests covering install-time unset + wrapper contents.Validation
bash -n scripts/install.sh— OKscripts/run_tests.sh tests/test_install_sh_pythonpath_sanitization.py— 2/2 passPYTHONPATH=/stale+PYTHONHOME=/fakeset; fake HERMES_BIN saw both as unset and args were forwarded verbatim.Notes
hermes doctoralready tolerates a non-symlink at the command-link path (line 854 treats it as "exists (non-symlink)"), so the switch from symlink to wrapper doesn't break the existing doctor check.hermes doctor --fixonly re-creates symlinks, so a stale wrapper pointing to a moved venv wouldn't self-heal — same failure mode as a stale symlink, different error text. Not addressed here.Credits @adybag14-cyber — cherry-picked onto current main with authorship preserved.
Closes part of #20466.