You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Pass through TERMINFO and TERMINFO_DIRS environment variables in mkosi/run.py subprocess spawning alongside SYSTEMD_LOG_LEVEL, SYSTEMD_LOG_LOCATION, and LD_LIBRARY_PATH.
Motivation
When using terminal emulators such as xterm-kitty that rely on non-standard terminfo definitions, commands and VMs spawned via run() would fail terminal capabilities detection (tput: unknown terminal "xterm-kitty") when exiting because TERMINFO / TERMINFO_DIRS were dropped from the sanitized subprocess environment.
Changes
In mkosi/run.py, added "TERMINFO" and "TERMINFO_DIRS" to the list of environment variables preserved from os.environ.
Added unit test in tests/test_run.py asserting that TERMINFO and TERMINFO_DIRS are properly passed through by run().
Validation
Verified with unit test regression in tests/test_run.py.
Another option is to only pass through the environment variables to the mkosi vm subcommand, since the error arises there due the fact that the subcommand calls tput; it could still be worth unsetting those variables in most other cases.
Looking closer at the execution path, tput is actually invoked from the finally: block in mkosi/__main__.py to restore cursor visibility (cnorm) and line wrapping (smam) on exit. The error surfaced after running interactive commands like mkosi vm because run() sanitized TERMINFO and TERMINFO_DIRS before executing those exit cleanup calls.
Rather than whitelisting these variables globally in run.py or passing them through mkosi vm, we narrowed the passthrough strictly to the tput invocations in mkosi/__main__.py. This fixes the tput: unknown terminal "xterm-kitty" failure on exit while ensuring terminal environment variables do not leak into build sandboxes or other subcommands.
This branch has not been deployed
No deployments
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
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.
Fixes #4448
Summary
Pass through
TERMINFOandTERMINFO_DIRSenvironment variables inmkosi/run.pysubprocess spawning alongsideSYSTEMD_LOG_LEVEL,SYSTEMD_LOG_LOCATION, andLD_LIBRARY_PATH.Motivation
When using terminal emulators such as
xterm-kittythat rely on non-standard terminfo definitions, commands and VMs spawned viarun()would fail terminal capabilities detection (tput: unknown terminal "xterm-kitty") when exiting becauseTERMINFO/TERMINFO_DIRSwere dropped from the sanitized subprocess environment.Changes
mkosi/run.py, added"TERMINFO"and"TERMINFO_DIRS"to the list of environment variables preserved fromos.environ.tests/test_run.pyasserting thatTERMINFOandTERMINFO_DIRSare properly passed through byrun().Validation
tests/test_run.py.