2.2. Other functions provided by libpam

2.2.1. Strings describing PAM error codes

#include <security/pam_appl.h>
const char *pam_strerror(pamh,
pam_handle_t *pamh;
int errnum; DESCRIPTION

The pam_strerror function returns a pointer to a string describing the error code passed in the argument errnum, possibly using the LC_MESSAGES part of the current locale to select the appropriate language. This string must not be modified by the application. No library function will modify this string. RETURN VALUES

This function returns always a pointer to a string.

2.2.2. Request a delay on failure

#include <security/pam_appl.h>
int pam_fail_delay(pamh,
pam_handle_t *pamh;
unsigned int usec; DESCRIPTION

The pam_fail_delay function provides a mechanism by which an application or module can suggest a minimum delay of usec micro-seconds. The function keeps a record of the longest time requested with this function. Should pam_authenticate(3) fail, the failing return to the application is delayed by an amount of time randomly distributed (by up to 25%) about this longest value.

Independent of success, the delay time is reset to its zero default value when the PAM service module returns control to the application. The delay occurs after all authentication modules have been called, but before control is returned to the service application.

When using this function the programmer should check if it is available with:

#endif /* HAVE_PAM_FAIL_DELAY */

For applications written with a single thread that are event driven in nature, generating this delay may be undesirable. Instead, the application may want to register the delay in some other way. For example, in a single threaded server that serves multiple authentication requests from a single event loop, the application might want to simply mark a given connection as blocked until an application timer expires. For this reason the delay function can be changed with the PAM_FAIL_DELAY item. It can be queried and set with pam_get_item(3) and pam_set_item (3) respectively. The value used to set it should be a function pointer of the following prototype:

void (*delay_fn)(int retval, unsigned usec_delay, void *appdata_ptr);

The arguments being the retval return code of the module stack, the usec_delay micro-second delay that libpam is requesting and the appdata_ptr that the application has associated with the current pamh. This last value was set by the application when it called pam_start(3) or explicitly with pam_set_item(3). Note, if PAM_FAIL_DELAY item is unset (or set to NULL), then no delay will be performed. RETURN VALUES


Delay was successful adjusted.


A NULL pointer was submitted as PAM handle.