Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 952840 - lib/portage/output.py: xtermTitleReset(): assumes HOSTNAME environment variable is present
Summary: lib/portage/output.py: xtermTitleReset(): assumes HOSTNAME environment variab...
Status: UNCONFIRMED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Core (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Portage team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-03-28 15:46 UTC by Aaron Jones
Modified: 2025-03-28 15:52 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
When HOSTNAME is missing from the environment (WpX1HqQ.jpeg,46.77 KB, image/jpeg)
2025-03-28 15:47 UTC, Aaron Jones
Details
When HOSTNAME is manually added to /etc/env.d/ (Wbmhcb9.jpeg,47.95 KB, image/jpeg)
2025-03-28 15:47 UTC, Aaron Jones
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Aaron Jones 2025-03-28 15:46:17 UTC
Portage assumes that the HOSTNAME environment variable is present [1], and uses it as part of resetting an xterm window title. This results in nonsense when it is not, as on my systems; it appears as "root@:/your/cwd".

This manifests most obviously during the end of depclean (immediately before returning to the shell) and, based upon reading the source code callers, would manifest during any emerge operation.

I suggest reading /etc/hostname or /proc/sys/kernel/hostname or something instead. Alternatively, have Portage set the HOSTNAME environment variable in its own process when it is started, based on the contents of one of those, if it is missing.

[1] https://gitweb.gentoo.org/proj/portage.git/tree/lib/portage/output.py#n340
Comment 1 Aaron Jones 2025-03-28 15:47:03 UTC
Created attachment 923183 [details]
When HOSTNAME is missing from the environment
Comment 2 Aaron Jones 2025-03-28 15:47:26 UTC
Created attachment 923184 [details]
When HOSTNAME is manually added to /etc/env.d/
Comment 3 Aaron Jones 2025-03-28 15:52:07 UTC
gethostname(2) is another possibility, if there is a Python binding for that.