1. the UNIX system password file contains the fields shown in the passwd struct defined in <PWD. h>.
POSIX defines two functions for getting password file items. After the user login name or user ID is given. The two functions can be used to view related items.
# Include <PWD. h>
Struct passwd * getpwuid (uid_t UID );
Struct passwd * getpwnam (const char * Name );
To view the entire password file, use the following three functions:
# Include <PWD. h>
Struct passwd * getpwent (void); // return the next record in the password file
Void setpwent (void); // locate the password file to the opening
Void endpwent (void); // close the password file. After opening the password file, remember to close the password file.
2. For the sake of security, many systems store encryption passwords in a place called Shadow passwords. The fields stored in the file are as follows:
Similar to a group of functions that access the password file, another group of functions can access the shadow password file.
# Include <shadow. h>
Struct spwd * getspnam (const char * Name );
Struct spwd * getspent (void );
Void setspent (void );
Void endspent (void );
3. group files
UNIX files contain the fields shown in. These fields are also included in the group structure defined in <GRP. h>.
POSIX defines the following two functions to find information about the user group based on the user name or user ID.
# Include <GRP. h>
Struct Group * getgrgid (gid_t GID );
Struct Group * getgrnam (const char * Name );
Similar to accessing a password file. To access the entire group file, you need to use the following three functions:
# Include <GRP. h>
Struct Group * getgrent (void );
Void setgrent (void );
Void endgrent (void );
System data files and information of Reading Notes in UNIX advanced programming (1)