in reply to Authen::PAM

In your command-line code, you have this:
my $passwd = "bar";
This declares $passwd as scoped to the module. Later on, where you have this:
$ans = $passwd;
in conv_func(), $passwd is just grabbing the value you declared earlier. In your web snippet, however, $passwd is scoped to the if block and conv_func doesn't have access to it (at least, it doesn't have access to the right one, if you predeclared $passwd). This is my best guess without seeing more of the code and having no idea how Authen::PAM works. If you're trying to authenticate against that $passwd, you'll need to find another way to pass it to conv_func.

Replies are listed 'Best First'.
Re: Re: Authen::PAM
by Kageneko (Scribe) on Jul 21, 2003 at 21:50 UTC
    To reply to my own reply, this will also be a problem:
    my $username; my $passwd;
    Effectively, that makes it so that every time conv_func is called, $username and $passwd are blank - probably not what you want. The simplest solution is to add the my declarations to the top of the program and then never, ever, ever redeclare them :) Get rid of the line I quoted above from conv_func and get rid of the my keyword in front of $passwd and $username in the if block.
      Thanks, but now I'm really stumped. I thought this would be a scoping issue, and your suggestion made sense (I'd lost track of the blocks in the larger app). But I declared $username and $passwd early, have confirmed that the right values are getting to the subroutine, and I'm still not authenticating.