typedef __gid_t | gid_t |
typedef __size_t | size_t |
IMPORT_C struct passwd * | getpwnam | ( | const char * | ) |
See also: getgrent()
Parameters | |
---|---|
Refer to getpwent() for the documentation |
IMPORT_C struct passwd * | getpwent | ( | void | ) |
Note: This description also covers the following functions - getpwnam() getpwnam_r() getpwuid() getpwuid_r() setpwent() endpwent()
#include <pwd.h> struct passwd { char *pw_name; /* user name */ char *pw_passwd; /* encrypted password */ uid_t pw_uid; /* user uid */ gid_t pw_gid; /* user gid */ time_t pw_change; /* password change time */ char *pw_class; /* user access class */ char *pw_gecos; /* Honeywell login info */ char *pw_dir; /* home directory */ char *pw_shell; /* default shell */ time_t pw_expire; /* account expiration */ int pw_fields; /* internal: fields filled in */ };
The functions getpwnam and getpwuid returns the default values for a single user system i.e., pw_name,pw_passwd,pw_uid and pw_gid set to root,NULL,0 and 0 respectively in case the input parameter uid/login is 0/ root else the error number is set and NULL is returned by the APIs.
The getpwent when called the first time by an application returns the pointer to a valid passwd structure,that of the simulated single-user group.Subsequent calls return NULL until setpwent is called
The functions getpwnam_r, and getpwuid_r are thread-safe versions of getpwnam, and getpwuid, respectively. The caller must provide storage for the results of the search in the pwd, buffer, bufsize, and result arguments. When these functions are successful, the pwd argument will be filled-in, and a pointer to that argument will be stored in result. If an entry is not found or an error occurs, result will be set to NULL.
The setpwent function sets the library such that subsequent getpwent call returns a filled passwd structure.
endpwent function sets up the library such that the subsequent getpwent call returns NULL.
See also: getgrent()
Bugs:
The functions getpwent, getpwnam, and getpwuid, leave their results in an internal static object and return a pointer to that object. Subsequent calls to the same function will modify the same object. The functions getpwent, endpwent, and setpwent are fairly useless in a networked environment and should be avoided, if possible.
See also: getgrent()
Parameters | |
---|---|
Refer to getpwent() for the documentation |
See also: getgrent()
Parameters | |
---|---|
Refer to getpwent() for the documentation |