Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
HP-UX Reference > U

userdb_read(3)

HP-UX 11i Version 3: February 2007
» 

Technical documentation

» Feedback
Content starts here

 » Table of Contents

 » Index

NAME

userdb_read(), userdb_write(), userdb_delete() — read, write or delete information in the user database, /var/adm/userdb

SYNOPSIS

#include <hpsecurity.h> int userdb_read(const char *name, const char * const attr[], char * const value[]); int userdb_write(const char *name, const char * const attr[], const char * const value[]); int userdb_delete(const char *name);

DESCRIPTION

These functions read, write, or delete information in the user database, /var/adm/userdb, which is described in userdb(4).

The name argument indicates a specific user entry in the user database. Attributes are accessed or modified only in this entry.

For element i of the two arrays, attr[i] is a pointer to the name of an attribute, and value[i] is a pointer to its value represented as text. The arrays attr and value are terminated by a null character.

userdb_read() reads the values of the attributes specified in the attr array from the user database into the corresponding value array. If an attribute is not present, a null string is copied into the value array. Each element (except for the terminating null) of the value array is a pointer to a buffer. The size of each buffer is assumed to be at least USERDB_MAX_ATTR_SIZE bytes, which is defined in <hpsecurity.h>.

userdb_write() writes the values of the attributes specified in the attr array from the corresponding value array into the database. For each null string in the value array, the corresponding attribute is deleted; the system-wide default described in /etc/default/security will then apply; see security(4). Attribute values are allowed to contain only printable ASCII characters (hex 20-7e).

The tab character (hex 09) may also be used for the following special cases for value:

\t+num or \t-num

Add or subtract num to or from the current attribute value. Both num and the current value are assumed to be a string of at most nine ASCII decimal digits. The current value may also have an optional sign, and is assumed to have a value of 0 if the attribute is not defined.

\t

No operation (do not modify the attribute).

userdb_delete() deletes a user entry from the database. The user entry contains all of the configurable and internal attributes for a user.

RETURN VALUE

Upon successful completion, 0 is returned.

ERRORS

If an error occurs, one of the following values is returned.

USERDB_USER_NOT_FOUND

could not find a database entry for the user specified in the name argument

USERDB_INVALID_ARG

invalid argument

USERDB_NOPERM

insufficient permission to access the user database

USERDB_IOERROR

a file system error occurred

USERDB_INVALID_ATTR

the value of one of the attr arguments is invalid

USERDB_INVALID_ATTR_VALUE

the value of one of the value arguments is invalid

USERDB_BLOCK_OVERFLOW

overflowed a database block

USERDB_ENTRY_OVERFLOW

overflowed the user entry

USERDB_LOCK_FAILURE

database lock failure

USERDB_DISABLED

the database is disabled; see userdb(4)

USERDB_INVALID_USERNAME

the name argument is not a valid username

USERDB_NOT_LOCAL_USER

the username specified by the name argument is not a local user in /etc/passwd

EXAMPLES

The following program segment writes values for two attributes into the user database for user joe, and then deletes a third attribute. It then reads and prints two attributes plus the attribute which it removed. Finally, it removes all of the attributes for user amy.

#include <hpsecurity.h> char p1[USERDB_MAX_ATTR_SIZE]; char p2[USERDB_MAX_ATTR_SIZE]; char p3[USERDB_MAX_ATTR_SIZE]; char *write_attrs[] = { "AUDIT_FLAG", "MIN_PASSWORD_LENGTH", "AUTH_MAXTRIES", 0 }; char *write_values[] = { "1", "7", "", 0 }; char *read_attrs[] = { "MIN_PASSWORD_LENGTH", "AUTH_MAXTRIES", "AUDIT_FLAG", 0 }; char *read_values[] = { p1, p2, p3, 0 }; if (userdb_write("joe", write_attrs, write_values)) exit(1); if (userdb_read("joe", read_attrs, read_values)) exit(2); printf ("p1=%s p2=%s p3=%s", p1, p2, p3); userdb_delete("amy");

After successful execution, the output is:

p1=7 p2= p3=1

FILES

/var/adm/userdb

user database

/etc/default/security

security defaults configuration file

/etc/security.dsc

security attributes description file

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© 1983-2007 Hewlett-Packard Development Company, L.P.