pam_setcred Subroutine

Purpose

Establishes, changes, or removes user credentials for authentication.

Library

PAM Library (libpam.a)

Syntax

#include <security/pam_appl.h>

int pam_setcred (PAMHandle, Flags)
pam_handle_t *PAMHandle;
int Flags;

Description

The pam_setcred subroutine allows for the credentials of the PAM user for the current PAM session to be modified. Functions such as establishing, deleting, renewing, and refreshing credentials are defined.

Parameters

Item Description
PAMhandle The PAM handle representing the current user authentication session. This handle is obtained by a call to pam_start().
Flags The flags are used to set pam_setcred options. The recognized flags are:
  • PAM_SILENT
    • No messages should be displayed.
  • PAM_ESTABLISH_CRED*
    • Sets the user's credentials. This is the default.
  • PAM_DELETE_CRED*
    • Removes the user credentials.
  • PAM_REINITIALIZE_CRED*
    • Renews the user credentials.
  • PAM_REFRESH_CRED*
    • Refresh the user credentials, extending their lifetime.
*Mutually exclusive but may be logically OR'd with PAM_SILENT. If one of them is not set, PAM_ESTABLISH_CRED is assumed.

Return Values

Upon successful completion, pam_setcred returns PAM_SUCCESS. If the routine fails, a different error is returned, depending on the actual error.

Error Codes

Item Description
PAM_CRED_UNAVAIL The user credentials cannot be found.
PAM_CRED_EXPIRED The user's credentials have expired.
PAM_CRED_ERR A failure occurred while setting user credentials.
PAM_USER_UNKNOWN The user is not known.
PAM_OPEN_ERR One of the PAM authentication modules could not be loaded.
PAM_SYMBOL_ERR A necessary item is not available to a PAM module.
PAM_SERVICE_ERR An error occurred in a PAM module.
PAM_SYSTEM_ERR A system error occurred.
PAM_BUF_ERR A memory error occurred.
PAM_CONV_ERR A conversation error occurred.
PAM_PERM_DENIED Access permission was denied to the user.