Repository navigation
fix(core): make the Linux icon lookup find icons, and read them defensively - #2289
aibizagility wants to merge 1 commit into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to No confirmed issue remains that needs resolution before merging. Pre-merge checks |
|
13e620a to
eacf3a3
Compare
…sively
On Linux, core found no icon for any binary (GetIconAndName always
returned nil), so every profile icon came from the UI's process-based
resolver. Two defects in binmeta:
- find_linux.go compared the full binary path (e.g. "/usr/bin/firefox")
against icon file stems ("firefox"), so nothing ever matched.
- LoadAndSaveIcon passed filepath.Ext(path) (".png") to UpdateProfileIcon,
which expects the extension without the dot ("png") and rejected it.
The lookup now compares the lower-cased base name of the binary against
file stems. An exact name match in any location wins over a prefix match
in any location; among prefix matches the shortest wins, earlier locations
first on ties. Directories named like a match are skipped, and the first
directory error is kept and reported only when nothing was found.
Core runs as root, so the locations and the read are deliberately
conservative:
- Only root-owned trees are searched: /usr/share/pixmaps, /usr/share,
/usr/local/share, /var/lib/flatpak/exports/share and /usr/share/<name>.
The per-user locations (~/.local/share, ~/.local/share/flatpak) are no
longer searched by core; the UI resolves those as the user.
- readIconFile opens without blocking (a FIFO cannot stall core), only
accepts a regular file on the open handle, reads at most 1 MB, and
requires the bytes to carry the signature of the format the extension
announces; for SVG the first XML element must be <svg>. The locations
are assumed administrator-controlled; ownership is not checked.
Effect: freshly created profiles on Linux now get a core-sourced icon
when the binary has one in the standard locations, instead of waiting
for the UI to guess from a running process. The only other caller of
LoadAndSaveIcon is the default icon of Windows service profiles
(service/process/tags/svchost_windows.go), which was failing the same
way and is repaired by the ".png" fix as well.
Tests: searchDirectory (exact, prefix, dotted names, case, directory
skip, missing vs broken directory), searchForIcon preference order and
first-error retention, readIconFile (signatures of all formats, SVG root
element, symlink to image and to non-image, size boundary, FIFO,
directory) and the LoadAndSaveIcon extension round trip.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
eacf3a3 to
2aa5ad7
Compare
Summary
On Linux, core produced no icons: the lookup compared absolute binary paths with icon file stems, so nothing matched, and a separate extension bug would have prevented importing a match. Two defects in
service/profile/binmeta:find_linux.gocompared the full binary path (/usr/bin/firefox) against icon file stems (firefox), so nothing matched.LoadAndSaveIconpassedfilepath.Ext(path)(.png) toUpdateProfileIcon, which expectspngand rejected it. The default icon of Windows service profiles (svchost_windows.go) goes through the same call and fails the same way.Change
hicolor/scalable. Exact name match in any location wins over a prefix match in any location; among prefix matches the shortest wins, earlier locations first on ties. Directories named like a match are skipped. The first directory error is reported only when nothing was found./usr/share/pixmaps,/usr/share,/usr/local/share,/var/lib/flatpak/exports/share,/usr/share/<name>. The per-user locations (~/.local/share,~/.local/share/flatpak) are no longer searched by core; the UI resolves those as the user.LoadAndSaveIconcallers now require a regular file, at most 1 MB, and a matching format signature; SVG is checked through its first XML element, which must be<svg>(strict decoder). Reads take one extra byte to detect growth; non-Windows opens are non-blocking so a FIFO cannot stall core. Symlinks are followed (flatpak exports are symlink farms); ownership is not checked.Effect
Linux profile creation can import a
Source: coreicon when a filename match passes validation; prefix matching remains a heuristic, so a binary without its own icon can still match another file by prefix. The extension fix also lets Windows service profiles import their default icon again.Tests
Verify with
go test -race ./service/profile/.... New tests coversearchDirectory(exact, prefix, dotted names, case, directory skip, missing vs broken directory),searchForIconpreference order and first-error retention,readIconFile(signatures of all formats, SVG root, symlink to image and to non-image, size boundary, FIFO, directory) and theLoadAndSaveIconextension round trip. Unit tests pass on Linux (Go 1.26). Verified on Linux Mint 22 with F3a, F4 and F5 applied to 2.2.3: newly created profiles for/usr/lib/chatgpt/ChatGPTand/usr/lib/claude-desktop/claude-desktopreceivedSource: coreicons; inspected profiles for binaries without matching system icons received no core icon.🤖 Generated with Claude Code & Codex under SCI collaboration
Summary by CodeRabbit