LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 03-11-2008, 08:35 AM   #1
sandiplinux
LQ Newbie
 
Registered: Mar 2008
Posts: 1

Rep: Reputation: 0
Smile using Authen::pam of perl module


Hi,
I have an perl programme that change password but not interactively..
the programme run and ends with this message
"Authentication token manipulation error"



__________________________________________________________________________
#!/usr/bin/perl -w

use Authen::PAM;

$service = "passwd";
$username = "vivek";
$oldpassword = "altctrl";
$newpassword = "redhat";

sub my_conv_func
{
my @res;
while ( @_ )
{
my $code = shift;
my $msg = shift;
my $ans = "";

$ans = $username if ($code == PAM_PROMPT_ECHO_ON() );
if($code == PAM_PROMPT_ECHO_OFF() )
{
$ans = $oldpassword if ($state == 0);
$ans = $newpassword if ($state == 1);
$ans = $newpassword if ($state == 2);
$state++;
}
push @res, (PAM_SUCCESS(),$ans);
}
push @res, PAM_SUCCESS();
return @res;
}
ref($pamh = new Authen::PAM($service, $username, \&my_conv_func)) ||die "Error code $pamh during PAM init!";
$state = 0;
$res = $pamh->pam_chauthtok;
print $pamh->pam_strerror($res),"\n" unless $res == PAM_SUCCESS();

#___________________________________________________________________________



THE BIG QUESTION:
What's going on?
Any help would be greatly appreciated as I'm not really sure what's going on with this!
i am login as root and OS is fedora 7

Thanks much in advance.
Regards,
sandip
 
Old 03-12-2008, 07:30 PM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Try these guys: www.perlmonks.org
 
  


Reply

Tags
module, password, while



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Perl module Compress::Zlib installed but perl not detecting it danran Programming 0 05-03-2007 01:50 PM
Radius PAM.D Module interpol Linux - Security 5 02-27-2007 03:29 AM
PAM Radius Module interpol Linux - Security 1 02-23-2007 09:29 AM
winbind pam module paul_mat Linux - Networking 0 12-21-2005 11:22 PM
Problem with perl module for w3c validator to work on my local Apache+PHP+perl instal tbamt Linux - Software 0 12-16-2004 05:37 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 01:35 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration