Skip to content

fix: fall back to getent for users that are not findable in /etc/passwd (backport #183 to 1.5)#213

Merged
tonyandrewmeyer merged 1 commit into
canonical:1.5-maintenancefrom
tonyandrewmeyer:backport/1.5/getent-fallback
Jun 17, 2026
Merged

fix: fall back to getent for users that are not findable in /etc/passwd (backport #183 to 1.5)#213
tonyandrewmeyer merged 1 commit into
canonical:1.5-maintenancefrom
tonyandrewmeyer:backport/1.5/getent-fallback

Conversation

@tonyandrewmeyer

@tonyandrewmeyer tonyandrewmeyer commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Backport of #183 to the 1.5-maintenance line.

Clean cherry-pick of 5b915d8; tests pass (including the new internal/system/util_test.go).

…wd (canonical#183)

The go `User.Lookup` method on Unix-like systems without ego [just looks
in the /etc/password
file](https://github.com/golang/go/blob/master/src/os/user/lookup_unix.go#L218)
(whereas cgo [does a getpwnam check via
libc](https://github.com/golang/go/blob/master/src/os/user/cgo_lookup_unix.go#L22)).
On some systems, like the Canonical laptops, the user that is trying to
run Concierge may not be in `/etc/passwd` and be loaded from a directory
service instead.

This PR adds a fallback system where we will run the
[getent](https://manpages.ubuntu.com/manpages/noble/en/man1/getent.1.html)
binary. That comes from the `libc-bin` package in Ubuntu, so is very
likely to be available (and the worst case is that it's not and we'll
fail just as we did before).

Fixes canonical#182

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
(cherry picked from commit 5b915d8)

@james-garner-canonical james-garner-canonical left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another clean backport, and familiar context (supporting NSS-managed systems).

@tonyandrewmeyer
tonyandrewmeyer merged commit 35d08ab into canonical:1.5-maintenance Jun 17, 2026
2 checks passed
@tonyandrewmeyer
tonyandrewmeyer deleted the backport/1.5/getent-fallback branch June 17, 2026 23:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants