2 * Conversation related functions
6 * $FreeBSD: src/contrib/libpam/modules/pam_userdb/conv.c,v 1.1.1.1.2.2 2001/06/11 15:28:33 markm Exp $
7 /* Copyright at the end of the file */
14 #include <security/pam_modules.h>
15 #include <security/_pam_macros.h>
17 #include "pam_userdb.h"
20 * dummy conversation function sending exactly one prompt
21 * and expecting exactly one response from the other party
23 static int converse(pam_handle_t *pamh,
24 struct pam_message **message,
25 struct pam_response **response)
28 const struct pam_conv *conv;
30 retval = pam_get_item(pamh, PAM_CONV, (const void **) &conv ) ;
31 if (retval == PAM_SUCCESS)
32 retval = conv->conv(1, (const struct pam_message **)message,
33 response, conv->appdata_ptr);
35 return retval; /* propagate error status */
39 static char *_pam_delete(register char *xx)
47 * This is a conversation function to obtain the user's password
49 int conversation(pam_handle_t *pamh)
51 struct pam_message msg[2],*pmsg[2];
52 struct pam_response *resp;
57 msg[0].msg_style = PAM_PROMPT_ECHO_OFF;
58 msg[0].msg = "Password: ";
60 /* so call the conversation expecting i responses */
62 retval = converse(pamh, pmsg, &resp);
66 /* interpret the response */
67 if (retval == PAM_SUCCESS) { /* a good conversation */
68 token = x_strdup(resp[0].resp);
70 return PAM_AUTHTOK_RECOVER_ERR;
74 /* set the auth token */
75 retval = pam_set_item(pamh, PAM_AUTHTOK, token);
76 token = _pam_delete(token); /* clean it up */
77 if ( (retval != PAM_SUCCESS) ||
78 (retval = pam_get_item(pamh, PAM_AUTHTOK, (const void **)&item))
83 _pam_drop_reply(resp, 1);
85 retval = (retval == PAM_SUCCESS)
86 ? PAM_AUTHTOK_RECOVER_ERR:retval ;
93 * Copyright (c) Cristian Gafton <gafton@redhat.com>, 1999
96 * Redistribution and use in source and binary forms, with or without
97 * modification, are permitted provided that the following conditions
99 * 1. Redistributions of source code must retain the above copyright
100 * notice, and the entire permission notice in its entirety,
101 * including the disclaimer of warranties.
102 * 2. Redistributions in binary form must reproduce the above copyright
103 * notice, this list of conditions and the following disclaimer in the
104 * documentation and/or other materials provided with the distribution.
105 * 3. The name of the author may not be used to endorse or promote
106 * products derived from this software without specific prior
107 * written permission.
109 * ALTERNATIVELY, this product may be distributed under the terms of
110 * the GNU Public License, in which case the provisions of the GPL are
111 * required INSTEAD OF the above restrictions. (This clause is
112 * necessary due to a potential bad interaction between the GPL and
113 * the restrictions contained in a BSD-style copyright.)
115 * THIS SOFTWARE IS PROVIDED `AS IS'' AND ANY EXPRESS OR IMPLIED
116 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
117 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
118 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
119 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
120 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
121 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
122 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
123 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
124 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
125 * OF THE POSSIBILITY OF SUCH DAMAGE.