Skip to content

Add only the chosen locale instead of rebuilding them all - #16414

Merged
ryanrhughes merged 7 commits into
quattrofrom
fix/issue-16244
Nov 1, 2026
Merged

ryanrhughes merged 7 commits into
quattrofrom
fix/issue-16244

Conversation

@omarchybot

@omarchybot omarchybot commented Oct 23, 2026 •

Copy link
Copy Markdown
Collaborator

omarchy language <code> generates the language's locale through bin/omarchy-locale-generate, which ran locale-gen "$locale". Arch's locale-gen ignores its argument: it deletes /usr/lib/locale/locale-archive, rebuilds every entry in /etc/locale.gen, and swallows each localedef failure with || :. On a nearly full disk the rebuild runs out of room part way, so locales the machine already had disappear, the helper still exits 0, and omarchy-language switches to a locale that was never built. Because the helper runs through the passwordless sudoers rule, a pick from Setup > Language is enough to trigger it. Any locale someone generated by hand without listing it in locale.gen was also lost on every language change, full disk or not.

The helper now adds only the chosen locale with localedef, with the same flags locale-gen uses, and leaves the rest of the archive alone. It picks the locale source the way locale-gen does, so a definition under /usr/local/share/i18n/locales still wins over the packaged one. It then checks localedef --list-archive for the locale rather than trusting the exit status: localedef exits 1 both for warnings and when it could not add the locale to a full archive ("cannot add to locale archive"), so the status alone can't tell success from failure. When the locale is missing the helper fails, and omarchy-language leaves the language as it was.

On an Omarchy worker with da_DK, en_US, fr_FR and ja_JP generated and 0–256 KB free under /usr/lib/locale, omarchy-locale-generate de on quattro exited 0 and dropped ja_JP. With this change it exits 1 and all four stay. The tests stub localedef instead of locale-gen, cover a locale.gen entry written without its codeset (hi_IN UTF-8), and cover a locale that localedef did not add while exiting 1, 4 or 135.

Reviewed by Codex at medium effort and by muse-spark-1.3 via pi at high thinking. Neither left anything open.

Fixes #16244

locale-gen ignores its argument: it deletes /usr/lib/locale/locale-archive and rebuilds every locale.gen entry, ignoring each localedef failure. On a nearly full disk that drops locales the machine already had and still exits 0, so omarchy language switched to a locale that was never built. localedef now adds just this one, honouring a /usr/local source override as locale-gen does, and the helper asks the archive whether it landed, because localedef exits 1 both for warnings and for a locale it could not add.

Co-Authored-By: Codex Medium <noreply@openai.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@greptile-apps

greptile-apps Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable issues remain.

Summary

Replaces the archive-wide locale-gen rebuild with a localedef call for only the chosen locale.

  • Language changes add one locale without rebuilding the archive.

No new actionable issues found. Both previous unnumbered findings are addressed. Tests were not run.

Reviews (5) · Last reviewed commit: "Run the checkout's locale helper in the ..." · Reviewed by Greptile

Comment thread test/shell.d/locale-sudoers-test.sh Resolved
@omarchybot omarchybot added the bug Something isn't working label Oct 23, 2026
omarchybot and others added 2 commits October 23, 2026 17:46
…t reason

The helper looks for a source under /usr/local/share/i18n/locales on whatever machine runs the test, so the exact `-i sv_SE` and `-i hi_IN` assertions failed on a host with an override there although the helper chose correctly. They now accept the override path as well as the packaged name.

The failure-path cases only checked the exit status, so a helper that refused `da` before ever calling localedef passed them. Each case now also checks localedef was asked for da_DK.UTF-8.

Co-Authored-By: Codex Medium <noreply@openai.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
localedef reads a bare-named source like sv_SE from the working directory before its installed locales, and sudo keeps the caller's directory. Through the passwordless rule, any process running as the user could plant a sv_SE there and have root compile it into the system locale archive, which the rule's own comment says it cannot do. The helper now changes to / once it holds root, beside the PATH pin that guards against the same kind of input.

Co-Authored-By: Codex Medium <noreply@openai.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment thread test/shell.d/locale-sudoers-test.sh Resolved
@omarchybot omarchybot added the verified Omarchy Triage has verified that this issue is ready for final review label Oct 23, 2026
It only checked that the line was there, which the house rules say not to test. The unprivileged suite cannot run the helper as root, so the cwd hardening is shown on a worker instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@omarchybot omarchybot added verified Omarchy Triage has verified that this issue is ready for final review ready Good to merge and removed verified Omarchy Triage has verified that this issue is ready for final review labels Oct 23, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator Author

Reviewed at 5fa4070 against quattro 967bbdd, on a disposable Omarchy worker. The fix holds, and I pushed two commits to it.

Reproduction. I put a tmpfs over /usr/lib/locale holding an archive with da_DK, en_US, fr_FR and ja_JP, then ran omarchy-locale-generate de as root. With 0–256 KB free, quattro's helper exits 0 and drops ja_JP. This head exits 1 and keeps all four. The same happens with this head's tests and only the helper reverted. With room to spare, quattro still drops every locale that isn't listed in locale.gen, and this head keeps them. ./test/cli and the locale shell tests (i18n, locale-setup, locale-sudoers, install-language, epochrealtime-locale) pass with this helper installed at /usr/bin.

Pushed:

  • 484f65f: when it holds root, the helper now runs cd / first. localedef -i sv_SE reads a file named sv_SE from the working directory before the packaged sources, and sudo keeps the caller's directory. On the worker, running sudo -n /usr/bin/omarchy-locale-generate sv from a directory holding a planted sv_SE compiled the planted file into the system archive through the passwordless rule. With cd /, it compiles the packaged one. locale-gen had the same exposure, and this change replaces the line that carried it.
  • f16fa8e: two fixes in locale-sudoers-test.sh. The -i assertions now accept a /usr/local/share/i18n/locales override path, so a host with such an override no longer fails a correct helper (Greptile's P2). The failure cases now also check that localedef was asked for da_DK.UTF-8, so a helper that refused early can't pass them. On the worker, each old assertion passed or failed the wrong way under its mutation, and each new one catches it.

Nothing is left for the author. The description doesn't yet mention the cd / change; the commit message explains it.

Second opinion: Codex at medium effort and muse-spark-1.3 via pi at high thinking, over three rounds.

  • Codex raised both test weaknesses and the working-directory lookup. Its last two rounds came back clean.
  • muse-spark claimed the extended patterns need shopt -s extglob. They match with extglob off on bash 5.3, so that claim doesn't hold.
  • muse-spark also wants a test that greps the helper for its own cd /. I left it out: the base branch's AGENTS.md rules out grepping the source for a line just added, and an unprivileged test can't exercise the root path. That is the maintainer's call.

Both reviewers can read this session's work, so their agreement isn't independent.

This waits on the maintainer. Once it lands it conflicts textually with #16275 and #16320, which edit the comment above the registry lookup in the same helper.

@omarchybot omarchybot removed ready Good to merge verified Omarchy Triage has verified that this issue is ready for final review labels Oct 27, 2026
ryanrhughes and others added 3 commits November 1, 2026 01:37
quattro moved the sudoers rule and root PATH checks from locale-sudoers-test.sh into sudoers-test.sh. Keep that split and this branch's localedef fixtures.
The locale helper no longer calls locale-gen, so poison the tool it does call and say what the sv probe now fails to write.
omarchy-language asks sudo or pkexec for /usr/bin/omarchy-locale-generate, so wherever Omarchy is installed the test exercised the packaged helper. An older one called the real locale-gen, which the test no longer stubs, and failed. The elevation stubs now run this checkout's copy.

Co-Authored-By: Codex gpt-6.1-sol <noreply@openai.com>
@ryanrhughes
ryanrhughes merged commit 9e0b5e2 into quattro Nov 1, 2026
2 of 4 checks passed
ryanrhughes added a commit that referenced this pull request Nov 1, 2026
* Add only the chosen locale instead of rebuilding them all

locale-gen ignores its argument: it deletes /usr/lib/locale/locale-archive and rebuilds every locale.gen entry, ignoring each localedef failure. On a nearly full disk that drops locales the machine already had and still exits 0, so omarchy language switched to a locale that was never built. localedef now adds just this one, honouring a /usr/local source override as locale-gen does, and the helper asks the archive whether it landed, because localedef exits 1 both for warnings and for a locale it could not add.

Co-Authored-By: Codex Medium <noreply@openai.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Make the locale-generate tests hold on any host and fail for the right reason

The helper looks for a source under /usr/local/share/i18n/locales on whatever machine runs the test, so the exact `-i sv_SE` and `-i hi_IN` assertions failed on a host with an override there although the helper chose correctly. They now accept the override path as well as the packaged name.

The failure-path cases only checked the exit status, so a helper that refused `da` before ever calling localedef passed them. Each case now also checks localedef was asked for da_DK.UTF-8.

Co-Authored-By: Codex Medium <noreply@openai.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Leave the caller's directory before generating a locale as root

localedef reads a bare-named source like sv_SE from the working directory before its installed locales, and sudo keeps the caller's directory. Through the passwordless rule, any process running as the user could plant a sv_SE there and have root compile it into the system locale archive, which the rule's own comment says it cannot do. The helper now changes to / once it holds root, beside the PATH pin that guards against the same kind of input.

Co-Authored-By: Codex Medium <noreply@openai.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Drop the test that greps the helper for its own cd

It only checked that the line was there, which the house rules say not to test. The unprivileged suite cannot run the helper as root, so the cwd hardening is shown on a worker instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Name localedef in the root PATH probe instead of locale-gen

The locale helper no longer calls locale-gen, so poison the tool it does call and say what the sv probe now fails to write.

* Run the checkout's locale helper in the language test

omarchy-language asks sudo or pkexec for /usr/bin/omarchy-locale-generate, so wherever Omarchy is installed the test exercised the packaged helper. An older one called the real locale-gen, which the test no longer stubs, and failed. The elevation stubs now run this checkout's copy.

Co-Authored-By: Codex gpt-6.1-sol <noreply@openai.com>

---------

Co-authored-by: Omarchybot <317366263+omarchybot@users.noreply.github.com>
Co-authored-by: Codex Medium <noreply@openai.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Ryan Hughes <ryan@heyoodle.com>
(cherry picked from commit 9e0b5e2)
@emirb emirb added this to the 4.5 milestone Nov 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

omarchy language <code> can wipe every system locale on a near-full disk (runs passwordless via sudoers)

3 participants