Bug 15509 - getgrgid() behavior differs from glibc when GID is not found
Summary: getgrgid() behavior differs from glibc when GID is not found
Status: NEW
Alias: None
Product: cwrap
Classification: Unclassified
Component: library (show other bugs)
Version: unspecified
Hardware: All All
: P5 normal
Target Milestone: ---
Assignee: Andreas Schneider
QA Contact:
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-11-01 20:50 UTC by Burt Holzman
Modified: 2023-11-03 12:31 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Burt Holzman 2023-11-01 20:50:48 UTC
getgrgid() differs from glibc when a GID is not found.
glibc does not set errno, while the nss_wrapper library sets errno to ENOENT.
FWIW, I've also checked musl, which also did not set errno.

Demonstrator:

#include <stdio.h>
#include <sys/types.h>
#include <grp.h>
#include <errno.h>

int main() {
  gid_t target_gid = 65530;
  if (getgrgid(target_gid) == NULL) { printf("No GID found, errno: %d\n", errno); }
}

$ ./test_getgrgid 
No GID found, errno: 0

$ LD_PRELOAD=/usr/lib64/libnss_wrapper.so NSS_WRAPPER_PASSWD=/etc/passwd NSS_WRAPPER_GROUP=/etc/group  ./test_getgrgid
No GID found, errno: 2