MentOS  0.8.0
The Mentoring Operating System
Functions
pwd.c File Reference

Functions

static void __parse_line (passwd_t *pwd, char *buf)
 Parses the input buffer and fills pwd with its details. More...
 
static char * __search_entry (int fd, char *buffer, int buflen, const char *name, uid_t uid)
 Searches for the given entry inside the buffer. More...
 
passwd_tgetpwnam (const char *name)
 Provides access to the password database entry for name. More...
 
passwd_tgetpwuid (uid_t uid)
 Provides access to the password database entry for uid. More...
 
int getpwnam_r (const char *name, passwd_t *pwd, char *buf, size_t buflen, passwd_t **result)
 Provides the same information as getpwnam but it stores the results inside pwd, and the string information are store store inside buf. More...
 
int getpwuid_r (uid_t uid, passwd_t *pwd, char *buf, size_t buflen, passwd_t **result)
 Provides the same information as getpwuid but it stores the results inside pwd, and the string information are store store inside buf. More...
 

Detailed Description

Function Documentation

◆ __parse_line()

static void __parse_line ( passwd_t pwd,
char *  buf 
)
inlinestatic

Parses the input buffer and fills pwd with its details.

Parameters
pwdthe structure we need to fill.
bufthe buffer from which we extract the information.

◆ __search_entry()

static char* __search_entry ( int  fd,
char *  buffer,
int  buflen,
const char *  name,
uid_t  uid 
)
inlinestatic

Searches for the given entry inside the buffer.

Parameters
fdthe file descriptor of the file.
bufferthe support buffer we use to read the file.
buflenthe length of the support buffer.
namethe username we are looking for.
uidthe user-id of the user we are looking for.
Returns
the buffer itself if we have found the entry, NULL otherwise.

◆ getpwnam()

passwd_t* getpwnam ( const char *  name)

Provides access to the password database entry for name.

Parameters
nameThe name to search inside the database.
Returns
A pointer to the structure containing the database entry.

◆ getpwnam_r()

int getpwnam_r ( const char *  name,
passwd_t pwd,
char *  buf,
size_t  buflen,
passwd_t **  result 
)

Provides the same information as getpwnam but it stores the results inside pwd, and the string information are store store inside buf.

Parameters
nameThe name to search inside the database.
pwdThe structure containing pointers to the entry fields.
bufThe buffer where the strings should be stored.
buflenThe lenght of the buffer.
resultA pointer to the result or NULL is stored here.
Returns
If the entry was found returns zero and set *result to pwd, if the entry was not found returns zero and set *result to NULL, on failure returns a number and sets and set *result to NULL.

◆ getpwuid()

passwd_t* getpwuid ( uid_t  uid)

Provides access to the password database entry for uid.

Parameters
uidThe uid to search inside the database.
Returns
A pointer to the structure containing the database entry.

◆ getpwuid_r()

int getpwuid_r ( uid_t  uid,
passwd_t pwd,
char *  buf,
size_t  buflen,
passwd_t **  result 
)

Provides the same information as getpwuid but it stores the results inside pwd, and the string information are store store inside buf.

Parameters
uidThe uid to search inside the database.
pwdThe structure containing pointers to the entry fields.
bufThe buffer where the strings should be stored.
buflenThe lenght of the buffer.
resultA pointer to the result or NULL is stored here.
Returns
If the entry was found returns zero and set *result to pwd, if the entry was not found returns zero and set *result to NULL, on failure returns a number and sets and set *result to NULL.