problem running perl script with Authen::PAM

Problems with the Mac OS X version of XAMPP, questions, comments, and anything related.

problem running perl script with Authen::PAM

Postby kodak » 26. July 2013 01:28

Hi,

Iam currently trying to run a perl script which uses the lib Auth::PAM (http://search.cpan.org/~nikip/Authen-PAM-0.16/) and tests a given user/pass if the user exists in the passwd file and checks the password.
The perl script sends a json response with "success" or "error" back.

This is the code:
Code: Select all
#!/usr/bin/perl

use Authen::PAM;
use POSIX qw(ttyname);
use CGI qw(:standard);
use JSON;

$service = "login";
$username = "$ARGV[0]\n";
$password = "$ARGV[1]\n";
$tty_name = ttyname(fileno(STDIN));

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

       $ans = $username if ($code == PAM_PROMPT_ECHO_ON() );
       $ans = $password if ($code == PAM_PROMPT_ECHO_OFF() );

       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!";

$res = $pamh->pam_authenticate;

#13 = OK and 0 = error
if($res == 13){
   print header('application/json');
   my $response = "success";
   my $response = to_json($response);
   print $response;

   }else{

      print header('application/json');
      my $response = "error";
      my $response = to_json($response);
      print $response;
   }


However, it works fine when I run it from my local shell.
When I try to run it though xampp (http://localhost/cgi-bin/checkuser.pl) I get this error:
Code: Select all
Can't find 'boot_Authen__PAM' symbol in /usr/lib/libPAM.dylib at /Applications/XAMPP/xamppfiles/cgi-bin/checkuser.pl line 3 Compilation failed in require at /Applications/XAMPP/xamppfiles/cgi-bin/checkuser.pl line 3. BEGIN failed--compilation aborted at /Applications/XAMPP/xamppfiles/cgi-bin/checkuser.pl line 3. ,
Error 500


When I comment out the Authen::PAM code I get an error about JSON (Can't locate JSON.pm).
I manually installed those two perl plugins with make and make install.

It seems like xammp does not find the plugins or cannot access them.

This is the JSON error:
Code: Select all
Can't locate JSON.pm in @INC (@INC contains: /Applications/XAMPP/xamppfiles/lib/perl5/site_perl/5.10.1//darwin-2level /Applications/XAMPP/xamppfiles/lib/perl5/site_perl/5.10.1/ /Applications/XAMPP/xamppfiles/lib/perl5/5.10.1/darwin-2level /Applications/XAMPP/xamppfiles/lib/perl5/5.10.1 /Applications/XAMPP/xamppfiles/lib/perl5/site_perl/5.10.1/darwin-2level /Applications/XAMPP/xamppfiles/lib/perl5/site_perl/5.10.1 . /Applications/XAMPP/xamppfiles) at /Applications/XAMPP/xamppfiles/cgi-bin/checkuser.pl line 6. BEGIN failed--compilation aborted at /Applications/XAMPP/xamppfiles/cgi-bin/checkuser.pl line 6. ,


And it looks like that XAMPP tries to find the plugins under /Applications/XAMPP/xamppfiles/lib/perl5/site_perl/5.10.1.
Does anyone know how I can install the perl plugins that xampp is able to use it?

Or does anyone know another/besser method to check for correct user/pass in passwd?

Thanks!
Kodak
kodak
 
Posts: 2
Joined: 26. July 2013 01:01
Operating System: OSX

Return to XAMPP for macOS

Who is online

Users browsing this forum: No registered users and 38 guests