pwd.h File Reference

Typedef gid_t

typedef __gid_t gid_t

_GID_T_DECLARED

Typedef time_t

typedef __time_t time_t

Used for time in seconds.

_TIME_T_DECLARED

Typedef uid_t

typedef __uid_t uid_t

Used for user IDs.

_UID_T_DECLARED

Typedef size_t

typedef __size_t size_t

_SIZE_T_DECLARED

_PATH_PWD

Defines to "//etc"

_PATH_PASSWD

Defines to "//etc//passwd"

_PASSWD

Defines to "passwd"

_PATH_MASTERPASSWD

Defines to "//etc//master.passwd"

_MASTERPASSWD

"master.passwd"

_PATH_MP_DB

Defines to "//etc//pwd.db"

_MP_DB

Defines to "pwd.db"

_PATH_SMP_DB

Defines to "//etc//spwd.db"

_SMP_DB

Defines to "spwd.db"

_PATH_PWD_MKDB

Defines to "//usr//sbin//pwd_mkdb"

_PW_VERSION_MASK

_PW_VERSIONED

_PW_KEYBYNAME

_PW_KEYBYNUM

_PW_KEYBYUID

_PW_KEYYPENABLED

_PW_KEYYPBYNUM

_PWD_VERSION_KEY

_PWD_CURRENT_VERSION

_PASSWORD_EFMT1

_PASSWORD_LEN

max length, not counting NULL

_PWF

_PWF_NAME

_PWF_PASSWD

_PWF_UID

_PWF_GID

_PWF_CHANGE

_PWF_CLASS

_PWF_GECOS

_PWF_DIR

_PWF_SHELL

_PWF_EXPIRE

_PWF_SOURCE

_PWF_FILES

_PWF_NIS

_PWF_HESIOD

getpwnam ( const char * )

IMPORT_C struct passwd *getpwnam(const char *)

See also: getgrent()

Parameters
Refer to getpwent() for the documentation

getpwuid ( uid_t )

IMPORT_C struct passwd *getpwuid(uid_t)

See also: getgrent()

Parameters
Refer to getpwent() for the documentation

endpwent ( void )

IMPORT_C voidendpwent(void)

Refer to getpwent() for the documentation

See also: getgrent()

getpwent ( void )

IMPORT_C struct passwd *getpwent(void)

Note: This description also covers the following functions - getpwnam() getpwnam_r() getpwuid() getpwuid_r() setpwent() endpwent()

These APIs belongs to set which are only build supported and not available functionally. The reason why only build support is extended to these APIs is that Symbian operating system does not support the creation of multiple users and groups in its environment. Moreover it may not make sense to have multiple users and groups in the context of a mobile environment. We refer to the structure
#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.

Return Value
The functions getpwent, getpwnam, and getpwuid return a valid pointer to a passwd structure on success or NULL if the entry is not found or if an error occurs. If an error does occur, errno will be set. The functions getpwnam_r, and getpwuid_r return 0 if no error occurred, or an error number to indicate failure. It is not an error if a matching entry is not found. (Thus, if result is NULL and the return value is 0, no matching entry exists.) The endpwent and setpwent functions have no return value.

setpwent ( void )

IMPORT_C voidsetpwent(void)

Refer to getpwent() for the documentation

See also: getgrent()

getpwnam_r ( const char *, struct passwd *, char *, size_t, struct passwd ** )

IMPORT_C intgetpwnam_r(const char *,
struct passwd *,
char *,
size_t,
struct passwd **
)

See also: getgrent()

Parameters
Refer to getpwent() for the documentation

getpwuid_r ( uid_t, struct passwd *, char *, size_t, struct passwd ** )

IMPORT_C intgetpwuid_r(uid_t,
struct passwd *,
char *,
size_t,
struct passwd **
)

See also: getgrent()

Parameters
Refer to getpwent() for the documentation