[ Previous | Next | Contents | Glossary | Home | Search ]
AIX Version 4.3 Base Operating System and Extensions Technical Reference, Volume 2

setuserdb or enduserdb Subroutine

Purpose

Opens and closes the user database.

Library

Security Library (libc.a)

Syntax

#include <usersec.h>
int setuserdb (Mode)
int Mode;
int enduserdb ( )

Description

These functions may be used to open and close access to the user database. Programs that call either the getuserattr or getgroupattr subroutine should call the setuserdb subroutine to open the user database and the enduserdb subroutine to close the user database.

The setuserdb subroutine opens the user database in the specified mode, if it is not already open. The open count is increased by 1.

The enduserdb subroutine decreases the open count by 1 and closes the user database when this count goes to 0. Any uncommitted changed data is lost.

Note: These subroutines are not safe for use with multiple threads. To call one of these subroutines from a threaded application, enclose the call with the _libs_rmutex lock. See "Making a Subroutine Safe for Multiple Threads" in AIX Version 4.3 General Programming Concepts: Writing and Debugging Programs for more information about this lock.

Parameters

Mode Specifies the mode of the open. This parameter may contain one or more of the following values defined in the usersec.h file:
S_READ Specifies read access
S_WRITE Specifies update access.

Return Values

The setuserdb and enduserdb subroutines return a value of 0 to indicate success. Otherwise, a value of -1 is returned and the errno global variable is set to indicate the error.

Error Codes

The setuserdb subroutine fails if the following is true:

EACCES Access permission is denied for the data request.

Both subroutines return errors from other subroutines.

Security

Files Accessed: The calling process must have access to the user data. Depending on the actual attributes accessed, this may include:

Modes File
rw /etc/passwd
rw /etc/group
rw /etc/security/user
rw /etc/security/limits
rw /etc/security/group
rw /etc/security/environ

Implementation Specifics

These subroutines are part of Base Operating System (BOS) Runtime.

Related Information

The getgroupattr subroutine, getuserattr subroutine, getuserpw subroutine, setpwdb subroutine.

List of Security and Auditing Subroutines and Subroutines Overview in AIX Version 4.3 General Programming Concepts: Writing and Debugging Programs.


[ Previous | Next | Contents | Glossary | Home | Search ]