<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
<a class="moz-txt-link-abbreviated" href="mailto:pam-list-request@redhat.com">pam-list-request@redhat.com</a> wrote:
<blockquote cite="mid20070313160012.133C27333F@hormel.redhat.com"
 type="cite"><br>
Hello,
  <br>
I'm writing a new module for Python to support PAM authorization, it
  <br>
is written in C.
  <br>
  <br>
What I currently do is what the misc_conv function does; I provide a
  <br>
password when it prompts for a message with pam_message.msg_style set
  <br>
to PAM_PROMPT_ECHO_OFF and a username when it prompts for
  <br>
PAM_PROMPT_ECHO_ON (which it doesn't ask for; I initialize the pam
  <br>
handle with a username already.)
  <br>
  <br>
This is my conversation function: <a class="moz-txt-link-freetext" href="http://rafb.net/p/sOjqmC47.html">http://rafb.net/p/sOjqmC47.html</a>
  <br>
I have tripple verified that userinfo is available and contains proper
  <br>
data. The function does reach the end.
  <br>
  <br>
When I do pam_authenticate(), I receive the error "Authentication
  <br>
error" and the syslog just says the regular thing when a password is
  <br>
incorrect.
  <br>
  <br>
  <br>
</blockquote>
To Ludvic Ericson:<br>
<br>
Looking at your conversion function i found you set the global return
code for the conversation<br>
function itself but forget to set the return code for each message.
Here is a snippet of a working<br>
conversation function:<br>
<br>
<pre class="code"><span class="keyword">switch</span> (msgv[i]->msg_style) {
            <span class="keyword">case</span> PAM_PROMPT_ECHO_ON: <span
 class="comment">// Echo on; Username
</span>                rsp[i].resp = strdup(userinfo->username);
                <b>rsp[i].resp_retcode = PAM_SUCCESS;</b>
                <span class="keyword">break</span>;
            <span class="keyword">case</span> PAM_PROMPT_ECHO_OFF: <span
 class="comment">// Echo off; Password
</span>                rsp[i].resp = strdup(userinfo->password);
                <b>rsp[i].resp_retcode = PAM_SUCCESS;</b>
                <span class="keyword">break</span>;

</pre>
I guess, if you had used 'calloc' instead of 'malloc' to create the<br>
response structure, this missing link would have never shown up, because<br>
PAM_SUCCESS == 0 ! So, be happy you found it.<br>
<br>
Good Luck!<br>
Andreas<br>
<pre class="moz-signature" cols="90">-- 
Dr.-Ing. Andreas Schindler
 
Alpha Zero One Computersysteme GmbH
Frankfurter Str. 141
63303 Dreieich
 
Telefon 06103-57187-21
Telefax 06103-373245
 
<a class="moz-txt-link-abbreviated" href="mailto:schindler@az1.de">schindler@az1.de</a>
<a class="moz-txt-link-abbreviated" href="http://www.az1.de">www.az1.de</a>

Alpha Zero One Computersysteme GmbH, Brandeniusstr. 3, 44265 Dortmund
HRB 11089 Amtsgericht Dortmund, Geschäftsführer : Klaus-Jürgen Koke, Joachim Carle 
</pre>
</body>
</html>