in reply to Re: Re: Re: Using Unix passwd/shadow to authenticate in perl
in thread Using Unix passwd/shadow to authenticate in perl
You can actually use pam to uthenticate as a normal user. You never get to see the encrypted password, but the pam lib tells you whether the password you are giving is right or not. Here is a quick example (cut & paste from the Authen::PAM perldocs):
The outcome changes depending on whether the password is correct. Cheers#!/usr/bin/perl -w use strict; use Authen::PAM; my $login_name = getpwuid($<); sub conversation { my @res; while ( @_ ) { my $msg_type = shift; my $msg = shift; my $ans = "put your password here"; push @res, (0,$ans); } push @res, PAM_SUCCESS(); return @res; } my $pamh; pam_start("passwd", $login_name, \&conversation, $pamh); print pam_authenticate($pamh); pam_end($pamh);
|
|---|