setauthdb or setauthdb_r Subroutine

Purpose

Defines the current administrative domain.

Library

Standard C Library (libc.a)

Syntax

#include <usersec.h>

int setauthdb (New, Old)
authdb_t *New;
authdb_t *Old;

int setauthdb_r (New, Old)
authdb_t *New;
authdb_t *Old;

Description

The setauthdb and setauthdb_r subroutines set the value of the current administrative domain in the New parameter. The setauthdb subroutine sets the value of the current process-wide administrative domain. The setauthdb_r subroutine sets the administrative domain for the current thread if one has been set. The subroutines return -1 if no administrative domain has been set. The current administrative domain is returned in the Old parameter. The Old parameter can be a null pointer if the value of the current administrative domain is not wanted.

The administrative domain determines which user and group information databases will be queried by the user and group library functions. The default behavior is to access all of the defined administrative domains. The setauthdb subroutine restricts the user and group library functions to the named administrative domains for all threads in the current process. The setauthdb_r subroutine restricts the user and group library functions to the named administrative domain for the current thread. The default behavior can be restored by using a null pointer for the value of the New parameter or an empty string for the value of the New parameter.

The string referenced by the New parameter must be the string files, compat or an administrative domain defined in the /usr/lib/security/methods.cfg file. The New and Old parameters are of type authdb_t. The authdb_t type is a 16-character array that contains the name of a loadable authentication module.

Note: The setauthdb subroutine affects all threads in the current process and can cause unintended results.

Parameters

Item Description
New Pointer to the name of the new database module. The New parameter must reference a value module name contained in the /usr/lib/security/methods.cfg file, or one of the predefined values (BUILTIN, compat, or files). The empty string can be used to remove the restriction on which modules are used.
Old Pointer to where the name of the current module will be stored. A NULL value for the Old parameter can be used if the current name of the database is not wanted.

Return Values

Item Description
0 The module search restriction has been successfully changed.
-1 The module search restriction could not be changed. The errno variable must be examined to determine the cause of the failure.

Error Codes

Item Description
EINVAL The new_auth_db parameter is longer than the permissible length of a stanza in the /usr/lib/security/methods.cfg file (15 characters).
ENOENT The new_auth_dbdoes not reference a valid stanza in /usr/lib/security/methods.cfg or one of the predefined values.