How does getpwnam () work in linux?

how does getpwnam () work in linux?

recently I was studying linux programming and encountered a function getpwnam (). This function definition is defined in pwd.h as:

extern struct passwd *getpwnam (const char *__name);

then I started to find out where the function was implemented. I downloaded a GNU lib, and didn"t find the getpwnam, but found a file called getpwnam.c

.
-sharpinclude <pwd.h>


-sharpdefine LOOKUP_TYPE    struct passwd
-sharpdefine FUNCTION_NAME    getpwnam
-sharpdefine DATABASE_NAME    passwd
-sharpdefine ADD_PARAMS    const char *name
-sharpdefine ADD_VARIABLES    name
-sharpdefine BUFLEN        NSS_BUFLEN_PASSWD

-sharpinclude "../nss/getXXbyYY.c"

but no other implementation getpwnam, was found. Excuse me, where is this getpwnam implemented?

C
May.06,2021

if you open the file .. / nss/getXXbyYY.c , you will suddenly realize

or you can use gcc-E to preprocess getpwnam.c to see

Menu