On Thu, Mar 11, 2021 at 06:05:04AM -0500, Viktor Dukhovni wrote:
So the question is why the lookup is failing. To that end compiling a tracing with "strace" the below C program should tell the story:
#include <sys/types.h> #include <grp.h> #include <errno.h> #include <stdio.h>
int main(int argc, char **argv) { struct group g, *p; char buf[1024]; int rc;
errno = 0; rc = getgrnam_r("nosuchgrouphere", &g, buf, sizeof(buf), &p); printf("%p: %m(%d)\n", p, errno); return (rc == 0 && p == NULL); }
To experiment with other group names and make sure that at least group "root" or similar works, a slightly extended version is: #include <sys/types.h> #include <grp.h> #include <errno.h> #include <stdio.h> int main(int argc, char **argv) { char buf[1024]; struct group g, *p; int rc; errno = 0; rc = getgrnam_r(argc > 1 ? argv[1] : "nosuchgrouphere", &g, buf, sizeof(buf), &p); printf("%s(%p) %m(%d)\n", p ? g.gr_name : NULL, p, errno); return (rc == 0 && p == NULL); } This gives (again Fedora 31) the expected results: $ make g cc g.c -o g $ ./g (null)((nil)) Success(0) $ ./g root root(0x7ffe6a6225d0) Success(0) -- Viktor.