Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Authen::Simple::PAM over CGI

by gman (Friar)
on Oct 06, 2010 at 14:44 UTC ( #863799=perlquestion: print w/replies, xml ) Need Help??
gman has asked for the wisdom of the Perl Monks concerning the following question:

Hello All,

I'm working on using Authen::Simple::PAM on a CGI script. I consistently fail authentication when submitting over CGI, works on command line. The user I use on the comand line does have a shell, as opposed to apache user, could this be the issue? Below is sample code that demonstrates the problem. I did find a link on the web link and this appeared to work for them, so I am wondering if this is an environment issue on my server (

#!/usr/bin/perl -w use strict; use warnings; use Authen::Simple::PAM; use CGI qw( :standard :html3 ); use CGI::Carp qw(fatalsToBrowser); my $cgi = new CGI; my $pam = Authen::Simple::PAM->new( service => 'sshd', ); print $cgi->header(); print $cgi->start_html(); print $cgi->start_form(); print $cgi->textfield(-name=>'username'); print $cgi->password_field(-name=>'passwd'); print $cgi->submit(-name=>'submit',-value=>'submit'); if($cgi->param('submit')) { my $password = $cgi->param('passwd'); my $username = $cgi->param('username'); if( $pam->authenticate( $username, $password) ) { print "Authentication Succesfull<br>"; } else { print "Authentication failed<br>"; } } print $cgi->end_html();


UPDATE: In case I was not clear, the following works;
./ "submit=submit;username=xxxxxx;passwd="xxxx"

Still have not found a solution, but using a global logon framework provided by 3rd party.

Replies are listed 'Best First'.
Re: Authen::Simple::PAM over CGI
by kapet3 (Initiate) on Oct 16, 2011 at 08:40 UTC
    Tried this, and when I switched from passwords stored in /etc/shadow to passwords stored in /etc/passwd, it started to work.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://863799]
Approved by Corion
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2017-02-26 23:45 GMT
Find Nodes?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?

    Results (376 votes). Check out past polls.