Forward host timezone to guest shell - #19
Merged
Merged
Conversation
The guest defaulted to UTC because macOS hosts rarely set $TZ; the timezone lives in the /etc/localtime symlink instead. When $TZ is unset, resolve the host zone from /etc/localtime (with /etc/timezone as the Debian fallback) and inject it as TZ for guest execs. Deterministic mode still pins TZ=UTC.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
The lnx guest shell defaulted to UTC even when the host was in another timezone.
$TZwas already forwarded to guest execs when set, but macOS hosts rarely set it — the timezone lives in the/etc/localtimesymlink, not the environment.When
$TZis unset,forwarded_exec_envnow falls back to detecting the host zone: it resolves/etc/localtime(e.g.…/zoneinfo/America/New_York), with/etc/timezoneas a Debian fallback, and injects it asTZfor every guest exec including the login shell. Deterministic mode still pinsTZ=UTC.Test plan
zone_from_localtime_target_parses_zoneinfo_pathscovers the symlink-target parsing (passes viabun run test).lnx run -- sh -c 'echo TZ=$TZ; date'now printsTZ=America/New_York/EDT, where before the guest reported UTC.Notes