Pin apt child process locale in UpdatesCollector - #117
Merged
Conversation
apt list --upgradable localises its output via gettext. Collect built the child environment by appending to os.Environ(), so on any non-English locale (e.g. de_DE) apt prints "aktualisierbar von:" instead of "upgradable from:", the parser regex never matches, and Updates.Count silently reports 0 forever with no error or log warning. Build the child environment explicitly instead of inheriting the host's: set LC_ALL, LANG and LANGUAGE to force English/C output, and preserve PATH so the bare "apt" command name still resolves via exec.LookPath.
|
5 tasks
LarsLaskowski
added a commit
that referenced
this pull request
Aug 22, 2026
vcgencmdRunner.run() left cmd.Env nil, so vcgencmd inherited the full service environment, including PIMONITOR_API_KEY when it is configured via the environment as SECURITY.md recommends. That put the secret in vcgencmd's /proc/<pid>/environ for no reason, the same class of exposure the -api-key flag warning already exists to avoid. updates.go was already fixed for the same issue by #117, which built an explicit cmd.Env while pinning apt's locale. Apply the same approach to vcgencmd: since it is invoked by the absolute path resolved at detection time, it needs no PATH at all, so its child environment can be empty.
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.



📖 Description
UpdatesCollector.Collect(internal/collector/updates.go) shells out toapt list --upgradableand parses its output with an English-only regex. The child process environment was built by appendingDEBIAN_FRONTEND=noninteractivetoos.Environ(), so on any host running a non-English locale (e.g.de_DE.UTF-8),aptlocalises its output via gettext ([upgradable from: ...]becomes[aktualisierbar von: ...]), the parser regex never matches, andUpdates.Countsilently reports0forever — with no error, no log warning, and no visible symptom other than a dashboard that always looks fully up to date.This is a fix, not a feature: it builds the child environment explicitly instead of inheriting the operator's, forcing
LC_ALL=C,LANG=C, andLANGUAGE=so apt output is always in the English form the parser expects, while preservingPATHso the bare"apt"command still resolves viaexec.LookPath.🎫 Issues
Closes #100
👩💻 Reviewer Notes
The only functional change is the
cmd.Envassignment inUpdatesCollector.Collect.parseAptListUpgradableand thestrings.HasPrefix(line, "Listing...")skip are unchanged — they were already correct forLC_ALL=Coutput, they just never received it in a non-English environment.📑 Test Plan
Added
TestUpdatesCollector_Collect_PinsLocaletointernal/collector/updates_test.go, following the existingwriteFakeVcgencmdstub-binary pattern used elsewhere in this file (no realaptbinary or real locale data involved, perdocs/TESTS.md):aptPathat a small shell script that dumps its own environment (env > file) instead of a real apt binary.LC_ALL=C,LANG=C, and an emptyLANGUAGE.PATHis still present in the child environment — a regression guard, since buildingcmd.Envfrom scratch instead of appending toos.Environ()could otherwise silently dropPATHand break command resolution.Ran locally:
go build ./...go vet ./...go test ./... -race -cover— all packages pass,internal/collectorat 90.8% coveragegolangci-lint run— 0 issues✅ Checklist
General
go test ./... -race -coverpasses locally).go vet ./...andgolangci-lint runare clean.ARCHITECTURE.mdif this changes a documented design decision. (N/A — internal parsing detail, no documented design decision changes.)REST API / configuration / packaging
Not applicable — no REST API, configuration, or packaging changes.
⏭ Next Steps
None. As noted in the issue, a more robust long-term option (parsing
apt-get --just-print upgradeor reading dpkg/apt state directly) is a larger change and intentionally out of scope here.