You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In this case, getent is resolving my user ID via the system libc function getpwuid(3). I suspect the problem is actually with the uzers-rs Rust library rather than your code, but I'm not yet sufficiently proficient in Rust to make that determination. That project claims to be a wrapper around the same libc library functions, so users.get_user_by_uidshould be a wrapper around getpwuid(3)/getpwuid_r(3) but obviously something is broken somewhere.
This is what I imagine the code in the library should be doing (in C and shamelessly ripped and rewritten from the manpage):
#include <pwd.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <sys/types.h>
int
main(int argc, char *argv[])
{
struct passwd pwd;
struct passwd *result;
char *buf;
size_t bufsize;
int s;
uid_t uid;
if (argc != 2) {
fprintf(stderr, "Usage: %s uid\n", argv[0]);
exit(EXIT_FAILURE);
}
bufsize = sysconf(_SC_GETPW_R_SIZE_MAX);
if (bufsize == -1) /* Value was indeterminate */
bufsize = 16384; /* Should be more than enough */
buf = malloc(bufsize);
if (buf == NULL) {
perror("malloc");
exit(EXIT_FAILURE);
}
uid = atoi(argv[1]);
s = getpwuid_r(uid, &pwd, buf, bufsize, &result);
if (result == NULL) {
if (s == 0)
printf("Not found\n");
else {
errno = s;
perror("getpwnam_r");
}
exit(EXIT_FAILURE);
}
printf("Name: %s; UID: %ld\n", pwd.pw_name, (long) pwd.pw_uid);
exit(EXIT_SUCCESS);
}
Update: Looking at line 342 in src/base.rs does suggest that users.get_user_by_uid() is a wrapper around getpwuid_r(), which is obviously just a Rust binding for the C function. Again, I'm not really proficient in Rust, but maybe someone with more skill in Rust could look at this.
I looked into this and the short answer is MUSL does not support sideloading the NSS plugins needed to retrieve things from SSSD.
Also, this is a duplicate of #541 therefore I'm going to close this one so we keep the discussion contained in the original issue. There I'm also going to go into more details about the uzers dependency.
Usernames are not being resolved if the user is not coming from
/etc/passwd
eza --long --header --icons
Example:
8126474 should in this case resolve to my username:
In this case,
getent
is resolving my user ID via the system libc functiongetpwuid(3)
. I suspect the problem is actually with the uzers-rs Rust library rather than your code, but I'm not yet sufficiently proficient in Rust to make that determination. That project claims to be a wrapper around the same libc library functions, sousers.get_user_by_uid
should be a wrapper aroundgetpwuid(3)
/getpwuid_r(3)
but obviously something is broken somewhere.This is what I imagine the code in the library should be doing (in C and shamelessly ripped and rewritten from the manpage):
The above code works on the same system:
The text was updated successfully, but these errors were encountered: