Authen::PAM (3)
Leading comments
Automatically generated by Pod::Man 4.09 (Pod::Simple 3.35) Standard preamble: ========================================================================
NAME
Authen::PAM - Perl interface to PAM librarySYNOPSIS
use Authen::PAM; $res = pam_start($service_name, $pamh); $res = pam_start($service_name, $user, $pamh); $res = pam_start($service_name, $user, \&my_conv_func, $pamh); $res = pam_end($pamh, $pam_status); $res = pam_authenticate($pamh, $flags); $res = pam_setcred($pamh, $flags); $res = pam_acct_mgmt($pamh, $flags); $res = pam_open_session($pamh, $flags); $res = pam_close_session($pamh, $flags); $res = pam_chauthtok($pamh, $flags); $error_str = pam_strerror($pamh, $errnum); $res = pam_set_item($pamh, $item_type, $item); $res = pam_get_item($pamh, $item_type, $item); if (HAVE_PAM_ENV_FUNCTIONS()) { $res = pam_putenv($pamh, $name_value); $val = pam_getenv($pamh, $name); %env = pam_getenvlist($pamh); } if (HAVE_PAM_FAIL_DELAY()) { $res = pam_fail_delay($pamh, $musec_delay); $res = pam_set_item($pamh, PAM_FAIL_DELAY(), \&my_fail_delay_func); }
DESCRIPTION
The Authen::PAM module provides a Perl interface to theIf you want to pass a
The $flags argument is optional for all functions which use it except for pam_setcred. The $pam_status argument is also optional for pam_end function. Both of these arguments will be set to 0 if not given.
The names of some constants from the
When this module supports some of the additional features of the
For compatibility with older
Object Oriented Style
If you prefer to use an object oriented style for accessing the
use Authen::PAM qw(:constants); $pamh = new Authen::PAM($service_name); $pamh = new Authen::PAM($service_name, $user); $pamh = new Authen::PAM($service_name, $user, \&my_conv_func); ref($pamh) || die "Error code $pamh during PAM init!"; $res = $pamh->pam_authenticate($flags); $res = $pamh->pam_setcred($flags); $res = $pamh->pam_acct_mgmt($flags); $res = $pamh->pam_open_session($flags); $res = $pamh->pam_close_session($flags); $res = $pamh->pam_chauthtok($flags); $error_str = $pamh->pam_strerror($errnum); $res = $pamh->pam_set_item($item_type, $item); $res = $pamh->pam_get_item($item_type, $item); $res = $pamh->pam_putenv($name_value); $val = $pamh->pam_getenv($name); %env = $pamh->pam_getenvlist;
The constructor new will call the pam_start function and if successfull will return an object reference. Otherwise the $pamh will contain the error number returned by pam_start. The pam_end function will be called automatically when the object is no longer referenced.
Examples
Here is an example of using
use Authen::PAM; $login_name = getpwuid($<); pam_start("passwd", $login_name, $pamh); pam_chauthtok($pamh); pam_end($pamh);
or the same thing but using
$pamh = new Authen::PAM("passwd", $login_name); $pamh->pam_chauthtok; $pamh = 0; # Force perl to call the destructor for the $pamh
Conversation function format
When starting theHere is a sample form of the
sub my_conv_func { my @res; while ( @_ ) { my $msg_type = shift; my $msg = shift; print $msg; # switch ($msg_type) { obtain value for $ans; } push @res, (0,$ans); } push @res, PAM_SUCCESS(); return @res; }
More examples can be found in the Authen::PAM:FAQ.
COMPATIBILITY
The following constant names:
use Authen::PAM qw(:DEFAULT :old);
This module still does not support some of the new Linux-PAM functions such as pam_system_log.