Accesses the user authentication data.
#include <userpw.h>
struct userpw *getuserpw ( User)
char *User;
int putuserpw ( Password)
struct userpw *Password;
int putuserpwhist ( Password, Message)
struct userpw *Password;
char **Message;
These subroutines may be used to access user authentication information. Because of their greater granularity and extensibility, you should use them instead of the getpwent routines.
The getuserpw subroutine reads the user's locally defined password information. If the setpwdb subroutine has not been called, the getuserpw subroutine will call it as setpwdb (S_READ). This can cause problems if the putuserpw subroutine is called later in the program.
The putuserpw subroutine updates or creates a locally defined password information stanza in the /etc/security/passwd file. The password entry created by the putuserpw subroutine is used only if there is an ! (exclamation point) in the /etc/passwd file's password field. The user application can use the putuserattr subroutine to add an ! to this field.
The putuserpw subroutine will open the authentication database read/write if no other access has taken place, but the program should call setpwdb (S_READ | S_WRITE) before calling the putuserpw subroutine.
The putuserpwhist subroutine updates or creates a locally defined password information stanza in the etc/security/passwd file. The subroutine also manages a database of previous passwords used for password reuse restriction checking. It is recommended to use the putuserpwhist subroutine, rather than the putuserpw subroutine, to ensure the password is added to the password history database.
Mode | File |
---|---|
rw | /etc/security/passwd |
If successful, the getuserpw subroutine returns a valid pointer to a pw structure. Otherwise, a null pointer is returned and the errno global variable is set to indicate the error.
If successful, the putuserpwhist subroutine returns a value of 0. If the subroutine failed to update or create a locally defined password information stanza in the /etc/security/ passwd file, the putuserpwhist subroutine returns a nonzero value. If the subroutine was unable to update the password history database, a message is returned in the Message parameter and a return code of 0 is returned.
If the getuserpw,
putuserpw, and putuserpwhist subroutines fail if one of the
following values is true:
ENOENT | The user does not have an entry in the /etc/security/passwd file. |
Subroutines invoked by the getuserpw, putuserpw, or putuserpwhist subroutines can also set errors.
These subroutines are part of Base Operating System (BOS) Runtime.
/etc/security/passwd | Contains user passwords. |
The getgroupattr (getgroupattr, IDtogroup, nextgroup, or putgroupattr Subroutine) subroutine, getuserattr, IDtouser, nextuser, or putuserattr (getuserattr, IDtouser, nextuser, or putuserattr Subroutine) subroutine, setpwdb or endpwdb subroutine, setuserdb subroutine.
List of Security and Auditing Subroutines and Subroutines, Example Programs, and Libraries in AIX 5L Version 5.1 General Programming Concepts: Writing and Debugging Programs.