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.


In reply to Authen::Simple::PAM over CGI by gman

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.