pam_set_data Subroutine

Purpose

Sets information for a specific PAM module for the active PAM session.

Library

PAM Library (libpam.a)

Syntax

#include <security/pam_appl.h>

int pam_set_data (PAMHandle, ModuleDataName, Data, *(cleanup)(pam_handle_t *pamh, void *data, 
                  int pam_end_status))
pam_handle_t *PAMHandle;
const char *ModuleDataName;
void *Data;
void *(cleanup)(pam_handle_t *pamh, void *data, int pam_end_status);

Description

The pam_set_data subroutine allows for the setting and updating of module-specific data within the PAM handle, PAMHandle. The ModuleDataName argument serves to uniquely identify the data, Data. Stored information can be retrieved by specifying ModuleDataName and passing it, along with the appropriate PAM handle, to pam_get_data(). The cleanup argument is a pointer to a function that is called to free allocated memory used by the Data when pam_end() is invoked. If data is already associated with ModuleDataName, PAM does a cleanup of the old data, overwrites it with Data, and replaces the old cleanup function. If the information being set is of a known PAM item type, use the pam_putenv subroutine instead.

Parameters

Item Description
PAMHandle The PAM handle representing the current user authentication session. This handle is obtained by a call to pam_start().
ModuleDataName A unique identifier for Data.
Data A reference to the data denoted by ModuleDataName.
cleanup A function pointer that is called by pam_end() to clean up all allocated memory used by Data.

Return Values

Upon successful completion, pam_set_data_ returns PAM_SUCCESS. If the routine fails, either PAM_SYSTEM_ERR or PAM_BUF_ERR is returned, depending on the actual error.

Error Codes

Item Description
PAM_SYSTEM_ERR A system error occurred.
PAM_BUF_ERR A memory error occurred.