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