fix: explicitly allow preservation for TERMINFO in shell-integration

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

Signed-off-by: definfo <hjsdbb1@gmail.com>
pull/9891/head
definfo 2025-12-13 16:55:41 +08:00
parent 7a1ff7779b
commit 4a04efaff1
No known key found for this signature in database
GPG Key ID: B10632A45606B53F
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