Skip to content

run: pass through TERMINFO and TERMINFO_DIRS environment variables - #4455

Open
Visio-Vanitas wants to merge 3 commits into
systemd:mainfrom
Visio-Vanitas:fix/run-terminfo-passthrough
Open

Visio-Vanitas wants to merge 3 commits into
systemd:mainfrom
Visio-Vanitas:fix/run-terminfo-passthrough

Conversation

@Visio-Vanitas

Copy link
Copy Markdown

Fixes #4448

Summary

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.

@Skyb0rg007

Copy link
Copy Markdown

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.

@Visio-Vanitas

Copy link
Copy Markdown
Author

Thanks for the review and suggestion.

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

run.py should pass through TERMINFO and TERMINFO_DIRS environment variables

2 participants