Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

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 (2.6.27.41-170.2.117.fc10.i686).


#!/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();

Thanks

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

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

Comment on Authen::Simple::PAM over CGI
Download Code
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?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://863799]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (11)
As of 2015-07-03 18:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (55 votes), past polls