Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support extrausers support in libcontainer/user #2215

Open
anonymouse64 opened this issue Jan 20, 2020 · 2 comments
Open

Support extrausers support in libcontainer/user #2215

anonymouse64 opened this issue Jan 20, 2020 · 2 comments

Comments

@anonymouse64
Copy link

The libcontainer methods for reading users, etc. currently only reads from /etc/passwd and /etc/group, however on Ubuntu Core devices (also yocto sometimes) it is desirably to also read the /var/lib/extrausers/passwd and /var/lib/extrausers/group files as well (from the pam_extrausers package in Ubuntu), as the /etc/passwd and /etc/group files are read-only and so any new users are added to the extrausers files instead of the /etc/passwd and /etc/group files.

I'm not sure what the design for this would look like, but it would be nice if the API that returns a io.Reader for the User/Group files (such as GetPasswd and GetGroup) just "auto-magically" included the /var/lib/extrausers files at the end of the /etc/passwd files via io.MultiReader. The *Path methods probably would have to remain the same behavior for backwards compatibility, but perhaps new methods returning a list of strings could be used to return all of the files if they exist?

I would be willing to submit a PR changing GetPasswd and GetGroup to include the extrausers patch if folks think this is a reasonable thing to do.

@metux
Copy link
Contributor

metux commented May 25, 2021

Just use the standard libc pwent functions for that (which can be and indeed are configured via /etc/nsswitch.conf), instead of completely bypassing the standard OS functionality by manually reading certain files.

@cyphar
Copy link
Member

cyphar commented May 29, 2021

libcontainer/user is only intended for resolving usernames within a container, so unless Ubuntu Core containers (if those exist) have such a layout, then an internal runc library is not the best place to implement such a feature. If you're trying to do username parsing just use the Go stdlib os/user package (which uses pwent internally).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants