fix: explicitly allow preservation for TERMINFO in shell-integration (#9891)

Due to security issues, `sudo` implementations may not preserve
environment variables unless appended with `--preserve-env=list`.

Problem context: https://github.com/ghostty-org/ghostty/discussions/9861
pull/9898/head
Mitchell Hashimoto 2025-12-13 08:41:28 -08:00 committed by GitHub
commit 1805a9cb87
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 4 additions and 4 deletions

View File

@ -103,7 +103,7 @@ if [[ "$GHOSTTY_SHELL_FEATURES" == *"sudo"* && -n "$TERMINFO" ]]; then
if [[ "$sudo_has_sudoedit_flags" == "yes" ]]; then
builtin command sudo "$@";
else
builtin command sudo TERMINFO="$TERMINFO" "$@";
builtin command sudo --preserve-env=TERMINFO "$@";
fi
}
fi

View File

@ -97,7 +97,7 @@
if (not (has-value $arg =)) { break }
}
if (not $sudoedit) { set args = [ TERMINFO=$E:TERMINFO $@args ] }
if (not $sudoedit) { set args = [ --preserve-env=TERMINFO $@args ] }
(external sudo) $@args
}

View File

@ -90,7 +90,7 @@ function __ghostty_setup --on-event fish_prompt -d "Setup ghostty integration"
if test "$sudo_has_sudoedit_flags" = "yes"
command sudo $argv
else
command sudo TERMINFO="$TERMINFO" $argv
command sudo --preserve-env=TERMINFO $argv
end
end
end

View File

@ -255,7 +255,7 @@ _ghostty_deferred_init() {
if [[ "$sudo_has_sudoedit_flags" == "yes" ]]; then
builtin command sudo "$@";
else
builtin command sudo TERMINFO="$TERMINFO" "$@";
builtin command sudo --preserve-env=TERMINFO "$@";
fi
}
fi