1 /* This file is part of pam-modules.
2    Copyright (C) 2008, 2010-2012, 2014-2015, 2018 Sergey Poznyakoff
3 
4    This program is free software; you can redistribute it and/or modify it
5    under the terms of the GNU General Public License as published by the
6    Free Software Foundation; either version 3 of the License, or (at your
7    option) any later version.
8 
9    This program is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12    GNU General Public License for more details.
13 
14    You should have received a copy of the GNU General Public License along
15    with this program.  If not, see <http://www.gnu.org/licenses/>.  */
16 
17 #include <graypam.h>
18 
19 int
20 gray_converse(pam_handle_t *pamh,
21 	      int nargs,
22 	      struct pam_message **message,
23 	      struct pam_response **response)
24 {
25 	int retval;
26 	struct pam_conv *conv;
27 
28 	retval = pam_get_item(pamh, PAM_CONV, (const void **) &conv);
texinfo-master-menu-list-recursivenull29 	if (retval == PAM_SUCCESS) {
30 
31 		retval = conv->conv(nargs,
32 				    (const struct pam_message **) message,
33 				    response,
34 				    conv->appdata_ptr);
35 
36 		if (retval != PAM_SUCCESS) {
37 			_pam_log(LOG_ERR,
38 				 "conversation failure [%s]",
39 				 pam_strerror(pamh, retval));
40 		}
41 	} else if (retval != PAM_CONV_AGAIN) {
42 		_pam_log(LOG_ERR,
43 		         "couldn't obtain coversation function: %s",
44 			 pam_strerror(pamh, retval));
45 	}
46 
47 	return retval;		/* propagate error status */
48 }
49 
50