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

use linux command id to lookup user/group ids #2851

Open
reubenmiller opened this issue May 2, 2024 · 0 comments
Open

use linux command id to lookup user/group ids #2851

reubenmiller opened this issue May 2, 2024 · 0 comments
Labels
improvement User value

Comments

@reubenmiller
Copy link
Contributor

reubenmiller commented May 2, 2024

Is your feature improvement request related to a problem? Please describe.

Looking up users using the current uzers crate fails when thin-edge.io is built using MUSL (instead of libc). MUSL builds do not use the NSS (Name Service Switch)

The lack of support for NSS results in some false negatives when looking up the linux user and/or group when creating files/folders which specific permissions.

Most notably, the installation fails in Fedora IoT as the OS makes use of an immutable file systems, but during installation of an RPM package, it creates a temporary passwd file in a temporary location to add the new users, resulting in thin-edge.io failing to lookup the mosquitto user if mosquitto is also being installed in the same installation transaction (see #2042 for more details).

Describe the solution you'd like

Use the binary id to check if a user/group exists, and to do a named lookup to either retrieve the user id or the group id by name. id is NSS enabled, so the lookups work correctly.

Lookup uid by name

id -u <USERNAME>

Lookup gid by name

id -g <USERNAME>

Describe alternatives you've considered

Switching back from MUSL to libc builds should also "fix" the issue, however this is not preferred as libc builds are still hard to manage as it would involve building individual binaries per OS target (e.g. Alpine requires musl builds, and other OS's not), and OS which generally use libc also require a specific version of libc which is difficult to control during the build process (as Rust does not provide an easy-to-use setting to control which version of libc the build should be linked again)

Additional context

There is a similar ticket which is also affected by the lack of NSS support in MUSL builds which results in mdns names not being resolvable: #2803 (comment)

And the discussion about the lack of NSS support for user/group lookups by the uzers crate.

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

No branches or pull requests

1 participant