Go to main content

man pages section 3: Basic Library Functions

Exit Print View

Updated: Wednesday, July 27, 2022
 
 

getpw(3C)

Name

getpw - get passwd entry from UID

Synopsis

#include <stdlib.h>

int getpw(uid_t uid, char *buf);

Description

The getpw() function searches the local user database for a user id number that equals uid, copies the line of the password file in which uid was found into the array pointed to by buf, and returns 0. getpw() returns non-zero if uid cannot be found.

Usage

This function is included only for compatibility with legacy systems and should not be used; the functions described on the getpwnam(3C) manual page should be used instead.

This function does not search any network name services, nor does it use the caching provided by nscd(8).

There is no limit to the length of data which getpw() may write to the provided buffer, making it impossible to use this function without risk of buffer overflow.

Return Values

The getpw() function returns non-zero on error.

Attributes

See attributes(7) for descriptions of the following attributes:

ATTRIBUTE TYPE
ATTRIBUTE VALUE
Interface Stability
Obsolete
MT-Level
Safe

See Also

getpwnam(3C), passwd(5), attributes(7)

History

The getpw() function was first documented in Bell Labs Research UNIX Version 4 in 1973. It was documented as deprecated in Bell Labs Research UNIX Version 7 in 1979 when the replacement getpwuid() function was introduced.

The getpw() function has been included for compatibility but deprecated for use by new software in all versions of SunOS and Solaris.