Read /etc/locale.conf when configuring the distro locale#40940
Open
i4M1k0SU wants to merge 1 commit into
Open
Conversation
ConfigUpdateLanguage only read /etc/default/locale to populate the $LANG environment variable. That path is used by Debian/Ubuntu, but systemd-based distributions (Fedora, Arch, openSUSE, ...) store the locale in /etc/locale.conf instead, so $LANG was never set on those distros. Check both locations and use the first one that exists. Both files share the same "LANG=" line format, so the existing parsing is reused unchanged. Fixes microsoft#13207
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates Linux init locale propagation so $LANG can be sourced from both Debian/Ubuntu-style /etc/default/locale and systemd-style /etc/locale.conf, improving correctness for systemd-based distributions.
Changes:
- Added
/etc/locale.confas an additional locale configuration path. - Updated
ConfigUpdateLanguageto try multiple locale file locations and use the first successfully opened file. - Expanded function comments to document the multiple supported locations.
Author
|
@microsoft-github-policy-service agree |
Member
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Member
|
@i4M1k0SU - this change looks good, I am not sure why the policy bot check isn't working... |
Author
|
@microsoft-github-policy-service agree |
Author
Thanks! I re-commented and the policy bot check went green now. |
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 of the Pull Request
initpopulates the distro's$LANGenvironment variable from/etc/default/locale, but that was the only path checked./etc/default/localeis the Debian/Ubuntu convention; systemd-based distributions (Fedora, Arch,
openSUSE, ...) store the locale in
/etc/locale.confinstead. On those distros$LANGwas never propagated from the distro's configuration.This change makes
ConfigUpdateLanguagecheck both locations and use the firstone that exists.
PR Checklist
/etc/default/locale, should fall back to/etc/locale.conf#13207Detailed Description of the Pull Request / Additional comments
LOCALE_CONF_FILE_PATH(/etc/locale.conf).ConfigUpdateLanguagenow tries/etc/default/localethen/etc/locale.conf,opening the first file that exists.
KEY=valueformat with aLANG=line, so the existingline-parsing logic is reused unchanged.
/etc/default/localetakes precedence when both files exist.ENOENT) is skipped silently; otherfopenerrors are stilllogged.
$LANGis left unchanged.Validation Steps Performed
inittarget (cross-compiled via the in-tree clang/LINUXSDKtoolchain) — compiles cleanly.
/etc/default/locale): existing behavior ispreserved —
$LANGis still propagated correctly./etc/locale.conf):$LANGis now correctlypropagated from the distro's locale configuration.